mirror of
https://github.com/mpv-player/mpv
synced 2025-02-17 21:27:08 +00:00
player: minor simplification in A/V-sync related code
Just minor things.
This commit is contained in:
parent
3813c3804f
commit
48f96f43ec
@ -146,6 +146,7 @@ void reset_audio_state(struct MPContext *mpctx)
|
||||
if (mpctx->ao_buffer)
|
||||
mp_audio_buffer_clear(mpctx->ao_buffer);
|
||||
mpctx->audio_status = mpctx->d_audio ? STATUS_SYNCING : STATUS_EOF;
|
||||
mpctx->delay = 0;
|
||||
}
|
||||
|
||||
void uninit_audio_out(struct MPContext *mpctx)
|
||||
@ -406,11 +407,10 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip)
|
||||
|
||||
double sync_pts = MP_NOPTS_VALUE;
|
||||
if (sync_to_video) {
|
||||
if (mpctx->video_next_pts != MP_NOPTS_VALUE) {
|
||||
sync_pts = mpctx->video_next_pts;
|
||||
} else if (mpctx->video_status < STATUS_READY) {
|
||||
if (mpctx->video_status < STATUS_READY)
|
||||
return false; // wait until we know a video PTS
|
||||
}
|
||||
if (mpctx->video_next_pts != MP_NOPTS_VALUE)
|
||||
sync_pts = mpctx->video_next_pts - (opts->audio_delay - mpctx->delay);
|
||||
} else if (mpctx->hrseek_active) {
|
||||
sync_pts = mpctx->hrseek_pts;
|
||||
}
|
||||
@ -419,9 +419,6 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip)
|
||||
return true; // syncing disabled
|
||||
}
|
||||
|
||||
if (sync_to_video)
|
||||
sync_pts -= opts->audio_delay - mpctx->delay;
|
||||
|
||||
double ptsdiff = written_pts - sync_pts;
|
||||
// Missing timestamp, or PTS reset, or just broken.
|
||||
if (written_pts == MP_NOPTS_VALUE || fabs(ptsdiff) > 300) {
|
||||
|
@ -588,9 +588,8 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
|
||||
frame_time = 0;
|
||||
}
|
||||
mpctx->video_next_pts = pts;
|
||||
if (mpctx->d_audio)
|
||||
mpctx->delay -= frame_time;
|
||||
if (mpctx->video_status >= STATUS_READY) {
|
||||
mpctx->delay -= frame_time;
|
||||
if (mpctx->video_status >= STATUS_PLAYING) {
|
||||
mpctx->time_frame += frame_time / mpctx->opts->playback_speed;
|
||||
adjust_sync(mpctx, pts, frame_time);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user