summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-01 22:14:32 +0100
committerwm4 <wm4@nowhere>2016-02-01 22:14:32 +0100
commit5c8378b71aaa4fbfda69ed9f50fe10f40cd124f2 (patch)
tree910c0840b089edbbae8a3cc1c6da60d4e06cb904 /player
parentab318aeea84f51fa0adcfb09a8a43abc67dae1cd (diff)
downloadmpv-5c8378b71aaa4fbfda69ed9f50fe10f40cd124f2.tar.bz2
mpv-5c8378b71aaa4fbfda69ed9f50fe10f40cd124f2.tar.xz
player: use different variable to indicate coverart
Slightly better.
Diffstat (limited to 'player')
-rw-r--r--player/audio.c6
-rw-r--r--player/core.h7
-rw-r--r--player/osd.c2
-rw-r--r--player/video.c17
4 files changed, 15 insertions, 17 deletions
diff --git a/player/audio.c b/player/audio.c
index b2581aa2fc..1a67cdca63 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -525,7 +525,7 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip)
!mp_audio_buffer_samples(mpctx->ao_chain->ao_buffer))
return false; // no audio read yet
- bool sync_to_video = mpctx->vo_chain && mpctx->sync_audio_to_video &&
+ bool sync_to_video = mpctx->vo_chain && !mpctx->vo_chain->is_coverart &&
mpctx->video_status != STATUS_EOF;
double sync_pts = MP_NOPTS_VALUE;
@@ -815,8 +815,8 @@ void fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
// Even if we're done decoding and syncing, let video start first - this is
// required, because sending audio to the AO already starts playback.
- if (mpctx->audio_status == STATUS_FILLING && mpctx->sync_audio_to_video &&
- mpctx->video_status <= STATUS_READY)
+ if (mpctx->audio_status == STATUS_FILLING && mpctx->vo_chain &&
+ !mpctx->vo_chain->is_coverart && mpctx->video_status <= STATUS_READY)
{
mpctx->audio_status = STATUS_READY;
return;
diff --git a/player/core.h b/player/core.h
index b144ab6936..90ceeb1d08 100644
--- a/player/core.h
+++ b/player/core.h
@@ -171,6 +171,10 @@ struct vo_chain {
struct mp_image_params input_format;
struct dec_video *video_src;
+
+ // - video consists of a single picture, which should be shown only once
+ // - do not sync audio to video in any way
+ bool is_coverart;
};
// Like vo_chain, for audio.
@@ -325,9 +329,6 @@ typedef struct MPContext {
double audio_drop_throttle;
// Number of mistimed frames.
int mistimed_frames_total;
- /* Set if audio should be timed to start with video frame after seeking,
- * not set when e.g. playing cover art */
- bool sync_audio_to_video;
bool hrseek_active; // skip all data until hrseek_pts
bool hrseek_framedrop; // allow decoder to drop frames before hrseek_pts
bool hrseek_lastframe; // drop everything until last frame reached
diff --git a/player/osd.c b/player/osd.c
index b88feee9f6..41c483c0f5 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -217,7 +217,7 @@ static void print_status(struct MPContext *mpctx)
saddf(&line, " x%4.2f", opts->playback_speed);
// A-V sync
- if (mpctx->ao_chain && mpctx->vo_chain && mpctx->sync_audio_to_video) {
+ if (mpctx->ao_chain && mpctx->vo_chain && !mpctx->vo_chain->is_coverart) {
saddf(&line, " A-V:%7.3f", mpctx->last_av_difference);
if (fabs(mpctx->total_avsync_change) > 0.05)
saddf(&line, " ct:%7.3f", mpctx->total_avsync_change);
diff --git a/player/video.c b/player/video.c
index bb339503d7..0cba95a9c8 100644
--- a/player/video.c
+++ b/player/video.c
@@ -301,7 +301,6 @@ void uninit_video_chain(struct MPContext *mpctx)
vo_chain_uninit(mpctx->vo_chain);
mpctx->vo_chain = NULL;
mpctx->video_status = STATUS_EOF;
- mpctx->sync_audio_to_video = false;
reselect_demux_streams(mpctx);
remove_deint_filter(mpctx);
mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
@@ -361,6 +360,7 @@ int reinit_video_chain(struct MPContext *mpctx)
}
vo_c->container_fps = d_video->fps;
+ vo_c->is_coverart = !!sh->attached_picture;
vo_c->video_src = d_video;
#if HAVE_ENCODING
@@ -379,8 +379,6 @@ int reinit_video_chain(struct MPContext *mpctx)
vo_set_paused(vo_c->vo, mpctx->paused);
- mpctx->sync_audio_to_video = !sh->attached_picture;
-
// If we switch on video again, ensure audio position matches up.
if (mpctx->ao_chain)
mpctx->audio_status = STATUS_SYNCING;
@@ -697,11 +695,10 @@ static bool have_new_frame(struct MPContext *mpctx, bool eof)
// returns VD_* code
static int video_output_image(struct MPContext *mpctx, double endpts)
{
+ struct vo_chain *vo_c = mpctx->vo_chain;
bool hrseek = mpctx->hrseek_active && mpctx->video_status == STATUS_SYNCING;
- struct track *track = mpctx->current_track[0][STREAM_VIDEO];
- bool is_coverart = track && track->stream && track->stream->attached_picture;
- if (is_coverart) {
+ if (vo_c->is_coverart) {
if (vo_has_frame(mpctx->video_out))
return VD_EOF;
hrseek = false;
@@ -717,7 +714,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
r = video_decode_and_filter(mpctx);
if (r < 0)
return r; // error
- struct mp_image *img = vf_read_output_frame(mpctx->vo_chain->vf);
+ struct mp_image *img = vf_read_output_frame(vo_c->vf);
if (img) {
if (endpts != MP_NOPTS_VALUE && img->pts >= endpts) {
r = VD_EOF;
@@ -731,7 +728,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
mp_image_setrefp(&mpctx->saved_frame, img);
} else if (mpctx->video_status == STATUS_SYNCING &&
mpctx->playback_pts != MP_NOPTS_VALUE &&
- img->pts < mpctx->playback_pts && !is_coverart)
+ img->pts < mpctx->playback_pts && !vo_c->is_coverart)
{
/* skip after stream-switching */
} else {
@@ -769,7 +766,7 @@ static void update_avsync_before_frame(struct MPContext *mpctx)
struct MPOpts *opts = mpctx->opts;
struct vo *vo = mpctx->video_out;
- if (!mpctx->sync_audio_to_video || mpctx->video_status < STATUS_READY) {
+ if (mpctx->vo_chain->is_coverart || mpctx->video_status < STATUS_READY) {
mpctx->time_frame = 0;
} else if (mpctx->display_sync_active || opts->video_sync == VS_NONE) {
// don't touch the timing
@@ -1345,7 +1342,7 @@ void write_video(struct MPContext *mpctx, double endpts)
mp_notify(mpctx, MPV_EVENT_TICK, NULL);
- if (!mpctx->sync_audio_to_video)
+ if (mpctx->vo_chain->is_coverart)
mpctx->video_status = STATUS_EOF;
if (mpctx->video_status != STATUS_EOF) {