diff --git a/Core/HLE/__sceAudio.h b/Core/HLE/__sceAudio.h index e338557683..4492703ad7 100644 --- a/Core/HLE/__sceAudio.h +++ b/Core/HLE/__sceAudio.h @@ -17,6 +17,9 @@ #pragma once #include "sceAudio.h" +#ifndef SCE_AUDIO_NO_MIX +#define SCE_AUDIO_NO_MIX -1 +#endif // Easy interface for sceAudio to write to, to keep the complexity in check. diff --git a/Core/PSPMixer.cpp b/Core/PSPMixer.cpp index 69cec9f4c9..7dc836faea 100644 --- a/Core/PSPMixer.cpp +++ b/Core/PSPMixer.cpp @@ -28,7 +28,7 @@ int PSPMixer::Mix(short *stereoout, int numSamples) { int numFrames = __AudioMix(stereoout, numSamples); #ifdef _WIN32 - if (numFrames < numSamples) { + if (numFrames < numSamples && numFrames != SCE_AUDIO_NO_MIX) { // Our dsound backend will not stop playing, let's just feed it zeroes if we miss data. memset(stereoout + 2 * 2 * numFrames, 0, 2 * 2 * (numSamples - numFrames)); numFrames = numSamples; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 40a29057f2..6843fd1a7e 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -194,13 +194,23 @@ void NativeHost::ShutdownSound() { int NativeMix(short *audio, int num_samples) { // ILOG("Entering mixer"); + int numMixedSamples = 0; + if (g_mixer) { - num_samples = g_mixer->Mix(audio, num_samples); - } else { + numMixedSamples = g_mixer->Mix(audio, num_samples); + + if(numMixedSamples == SCE_AUDIO_NO_MIX) { + goto noMix; + } + + } else{ + //this is the one place a goto is warranted. Still, find a way to rewrite + //;_; + noMix: memset(audio, 0, num_samples * 2 * sizeof(short)); } // ILOG("Leaving mixer"); - return num_samples; + return numMixedSamples; } void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, bool *landscape) {