Commit 9835a254 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Do not assume two pops are enough

parent c28cefee
...@@ -410,18 +410,18 @@ osx_render(void *vdata, ...@@ -410,18 +410,18 @@ osx_render(void *vdata,
requested_bytes = od->render_buffer_size; requested_bytes = od->render_buffer_size;
size_t available_bytes = od->ring_buffer->pop(od->render_buffer, requested_bytes); 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 Maybe this is paranoid but we have no way of knowing
if the 'pop' above ended at a frame boundary. In case if the 'pop' above ended at a frame boundary. In case
of an incomplete last frame, do a second pop to get of an incomplete last frame, keep popping until the
enough bytes to complete the last frame. 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( available_bytes += od->ring_buffer->pop(
od->render_buffer + available_bytes, 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 od->condition.signal(); // We are done consuming from ring_buffer
......
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