Use a ScopeLock around condition.wait()

This commit is contained in:
Jacob Vosmaer 2016-08-07 15:47:21 +02:00
parent 9f1ada898e
commit 4d6192adcd

View File

@ -618,15 +618,17 @@ osx_output_play(AudioOutput *ao, const void *chunk, size_t size,
{ {
OSXOutput *od = (OSXOutput *)ao; OSXOutput *od = (OSXOutput *)ao;
od->mutex.lock(); {
while (true) { const ScopeLock protect(od->mutex);
if (od->ring_buffer->write_available() > 0)
break;
/* wait for some free space in the buffer */ while (true) {
od->condition.wait(od->mutex); 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); return od->ring_buffer->push((uint8_t *) chunk, size);
} }