aaudio: Make input preset into a hint, don't set it by default.

Fixes #16130.
Reference Issue #13402.

(cherry picked from commit 22e42e6e1e)
This commit is contained in:
Ryan C. Gordon
2026-09-01 14:03:05 -04:00
parent 4aa40070ef
commit aba2d16233
2 changed files with 34 additions and 3 deletions

View File

@@ -368,9 +368,13 @@ static bool BuildAAudioStream(SDL_AudioDevice *device)
SetOptionalStreamUsage(builder);
if (recording && ctx.AAudioStreamBuilder_setInputPreset) { // optional API: requires Android 28
// try to use a microphone that is for recording external audio. Otherwise Android might choose the mic used for talking
// on the telephone when held to the user's ear, which is often not useful at any distance from the device.
ctx.AAudioStreamBuilder_setInputPreset(builder, AAUDIO_INPUT_PRESET_CAMCORDER);
const char *hint = SDL_GetHint(SDL_HINT_ANDROID_AAUDIO_INPUT_PRESET);
if (hint) {
const aaudio_input_preset_t preset = (const aaudio_input_preset_t) SDL_atoi(hint);
if (preset) {
ctx.AAudioStreamBuilder_setInputPreset(builder, preset);
}
}
}
LOGI("AAudio Try to open %u hz %s %u channels samples %u",