Bug 1432779 - P12. User proper sample size when calculating offsets. r?padenot
Should the user data be of a different types to what the AudioUnit output is set to, we would have written outside the end of our allocated buffer.
MozReview-Commit-ID: 4oLTyHmm6OZ
--- a/media/libcubeb/src/cubeb_audiounit.cpp
+++ b/media/libcubeb/src/cubeb_audiounit.cpp
@@ -593,28 +593,28 @@ audiounit_output_callback(void * user_pt
r = AudioOutputUnitStop(stm->input_unit);
assert(r == 0);
}
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR);
audiounit_make_silent(&outBufferList->mBuffers[0]);
return noErr;
}
- size_t outbpf = stm->output_desc.mBytesPerFrame;
stm->draining = (UInt32) outframes < output_frames;
stm->frames_played = stm->frames_queued;
stm->frames_queued += outframes;
AudioFormatFlags outaff = stm->output_desc.mFormatFlags;
float panning = (stm->output_desc.mChannelsPerFrame == 2) ?
stm->panning.load(memory_order_relaxed) : 0.0f;
/* Post process output samples. */
if (stm->draining) {
/* Clear missing frames (silence) */
+ size_t outbpf = cubeb_sample_size(stm->output_stream_params.format);
memset((uint8_t*)output_buffer + outframes * outbpf, 0, (output_frames - outframes) * outbpf);
// JYA TODO : shouldn't output_frames be reduced here for the remaining panning/remix operation?
}
/* Mixing */
if (stm->mixer) {
audiounit_mix_output_buffer(stm,
output_frames,