player: remove duplicated track option setter code

Well whatever.
This commit is contained in:
wm4 2020-04-15 17:10:01 +02:00
parent 6c02555397
commit cc2ee06e57
3 changed files with 11 additions and 17 deletions

View File

@ -1884,10 +1884,8 @@ static int property_switch_track(void *ctx, struct m_property *prop,
} 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;
m_config_notify_change_opt_ptr(mpctx->mconfig,
&mpctx->opts->stream_id[order][type]);
mark_track_selection(mpctx, order, type,
mpctx->opts->stream_id[order][type] == -1 ? -2 : -1);
}
return M_PROPERTY_OK;
}
@ -5094,9 +5092,7 @@ static void cmd_track_add(void *p)
mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
print_track_list(mpctx, "Track switched:");
} else {
mpctx->opts->stream_id[0][t->type] = t->user_tid;
m_config_notify_change_opt_ptr(mpctx->mconfig,
&mpctx->opts->stream_id[0][t->type]);
mark_track_selection(mpctx, 0, t->type, t->user_tid);
}
return;
}
@ -5116,9 +5112,7 @@ static void cmd_track_add(void *p)
if (mpctx->playback_initialized) {
mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
} else {
mpctx->opts->stream_id[0][t->type] = t->user_tid;
m_config_notify_change_opt_ptr(mpctx->mconfig,
&mpctx->opts->stream_id[0][t->type]);
mark_track_selection(mpctx, 0, t->type, t->user_tid);
}
}
char *title = cmd->args[2].v.s;

View File

@ -525,6 +525,8 @@ void mp_abort_trigger_locked(struct MPContext *mpctx,
void uninit_player(struct MPContext *mpctx, unsigned int mask);
int mp_add_external_file(struct MPContext *mpctx, char *filename,
enum stream_type filter, struct mp_cancel *cancel);
void mark_track_selection(struct MPContext *mpctx, int order,
enum stream_type type, int value);
#define FLAG_MARK_SELECTION 1
void mp_switch_track(struct MPContext *mpctx, enum stream_type type,
struct track *track, int flags);

View File

@ -573,11 +573,8 @@ static void check_previous_track_selection(struct MPContext *mpctx)
// defaults are -1 (default selection), or -2 (off) for secondary tracks.
for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
for (int i = 0; i < num_ptracks[t]; i++) {
if (opts->stream_id[i][t] >= 0) {
opts->stream_id[i][t] = i == 0 ? -1 : -2;
m_config_notify_change_opt_ptr(mpctx->mconfig,
&opts->stream_id[i][t]);
}
if (opts->stream_id[i][t] >= 0)
mark_track_selection(mpctx, i, t, i == 0 ? -1 : -2);
}
}
talloc_free(mpctx->track_layout_hash);
@ -586,8 +583,9 @@ static void check_previous_track_selection(struct MPContext *mpctx)
talloc_free(h);
}
static void mark_track_selection(struct MPContext *mpctx, int order,
enum stream_type type, int value)
// Update the matching track selection user option to the given value.
void mark_track_selection(struct MPContext *mpctx, int order,
enum stream_type type, int value)
{
assert(order >= 0 && order < num_ptracks[type]);
mpctx->opts->stream_id[order][type] = value;