Allow backends to work without stepping when threading is disabled.

This is per-backend.
This commit is contained in:
David Reid
2026-01-21 12:14:34 +10:00
parent f37ffed283
commit f6b973d384
+7 -3
View File
@@ -7297,6 +7297,7 @@ typedef struct ma_device_backend_info
const char* pName;
ma_bool32 isLoopbackSupported;
ma_bool32 noAudioThread; /* When set to true, the backend does not create a miniaudio-managed audio thread. Will be used for backends like Web Audio, or those that run on platforms that do not support multithreading. Depending on the backend, this may force single-threaded mode. Single-threaded mode will not be enforced for the Web Audio backend. */
ma_bool32 isMultiThreadedModeAllowedWhenThreadingDisabled; /* When set to true, the backend must be 100% thread safe. */
} ma_device_backend_info;
@@ -45937,6 +45938,7 @@ static void ma_backend_info__webaudio(ma_device_backend_info* pBackendInfo)
MA_ASSERT(pBackendInfo != NULL);
pBackendInfo->pName = "Web Audio";
pBackendInfo->noAudioThread = MA_TRUE; /* We don't want to be creating a miniaudio-managed audio thread with Web Audio. */
pBackendInfo->isMultiThreadedModeAllowedWhenThreadingDisabled = MA_TRUE;
}
static ma_result ma_context_init__webaudio(ma_context* pContext, const void* pContextBackendConfig, void** ppContextState)
@@ -48428,18 +48430,20 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
return MA_INVALID_ARGS;
}
/* We'll need the backend info to determine whether or not an audio thread can be created. */
ma_context_get_backend_info(pContext, &backendInfo);
threadingMode = pConfig->threadingMode;
/* Force single-threaded mode if threading has been disabled at compile time. */
#ifdef MA_NO_THREADING
{
if (!backendInfo.isMultiThreadedModeAllowedWhenThreadingDisabled) {
threadingMode = MA_THREADING_MODE_SINGLE_THREADED;
}
}
#endif
/* We'll need the backend info to determine whether or not an audio thread can be created. */
ma_context_get_backend_info(pContext, &backendInfo);
/* Check that we have our callbacks defined. */
if (pContext->pVTable->onDeviceInit == NULL) {
return MA_INVALID_OPERATION;