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();
}
}

View File

@ -12,37 +12,13 @@ class CMixer;
extern SoundStream *soundStream;
// UDSPControl
union UDSPControl
{
u16 Hex;
struct
{
u16 DSPReset : 1; // Write 1 to reset and waits for 0
u16 DSPAssertInt : 1;
u16 DSPHalt : 1;
u16 AI : 1;
u16 AI_mask : 1;
u16 ARAM : 1;
u16 ARAM_mask : 1;
u16 DSP : 1;
u16 DSP_mask : 1;
u16 ARAM_DMAState : 1; // DSPGetDMAStatus() uses this flag
u16 DSPInitCode : 1;
u16 DSPInit : 1; // DSPInit() writes to this flag
u16 pad : 4;
};
UDSPControl(u16 _Hex = 0) : Hex(_Hex) {}
};
namespace AudioCommon
{
SoundStream *InitSoundStream(CMixer *mixer, void *hWnd);
SoundStream *InitSoundStream(void *hWnd);
void ShutdownSoundStream();
std::vector<std::string> GetSoundBackends();
bool UseJIT();
void PauseAndLock(bool doLock, bool unpauseOnUnlock=true);
void UpdateSoundStream();
void ClearAudioBuffer(bool mute);
void SendAIBuffer(short* samples, unsigned int num_samples);
}