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.
This commit is contained in:
wm4 2016-02-05 21:15:47 +01:00
parent 1aa2ae5404
commit 242dbc6c2c
1 changed files with 13 additions and 15 deletions

View File

@ -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)