From 7ab1080749b02e3e545166e67528c6a039e04969 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Mon, 25 Mar 2024 09:50:24 -0400 Subject: [PATCH] af_scaletempo2: fix false reporting of frame availability With certain speed settings, the following can happen at the start of the playback: - can_perform_wsola returns false, so no frames are written - mp_scaletempo2_frames_available returns true when p->input_buffer_final_frames is 0 and target_block_index < 0 This results in infinite loop and completely stalls audio filter processing and playback. Fix this by only checking this condition after the final frame is set. Fixes: 8080d00d7f31a0e1ba25418e0f08474f1a2f1f61 --- audio/filter/af_scaletempo2_internals.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/filter/af_scaletempo2_internals.c b/audio/filter/af_scaletempo2_internals.c index 534f4f672a..6e5b31aeda 100644 --- a/audio/filter/af_scaletempo2_internals.c +++ b/audio/filter/af_scaletempo2_internals.c @@ -765,7 +765,8 @@ double mp_scaletempo2_get_latency(struct mp_scaletempo2 *p, double playback_rate bool mp_scaletempo2_frames_available(struct mp_scaletempo2 *p, double playback_rate) { - return p->input_buffer_final_frames > p->target_block_index + return (p->input_buffer_final_frames > p->target_block_index && + p->input_buffer_final_frames > 0) || can_perform_wsola(p, playback_rate) || p->num_complete_frames > 0; }