audio(4): Failed context initialization if /dev/audioctl does not exist.

This allows initialization to abort at an earlier stage which gives the
fallback logic a chance to try a different backend.
This commit is contained in:
David Reid
2026-01-28 16:33:30 +10:00
parent 38e35935d7
commit 3ab152afb3
+11 -6
View File
@@ -41181,7 +41181,17 @@ static ma_result ma_context_init__audio4(ma_context* pContext, const void* pCont
const ma_context_config_audio4* pContextConfigAudio4 = (const ma_context_config_audio4*)pContextBackendConfig;
ma_context_config_audio4 defaultConfigAudio4;
/* Check if /dev/audioctl actually exists. If not, the backend cannot be used. */
#if !defined(MA_AUDIO4_USE_NEW_API) /* Old API */
{
struct stat stDefault;
if (stat("/dev/audioctl", &stDefault) < 0) {
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[audio4] Failed to open /dev/audioctl. Backend not usable.");
return MA_NO_BACKEND;
}
}
#endif
if (pContextConfigAudio4 == NULL) {
defaultConfigAudio4 = ma_context_config_audio4_init();
@@ -41578,11 +41588,6 @@ static ma_result ma_context_enumerate_devices__audio4(ma_context* pContext, ma_e
int iDevice;
struct stat stDefault;
if (stat("/dev/audioctl", &stDefault) < 0) {
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[audio4] Failed to open /dev/audioctl. Backend not usable.");
return MA_NO_BACKEND;
}
/*
Every device will be named "/dev/audioN", with a "/dev/audioctlN" equivalent. We use the "/dev/audioctlN"
version here since we can open it even when another process has control of the "/dev/audioN" device.