output/osx: remove incorrect memset behavior

In e068d62 I added code that zeros the remainder of the output buffer
if there are not enough input frames available. I have now learned
that we can signal to the caller of the render callback how much data
is in the output buffers. In practice, the input buffer is so large
that it does not matter so much how we handle input buffer underruns,
but I suppose that saying 'there is no data' is better than 'here is
some silence for you'.
This commit is contained in:
Jacob Vosmaer 2016-07-22 20:58:37 +02:00
parent bd8414f8ea
commit ad80acb22a
1 changed files with 3 additions and 21 deletions

View File

@ -367,13 +367,6 @@ done:
sake of correctness this callback allows for de-interleaving
anyway, and calculates the expected output layout by examining
the output buffers.
The input buffer is a DynamicFifoBuffer. When a
DynamicFifoBuffer contains less data than we want to read from
it there is no point in doing a second Read(). So in the case
of insufficient audio data in the input buffer, this render
callback will emit silence into the output buffers (memset
zero).
*/
static OSStatus
@ -413,7 +406,7 @@ osx_render(void *vdata,
// Acquire mutex when accessing input_buffer
od->mutex.lock();
auto src = input_buffer->Read();
DynamicFifoBuffer<uint8_t>::Range src = input_buffer->Read();
UInt32 available_frames = src.size / input_buffer_frame_size;
// Never write more frames than we were asked
@ -429,6 +422,7 @@ osx_render(void *vdata,
for (unsigned int i = 0 ; i < buffer_list->mNumberBuffers; ++i) {
output_buffer = &buffer_list->mBuffers[i];
output_buffer_frame_size = output_buffer->mNumberChannels * sample_size;
output_buffer->mDataByteSize = 0; // Record how much data we actually rendered
for (UInt32 current_frame = 0; current_frame < available_frames; ++current_frame) {
dest = (size_t) output_buffer->mData + current_frame * output_buffer_frame_size;
memcpy(
@ -436,6 +430,7 @@ osx_render(void *vdata,
src.data + current_frame * input_buffer_frame_size + sub_frame_offset,
output_buffer_frame_size
);
output_buffer->mDataByteSize += output_buffer_frame_size;
}
sub_frame_offset += output_buffer_frame_size;
}
@ -445,19 +440,6 @@ osx_render(void *vdata,
od->condition.signal();
od->mutex.unlock();
if (available_frames < in_number_frames) {
for (unsigned int i = 0 ; i < buffer_list->mNumberBuffers; ++i) {
output_buffer = &buffer_list->mBuffers[i];
output_buffer_frame_size = output_buffer->mNumberChannels * sample_size;
dest = (size_t) output_buffer->mData + available_frames * output_buffer_frame_size;
memset(
(void *) dest,
0,
(in_number_frames - available_frames) * output_buffer_frame_size
);
}
}
return noErr;
}