move direct sound specific behavior into the actual direct sound function instead of into an ifdef

This commit is contained in:
Peter Tissen 2013-11-04 18:29:49 +01:00
parent ae27874cf1
commit 9b9ba165e0
2 changed files with 5 additions and 14 deletions

View File

@ -26,11 +26,5 @@
int PSPMixer::Mix(short *stereoout, int numSamples)
{
int numFrames = __AudioMix(stereoout, numSamples);
#ifdef _WIN32
// Our dsound backend will not stop playing.
//__AudioMix fills the rest of the buffer with 0 already
numFrames = numSamples;
#endif
return numFrames;
return __AudioMix(stereoout, numSamples);
}

View File

@ -128,15 +128,13 @@ namespace DSound
dsBuffer->GetCurrentPosition((DWORD *)&currentPos, 0);
int numBytesToRender = RoundDown128(ModBufferSize(currentPos - lastPos));
//renderStuff(numBytesToRender/2);
//if (numBytesToRender>bufferSize/2) numBytesToRender=0;
if (numBytesToRender >= 256)
{
int numBytesRendered = 4 * (*callback)(realtimeBuffer, numBytesToRender >> 2, 16, 44100, 2);
if (numBytesRendered != 0)
writeDataToBuffer(lastPos, (char *)realtimeBuffer, numBytesRendered);
//We need to copy the full buffer, regardless of what the mixer claims to have filled
//If we don't do this then the sound will loop if the sound stops and the mixer writes only zeroes
numBytesRendered = numBytesToRender;
writeDataToBuffer(lastPos, (char *) realtimeBuffer, numBytesRendered);
currentPos = ModBufferSize(lastPos + numBytesRendered);
totalRenderedBytes += numBytesRendered;
@ -144,7 +142,6 @@ namespace DSound
lastPos = currentPos;
}
LeaveCriticalSection(&soundCriticalSection);
WaitForSingleObject(soundSyncEvent, MAXWAIT);
}