From 2f9322dfc63a86b3affb9b77ab4c06b46aa7ce2e Mon Sep 17 00:00:00 2001 From: Bill Lash Date: Thu, 27 Jun 2019 22:35:46 -0500 Subject: [PATCH] Fixing assert due to failure of src_process Based on discussion with @borg323 src_process was leaving the input data pointer at an old value if it ran out of input data and completed the output buffer in the same call. Fixed it by setting the input data pointer back to the beginning, but since the number of input frames was set to 0, it wouldn't read any data from it. --- src/curses/ux_audio.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/curses/ux_audio.c b/src/curses/ux_audio.c index 3db196e..b700d5d 100644 --- a/src/curses/ux_audio.c +++ b/src/curses/ux_audio.c @@ -291,20 +291,18 @@ resampler_step(resampler_t *rsmp, float *block) rsmp->src_data.data_in = rsmp->input; rsmp->src_data.input_frames = smps; } - - if (src_process(rsmp->src_state, &rsmp->src_data)) - { - /* - * src_process returned an error, don't update - * the rsmp structure, and tell the caller to - * re-run the resampler - */ - return 1; - } + int err = src_process(rsmp->src_state, &rsmp->src_data); + assert(err == 0); int u_in = rsmp->src_data.input_frames_used; rsmp->src_data.data_in += 2*u_in; rsmp->src_data.input_frames -= u_in; + /* + * If input buffer is empty, reset data_in pointer just in case + * the output buffer is also full. + */ + if(rsmp->src_data.input_frames == 0) + rsmp->src_data.data_in = rsmp->input; int g_out = rsmp->src_data.output_frames_gen; rsmp->src_data.data_out += 2*g_out; rsmp->src_data.output_frames -= g_out; -- 2.34.1