ref: a177f44b8884810adc58ce5d83617ef421fb49aa
parent: 9eacc74ee23cd776c507444132558f277b54bd68
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Apr 17 10:15:23 EDT 2020
Clean up Wii U audio backend
--- a/src/Backends/Audio/WiiU.cpp
+++ b/src/Backends/Audio/WiiU.cpp
@@ -37,7 +37,7 @@
return pow(10.0, volume / 2000.0);
}
-static unsigned long tick_delta;
+static unsigned long ticks_per_second;
static unsigned long GetTicksMilliseconds(void)
{
@@ -51,7 +51,7 @@
last_tick = current_tick;
- return (accumulator * 1000) / tick_delta;
+ return (accumulator * 1000) / ticks_per_second;
}
static int ThreadFunction(int argc, const char *argv[])
@@ -62,7 +62,7 @@
if (organya_milliseconds == 0)
{
- OSSleepTicks(1);
+ OSSleepTicks(ticks_per_second / 1000);
}
else
{
@@ -79,7 +79,7 @@
break;
}
- OSSleepTicks(1);
+ OSSleepTicks(ticks_per_second / 1000);
}
if (organya_callback != NULL)
@@ -102,8 +102,9 @@
AXInitWithParams(&initparams);
}
- tick_delta = OSGetSystemInfo()->busClockSpeed / 4;
+ ticks_per_second = OSGetSystemInfo()->busClockSpeed / 4;
+
OSRunThread(OSGetDefaultThread(0), ThreadFunction, 0, NULL);
return true;
@@ -113,8 +114,7 @@
{
OSCancelThread(OSGetDefaultThread(0));
- //int result;
- //OSJoinThread(&thread, &result);
+ OSJoinThread(OSGetDefaultThread(0), NULL);
AXQuit();
}
@@ -168,17 +168,15 @@
if (voice != NULL)
{
- AXVoiceOffsets offs;
- AXVoiceVeData vol = {
- .volume = sound->volume,
- };
-
AXVoiceBegin(voice);
AXSetVoiceType(voice, 0);
+
+ AXVoiceVeData vol = {.volume = sound->volume};
AXSetVoiceVe(voice, &vol);
- static AXVoiceDeviceMixData mix_data[1][6];
+ AXVoiceDeviceMixData mix_data[1][6];
+ memset(mix_data, 0, sizeof(mix_data));
mix_data[0][0].bus[0].volume = sound->pan_l;
mix_data[0][1].bus[0].volume = sound->pan_r;
@@ -189,6 +187,7 @@
AXSetVoiceSrcRatio(voice, srcratio);
AXSetVoiceSrcType(voice, AX_VOICE_SRC_TYPE_LINEAR);
+ AXVoiceOffsets offs;
offs.dataType = AX_VOICE_FORMAT_LPCM8;
offs.endOffset = sound->length;
offs.loopingEnabled = AX_VOICE_LOOP_DISABLED;
@@ -214,7 +213,6 @@
{
if (sound->voice != NULL)
{
-// AXSetVoiceState(sound->voice, AX_VOICE_STATE_STOPPED);
AXFreeVoice(sound->voice);
sound->voice = NULL;
}
@@ -223,10 +221,7 @@
void AudioBackend_RewindSound(AudioBackend_Sound *sound)
{
if (sound->voice != NULL)
- {
- // AXSetVoiceState(sound->voice, AX_VOICE_STATE_STOPPED);
AXSetVoiceCurrentOffset(sound->voice, 0);
- }
}
void AudioBackend_SetSoundFrequency(AudioBackend_Sound *sound, unsigned int frequency)
@@ -259,7 +254,8 @@
sound->pan_l = (unsigned short)(0x8000 * MillibelToScale(-pan));
sound->pan_r = (unsigned short)(0x8000 * MillibelToScale(pan));
- static AXVoiceDeviceMixData mix_data[1][6];
+ AXVoiceDeviceMixData mix_data[1][6];
+ memset(mix_data, 0, sizeof(mix_data));
mix_data[0][0].bus[0].volume = sound->pan_l;
mix_data[0][1].bus[0].volume = sound->pan_r;