summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-26 21:33:34 +0200
committerwm4 <wm4@nowhere>2015-05-26 21:33:34 +0200
commit3c24250c143237c86d0b3db0b7f8bf429034a448 (patch)
tree0c6e8c90e148d3f362dc0b4f4d468d27954b4981
parent88249baf5bb66e164b17bc53e10441c3c3111e45 (diff)
downloadmpv-3c24250c143237c86d0b3db0b7f8bf429034a448.tar.bz2
mpv-3c24250c143237c86d0b3db0b7f8bf429034a448.tar.xz
command: fix track property when no file is loaded
The previous commit removed this. Although mp_switch_track() can now be called in all situations, we still don't want it to be called here. Setting a track property while no file is loaded would simply deselect the track instead of setting the underlying option to the requested value. Likewise, if the "cycle" command (M_PROPERTY_SWITCH) is used, don't just deselect the track.
-rw-r--r--player/command.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/player/command.c b/player/command.c
index 1fdf6654be..f7d277dfd5 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1793,6 +1793,8 @@ static int property_switch_track(struct m_property *prop, int action, void *arg,
return M_PROPERTY_OK;
case M_PROPERTY_SWITCH: {
+ if (!mpctx->num_sources)
+ return M_PROPERTY_ERROR;
struct m_property_switch_arg *sarg = arg;
mp_switch_track_n(mpctx, order, type,
track_next(mpctx, order, type, sarg->inc >= 0 ? +1 : -1, track),
@@ -1800,8 +1802,12 @@ static int property_switch_track(struct m_property *prop, int action, void *arg,
return M_PROPERTY_OK;
}
case M_PROPERTY_SET:
- track = mp_track_by_tid(mpctx, type, *(int *)arg);
- mp_switch_track_n(mpctx, order, type, track, FLAG_MARK_SELECTION);
+ if (mpctx->num_sources) {
+ track = mp_track_by_tid(mpctx, type, *(int *)arg);
+ mp_switch_track_n(mpctx, order, type, track, FLAG_MARK_SELECTION);
+ } else {
+ mpctx->opts->stream_id[order][type] = *(int *)arg;
+ }
return M_PROPERTY_OK;
}
return mp_property_generic_option(mpctx, prop, action, arg);