Synchronous lifetime control of AudioQueue on macOS

This commit is contained in:
Jack Andersen 2017-01-18 10:56:26 -10:00
parent 93f6e11fa8
commit f0e8e0a1fa
3 changed files with 17 additions and 3 deletions

View File

@ -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<std::mutex> 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);
}

View File

@ -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[] =

@ -1 +1 @@
Subproject commit f913fb8479e14029aa510b01d620e64b17d4ad31
Subproject commit e6f24e64284fff5d5559b3d7e5aa44b610e2d7e9