From 242dbc6c2c985bfd4dd8df699c6df6c33f8889d1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 5 Feb 2016 21:15:47 +0100 Subject: player: simplify error_on_track() track can't be NLUL at this point, so the if is redundant. Remove it and unindent the block. Also, make the function check whether the track is selected at all, which makes it safer and idempotent. --- player/misc.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'player/misc.c') diff --git a/player/misc.c b/player/misc.c index 1343c60eaf..d68ad1db3e 100644 --- a/player/misc.c +++ b/player/misc.c @@ -163,24 +163,22 @@ void update_window_title(struct MPContext *mpctx, bool force) void error_on_track(struct MPContext *mpctx, struct track *track) { - if (!track) + if (!track || !track->selected) return; mp_deselect_track(mpctx, track); - if (track) { - if (track->type == STREAM_AUDIO) - MP_INFO(mpctx, "Audio: no audio\n"); - if (track->type == STREAM_VIDEO) - MP_INFO(mpctx, "Video: no video\n"); - if (mpctx->opts->stop_playback_on_init_failure || - !(mpctx->vo_chain || mpctx->ao_chain)) - { - if (!mpctx->stop_play) - mpctx->stop_play = PT_ERROR; - if (mpctx->error_playing >= 0) - mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY; - } - mpctx->sleeptime = 0; + if (track->type == STREAM_AUDIO) + MP_INFO(mpctx, "Audio: no audio\n"); + if (track->type == STREAM_VIDEO) + MP_INFO(mpctx, "Video: no video\n"); + if (mpctx->opts->stop_playback_on_init_failure || + !(mpctx->vo_chain || mpctx->ao_chain)) + { + if (!mpctx->stop_play) + mpctx->stop_play = PT_ERROR; + if (mpctx->error_playing >= 0) + mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY; } + mpctx->sleeptime = 0; } int stream_dump(struct MPContext *mpctx, const char *source_filename) -- cgit v1.2.3