From 86d4094b98dcfb3e57578c38d842fa7a13aa2605 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 29 Jan 2015 12:10:07 +0100 Subject: player: remove redundant variable mpctx->audio_delay always has the same value as opts->audio_delay. (This was not the case a long time ago, when the audio-delay property didn't actually write to opts->audio_delay. I think.) --- player/audio.c | 4 ++-- player/command.c | 4 ++-- player/core.h | 2 -- player/loadfile.c | 2 -- player/video.c | 9 +++++---- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/player/audio.c b/player/audio.c index d6fb348f58..9193d9d6f2 100644 --- a/player/audio.c +++ b/player/audio.c @@ -420,7 +420,7 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip) } if (sync_to_video) - sync_pts -= mpctx->audio_delay - mpctx->delay; + sync_pts -= opts->audio_delay - mpctx->delay; double ptsdiff = written_pts - sync_pts; // Missing timestamp, or PTS reset, or just broken. @@ -560,7 +560,7 @@ static void do_fill_audio_out_buffers(struct MPContext *mpctx, double endpts) int playflags = 0; if (endpts != MP_NOPTS_VALUE) { - double samples = (endpts - written_audio_pts(mpctx) - mpctx->audio_delay) + double samples = (endpts - written_audio_pts(mpctx) - opts->audio_delay) * play_samplerate; if (playsize > samples) { playsize = MPMAX(samples, 0); diff --git a/player/command.c b/player/command.c index 397e527ec9..8779ea8c0a 100644 --- a/player/command.c +++ b/player/command.c @@ -1583,8 +1583,8 @@ static int mp_property_audio_delay(void *ctx, struct m_property *prop, *(char **)arg = format_delay(delay); return M_PROPERTY_OK; case M_PROPERTY_SET: - mpctx->audio_delay = mpctx->opts->audio_delay = *(float *)arg; - mpctx->delay += mpctx->audio_delay - delay; + mpctx->opts->audio_delay = *(float *)arg; + mpctx->delay += mpctx->opts->audio_delay - delay; return M_PROPERTY_OK; } return mp_property_generic_option(mpctx, prop, action, arg); diff --git a/player/core.h b/player/core.h index 4aad52ceb5..06abd0eff8 100644 --- a/player/core.h +++ b/player/core.h @@ -276,8 +276,6 @@ typedef struct MPContext { uint64_t backstep_start_seek_ts; bool backstep_active; - double audio_delay; - double next_heartbeat; double last_idle_tick; double next_cache_update; diff --git a/player/loadfile.c b/player/loadfile.c index 08077262de..92018135e7 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -950,7 +950,6 @@ static void play_current_file(struct MPContext *mpctx) mpctx->paused_for_cache = false; mpctx->playing_msg_shown = false; mpctx->backstep_active = false; - mpctx->audio_delay = 0; mpctx->max_frames = -1; mpctx->seek = (struct seek_params){ 0 }; @@ -987,7 +986,6 @@ static void play_current_file(struct MPContext *mpctx) load_per_file_options(mpctx->mconfig, mpctx->playing->params, mpctx->playing->num_params); - mpctx->audio_delay = opts->audio_delay; mpctx->max_frames = opts->play_frames; MP_INFO(mpctx, "Playing: %s\n", mpctx->filename); diff --git a/player/video.c b/player/video.c index e0424eab4e..442ae0d19f 100644 --- a/player/video.c +++ b/player/video.c @@ -528,7 +528,7 @@ static void adjust_sync(struct MPContext *mpctx, double v_pts, double frame_time if (mpctx->audio_status != STATUS_PLAYING) return; - double a_pts = written_audio_pts(mpctx) + mpctx->audio_delay - mpctx->delay; + double a_pts = written_audio_pts(mpctx) + opts->audio_delay - mpctx->delay; double av_delay = a_pts - v_pts; double change = av_delay * 0.1; @@ -704,6 +704,8 @@ static void update_avsync_before_frame(struct MPContext *mpctx) // Update the A/V sync difference after a video frame has been shown. static void update_avsync_after_frame(struct MPContext *mpctx) { + struct MPOpts *opts = mpctx->opts; + mpctx->time_frame -= get_relative_time(mpctx); mpctx->last_av_difference = 0; @@ -713,10 +715,9 @@ static void update_avsync_after_frame(struct MPContext *mpctx) double a_pos = playing_audio_pts(mpctx); - mpctx->last_av_difference = a_pos - mpctx->video_pts + mpctx->audio_delay; + mpctx->last_av_difference = a_pos - mpctx->video_pts + opts->audio_delay; if (mpctx->time_frame > 0) - mpctx->last_av_difference += - mpctx->time_frame * mpctx->opts->playback_speed; + mpctx->last_av_difference += mpctx->time_frame * opts->playback_speed; if (a_pos == MP_NOPTS_VALUE || mpctx->video_pts == MP_NOPTS_VALUE) mpctx->last_av_difference = MP_NOPTS_VALUE; if (mpctx->last_av_difference > 0.5 && !mpctx->drop_message_shown) { -- cgit v1.2.3