summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-03-25 09:50:24 -0400
committersfan5 <sfan5@live.de>2024-03-28 16:16:43 +0100
commit7ab1080749b02e3e545166e67528c6a039e04969 (patch)
tree0561f466345839eab8ef61aaa0d06250afd65391
parentf4a7931c534158d254a4a36f289494c1de6a16b9 (diff)
downloadmpv-7ab1080749b02e3e545166e67528c6a039e04969.tar.bz2
mpv-7ab1080749b02e3e545166e67528c6a039e04969.tar.xz
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
-rw-r--r--audio/filter/af_scaletempo2_internals.c3
1 files changed, 2 insertions, 1 deletions
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;
}