mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +02:00
CoreAudio: Try fixing a deadlock on uninit.
This commit is contained in:
@@ -14976,6 +14976,16 @@ void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, AudioUnitPro
|
|||||||
mal_device* pDevice = (mal_device*)pUserData;
|
mal_device* pDevice = (mal_device*)pUserData;
|
||||||
mal_assert(pDevice != NULL);
|
mal_assert(pDevice != NULL);
|
||||||
|
|
||||||
|
// There's been a report of a deadlock here when triggered by mal_device_uninit(). It looks like
|
||||||
|
// AudioUnitGetProprty (called below) and AudioComponentInstanceDispose (called in mal_device_uninit)
|
||||||
|
// can try waiting on the same lock. I'm going to try working around this by not calling any Core
|
||||||
|
// Audio APIs in the callback when the device has been stopped or initialized.
|
||||||
|
if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED || mal_device__get_state(pDevice) == MAL_STATE_STOPPING) {
|
||||||
|
mal_stop_proc onStop = pDevice->onStop;
|
||||||
|
if (onStop) {
|
||||||
|
onStop(pDevice);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
UInt32 isRunning;
|
UInt32 isRunning;
|
||||||
UInt32 isRunningSize = sizeof(isRunning);
|
UInt32 isRunningSize = sizeof(isRunning);
|
||||||
OSStatus status = ((mal_AudioUnitGetProperty_proc)pDevice->pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioOutputUnitProperty_IsRunning, scope, element, &isRunning, &isRunningSize);
|
OSStatus status = ((mal_AudioUnitGetProperty_proc)pDevice->pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioOutputUnitProperty_IsRunning, scope, element, &isRunning, &isRunningSize);
|
||||||
@@ -15014,6 +15024,7 @@ void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, AudioUnitPro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(MAL_APPLE_DESKTOP)
|
#if defined(MAL_APPLE_DESKTOP)
|
||||||
OSStatus mal_default_output_device_changed__coreaudio(AudioObjectID objectID, UInt32 addressCount, const AudioObjectPropertyAddress* pAddresses, void* pUserData)
|
OSStatus mal_default_output_device_changed__coreaudio(AudioObjectID objectID, UInt32 addressCount, const AudioObjectPropertyAddress* pAddresses, void* pUserData)
|
||||||
|
|||||||
Reference in New Issue
Block a user