aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_audiounit.cpp
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2019-10-02 13:10:55 +0200
committerPaul Adenot <[email protected]>2019-10-02 13:48:04 +0200
commitfcd9a380e0b0ae58d601a07338ef7f9569b046bd (patch)
tree100835ca909abe8bd6a9a4dbf80ddabb8debcebf /src/cubeb_audiounit.cpp
parent044f28a5e5f3254d6b08b053ceaae910554405cf (diff)
downloadcubeb-fcd9a380e0b0ae58d601a07338ef7f9569b046bd.tar.gz
cubeb-fcd9a380e0b0ae58d601a07338ef7f9569b046bd.zip
Use the number of channels of the stream, not the device, for draining computation.
This is right after the callback, that has the number of channels the user requested, and can be different from the number of channels of the device.
Diffstat (limited to 'src/cubeb_audiounit.cpp')
-rw-r--r--src/cubeb_audiounit.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cubeb_audiounit.cpp b/src/cubeb_audiounit.cpp
index bdd1db0..e0c8fc6 100644
--- a/src/cubeb_audiounit.cpp
+++ b/src/cubeb_audiounit.cpp
@@ -693,10 +693,11 @@ audiounit_output_callback(void * user_ptr,
/* Post process output samples. */
if (stm->draining) {
/* Clear missing frames (silence) */
- size_t missing_samples = (output_frames - outframes) * stm->output_desc.mChannelsPerFrame;
+ size_t channels = stm->output_stream_params.channels;
+ size_t missing_samples = (output_frames - outframes) * channels;
size_t size_sample = cubeb_sample_size(stm->output_stream_params.format);
/* number of bytes that have been filled with valid audio by the callback. */
- size_t audio_byte_count = outframes * stm->output_desc.mChannelsPerFrame * size_sample;
+ size_t audio_byte_count = outframes * channels * size_sample;
PodZero((uint8_t*)output_buffer + audio_byte_count,
missing_samples * size_sample);
}