From fa6d0c47b8b57e7e4f0b263ef033205a6e3ca993 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Fri, 20 Sep 2019 23:07:36 +1000 Subject: [PATCH] audio/wiiu: Properly initialise AXVoiceDeviceMixData (fixes odd behaviour when surround sound is enabled, hopefully) --- src/audio/wiiu/SDL_wiiuaudio.c | 98 +++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 12 deletions(-) diff --git a/src/audio/wiiu/SDL_wiiuaudio.c b/src/audio/wiiu/SDL_wiiuaudio.c index 8004ff99d..af7e84471 100644 --- a/src/audio/wiiu/SDL_wiiuaudio.c +++ b/src/audio/wiiu/SDL_wiiuaudio.c @@ -66,15 +66,92 @@ static int WIIUAUDIO_OpenDevice(_THIS, void* handle, const char* devname, int is AXVoiceVeData vol = { .volume = 0x8000, }; - AXVoiceDeviceMixData drcmix = { - .bus = { - { .volume = 0x8000 }, //bus 0 - { .volume = 0x0000 }, //bus 1 - { .volume = 0x0000 }, //bus 2 - { .volume = 0x0000 }, //bus 3 + //TODO: AXGetDeviceChannelCount. For now we'll use Decaf's values and + //configure for stereo (muted surrounds). + AXVoiceDeviceMixData drcmix[4] = { + [0] = { //gamepad left channel + .bus = { + { .volume = 0x8000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + [1] = { //gamepad right channel + .bus = { + { .volume = 0x8000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + [2] = { //gamepad surround #1 (virtual) + .bus = { + { .volume = 0x0000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + [3] = { //gamepad surround #2 (virtual) + .bus = { + { .volume = 0x0000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + }; + AXVoiceDeviceMixData tvmix[6] = { + [0] = { //tv left channel + .bus = { + { .volume = 0x8000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + [1] = { //tv right channel + .bus = { + { .volume = 0x8000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + [2] = { //tv surround #1 + .bus = { + { .volume = 0x8000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + [3] = { //tv surround #2 + .bus = { + { .volume = 0x0000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + [4] = { //tv surround #3 + .bus = { + { .volume = 0x0000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } + }, + [5] = { //tv surround #4 + .bus = { + { .volume = 0x0000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + } }, }; - AXVoiceDeviceMixData tvmix = drcmix; uint32_t old_affinity; float srcratio; @@ -96,9 +173,6 @@ static int WIIUAUDIO_OpenDevice(_THIS, void* handle, const char* devname, int is AXInitWithParams(&initparams); } else printf("DEBUG: AX already up?\n"); -/* Disable gamepad virtual surround (causes distortion) */ - AXSetDRCVSMode(0); - /* Get a voice, top priority (we only need one) */ this->hidden->voice = AXAcquireVoice(31, NULL, NULL); if (!this->hidden->voice) { @@ -114,8 +188,8 @@ static int WIIUAUDIO_OpenDevice(_THIS, void* handle, const char* devname, int is /* Set the voice's volume */ AXSetVoiceVe(this->hidden->voice, &vol); - AXSetVoiceDeviceMix(this->hidden->voice, AX_DEVICE_TYPE_DRC, 0, &drcmix); - AXSetVoiceDeviceMix(this->hidden->voice, AX_DEVICE_TYPE_TV, 0, &tvmix); + AXSetVoiceDeviceMix(this->hidden->voice, AX_DEVICE_TYPE_DRC, 0, drcmix); + AXSetVoiceDeviceMix(this->hidden->voice, AX_DEVICE_TYPE_TV, 0, tvmix); /* Set the samplerate conversion ratio / */