Commit d73267df authored by Yue Wang's avatar Yue Wang Committed by GitHub

use osx_output_delay to wait until ring buffer is able to write

This further optimize the performance. This is now working properly with a conditional variable bug being fixed (8bbfb5cd).
parent 8bbfb5cd
......@@ -740,15 +740,16 @@ osx_output_play(AudioOutput *ao, const void *chunk, size_t size,
gcc_unused Error &error)
{
OSXOutput *od = (OSXOutput *)ao;
while (!od->ring_buffer->write_available()) {
struct timespec req;
req.tv_sec = 0;
req.tv_nsec = 25 * 1e6;
nanosleep(&req, NULL);
}
return od->ring_buffer->push((uint8_t *)chunk, size);
}
static unsigned
osx_output_delay(AudioOutput *ao)
{
OSXOutput *od = (OSXOutput *)ao;
return od->ring_buffer->write_available() ? 0 : 25;
}
const struct AudioOutputPlugin osx_output_plugin = {
"osx",
osx_output_test_default_device,
......@@ -758,7 +759,7 @@ const struct AudioOutputPlugin osx_output_plugin = {
osx_output_disable,
osx_output_open,
osx_output_close,
nullptr,
osx_output_delay,
nullptr,
osx_output_play,
nullptr,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment