mirror of https://github.com/PCSX2/pcsx2.git
SPU2ghz: Fixed a couple rare odd-case XAudio2 crashes, and fixed a small glitch in in the over/underrun code when timestretching disabled.
git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@288 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
c69df473ad
commit
211829bb18
|
@ -213,7 +213,7 @@ public:
|
|||
else
|
||||
{
|
||||
// Toss half the buffer plus whatever's being written anew:
|
||||
s32 comp = GetAlignedBufferSize( (size + nSamples ) / 2 );
|
||||
comp = GetAlignedBufferSize( (size + nSamples ) / 2 );
|
||||
if( comp > (size-SndOutPacketSize) ) comp = size-SndOutPacketSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -424,7 +424,7 @@ s32 CALLBACK SPU2open(void *pDsp)
|
|||
debugDialogOpen=1;
|
||||
}*/
|
||||
|
||||
spu2open=1;
|
||||
spu2open=true;
|
||||
if (!SndInit())
|
||||
{
|
||||
srate_pv=(double)SampleRate/48000.0;
|
||||
|
|
|
@ -53,7 +53,9 @@ private:
|
|||
STDMETHOD_(void, OnBufferStart) ( void* ) {}
|
||||
STDMETHOD_(void, OnBufferEnd) ( void* context )
|
||||
{
|
||||
if( context == NULL || sndout == NULL ) return;
|
||||
// All of these checks are necessary because XAudio2 is wonky shizat.
|
||||
if( pSourceVoice == NULL || context == NULL || sndout == NULL ) return;
|
||||
|
||||
s16* qb = (s16*)context;
|
||||
|
||||
for(int p=0; p<PacketsPerBuffer; p++, qb+=SndOutPacketSize )
|
||||
|
@ -123,9 +125,6 @@ public:
|
|||
// or after CreateSourceVoice. Some drivers could do evil things to
|
||||
// our structure whn we create the voice.
|
||||
|
||||
voiceContext.sndout = sb;
|
||||
voiceContext.pSourceVoice = pSourceVoice;
|
||||
|
||||
//
|
||||
// Create an XAudio2 voice to stream this wave
|
||||
//
|
||||
|
@ -139,8 +138,8 @@ public:
|
|||
|
||||
// See comment above. Leave this redundant code in to protect against
|
||||
// potentially stupid drivers.
|
||||
voiceContext.sndout = sb;
|
||||
voiceContext.pSourceVoice = pSourceVoice;
|
||||
pSourceVoice->FlushSourceBuffers();
|
||||
pSourceVoice->Start( 0, 0 );
|
||||
|
||||
qbuffer = new s16[BufferSize*MAX_BUFFER_COUNT];
|
||||
|
@ -165,6 +164,8 @@ public:
|
|||
buf.pAudioData=(BYTE*)buf.pContext;
|
||||
pSourceVoice->SubmitSourceBuffer( &buf );
|
||||
}
|
||||
voiceContext.sndout = sb;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -176,7 +177,10 @@ public:
|
|||
if( pSourceVoice != NULL )
|
||||
{
|
||||
pSourceVoice->Stop( 0 );
|
||||
pSourceVoice->FlushSourceBuffers();
|
||||
Sleep(50); // give the engine some time to stop voices
|
||||
voiceContext.pSourceVoice = NULL;
|
||||
voiceContext.sndout = NULL;
|
||||
pSourceVoice->DestroyVoice();
|
||||
pSourceVoice = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue