From 49660bcc3efa6ec6d86db30fa9d0b71b6a06b7d7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 27 Feb 2016 20:02:51 +0100 Subject: player: minor simplification No need to pass endpts down in such a dumb way. Also remove an outdated comment somewhere. --- player/audio.c | 3 ++- player/core.h | 4 ++-- player/playloop.c | 17 +++++------------ player/video.c | 7 ++++--- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/player/audio.c b/player/audio.c index 537d2e1b29..f17587a1ca 100644 --- a/player/audio.c +++ b/player/audio.c @@ -713,7 +713,7 @@ static int filter_audio(struct ao_chain *ao_c, struct mp_audio_buffer *outbuf, return res; } -void fill_audio_out_buffers(struct MPContext *mpctx, double endpts) +void fill_audio_out_buffers(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; struct ao_chain *ao_c = mpctx->ao_chain; @@ -895,6 +895,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx, double endpts) bool partial_fill = false; int playflags = 0; + double endpts = get_play_end_pts(mpctx); if (endpts != MP_NOPTS_VALUE) { double samples = (endpts - written_audio_pts(mpctx) - opts->audio_delay) * play_samplerate; diff --git a/player/core.h b/player/core.h index 2696823cf9..f26cacbb51 100644 --- a/player/core.h +++ b/player/core.h @@ -424,7 +424,7 @@ void reinit_audio_chain(struct MPContext *mpctx); int init_audio_decoder(struct MPContext *mpctx, struct track *track); int reinit_audio_filters(struct MPContext *mpctx); double playing_audio_pts(struct MPContext *mpctx); -void fill_audio_out_buffers(struct MPContext *mpctx, double endpts); +void fill_audio_out_buffers(struct MPContext *mpctx); double written_audio_pts(struct MPContext *mpctx); void clear_audio_output_buffers(struct MPContext *mpctx); void update_playback_speed(struct MPContext *mpctx); @@ -552,7 +552,7 @@ int init_video_decoder(struct MPContext *mpctx, struct track *track); int reinit_video_chain(struct MPContext *mpctx); int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src); int reinit_video_filters(struct MPContext *mpctx); -void write_video(struct MPContext *mpctx, double endpts); +void write_video(struct MPContext *mpctx); void mp_force_video_refresh(struct MPContext *mpctx); void uninit_video_out(struct MPContext *mpctx); void uninit_video_chain(struct MPContext *mpctx); diff --git a/player/playloop.c b/player/playloop.c index f83547d019..3e68ee9027 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -293,11 +293,6 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek) * seeks etc until a new video frame has been decoded */ mpctx->last_seek_pts = target_time; - // It's not really known where the demuxer - // level seek will end up, so the hrseek mechanism is abused to skip all - // frames before chapter start by setting hrseek_pts to the chapter start. - // It does nothing when the seek is inside of the current chapter, and - // seeking past the chapter is handled elsewhere. if (hr_seek) { mpctx->hrseek_active = true; mpctx->hrseek_framedrop = !hr_seek_very_exact && opts->hr_seek_framedrop; @@ -850,7 +845,7 @@ static void handle_dummy_ticks(struct MPContext *mpctx) // We always make sure audio and video buffers are filled before actually // starting playback. This code handles starting them at the same time. -static void handle_playback_restart(struct MPContext *mpctx, double endpts) +static void handle_playback_restart(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; @@ -865,7 +860,7 @@ static void handle_playback_restart(struct MPContext *mpctx, double endpts) } if (mpctx->audio_status == STATUS_READY) - fill_audio_out_buffers(mpctx, endpts); // actually play prepared buffer + fill_audio_out_buffers(mpctx); // actually play prepared buffer if (!mpctx->restart_complete) { mpctx->hrseek_active = false; @@ -948,8 +943,6 @@ static void handle_complex_filter_decoders(struct MPContext *mpctx) void run_playloop(struct MPContext *mpctx) { - double endpts = get_play_end_pts(mpctx); - #if HAVE_ENCODING if (encode_lavc_didfail(mpctx->encode_lavc_ctx)) { mpctx->stop_play = PT_QUIT; @@ -966,8 +959,8 @@ void run_playloop(struct MPContext *mpctx) handle_heartbeat_cmd(mpctx); handle_command_updates(mpctx); - fill_audio_out_buffers(mpctx, endpts); - write_video(mpctx, endpts); + fill_audio_out_buffers(mpctx); + write_video(mpctx); if (mpctx->lavfi) { if (lavfi_process(mpctx->lavfi)) @@ -976,7 +969,7 @@ void run_playloop(struct MPContext *mpctx) mpctx->stop_play = AT_END_OF_FILE; } - handle_playback_restart(mpctx, endpts); + handle_playback_restart(mpctx); // Use the audio timestamp if no video, or video is enabled, but has ended. if (mpctx->video_status == STATUS_EOF && diff --git a/player/video.c b/player/video.c index 62a144afe9..24e01d3c06 100644 --- a/player/video.c +++ b/player/video.c @@ -749,7 +749,7 @@ static bool have_new_frame(struct MPContext *mpctx, bool eof) // Fill mpctx->next_frames[] with a newly filtered or decoded image. // returns VD_* code -static int video_output_image(struct MPContext *mpctx, double endpts) +static int video_output_image(struct MPContext *mpctx) { struct vo_chain *vo_c = mpctx->vo_chain; bool hrseek = mpctx->hrseek_active && mpctx->video_status == STATUS_SYNCING; @@ -772,6 +772,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts) return r; // error struct mp_image *img = vf_read_output_frame(vo_c->vf); if (img) { + double endpts = get_play_end_pts(mpctx); if (endpts != MP_NOPTS_VALUE && img->pts >= endpts) { r = VD_EOF; } else if (mpctx->max_frames == 0) { @@ -1243,7 +1244,7 @@ static void calculate_frame_duration(struct MPContext *mpctx) mpctx->past_frames[0].approx_duration = approx_duration; } -void write_video(struct MPContext *mpctx, double endpts) +void write_video(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; @@ -1259,7 +1260,7 @@ void write_video(struct MPContext *mpctx, double endpts) if (mpctx->paused && mpctx->video_status >= STATUS_READY) return; - int r = video_output_image(mpctx, endpts); + int r = video_output_image(mpctx); MP_TRACE(mpctx, "video_output_image: %d\n", r); if (r < 0) -- cgit v1.2.3