summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-04-28 16:47:25 +0200
committerJan Ekström <jeebjp@gmail.com>2018-04-29 02:21:32 +0300
commit573159734271c3969ffb3818af9dde3b116f9c92 (patch)
tree250cc0dd37d318e5b559a910a238f50b66a1e268 /player/command.c
parenta208179ffed36c6ea2f488bc2849fd3644eadabd (diff)
downloadmpv-573159734271c3969ffb3818af9dde3b116f9c92.tar.bz2
mpv-573159734271c3969ffb3818af9dde3b116f9c92.tar.xz
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.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c27
1 files 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: