aaudio: Try to select a more-useful microphone for recording.
Fixes #13402.
This commit is contained in:
@@ -65,11 +65,16 @@ static bool AAUDIO_LoadFunctions(AAUDIO_Data *data)
|
|||||||
{
|
{
|
||||||
#define SDL_PROC(ret, func, params) \
|
#define SDL_PROC(ret, func, params) \
|
||||||
do { \
|
do { \
|
||||||
data->func = (ret (*) params)SDL_LoadFunction(data->handle, #func); \
|
data->func = (ret (*) params)SDL_LoadFunction(data->handle, #func); \
|
||||||
if (!data->func) { \
|
if (!data->func) { \
|
||||||
return SDL_SetError("Couldn't load AAUDIO function %s: %s", #func, SDL_GetError()); \
|
return SDL_SetError("Couldn't load AAUDIO function %s: %s", #func, SDL_GetError()); \
|
||||||
} \
|
} \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
#define SDL_PROC_OPTIONAL(ret, func, params) \
|
||||||
|
do { \
|
||||||
|
data->func = (ret (*) params)SDL_LoadFunction(data->handle, #func); /* if it fails, okay. */ \
|
||||||
|
} while (0);
|
||||||
#include "SDL_aaudiofuncs.h"
|
#include "SDL_aaudiofuncs.h"
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -327,6 +332,12 @@ static bool BuildAAudioStream(SDL_AudioDevice *device)
|
|||||||
SDL_Log("Low latency audio disabled");
|
SDL_Log("Low latency audio disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
LOGI("AAudio Try to open %u hz %s %u channels samples %u",
|
LOGI("AAudio Try to open %u hz %s %u channels samples %u",
|
||||||
device->spec.freq, SDL_GetAudioFormatName(device->spec.format),
|
device->spec.freq, SDL_GetAudioFormatName(device->spec.format),
|
||||||
device->spec.channels, device->sample_frames);
|
device->spec.channels, device->sample_frames);
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef SDL_PROC_OPTIONAL(ret, func, params)
|
||||||
|
#define SDL_PROC_OPTIONAL(ret, func, params) SDL_PROC(ret, func, params)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SDL_PROC_UNUSED(ret, func, params)
|
#define SDL_PROC_UNUSED(ret, func, params)
|
||||||
|
|
||||||
SDL_PROC(const char *, AAudio_convertResultToText, (aaudio_result_t returnCode))
|
SDL_PROC(const char *, AAudio_convertResultToText, (aaudio_result_t returnCode))
|
||||||
@@ -35,7 +39,7 @@ SDL_PROC(void, AAudioStreamBuilder_setBufferCapacityInFrames, (AAudioStreamBuild
|
|||||||
SDL_PROC(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder * builder, aaudio_performance_mode_t mode))
|
SDL_PROC(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder * builder, aaudio_performance_mode_t mode))
|
||||||
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder * builder, aaudio_usage_t usage)) // API 28
|
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder * builder, aaudio_usage_t usage)) // API 28
|
||||||
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder * builder, aaudio_content_type_t contentType)) // API 28
|
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder * builder, aaudio_content_type_t contentType)) // API 28
|
||||||
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder * builder, aaudio_input_preset_t inputPreset)) // API 28
|
SDL_PROC_OPTIONAL(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder * builder, aaudio_input_preset_t inputPreset)) // API 28
|
||||||
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setAllowedCapturePolicy, (AAudioStreamBuilder * builder, aaudio_allowed_capture_policy_t capturePolicy)) // API 29
|
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setAllowedCapturePolicy, (AAudioStreamBuilder * builder, aaudio_allowed_capture_policy_t capturePolicy)) // API 29
|
||||||
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSessionId, (AAudioStreamBuilder * builder, aaudio_session_id_t sessionId)) // API 28
|
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSessionId, (AAudioStreamBuilder * builder, aaudio_session_id_t sessionId)) // API 28
|
||||||
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPrivacySensitive, (AAudioStreamBuilder * builder, bool privacySensitive)) // API 30
|
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPrivacySensitive, (AAudioStreamBuilder * builder, bool privacySensitive)) // API 30
|
||||||
@@ -80,3 +84,4 @@ SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream * stream))
|
|||||||
|
|
||||||
#undef SDL_PROC
|
#undef SDL_PROC
|
||||||
#undef SDL_PROC_UNUSED
|
#undef SDL_PROC_UNUSED
|
||||||
|
#undef SDL_PROC_OPTIONAL
|
||||||
|
|||||||
Reference in New Issue
Block a user