From 9835a2545dc55efa2c51e00e8a9cc5480f064da9 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Sat, 6 Aug 2016 15:19:10 +0200 Subject: [PATCH] Do not assume two pops are enough --- src/output/plugins/OSXOutputPlugin.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index a5b235f9b..2da3af9f6 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -410,18 +410,18 @@ osx_render(void *vdata, requested_bytes = od->render_buffer_size; size_t available_bytes = od->ring_buffer->pop(od->render_buffer, requested_bytes); - size_t wraparound_remainder = available_bytes % input_buffer_frame_size; /* Maybe this is paranoid but we have no way of knowing if the 'pop' above ended at a frame boundary. In case - of an incomplete last frame, do a second pop to get - enough bytes to complete the last frame. + of an incomplete last frame, keep popping until the + last frame is complete. */ - if (wraparound_remainder > 0) + size_t remainder; + while ((remainder = available_bytes % input_buffer_frame_size) > 0) available_bytes += od->ring_buffer->pop( od->render_buffer + available_bytes, - input_buffer_frame_size - wraparound_remainder + input_buffer_frame_size - remainder ); od->condition.signal(); // We are done consuming from ring_buffer