Wii U: Support For Seperate Gamepad and TV Audio Devices#116
Wii U: Support For Seperate Gamepad and TV Audio Devices#116Fangal-Airbag wants to merge 3 commits intodevkitPro:wiiu-sdl2-2.32from
Conversation
GaryOderNichts
left a comment
There was a problem hiding this comment.
Thanks for the PR! Hmm, this code seems somewhat fragile at the moment.
Closing a single audio device will uninitialize AX, even if other devices are still running. wiiuDevices is also not updated when closing a device, causing potential issues in the frame callback.
Ideally it should be possible to close and reopen audio devices. I think separating the AX initialization from opening and closing audio devices might be a good idea.
|
So with this commit AX will only deinitialize if its the last audio device being closed. |
GaryOderNichts
left a comment
There was a problem hiding this comment.
Looks better now. There is still an issue if the first initialized device is closed before the last initialized device though.
874da16 to
398f949
Compare
…dles for device identification
GaryOderNichts
left a comment
There was a problem hiding this comment.
wiiuDevicesis also not updated when closing a device, causing potential issues in the frame callback.
There is still an issue if the first initialized device is closed before the last initialized device though.
This still isn't addressed yet. If you create 2 devices for TV and DRC, then close the first created one first, deviceCount is now 1, while the first pointer is already free'd.
| SDL_AddAudioDevice(SDL_FALSE, SDL_AUDIO_DEVICE_WIIU_MIRRORED, &spec, &mirroredHandle); | ||
| SDL_AddAudioDevice(SDL_FALSE, SDL_AUDIO_DEVICE_WIIU_TV, &spec, &tvHandle); | ||
| SDL_AddAudioDevice(SDL_FALSE, SDL_AUDIO_DEVICE_WIIU_GAMEPAD, &spec, &drcHandle); |
There was a problem hiding this comment.
I meant something like
SDL_AddAudioDevice(SDL_FALSE, SDL_AUDIO_DEVICE_WIIU_MIRRORED, &spec, (void*) WIIU_DEVICE_MIRRORED);
SDL_AddAudioDevice(SDL_FALSE, SDL_AUDIO_DEVICE_WIIU_TV, &spec, (void*) WIIU_DEVICE_TV);
SDL_AddAudioDevice(SDL_FALSE, SDL_AUDIO_DEVICE_WIIU_GAMEPAD, &spec, (void*) WIIU_DEVICE_GAMEPAD);The handle is entirely user controlled, there's no need to store an actual pointer there if you don't read/write to it.
| if (this->handle == &tvHandle) { | ||
| deviceType = WIIU_DEVICE_TV; | ||
| } | ||
| else if (this->handle == &drcHandle) { | ||
| deviceType = WIIU_DEVICE_GAMEPAD; | ||
| } |
There was a problem hiding this comment.
You don't need to set a global variable for the device here. You can use device->handle to check for the device type when needed.
This PR adds in support for separate Gamepad and TV SDL Devices while retaining support for mirroring the audio on both at the same time.
These audio devices can be created as follows:
When setting up SDL_Audio and creating an audio device, if not specified, the audio device will default to
SDL_AUDIO_DEVICE_WIIU_MIRRORED.sorry for the second PR, had to fix some git stuff