Fixed NullSound hanging on movies. Compared to DSound, it's now slower on movies but faster in menus

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2183 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
XTra.KrazzY 2009-02-09 19:50:06 +00:00
parent 59a8fd4848
commit 09c8368180
8 changed files with 52 additions and 38 deletions

View File

@ -24,7 +24,7 @@ class IEXIDevice
{ {
private: private:
// Byte transfer function for this device // Byte transfer function for this device
virtual void TransferByte(u8& _byte) {}; virtual void TransferByte(u8&) {};
public: public:
// Immediate copy functions // Immediate copy functions

View File

@ -110,8 +110,7 @@ void DSound::SoundLoop() {
// No blocking inside the csection // No blocking inside the csection
soundCriticalSection->Enter(); soundCriticalSection->Enter();
dsBuffer->GetCurrentPosition((DWORD*)&currentPos, 0); dsBuffer->GetCurrentPosition((DWORD*)&currentPos, 0);
int numBytesToRender = FIX128( int numBytesToRender = FIX128(ModBufferSize(currentPos - lastPos));
ModBufferSize(currentPos - lastPos));
if (numBytesToRender >= 256) if (numBytesToRender >= 256)
{ {

View File

@ -68,13 +68,7 @@ void Mixer(short *buffer, int numSamples, int bits, int rate, int channels)
g_dspInitialize.pGetAudioStreaming(buffer, numSamples); g_dspInitialize.pGetAudioStreaming(buffer, numSamples);
} }
//if this was called directly from the HLE, and not by timeout Mixer_MixUCode(buffer, numSamples, bits, rate, channels);
if (g_Config.m_EnableHLEAudio && mixer_HLEready)
{
IUCode* pUCode = CDSPHandler::GetInstance().GetUCode();
if (pUCode != NULL)
pUCode->MixAdd(buffer, numSamples);
}
push_sync.Enter(); push_sync.Enter();
int count = 0; int count = 0;
@ -96,6 +90,17 @@ void Mixer(short *buffer, int numSamples, int bits, int rate, int channels)
push_sync.Leave(); 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) { void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate) {
// static FILE *f; // static FILE *f;
// if (!f) // if (!f)

View File

@ -23,6 +23,8 @@ extern volatile bool mixer_HLEready;
// Called from audio threads // Called from audio threads
void Mixer(short* buffer, int numSamples, int bits, int rate, int channels); 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 // Called from main thread
void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate); void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate);

View File

@ -33,6 +33,10 @@ public:
} }
virtual bool Start() { return true; } virtual bool Start() { return true; }
virtual void Update() {
(*callback)(NULL, 256 >> 2, 16, sampleRate, 2);
}
}; };
#endif //__NULLSOUNDSTREAM_H__ #endif //__NULLSOUNDSTREAM_H__

View File

@ -326,7 +326,7 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize)
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
// write logging data to debugger // write logging data to debugger
if (m_frame) if (m_frame && _pBuffer)
{ {
CUCode_AX::Logging(_pBuffer, _iSize, 0, false); CUCode_AX::Logging(_pBuffer, _iSize, 0, false);
} }
@ -383,6 +383,7 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize)
// write back out pbs // write back out pbs
WriteBackPBs(m_addressPBs, PBs, numberOfPBs); WriteBackPBs(m_addressPBs, PBs, numberOfPBs);
if(_pBuffer) {
for (int i = 0; i < _iSize; i++) for (int i = 0; i < _iSize; i++)
{ {
// Clamp into 16-bit. Maybe we should add a volume compressor here. // Clamp into 16-bit. Maybe we should add a volume compressor here.
@ -395,10 +396,10 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize)
*_pBuffer++ = left; *_pBuffer++ = left;
*_pBuffer++ = right; *_pBuffer++ = right;
} }
}
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
// write logging data to debugger again after the update // write logging data to debugger again after the update
if (m_frame) if (m_frame && _pBuffer)
{ {
CUCode_AX::Logging(_pBuffer, _iSize, 1, false); CUCode_AX::Logging(_pBuffer, _iSize, 1, false);
} }

View File

@ -110,7 +110,7 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
// ------------------------------------------- // -------------------------------------------
// write logging data to debugger // write logging data to debugger
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
if (m_frame) if (m_frame && _pBuffer)
{ {
lCUCode_AX->Logging(_pBuffer, _iSize, 0, true); lCUCode_AX->Logging(_pBuffer, _iSize, 0, true);
@ -199,6 +199,8 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
WriteBackPBsWii(m_addressPBs, PBs, numberOfPBs); WriteBackPBsWii(m_addressPBs, PBs, numberOfPBs);
// We write the sound to _pBuffer // We write the sound to _pBuffer
if(_pBuffer)
{
for (int i = 0; i < _iSize; i++) for (int i = 0; i < _iSize; i++)
{ {
// Clamp into 16-bit. Maybe we should add a volume compressor here. // Clamp into 16-bit. Maybe we should add a volume compressor here.
@ -211,10 +213,11 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
*_pBuffer++ = left; *_pBuffer++ = left;
*_pBuffer++ = right; *_pBuffer++ = right;
} }
}
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
// write logging data to debugger again after the update // write logging data to debugger again after the update
if (m_frame) if (m_frame && _pBuffer)
{ {
lCUCode_AX->Logging(_pBuffer, _iSize, 1, true); lCUCode_AX->Logging(_pBuffer, _iSize, 1, true);
} }

View File

@ -232,7 +232,7 @@ void Initialize(void *init)
if (AOSound::isValid()) if (AOSound::isValid())
soundStream = new AOSound(48000, Mixer); soundStream = new AOSound(48000, Mixer);
} else if(strncasecmp(g_Config.sBackend, "NullSound", 10) == 0) { } else if(strncasecmp(g_Config.sBackend, "NullSound", 10) == 0) {
soundStream = new NullSound(48000, Mixer); soundStream = new NullSound(48000, Mixer_MixUCode);
} else { } else {
PanicAlert("Cannot recognize backend %s", g_Config.sBackend); PanicAlert("Cannot recognize backend %s", g_Config.sBackend);
return; return;