mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-14 23:38:14 +00:00
aaudio: Deal with device recovery.
Android claims to work with multiple devices, but doesn't actually appear to (at least, afaict), and it will report tons of devices that all just seem to play to the current default output, so for now, turn this off and only expose a default device. And then, with that default output, attempt to recover on errors by throwing away the current AAudioStream and building a new one. This let me plug/unplug a set of headphones from the headphone jack and audio would switch correctly to the new output.
This commit is contained in:
@@ -1006,6 +1006,7 @@ JNIEXPORT void JNICALL
|
||||
SDL_JAVA_AUDIO_INTERFACE(addAudioDevice)(JNIEnv *env, jclass jcls, jboolean is_capture,
|
||||
jstring name, jint device_id)
|
||||
{
|
||||
#if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
|
||||
if (SDL_GetCurrentAudioDriver() != NULL) {
|
||||
void *handle = (void *)((size_t)device_id);
|
||||
if (!SDL_FindPhysicalAudioDeviceByHandle(handle)) {
|
||||
@@ -1014,16 +1015,19 @@ SDL_JAVA_AUDIO_INTERFACE(addAudioDevice)(JNIEnv *env, jclass jcls, jboolean is_c
|
||||
(*env)->ReleaseStringUTFChars(env, name, utf8name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
SDL_JAVA_AUDIO_INTERFACE(removeAudioDevice)(JNIEnv *env, jclass jcls, jboolean is_capture,
|
||||
jint device_id)
|
||||
{
|
||||
#if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
|
||||
if (SDL_GetCurrentAudioDriver() != NULL) {
|
||||
SDL_Log("Removing device with handle %d, capture %d", device_id, is_capture);
|
||||
SDL_AudioDeviceDisconnected(SDL_FindPhysicalAudioDeviceByHandle((void *)((size_t)device_id)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Paddown */
|
||||
|
Reference in New Issue
Block a user