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: 8080d00d7f
This commit is contained in:
nanahi 2024-03-25 09:50:24 -04:00 committed by sfan5
parent f4a7931c53
commit 7ab1080749
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}