From 72ded59b4d084e9dc4a8324b67ff7b98c7b88ab3 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Thu, 9 Nov 2023 11:11:58 +0100 Subject: Fix output buffer conversion: handle differing channel count between input and output --- src/cubeb_opensl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cubeb_opensl.cpp b/src/cubeb_opensl.cpp index 6f3c7bd..4115050 100644 --- a/src/cubeb_opensl.cpp +++ b/src/cubeb_opensl.cpp @@ -592,6 +592,8 @@ player_fullduplex_callback(SLBufferQueueItf caller, void * user_ptr) long input_frame_count = stm->input_buffer_length / stm->input_frame_size; long sample_count = input_frame_count * stm->input_params->channels; long frames_needed = stm->queuebuf_len / stm->framesize; + uint32_t output_sample_count = + stm->output_params->channels * stm->queuebuf_len / stm->framesize; if (!input_buffer) { LOG("Input hole set silent input buffer"); @@ -601,7 +603,7 @@ player_fullduplex_callback(SLBufferQueueItf caller, void * user_ptr) input_buffer = convert_input_buffer_if_needed(stm, input_buffer, sample_count); - output_buffer = get_output_buffer(stm, output_buffer, sample_count); + output_buffer = get_output_buffer(stm, output_buffer, output_sample_count); long written = 0; // Trigger user callback through resampler -- cgit v1.2.3