mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +02:00
Allow backends to work without stepping when threading is disabled.
This is per-backend.
This commit is contained in:
+7
-3
@@ -7297,6 +7297,7 @@ typedef struct ma_device_backend_info
|
|||||||
const char* pName;
|
const char* pName;
|
||||||
ma_bool32 isLoopbackSupported;
|
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 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;
|
} ma_device_backend_info;
|
||||||
|
|
||||||
|
|
||||||
@@ -45937,6 +45938,7 @@ static void ma_backend_info__webaudio(ma_device_backend_info* pBackendInfo)
|
|||||||
MA_ASSERT(pBackendInfo != NULL);
|
MA_ASSERT(pBackendInfo != NULL);
|
||||||
pBackendInfo->pName = "Web Audio";
|
pBackendInfo->pName = "Web Audio";
|
||||||
pBackendInfo->noAudioThread = MA_TRUE; /* We don't want to be creating a miniaudio-managed audio thread with 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)
|
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;
|
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;
|
threadingMode = pConfig->threadingMode;
|
||||||
|
|
||||||
/* Force single-threaded mode if threading has been disabled at compile time. */
|
/* Force single-threaded mode if threading has been disabled at compile time. */
|
||||||
#ifdef MA_NO_THREADING
|
#ifdef MA_NO_THREADING
|
||||||
{
|
{
|
||||||
|
if (!backendInfo.isMultiThreadedModeAllowedWhenThreadingDisabled) {
|
||||||
threadingMode = MA_THREADING_MODE_SINGLE_THREADED;
|
threadingMode = MA_THREADING_MODE_SINGLE_THREADED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#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. */
|
/* Check that we have our callbacks defined. */
|
||||||
if (pContext->pVTable->onDeviceInit == NULL) {
|
if (pContext->pVTable->onDeviceInit == NULL) {
|
||||||
return MA_INVALID_OPERATION;
|
return MA_INVALID_OPERATION;
|
||||||
|
|||||||
Reference in New Issue
Block a user