1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-12 18:02:36 +00:00

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.
This commit is contained in:
wm4 2015-05-26 21:33:34 +02:00
parent 88249baf5b
commit 3c24250c14

View File

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