Attempt 100 of trying to fix Wii U audio hangs
There's a new bug I've noticed: sometimes, an instrument will just 'disappear', and refuse to ever play again. This stuff is practically impossible to debug, so I'm just throwing things at the wall. This time, I'm going to make more use of the `AXVoiceBegin` and `AXVoiceEnd` functions. I have no idea what they're meant to do: code I found online uses it inconstently, and Decaf doesn't have it implemented at all! Hopefully, all of my problems have just been race conditions caused by not using these guard functions (assuming that's what they are).
This commit is contained in:
parent
bbfcc48e2a
commit
873566a19e
1 changed files with 28 additions and 0 deletions
|
@ -261,8 +261,12 @@ void AudioBackend_PlaySound(AudioBackend_Sound *sound, bool looping)
|
|||
|
||||
if (sound->voice != NULL)
|
||||
{
|
||||
AXVoiceBegin(sound->voice);
|
||||
|
||||
AXSetVoiceLoop(sound->voice, looping ? AX_VOICE_LOOP_ENABLED : AX_VOICE_LOOP_DISABLED);
|
||||
AXSetVoiceState(sound->voice, AX_VOICE_STATE_PLAYING);
|
||||
|
||||
AXVoiceEnd(sound->voice);
|
||||
}
|
||||
|
||||
OSUnlockMutex(&sound_list_mutex);
|
||||
|
@ -273,8 +277,14 @@ void AudioBackend_StopSound(AudioBackend_Sound *sound)
|
|||
OSLockMutex(&sound_list_mutex);
|
||||
|
||||
if (sound->voice != NULL)
|
||||
{
|
||||
AXVoiceBegin(sound->voice);
|
||||
|
||||
AXSetVoiceState(sound->voice, AX_VOICE_STATE_STOPPED);
|
||||
|
||||
AXVoiceEnd(sound->voice);
|
||||
}
|
||||
|
||||
OSUnlockMutex(&sound_list_mutex);
|
||||
}
|
||||
|
||||
|
@ -283,8 +293,14 @@ void AudioBackend_RewindSound(AudioBackend_Sound *sound)
|
|||
OSLockMutex(&sound_list_mutex);
|
||||
|
||||
if (sound->voice != NULL)
|
||||
{
|
||||
AXVoiceBegin(sound->voice);
|
||||
|
||||
AXSetVoiceCurrentOffset(sound->voice, 0);
|
||||
|
||||
AXVoiceEnd(sound->voice);
|
||||
}
|
||||
|
||||
OSUnlockMutex(&sound_list_mutex);
|
||||
}
|
||||
|
||||
|
@ -296,8 +312,12 @@ void AudioBackend_SetSoundFrequency(AudioBackend_Sound *sound, unsigned int freq
|
|||
|
||||
if (sound->voice != NULL)
|
||||
{
|
||||
AXVoiceBegin(sound->voice);
|
||||
|
||||
float srcratio = (float)frequency / (float)AXGetInputSamplesPerSec();
|
||||
AXSetVoiceSrcRatio(sound->voice, srcratio);
|
||||
|
||||
AXVoiceEnd(sound->voice);
|
||||
}
|
||||
|
||||
OSUnlockMutex(&sound_list_mutex);
|
||||
|
@ -311,9 +331,13 @@ void AudioBackend_SetSoundVolume(AudioBackend_Sound *sound, long volume)
|
|||
|
||||
if (sound->voice != NULL)
|
||||
{
|
||||
AXVoiceBegin(sound->voice);
|
||||
|
||||
AXVoiceVeData vol = {.volume = sound->volume};
|
||||
|
||||
AXSetVoiceVe(sound->voice, &vol);
|
||||
|
||||
AXVoiceEnd(sound->voice);
|
||||
}
|
||||
|
||||
OSUnlockMutex(&sound_list_mutex);
|
||||
|
@ -328,11 +352,15 @@ void AudioBackend_SetSoundPan(AudioBackend_Sound *sound, long pan)
|
|||
|
||||
if (sound->voice != NULL)
|
||||
{
|
||||
AXVoiceBegin(sound->voice);
|
||||
|
||||
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);
|
||||
|
||||
AXVoiceEnd(sound->voice);
|
||||
}
|
||||
|
||||
OSUnlockMutex(&sound_list_mutex);
|
||||
|
|
Loading…
Add table
Reference in a new issue