mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 00:02:13 +00:00
command: allow changing track properties while no file is loaded
Now it simply changes the options, i.e. what will be requested, instead of returning M_PROPERTY_UNAVAILABLE. This is another minor step towards unifying options and properties. Still a bit weird: it will always return "no" if no file is loaded, and disregards the option value.
This commit is contained in:
parent
ae46833836
commit
f7ca2c83e1
@ -1771,8 +1771,6 @@ static int property_switch_track(struct m_property *prop, int action, void *arg,
|
||||
MPContext *mpctx, int order,
|
||||
enum stream_type type)
|
||||
{
|
||||
if (!mpctx->num_sources)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
struct track *track = mpctx->current_track[order][type];
|
||||
|
||||
switch (action) {
|
||||
@ -1804,9 +1802,13 @@ static int property_switch_track(struct m_property *prop, int action, void *arg,
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
case M_PROPERTY_SET:
|
||||
if (mpctx->num_sources) {
|
||||
track = mp_track_by_tid(mpctx, type, *(int *)arg);
|
||||
mp_switch_track_n(mpctx, order, type, track);
|
||||
mp_mark_user_track_selection(mpctx, order, type);
|
||||
} else {
|
||||
mpctx->opts->stream_id[order][type] = *(int *)arg;
|
||||
}
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
return mp_property_generic_option(mpctx, prop, action, arg);
|
||||
@ -1818,8 +1820,6 @@ static int property_switch_track_ff(void *ctx, struct m_property *prop,
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
enum stream_type type = (intptr_t)prop->priv;
|
||||
if (!mpctx->num_sources)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
struct track *track = mpctx->current_track[0][type];
|
||||
|
||||
switch (action) {
|
||||
@ -1828,6 +1828,7 @@ static int property_switch_track_ff(void *ctx, struct m_property *prop,
|
||||
return M_PROPERTY_OK;
|
||||
case M_PROPERTY_SET: {
|
||||
int id = *(int *)arg;
|
||||
if (mpctx->num_sources) {
|
||||
track = NULL;
|
||||
for (int n = 0; n < mpctx->num_tracks; n++) {
|
||||
struct track *cur = mpctx->tracks[n];
|
||||
@ -1839,6 +1840,9 @@ static int property_switch_track_ff(void *ctx, struct m_property *prop,
|
||||
if (!track && id >= 0)
|
||||
return M_PROPERTY_ERROR;
|
||||
mp_switch_track_n(mpctx, 0, type, track);
|
||||
} else {
|
||||
mpctx->opts->stream_id_ff[type] = *(int *)arg;
|
||||
}
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user