From: Bill Lash Date: Fri, 28 Jun 2019 03:35:46 +0000 (-0500) Subject: Fixing assert due to failure of src_process X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=2f9322dfc63a86b3affb9b77ab4c06b46aa7ce2e;p=liskon_frotz.git 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. --- 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;