mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 09:14:04 +02:00
Cleanup old backend callback stuff.
This commit is contained in:
+11
-232
@@ -3603,16 +3603,6 @@ struct ma_context
|
||||
ma_uint32 playbackDeviceInfoCount;
|
||||
ma_uint32 captureDeviceInfoCount;
|
||||
ma_device_info* pDeviceInfos; /* Playback devices first, then capture. */
|
||||
ma_bool8 isBackendAsynchronous; /* Set when the context is initialized. Set to 1 for asynchronous backends such as Core Audio and JACK. Do not modify. */
|
||||
|
||||
ma_result (* onUninit )(ma_context* pContext);
|
||||
ma_result (* onEnumDevices )(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData); /* Return false from the callback to stop enumeration. */
|
||||
ma_result (* onGetDeviceInfo )(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_share_mode shareMode, ma_device_info* pDeviceInfo);
|
||||
ma_result (* onDeviceInit )(ma_context* pContext, const ma_device_config* pConfig, ma_device* pDevice);
|
||||
void (* onDeviceUninit )(ma_device* pDevice);
|
||||
ma_result (* onDeviceStart )(ma_device* pDevice);
|
||||
ma_result (* onDeviceStop )(ma_device* pDevice);
|
||||
ma_result (* onDeviceMainLoop)(ma_device* pDevice);
|
||||
|
||||
union
|
||||
{
|
||||
@@ -3845,7 +3835,6 @@ struct ma_context
|
||||
ma_proc AudioUnitRender;
|
||||
|
||||
/*AudioComponent*/ ma_ptr component;
|
||||
|
||||
ma_bool32 noAudioSessionDeactivate; /* For tracking whether or not the iOS audio session should be explicitly deactivated. Set from the config in ma_context_init__coreaudio(). */
|
||||
} coreaudio;
|
||||
#endif
|
||||
@@ -4207,7 +4196,6 @@ struct ma_device
|
||||
{
|
||||
/*AAudioStream**/ ma_ptr pStreamPlayback;
|
||||
/*AAudioStream**/ ma_ptr pStreamCapture;
|
||||
ma_pcm_rb duplexRB;
|
||||
} aaudio;
|
||||
#endif
|
||||
#ifdef MA_SUPPORT_OPENSL
|
||||
@@ -31843,15 +31831,6 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
|
||||
}
|
||||
|
||||
|
||||
/* TEMP: Helper for determining whether or not a context is using the new callback system. Eventually all backends will be using the new callback system. */
|
||||
static ma_bool32 ma_context__is_using_new_callbacks(ma_context* pContext)
|
||||
{
|
||||
MA_ASSERT(pContext != NULL);
|
||||
|
||||
return pContext->callbacks.onContextInit != NULL;
|
||||
}
|
||||
|
||||
|
||||
static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
|
||||
{
|
||||
ma_device* pDevice = (ma_device*)pData;
|
||||
@@ -31903,20 +31882,12 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
|
||||
ma_device__set_state(pDevice, MA_STATE_STARTED);
|
||||
ma_event_signal(&pDevice->startEvent);
|
||||
|
||||
if (ma_context__is_using_new_callbacks(pDevice->pContext)) {
|
||||
if (pDevice->pContext->callbacks.onDeviceAudioThread != NULL) {
|
||||
pDevice->pContext->callbacks.onDeviceAudioThread(pDevice);
|
||||
} else {
|
||||
/* The backend is not using a custom main loop implementation, so now fall back to the blocking read-write implementation. */
|
||||
ma_device_audio_thread__default_read_write(pDevice, &pDevice->pContext->callbacks);
|
||||
}
|
||||
} else {
|
||||
if (pDevice->pContext->onDeviceMainLoop != NULL) {
|
||||
pDevice->pContext->onDeviceMainLoop(pDevice);
|
||||
} else {
|
||||
ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "No main loop implementation.", MA_API_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Getting here means we have broken from the main loop which happens the application has requested that device be stopped. Note that this
|
||||
@@ -31924,15 +31895,9 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
|
||||
don't want to be doing this a second time.
|
||||
*/
|
||||
if (ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED) {
|
||||
if (ma_context__is_using_new_callbacks(pDevice->pContext)) {
|
||||
if (pDevice->pContext->callbacks.onDeviceStop != NULL) {
|
||||
pDevice->pContext->callbacks.onDeviceStop(pDevice);
|
||||
}
|
||||
} else {
|
||||
if (pDevice->pContext->onDeviceStop != NULL) {
|
||||
pDevice->pContext->onDeviceStop(pDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* After the device has stopped, make sure an event is posted. */
|
||||
@@ -32128,7 +32093,6 @@ static ma_bool32 ma_context_is_backend_asynchronous(ma_context* pContext)
|
||||
{
|
||||
MA_ASSERT(pContext != NULL);
|
||||
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
if (pContext->callbacks.onDeviceRead == NULL && pContext->callbacks.onDeviceWrite == NULL) {
|
||||
if (pContext->callbacks.onDeviceAudioThread == NULL) {
|
||||
return MA_TRUE;
|
||||
@@ -32138,9 +32102,6 @@ static ma_bool32 ma_context_is_backend_asynchronous(ma_context* pContext)
|
||||
} else {
|
||||
return MA_FALSE;
|
||||
}
|
||||
} else {
|
||||
return pContext->isBackendAsynchronous;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32202,24 +32163,12 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC
|
||||
|
||||
MA_ASSERT(pBackendsToIterate != NULL);
|
||||
|
||||
for (iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) {
|
||||
for (iBackend = 0; iBackend < backendsToIterateCount; iBackend += 1) {
|
||||
ma_backend backend = pBackendsToIterate[iBackend];
|
||||
|
||||
/* Make sure all callbacks are reset so we don't accidentally drag in any from previously failed initialization attempts. */
|
||||
MA_ZERO_OBJECT(&pContext->callbacks);
|
||||
|
||||
/*
|
||||
I've had a subtle bug where some state is set by the backend's ma_context_init__*() function, but then later failed because
|
||||
a setting in the context that was set in the prior failed attempt was left unchanged in the next attempt which resulted in
|
||||
inconsistent state. Specifically what happened was the PulseAudio backend set the pContext->isBackendAsynchronous flag to true,
|
||||
but since ALSA is not an asynchronous backend (it's a blocking read-write backend) it just left it unmodified with the assumption
|
||||
that it would be initialized to false. This assumption proved to be incorrect because of the fact that the PulseAudio backend set
|
||||
it earlier. For safety I'm going to reset this flag for each iteration.
|
||||
|
||||
TODO: Remove this comment when the isBackendAsynchronous flag is removed.
|
||||
*/
|
||||
pContext->isBackendAsynchronous = MA_FALSE;
|
||||
|
||||
/* These backends are using the new callback system. */
|
||||
switch (backend) {
|
||||
#ifdef MA_HAS_WASAPI
|
||||
@@ -32322,102 +32271,6 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC
|
||||
result = pContext->callbacks.onContextInit(pContext, pConfig, &pContext->callbacks);
|
||||
} else {
|
||||
result = MA_NO_BACKEND;
|
||||
|
||||
/* TEMP. Try falling back to the old callback system. Eventually this switch will be removed completely. */
|
||||
switch (backend) {
|
||||
#ifdef MA_HAS_WASAPI
|
||||
case ma_backend_wasapi:
|
||||
{
|
||||
/*result = ma_context_init__wasapi(&config, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_DSOUND
|
||||
case ma_backend_dsound:
|
||||
{
|
||||
/*result = ma_context_init__dsound(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_WINMM
|
||||
case ma_backend_winmm:
|
||||
{
|
||||
/*result = ma_context_init__winmm(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_ALSA
|
||||
case ma_backend_alsa:
|
||||
{
|
||||
/*result = ma_context_init__alsa(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_PULSEAUDIO
|
||||
case ma_backend_pulseaudio:
|
||||
{
|
||||
/*result = ma_context_init__pulse(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_JACK
|
||||
case ma_backend_jack:
|
||||
{
|
||||
/*result = ma_context_init__jack(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_COREAUDIO
|
||||
case ma_backend_coreaudio:
|
||||
{
|
||||
/*result = ma_context_init__coreaudio(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_SNDIO
|
||||
case ma_backend_sndio:
|
||||
{
|
||||
/*result = ma_context_init__sndio(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_AUDIO4
|
||||
case ma_backend_audio4:
|
||||
{
|
||||
/*result = ma_context_init__audio4(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_OSS
|
||||
case ma_backend_oss:
|
||||
{
|
||||
/*result = ma_context_init__oss(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_AAUDIO
|
||||
case ma_backend_aaudio:
|
||||
{
|
||||
/*result = ma_context_init__aaudio(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_OPENSL
|
||||
case ma_backend_opensl:
|
||||
{
|
||||
/*result = ma_context_init__opensl(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_WEBAUDIO
|
||||
case ma_backend_webaudio:
|
||||
{
|
||||
/*result = ma_context_init__webaudio(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_CUSTOM
|
||||
case ma_backend_custom:
|
||||
{
|
||||
/*result = ma_context_init__custom(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
#ifdef MA_HAS_NULL
|
||||
case ma_backend_null:
|
||||
{
|
||||
/*result = ma_context_init__null(pConfig, pContext);*/
|
||||
} break;
|
||||
#endif
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If this iteration was successful, return. */
|
||||
@@ -32426,18 +32279,21 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device enumeration. ma_context_get_devices() is not thread safe.", result);
|
||||
}
|
||||
|
||||
result = ma_mutex_init(&pContext->deviceInfoLock);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device info retrieval. ma_context_get_device_info() is not thread safe.", result);
|
||||
}
|
||||
|
||||
#ifdef MA_DEBUG_OUTPUT
|
||||
#ifdef MA_DEBUG_OUTPUT
|
||||
{
|
||||
printf("[miniaudio] Endian: %s\n", ma_is_little_endian() ? "LE" : "BE");
|
||||
printf("[miniaudio] SSE2: %s\n", ma_has_sse2() ? "YES" : "NO");
|
||||
printf("[miniaudio] AVX2: %s\n", ma_has_avx2() ? "YES" : "NO");
|
||||
printf("[miniaudio] AVX512F: %s\n", ma_has_avx512f() ? "YES" : "NO");
|
||||
printf("[miniaudio] NEON: %s\n", ma_has_neon() ? "YES" : "NO");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
pContext->backend = backend;
|
||||
return result;
|
||||
@@ -32457,15 +32313,9 @@ MA_API ma_result ma_context_uninit(ma_context* pContext)
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
if (pContext->callbacks.onContextUninit != NULL) {
|
||||
pContext->callbacks.onContextUninit(pContext);
|
||||
}
|
||||
} else {
|
||||
if (pContext->onUninit != NULL) {
|
||||
pContext->onUninit(pContext);
|
||||
}
|
||||
}
|
||||
|
||||
ma_mutex_uninit(&pContext->deviceEnumLock);
|
||||
ma_mutex_uninit(&pContext->deviceInfoLock);
|
||||
@@ -32489,7 +32339,6 @@ MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devi
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
if (pContext->callbacks.onContextEnumerateDevices == NULL) {
|
||||
return MA_INVALID_OPERATION;
|
||||
}
|
||||
@@ -32499,17 +32348,6 @@ MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devi
|
||||
result = pContext->callbacks.onContextEnumerateDevices(pContext, callback, pUserData);
|
||||
}
|
||||
ma_mutex_unlock(&pContext->deviceEnumLock);
|
||||
} else {
|
||||
if (pContext->onEnumDevices == NULL) {
|
||||
return MA_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
ma_mutex_lock(&pContext->deviceEnumLock);
|
||||
{
|
||||
result = pContext->onEnumDevices(pContext, callback, pUserData);
|
||||
}
|
||||
ma_mutex_unlock(&pContext->deviceEnumLock);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -32578,15 +32416,9 @@ MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** p
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
if (pContext->callbacks.onContextEnumerateDevices == NULL) {
|
||||
return MA_INVALID_OPERATION;
|
||||
}
|
||||
} else {
|
||||
if (pContext->onEnumDevices == NULL) {
|
||||
return MA_INVALID_OPERATION;
|
||||
}
|
||||
}
|
||||
|
||||
/* Note that we don't use ma_context_enumerate_devices() here because we want to do locking at a higher level. */
|
||||
ma_mutex_lock(&pContext->deviceEnumLock);
|
||||
@@ -32596,12 +32428,7 @@ MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** p
|
||||
pContext->captureDeviceInfoCount = 0;
|
||||
|
||||
/* Now enumerate over available devices. */
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
result = pContext->callbacks.onContextEnumerateDevices(pContext, ma_context_get_devices__enum_callback, NULL);
|
||||
} else {
|
||||
result = pContext->onEnumDevices(pContext, ma_context_get_devices__enum_callback, NULL);
|
||||
}
|
||||
|
||||
if (result == MA_SUCCESS) {
|
||||
/* Playback devices. */
|
||||
if (ppPlaybackDeviceInfos != NULL) {
|
||||
@@ -32630,6 +32457,8 @@ MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type
|
||||
ma_result result;
|
||||
ma_device_info deviceInfo;
|
||||
|
||||
(void)shareMode; /* Unused. This parameter will be removed in version 0.11. */
|
||||
|
||||
/* NOTE: Do not clear pDeviceInfo on entry. The reason is the pDeviceID may actually point to pDeviceInfo->id which will break things. */
|
||||
if (pContext == NULL || pDeviceInfo == NULL) {
|
||||
return MA_INVALID_ARGS;
|
||||
@@ -32642,23 +32471,13 @@ MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type
|
||||
MA_COPY_MEMORY(&deviceInfo.id, pDeviceID, sizeof(*pDeviceID));
|
||||
}
|
||||
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
if (pContext->callbacks.onContextGetDeviceInfo == NULL) {
|
||||
return MA_INVALID_OPERATION;
|
||||
}
|
||||
} else {
|
||||
if (pContext->onGetDeviceInfo == NULL) {
|
||||
return MA_INVALID_OPERATION;
|
||||
}
|
||||
}
|
||||
|
||||
ma_mutex_lock(&pContext->deviceInfoLock);
|
||||
{
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
result = pContext->callbacks.onContextGetDeviceInfo(pContext, deviceType, pDeviceID, &deviceInfo);
|
||||
} else {
|
||||
result = pContext->onGetDeviceInfo(pContext, deviceType, pDeviceID, shareMode, &deviceInfo);
|
||||
}
|
||||
}
|
||||
ma_mutex_unlock(&pContext->deviceInfoLock);
|
||||
|
||||
@@ -32769,6 +32588,8 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
|
||||
{
|
||||
ma_result result;
|
||||
ma_device_config config;
|
||||
ma_device_descriptor descriptorPlayback;
|
||||
ma_device_descriptor descriptorCapture;
|
||||
|
||||
/* The context can be null, in which case we self-manage it. */
|
||||
if (pContext == NULL) {
|
||||
@@ -32787,15 +32608,9 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
|
||||
|
||||
|
||||
/* Check that we have our callbacks defined. */
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
if (pContext->callbacks.onDeviceInit == NULL) {
|
||||
return MA_INVALID_OPERATION;
|
||||
}
|
||||
} else {
|
||||
if (pContext->onDeviceInit == NULL) {
|
||||
return MA_INVALID_OPERATION;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* We need to make a copy of the config so we can set default values if they were left unset in the input config. */
|
||||
@@ -32971,10 +32786,6 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
|
||||
}
|
||||
|
||||
|
||||
if (ma_context__is_using_new_callbacks(pContext)) {
|
||||
ma_device_descriptor descriptorPlayback;
|
||||
ma_device_descriptor descriptorCapture;
|
||||
|
||||
MA_ZERO_OBJECT(&descriptorPlayback);
|
||||
descriptorPlayback.pDeviceID = pConfig->playback.pDeviceID;
|
||||
descriptorPlayback.shareMode = pConfig->playback.shareMode;
|
||||
@@ -33015,6 +32826,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
On output the descriptors will contain the *actual* data format of the device. We need this to know how to convert the data between
|
||||
the requested format and the internal format.
|
||||
@@ -33091,15 +32903,6 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = pContext->onDeviceInit(pContext, &config, pDevice);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_event_uninit(&pDevice->startEvent);
|
||||
ma_event_uninit(&pDevice->wakeupEvent);
|
||||
ma_mutex_uninit(&pDevice->lock);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ma_device__post_init_setup(pDevice, pConfig->deviceType);
|
||||
@@ -33122,7 +32925,6 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
|
||||
If the backend is asynchronous and the device is duplex, we'll need an intermediary ring buffer. Note that this needs to be done
|
||||
after ma_device__post_init_setup().
|
||||
*/
|
||||
if (ma_context__is_using_new_callbacks(pContext)) { /* <-- TEMP: Will be removed once all asynchronous backends have been converted to the new callbacks. */
|
||||
if (ma_context_is_backend_asynchronous(pContext)) {
|
||||
if (pConfig->deviceType == ma_device_type_duplex) {
|
||||
result = ma_duplex_rb_init(pDevice->capture.format, pDevice->capture.channels, pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalPeriodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB);
|
||||
@@ -33132,7 +32934,6 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ma_device__set_state(pDevice, MA_STATE_STOPPED);
|
||||
}
|
||||
@@ -33253,15 +33054,9 @@ MA_API void ma_device_uninit(ma_device* pDevice)
|
||||
ma_thread_wait(&pDevice->thread);
|
||||
}
|
||||
|
||||
if (ma_context__is_using_new_callbacks(pDevice->pContext)) {
|
||||
if (pDevice->pContext->callbacks.onDeviceUninit != NULL) {
|
||||
pDevice->pContext->callbacks.onDeviceUninit(pDevice);
|
||||
}
|
||||
} else {
|
||||
if (pDevice->pContext->onDeviceUninit != NULL) {
|
||||
pDevice->pContext->onDeviceUninit(pDevice);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ma_event_uninit(&pDevice->stopEvent);
|
||||
@@ -33310,19 +33105,11 @@ MA_API ma_result ma_device_start(ma_device* pDevice)
|
||||
|
||||
/* Asynchronous backends need to be handled differently. */
|
||||
if (ma_context_is_backend_asynchronous(pDevice->pContext)) {
|
||||
if (ma_context__is_using_new_callbacks(pDevice->pContext)) {
|
||||
if (pDevice->pContext->callbacks.onDeviceStart != NULL) {
|
||||
result = pDevice->pContext->callbacks.onDeviceStart(pDevice);
|
||||
} else {
|
||||
result = MA_INVALID_OPERATION;
|
||||
}
|
||||
} else {
|
||||
if (pDevice->pContext->onDeviceStart != NULL) {
|
||||
result = pDevice->pContext->onDeviceStart(pDevice);
|
||||
} else {
|
||||
result = MA_INVALID_OPERATION;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == MA_SUCCESS) {
|
||||
ma_device__set_state(pDevice, MA_STATE_STARTED);
|
||||
@@ -33378,19 +33165,11 @@ MA_API ma_result ma_device_stop(ma_device* pDevice)
|
||||
/* Asynchronous backends need to be handled differently. */
|
||||
if (ma_context_is_backend_asynchronous(pDevice->pContext)) {
|
||||
/* Asynchronous backends must have a stop operation. */
|
||||
if (ma_context__is_using_new_callbacks(pDevice->pContext)) {
|
||||
if (pDevice->pContext->callbacks.onDeviceStop != NULL) {
|
||||
result = pDevice->pContext->callbacks.onDeviceStop(pDevice);
|
||||
} else {
|
||||
result = MA_INVALID_OPERATION;
|
||||
}
|
||||
} else {
|
||||
if (pDevice->pContext->onDeviceStop != NULL) {
|
||||
result = pDevice->pContext->onDeviceStop(pDevice);
|
||||
} else {
|
||||
result = MA_INVALID_OPERATION;
|
||||
}
|
||||
}
|
||||
|
||||
ma_device__set_state(pDevice, MA_STATE_STOPPED);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user