shithub: cstory

Download patch

ref: b123e3743edf399350e6b8d9e94a49a6e86aa5f0
parent: db14899b3e83712f18d8723bc30db3f0e35b58ed
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Apr 17 17:48:34 EDT 2020

Clean-up the weird buggy code

I'mma just assume each sound needs their struct preserving for some
reason.

--- a/src/Backends/Audio/WiiU.cpp
+++ b/src/Backends/Audio/WiiU.cpp
@@ -25,6 +25,7 @@
 	unsigned short volume;
 	unsigned short pan_l;
 	unsigned short pan_r;
+	AXVoiceDeviceMixData mix_data[6];
 };
 
 static void (*organya_callback)(void);
@@ -174,12 +175,12 @@
 			AXVoiceVeData vol = {.volume = sound->volume};
 			AXSetVoiceVe(voice, &vol);
 
-			static AXVoiceDeviceMixData mix_data[1][6];
-			mix_data[0][0].bus[0].volume = sound->pan_l;
-			mix_data[0][1].bus[0].volume = sound->pan_r;
+			memset(sound->mix_data, 0, sizeof(sound->mix_data));
+			sound->mix_data[0].bus[0].volume = sound->pan_l;
+			sound->mix_data[1].bus[0].volume = sound->pan_r;
 
-			AXSetVoiceDeviceMix(voice, AX_DEVICE_TYPE_DRC, 0, mix_data[0]);
-			AXSetVoiceDeviceMix(voice, AX_DEVICE_TYPE_TV, 0, mix_data[0]);
+			AXSetVoiceDeviceMix(voice, AX_DEVICE_TYPE_DRC, 0, sound->mix_data);
+			AXSetVoiceDeviceMix(voice, AX_DEVICE_TYPE_TV, 0, sound->mix_data);
 
 			float srcratio = (float)sound->frequency / (float)AXGetInputSamplesPerSec();
 			AXSetVoiceSrcRatio(voice, srcratio);
@@ -251,14 +252,13 @@
 	sound->pan_l = (unsigned short)(0x8000 * MillibelToScale(-pan));
 	sound->pan_r = (unsigned short)(0x8000 * MillibelToScale(pan));
 
-	static AXVoiceDeviceMixData mix_data[1][6];
-	mix_data[0][0].bus[0].volume = sound->pan_l;
-	mix_data[0][1].bus[0].volume = sound->pan_r;
-
 	if (sound->voice != NULL)
 	{
-		AXSetVoiceDeviceMix(sound->voice, AX_DEVICE_TYPE_DRC, 0, mix_data[0]);
-		AXSetVoiceDeviceMix(sound->voice, AX_DEVICE_TYPE_TV, 0, mix_data[0]);
+		sound->mix_data[0].bus[0].volume = sound->pan_l;
+		sound->mix_data[1].bus[0].volume = sound->pan_r;
+
+		AXSetVoiceDeviceMix(sound->voice, AX_DEVICE_TYPE_DRC, 0, sound->mix_data);
+		AXSetVoiceDeviceMix(sound->voice, AX_DEVICE_TYPE_TV, 0, sound->mix_data);
 	}
 }