summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-15 17:10:01 +0200
committerwm4 <wm4@nowhere>2020-04-15 17:10:01 +0200
commitcc2ee06e576f59d95adc2e863ac8efcca89ad588 (patch)
tree9a3c7e58f6aa006ed4c368c7dea92ae7f902f25f
parent6c02555397ca599a7ec9ea781e492631ecf1c7f2 (diff)
downloadmpv-cc2ee06e576f59d95adc2e863ac8efcca89ad588.tar.bz2
mpv-cc2ee06e576f59d95adc2e863ac8efcca89ad588.tar.xz
player: remove duplicated track option setter code
Well whatever.
-rw-r--r--player/command.c14
-rw-r--r--player/core.h2
-rw-r--r--player/loadfile.c12
3 files changed, 11 insertions, 17 deletions
diff --git a/player/command.c b/player/command.c
index c10c4374aa..a5105ffe92 100644
--- a/player/command.c
+++ b/player/command.c
@@ -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;
diff --git a/player/core.h b/player/core.h
index bbd3f5ce33..6882246942 100644
--- a/player/core.h
+++ b/player/core.h
@@ -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);
diff --git a/player/loadfile.c b/player/loadfile.c
index 8461731518..97ae9328f1 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -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;