Merge pull request #220 from magumagu/audio-handling-cleanup-v2

Audio handling cleanup v2
This commit is contained in:
Pierre Bourdon
2014-03-30 13:24:52 +02:00
12 changed files with 81 additions and 232 deletions

View File

@ -26,8 +26,13 @@ SoundStream *soundStream = nullptr;
namespace AudioCommon
{
SoundStream *InitSoundStream(CMixer *mixer, void *hWnd)
SoundStream *InitSoundStream(void *hWnd)
{
unsigned int AISampleRate, DACSampleRate;
AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate);
delete soundStream;
CMixer *mixer = new CMixer(AISampleRate, DACSampleRate, 48000);
// TODO: possible memleak with mixer
std::string backend = SConfig::GetInstance().sBackend;
@ -128,15 +133,6 @@ namespace AudioCommon
return backends;
}
bool UseJIT()
{
if (!Movie::IsDSPHLE() && Movie::IsPlayingInput() && Movie::IsConfigSaved())
{
return true;
}
return SConfig::GetInstance().m_DSPEnableJIT;
}
void PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
if (soundStream)
@ -163,4 +159,25 @@ namespace AudioCommon
soundStream->SetVolume(SConfig::GetInstance().m_Volume);
}
}
void ClearAudioBuffer(bool mute)
{
if (soundStream)
soundStream->Clear(mute);
}
void SendAIBuffer(short *samples, unsigned int num_samples)
{
if (!soundStream)
return;
CMixer* pMixer = soundStream->GetMixer();
if (pMixer && samples)
{
pMixer->PushSamples(samples, num_samples);
}
soundStream->Update();
}
}