From 11ed012c343e32da1c7a0cb8ddb7006f53f1f0bc Mon Sep 17 00:00:00 2001 From: llyyr Date: Thu, 1 Aug 2024 03:35:29 +0530 Subject: [PATCH] player/audio: invert audio_started boolean Waiting for audio_started to be set to true takes too long which causes us to miss it for the first frame, instead invert the condition so it's set on the first frame. Fixes #14615 --- player/audio.c | 4 +++- player/core.h | 2 +- player/video.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/player/audio.c b/player/audio.c index 4fe78953db..b6e8118612 100644 --- a/player/audio.c +++ b/player/audio.c @@ -213,6 +213,7 @@ static void ao_chain_reset_state(struct ao_chain *ao_c) ao_c->start_pts = MP_NOPTS_VALUE; ao_c->untimed_throttle = false; ao_c->underrun = false; + ao_c->delaying_audio_start = false; } void reset_audio_state(struct MPContext *mpctx) @@ -841,12 +842,13 @@ void audio_start_ao(struct MPContext *mpctx) MP_VERBOSE(mpctx, "delaying audio start %f vs. %f, diff=%f\n", apts, pts, diff); mpctx->logged_async_diff = diff; + ao_c->delaying_audio_start = true; } return; } MP_VERBOSE(mpctx, "starting audio playback\n"); - ao_c->audio_started = true; + ao_c->delaying_audio_start = false; 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 ef9470ed9e..e37851e100 100644 --- a/player/core.h +++ b/player/core.h @@ -194,7 +194,7 @@ struct ao_chain { double start_pts; bool start_pts_known; - bool audio_started; + bool delaying_audio_start; struct track *track; struct mp_pin *filter_src; diff --git a/player/video.c b/player/video.c index ece77e91aa..ee2da584cc 100644 --- a/player/video.c +++ b/player/video.c @@ -388,7 +388,7 @@ 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) + if (mpctx->ao_chain && !mpctx->ao_chain->delaying_audio_start) mpctx->delay -= frame_time; if (mpctx->video_status >= STATUS_PLAYING) adjust_sync(mpctx, pts, frame_time);