From 4d6192adcd14ea510ff1e9832e58645d327951a0 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Sun, 7 Aug 2016 15:47:21 +0200 Subject: [PATCH] Use a ScopeLock around condition.wait() --- src/output/plugins/OSXOutputPlugin.cxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index 38a020021..540d342f9 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -618,15 +618,17 @@ osx_output_play(AudioOutput *ao, const void *chunk, size_t size, { OSXOutput *od = (OSXOutput *)ao; - od->mutex.lock(); - while (true) { - if (od->ring_buffer->write_available() > 0) - break; + { + const ScopeLock protect(od->mutex); - /* wait for some free space in the buffer */ - od->condition.wait(od->mutex); + while (true) { + if (od->ring_buffer->write_available() > 0) + break; + + /* wait for some free space in the buffer */ + od->condition.wait(od->mutex); + } } - od->mutex.unlock(); return od->ring_buffer->push((uint8_t *) chunk, size); }