File tree Expand file tree Collapse file tree
MarathonRecomp/apu/driver Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,8 +131,11 @@ void XAudioSubmitFrame(void* samples)
131131 float ch4 = floatSamples[4 * XAUDIO_NUM_SAMPLES + i];
132132 float ch5 = floatSamples[5 * XAUDIO_NUM_SAMPLES + i];
133133
134- audioFrames[i * 2 + 0 ] = (ch0 + ch2 * 0 .75f + ch4) * Config::MasterVolume;
135- audioFrames[i * 2 + 1 ] = (ch1 + ch2 * 0 .75f + ch5) * Config::MasterVolume;
134+ float samp0 = (ch0 + ch2 * 0 .75f + ch4) * Config::MasterVolume;
135+ float samp1 = (ch1 + ch2 * 0 .75f + ch5) * Config::MasterVolume;
136+
137+ audioFrames[i * 2 + 0 ] = isnan (samp0) ? 0 .0f : samp0;
138+ audioFrames[i * 2 + 1 ] = isnan (samp1) ? 0 .0f : samp1;
136139 }
137140
138141 SDL_QueueAudio (g_audioDevice, &audioFrames, sizeof (audioFrames));
@@ -143,8 +146,10 @@ void XAudioSubmitFrame(void* samples)
143146
144147 for (size_t i = 0 ; i < XAUDIO_NUM_SAMPLES ; i++)
145148 {
146- for (size_t j = 0 ; j < XAUDIO_NUM_CHANNELS ; j++)
147- audioFrames[i * XAUDIO_NUM_CHANNELS + j] = floatSamples[j * XAUDIO_NUM_SAMPLES + i] * Config::MasterVolume;
149+ for (size_t j = 0 ; j < XAUDIO_NUM_CHANNELS ; j++) {
150+ float samp = floatSamples[j * XAUDIO_NUM_SAMPLES + i] * Config::MasterVolume;
151+ audioFrames[i * 2 + j] = isnan (samp) ? 0 .0f : samp;
152+ }
148153 }
149154
150155 SDL_QueueAudio (g_audioDevice, &audioFrames, sizeof (audioFrames));
You can’t perform that action at this time.
0 commit comments