From f0e8e0a1fac69a7a3e67ced0dc80915701ff1183 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 18 Jan 2017 10:56:26 -1000 Subject: [PATCH] Synchronous lifetime control of AudioQueue on macOS --- lib/audiodev/AQS.cpp | 9 ++++++++- lib/graphicsdev/Metal.mm | 9 ++++++++- logvisor | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/audiodev/AQS.cpp b/lib/audiodev/AQS.cpp index 143972d..9a6f374 100644 --- a/lib/audiodev/AQS.cpp +++ b/lib/audiodev/AQS.cpp @@ -48,9 +48,13 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine std::condition_variable m_engineEnterCv; std::condition_variable m_engineLeaveCv; bool m_cbWaiting = false; + bool m_cbRunning = true; static void Callback(AQSAudioVoiceEngine* engine, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer) { + if (!engine->m_cbRunning) + return; + std::unique_lock lk(engine->m_engineMutex); engine->m_cbWaiting = true; engine->m_engineEnterCv.wait(lk); @@ -712,7 +716,10 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine ~AQSAudioVoiceEngine() { - AudioQueueDispose(m_queue, false); + m_cbRunning = false; + if (m_cbWaiting) + m_engineEnterCv.notify_one(); + AudioQueueDispose(m_queue, true); if (m_midiClient) MIDIClientDispose(m_midiClient); } diff --git a/lib/graphicsdev/Metal.mm b/lib/graphicsdev/Metal.mm index e5e27e2..1d73004 100644 --- a/lib/graphicsdev/Metal.mm +++ b/lib/graphicsdev/Metal.mm @@ -467,7 +467,14 @@ static const MTLBlendFactor BLEND_FACTOR_TABLE[] = MTLBlendFactorSourceAlpha, MTLBlendFactorOneMinusSourceAlpha, MTLBlendFactorDestinationAlpha, - MTLBlendFactorOneMinusDestinationAlpha + MTLBlendFactorOneMinusDestinationAlpha, +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 + MTLBlendFactorSource1Color, + MTLBlendFactorOneMinusSource1Color, +#else + MTLBlendFactorSourceColor, + MTLBlendFactorOneMinusSourceColor, +#endif }; static const MTLPrimitiveType PRIMITIVE_TABLE[] = diff --git a/logvisor b/logvisor index f913fb8..e6f24e6 160000 --- a/logvisor +++ b/logvisor @@ -1 +1 @@ -Subproject commit f913fb8479e14029aa510b01d620e64b17d4ad31 +Subproject commit e6f24e64284fff5d5559b3d7e5aa44b610e2d7e9