diff --git a/Source/Core/Core/Src/HW/EXI_Device.h b/Source/Core/Core/Src/HW/EXI_Device.h index 3328d41124..2571b6e5fa 100644 --- a/Source/Core/Core/Src/HW/EXI_Device.h +++ b/Source/Core/Core/Src/HW/EXI_Device.h @@ -24,7 +24,7 @@ class IEXIDevice { private: // Byte transfer function for this device - virtual void TransferByte(u8& _byte) {}; + virtual void TransferByte(u8&) {}; public: // Immediate copy functions diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/DSoundStream.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/DSoundStream.cpp index 839d6ca345..d387036fab 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/DSoundStream.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/DSoundStream.cpp @@ -110,8 +110,7 @@ void DSound::SoundLoop() { // No blocking inside the csection soundCriticalSection->Enter(); dsBuffer->GetCurrentPosition((DWORD*)¤tPos, 0); - int numBytesToRender = FIX128( - ModBufferSize(currentPos - lastPos)); + int numBytesToRender = FIX128(ModBufferSize(currentPos - lastPos)); if (numBytesToRender >= 256) { diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp index f94d835030..d777166505 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp @@ -68,13 +68,7 @@ void Mixer(short *buffer, int numSamples, int bits, int rate, int channels) g_dspInitialize.pGetAudioStreaming(buffer, numSamples); } - //if this was called directly from the HLE, and not by timeout - if (g_Config.m_EnableHLEAudio && mixer_HLEready) - { - IUCode* pUCode = CDSPHandler::GetInstance().GetUCode(); - if (pUCode != NULL) - pUCode->MixAdd(buffer, numSamples); - } + Mixer_MixUCode(buffer, numSamples, bits, rate, channels); push_sync.Enter(); int count = 0; @@ -96,6 +90,17 @@ void Mixer(short *buffer, int numSamples, int bits, int rate, int channels) push_sync.Leave(); } +void Mixer_MixUCode(short *buffer, int numSamples, int bits, int rate, + int channels) { + //if this was called directly from the HLE, and not by timeout + if (g_Config.m_EnableHLEAudio && mixer_HLEready) + { + IUCode* pUCode = CDSPHandler::GetInstance().GetUCode(); + if (pUCode != NULL) + pUCode->MixAdd(buffer, numSamples); + } +} + void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate) { // static FILE *f; // if (!f) diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.h b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.h index 3c5095ab70..49603919f8 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.h @@ -23,6 +23,8 @@ extern volatile bool mixer_HLEready; // Called from audio threads void Mixer(short* buffer, int numSamples, int bits, int rate, int channels); +void Mixer_MixUCode(short *buffer, int numSamples, int bits, int rate, int channels); + // Called from main thread void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate); diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/NullSoundStream.h b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/NullSoundStream.h index c5c52c4f87..bd6728b1ae 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/NullSoundStream.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/NullSoundStream.h @@ -33,6 +33,10 @@ public: } virtual bool Start() { return true; } + + virtual void Update() { + (*callback)(NULL, 256 >> 2, 16, sampleRate, 2); + } }; #endif //__NULLSOUNDSTREAM_H__ diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp index 66acd50362..6cb7aed966 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp @@ -326,7 +326,7 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize) #if defined(HAVE_WX) && HAVE_WX // write logging data to debugger - if (m_frame) + if (m_frame && _pBuffer) { CUCode_AX::Logging(_pBuffer, _iSize, 0, false); } @@ -383,22 +383,23 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize) // write back out pbs WriteBackPBs(m_addressPBs, PBs, numberOfPBs); - for (int i = 0; i < _iSize; i++) - { - // Clamp into 16-bit. Maybe we should add a volume compressor here. - int left = templbuffer[i] + _pBuffer[0]; - int right = temprbuffer[i] + _pBuffer[1]; - if (left < -32767) left = -32767; - if (left > 32767) left = 32767; - if (right < -32767) right = -32767; - if (right > 32767) right = 32767; - *_pBuffer++ = left; - *_pBuffer++ = right; + if(_pBuffer) { + for (int i = 0; i < _iSize; i++) + { + // Clamp into 16-bit. Maybe we should add a volume compressor here. + int left = templbuffer[i] + _pBuffer[0]; + int right = temprbuffer[i] + _pBuffer[1]; + if (left < -32767) left = -32767; + if (left > 32767) left = 32767; + if (right < -32767) right = -32767; + if (right > 32767) right = 32767; + *_pBuffer++ = left; + *_pBuffer++ = right; + } } - #if defined(HAVE_WX) && HAVE_WX // write logging data to debugger again after the update - if (m_frame) + if (m_frame && _pBuffer) { CUCode_AX::Logging(_pBuffer, _iSize, 1, false); } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp index 1ba421a90a..ed7be21fde 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp @@ -110,7 +110,7 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs) // ------------------------------------------- // write logging data to debugger #if defined(HAVE_WX) && HAVE_WX - if (m_frame) + if (m_frame && _pBuffer) { lCUCode_AX->Logging(_pBuffer, _iSize, 0, true); @@ -199,22 +199,25 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs) WriteBackPBsWii(m_addressPBs, PBs, numberOfPBs); // We write the sound to _pBuffer - for (int i = 0; i < _iSize; i++) + if(_pBuffer) { - // Clamp into 16-bit. Maybe we should add a volume compressor here. - int left = templbuffer[i] + _pBuffer[0]; - int right = temprbuffer[i] + _pBuffer[1]; - if (left < -32767) left = -32767; - if (left > 32767) left = 32767; - if (right < -32767) right = -32767; - if (right > 32767) right = 32767; - *_pBuffer++ = left; - *_pBuffer++ = right; + for (int i = 0; i < _iSize; i++) + { + // Clamp into 16-bit. Maybe we should add a volume compressor here. + int left = templbuffer[i] + _pBuffer[0]; + int right = temprbuffer[i] + _pBuffer[1]; + if (left < -32767) left = -32767; + if (left > 32767) left = 32767; + if (right < -32767) right = -32767; + if (right > 32767) right = 32767; + *_pBuffer++ = left; + *_pBuffer++ = right; + } } - + #if defined(HAVE_WX) && HAVE_WX // write logging data to debugger again after the update - if (m_frame) + if (m_frame && _pBuffer) { lCUCode_AX->Logging(_pBuffer, _iSize, 1, true); } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp index 35d2b657d3..6ace114da8 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp @@ -232,7 +232,7 @@ void Initialize(void *init) if (AOSound::isValid()) soundStream = new AOSound(48000, Mixer); } else if(strncasecmp(g_Config.sBackend, "NullSound", 10) == 0) { - soundStream = new NullSound(48000, Mixer); + soundStream = new NullSound(48000, Mixer_MixUCode); } else { PanicAlert("Cannot recognize backend %s", g_Config.sBackend); return;