summaryrefslogtreecommitdiffstats
path: root/player/audio.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-10-23 22:57:53 -0500
committerDudemanguy <random342@airmail.cc>2023-10-25 15:43:07 +0000
commitdac977193cccbf7e2e999cf0c4b0292314839c4c (patch)
tree83460ed06941a3169a25b8eb7b37896588c835e9 /player/audio.c
parentc62adc3018274b755849cd750ac33fc66f5d6e42 (diff)
downloadmpv-dac977193cccbf7e2e999cf0c4b0292314839c4c.tar.bz2
mpv-dac977193cccbf7e2e999cf0c4b0292314839c4c.tar.xz
player: don't calculate av delay if there's no audio or video
The point of the mpctx->delay field is for calculating a/v sync and adjusting the frame timings appropriately. However, the frame_time was always subtracted from mpctx->delay regardless of the audio status. This meant that for a video with no audio, every single frame had a subtraction with nothing ever added to it meaning that you get massive negative delay times. For weird videos where the audio starts way later, the massive delay leads to the VO sleeping for basically about as long as the video was previously playing without audio. This results in nothing being rendered during that brief period of time and just overall badness. When using display-sync, it happens to work since the video doesn't adjust itself based on audio and it renders anyway. The fix is to simply not touch mpctx->delay in player/video.c unless there's actually audio playing. This is what the rest of the code already does aside from setting it to 0 on resets or EOFs. Move the calculation into adjust_sync after the audio status check. It works exactly the same as before except that we don't constantly subtract bogus values when there's no audio playing. The reverse situation in player/audio.c also has the same issue. For something that is only audio, mpctx->delay is always added to but nothing will ever subtract from it. It's not really clear if this particular version could ever cause a real bug, but logically it needs to be guarded in the same way. The field here should only be updated if the video is actually playing. Fixes #12025.
Diffstat (limited to 'player/audio.c')
-rw-r--r--player/audio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/player/audio.c b/player/audio.c
index 4ea2d09f94..ba3cc90e7b 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -723,7 +723,8 @@ static void ao_process(struct mp_filter *f)
mpctx->shown_aframes += samples;
double real_samplerate = mp_aframe_get_rate(af) / mpctx->audio_speed;
- mpctx->delay += samples / real_samplerate;
+ if (mpctx->video_status == STATUS_PLAYING)
+ mpctx->delay += samples / real_samplerate;
ao_c->last_out_pts = mp_aframe_end_pts(af);
update_throttle(mpctx);