mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +02:00
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:
+11
-6
@@ -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;
|
const ma_context_config_audio4* pContextConfigAudio4 = (const ma_context_config_audio4*)pContextBackendConfig;
|
||||||
ma_context_config_audio4 defaultConfigAudio4;
|
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) {
|
if (pContextConfigAudio4 == NULL) {
|
||||||
defaultConfigAudio4 = ma_context_config_audio4_init();
|
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;
|
int iDevice;
|
||||||
struct stat stDefault;
|
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"
|
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.
|
version here since we can open it even when another process has control of the "/dev/audioN" device.
|
||||||
|
|||||||
Reference in New Issue
Block a user