sets audio samples to 0 if audio was not mixed.

This commit is contained in:
Siddharth 2013-10-07 22:03:14 +05:30
parent c4b44d3a39
commit 1708febac1
3 changed files with 17 additions and 4 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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) {