From 573159734271c3969ffb3818af9dde3b116f9c92 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 28 Apr 2018 16:47:25 +0200 Subject: command: make track properties cycle through no/auto if uninitialized If playback has not been initialized yet (decoders not initialized etc.), or if in idle mode, let the track properties cycle through "no" and "auto". This should be slightly more helpful than making it simply exit. Depending on the stage of loading, more could be done. For example, if youtube-dl loads additional subtitle files, it can happen that these get added before the main file, and this could be cycled through to an extent. This is probably too clever, and also sort of dangerous (unintended interactions with messy in-loading state), so don't do it. --- player/command.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/player/command.c b/player/command.c index 5af2a53ef5..fa0151c6b8 100644 --- a/player/command.c +++ b/player/command.c @@ -2178,19 +2178,28 @@ static int property_switch_track(struct m_property *prop, int action, void *arg, track->user_tid, lang); } } else { - *(char **) arg = talloc_strdup(NULL, "no"); + const char *msg = "no"; + if (!mpctx->playback_initialized && + mpctx->opts->stream_id[order][type] == -1) + msg = "auto"; + *(char **) arg = talloc_strdup(NULL, msg); } return M_PROPERTY_OK; case M_PROPERTY_SWITCH: { - if (!mpctx->playback_initialized) - return M_PROPERTY_ERROR; - struct m_property_switch_arg *sarg = arg; - do { - track = track_next(mpctx, type, sarg->inc >= 0 ? +1 : -1, track); - mp_switch_track_n(mpctx, order, type, track, FLAG_MARK_SELECTION); - } while (mpctx->current_track[order][type] != track); - print_track_list(mpctx, "Track switched:"); + if (mpctx->playback_initialized) { + struct m_property_switch_arg *sarg = arg; + do { + track = track_next(mpctx, type, sarg->inc >= 0 ? +1 : -1, track); + mp_switch_track_n(mpctx, order, type, track, FLAG_MARK_SELECTION); + } while (mpctx->current_track[order][type] != track); + print_track_list(mpctx, "Track switched:"); + } else { + // Simply cycle between "no" and "auto". It's possible that this does + // not always do what the user means, but keep the complexity low. + mpctx->opts->stream_id[order][type] = + mpctx->opts->stream_id[order][type] == -1 ? -2 : -1; + } return M_PROPERTY_OK; } case M_PROPERTY_SET: -- cgit v1.2.3