From 54f1f480099fd8f8aa597071343b8a90258ca586 Mon Sep 17 00:00:00 2001 From: David Reid Date: Mon, 30 Nov 2020 20:38:33 +1000 Subject: [PATCH] Fix another data race with PulseAudio. Public issue https://github.com/mackron/miniaudio/issues/235 --- miniaudio.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index ed515939..f80d00ae 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -22289,7 +22289,13 @@ static ma_result ma_device_init__pulse(ma_context* pContext, const ma_device_con devCapture = ((ma_pa_stream_get_device_name_proc)pContext->pulse.pa_stream_get_device_name)((ma_pa_stream*)pDevice->pulse.pStreamCapture); ma_mainloop_unlock__pulse(pContext, "ma_device_init__pulse"); if (devCapture != NULL) { - ma_wait_for_operation_and_unref__pulse(pContext, ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, devCapture, ma_device_source_name_callback, pDevice)); + ma_pa_operation* pOP; + + ma_mainloop_lock__pulse(pContext, "ma_device_init__pulse"); + pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, devCapture, ma_device_source_name_callback, pDevice); + ma_mainloop_unlock__pulse(pContext, "ma_device_init__pulse"); + + ma_wait_for_operation_and_unref__pulse(pContext, pOP); } } @@ -22386,7 +22392,13 @@ static ma_result ma_device_init__pulse(ma_context* pContext, const ma_device_con devPlayback = ((ma_pa_stream_get_device_name_proc)pContext->pulse.pa_stream_get_device_name)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); ma_mainloop_unlock__pulse(pContext, "ma_device_init__pulse"); if (devPlayback != NULL) { - ma_wait_for_operation_and_unref__pulse(pContext, ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, devPlayback, ma_device_sink_name_callback, pDevice)); + ma_pa_operation* pOP; + + ma_mainloop_lock__pulse(pContext, "ma_device_init__pulse"); + pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, devPlayback, ma_device_sink_name_callback, pDevice); + ma_mainloop_unlock__pulse(pContext, "ma_device_init__pulse"); + + ma_wait_for_operation_and_unref__pulse(pContext, pOP); } }