0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-19 19:42:24 +02:00

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
This commit is contained in:
llyyr 2024-08-01 03:35:29 +05:30 committed by Dudemanguy
parent 24f42acd1d
commit 11ed012c34
3 changed files with 5 additions and 3 deletions

View File

@ -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) {

View File

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

View File

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