diff options
-rw-r--r-- | player/audio.c | 1 | ||||
-rw-r--r-- | player/core.h | 2 | ||||
-rw-r--r-- | player/video.c | 3 |
3 files changed, 5 insertions, 1 deletions
diff --git a/player/audio.c b/player/audio.c index 05a39cd819..da91dd4340 100644 --- a/player/audio.c +++ b/player/audio.c @@ -846,6 +846,7 @@ void audio_start_ao(struct MPContext *mpctx) } MP_VERBOSE(mpctx, "starting audio playback\n"); + ao_c->audio_started = true; ao_start(ao_c->ao); mpctx->audio_status = STATUS_PLAYING; if (ao_c->out_eof) { diff --git a/player/core.h b/player/core.h index dcb3c27e12..fc5e2e3937 100644 --- a/player/core.h +++ b/player/core.h @@ -192,6 +192,8 @@ struct ao_chain { double start_pts; bool start_pts_known; + bool audio_started; + struct track *track; struct mp_pin *filter_src; struct mp_pin *dec_src; diff --git a/player/video.c b/player/video.c index 6b63cc7b0e..c33f947659 100644 --- a/player/video.c +++ b/player/video.c @@ -359,7 +359,6 @@ static void adjust_sync(struct MPContext *mpctx, double v_pts, double frame_time if (mpctx->audio_status != STATUS_PLAYING) return; - mpctx->delay -= frame_time; double a_pts = written_audio_pts(mpctx) + opts->audio_delay - mpctx->delay; double av_delay = a_pts - v_pts; @@ -401,6 +400,8 @@ static void handle_new_frame(struct MPContext *mpctx) } } mpctx->time_frame += frame_time / mpctx->video_speed; + if (mpctx->ao_chain && mpctx->ao_chain->audio_started) + mpctx->delay -= frame_time; if (mpctx->video_status >= STATUS_PLAYING) adjust_sync(mpctx, pts, frame_time); MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time); |