--- a/src/MacSrc/Shock.c +++ b/src/MacSrc/Shock.c @@ -162,9 +162,26 @@ void InitSDL() { SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#ifdef __ANDROID__ + // SDL2 2.28.5's AAudio backend (Android's default since API 26) only + // ever allows one open non-capture (playback) device at a time - it + // keeps a single static handle and asserts on a second open + // ('SDL_assert((audioDevice == NULL) || iscapture)' in + // src/audio/aaudio/SDL_aaudio.c). SDLSound.c opens two: one directly via + // SDL_OpenAudioDevice() for cutscene audio, one via Mix_OpenAudio() for + // SFX/MIDI. The older OpenSL ES backend has no such limitation, so force + // it instead of AAudio. Uses SDL_HINT_OVERRIDE priority so nothing set + // earlier (or by SDL/the platform) can take precedence over it. + SDL_SetHintWithPriority(SDL_HINT_AUDIODRIVER, "openslES", SDL_HINT_OVERRIDE); +#endif if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0) { DEBUG("%s: Init failed", __FUNCTION__); } +#ifdef __ANDROID__ + // Standing diagnostic: reports which audio driver SDL actually selected, + // to confirm the openslES override above took effect on-device. + INFO("SDL audio driver: %s", SDL_GetCurrentAudioDriver()); +#endif // TODO: figure out some universal set of settings that work... #ifdef __ANDROID__