From 3c24250c143237c86d0b3db0b7f8bf429034a448 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 26 May 2015 21:33:34 +0200 Subject: 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. --- player/command.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'player/command.c') 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); -- cgit v1.2.3