summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorZehua Chen <chenzh1993@gmail.com>2018-01-27 15:27:58 -0500
committerKevin Mitchell <kevmitch@gmail.com>2018-02-10 06:50:32 -0800
commit000a0e2775f47033ec1f6f933cb208bb608800b8 (patch)
treeba61b16183ed36fad4986ec00309848cab9af320 /player/command.c
parent6161cfd781974f8471b9ab99016db1d8bb8d33e7 (diff)
downloadmpv-000a0e2775f47033ec1f6f933cb208bb608800b8.tar.bz2
mpv-000a0e2775f47033ec1f6f933cb208bb608800b8.tar.xz
player: correctly set track information on adding external files
Before this commit, auto_loaded and lang were only set for the first track in auto-loaded external files. Likewise, for the title and lang arguments to the sub-add and audio-add commands. Fixes #5432
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/player/command.c b/player/command.c
index 0ebdb29d96..b282edda4c 100644
--- a/player/command.c
+++ b/player/command.c
@@ -5295,24 +5295,29 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
return 0;
}
}
- struct track *t = mp_add_external_file(mpctx, cmd->args[0].v.s, type);
- if (!t)
+ int first = mp_add_external_file(mpctx, cmd->args[0].v.s, type);
+ if (first < 0)
return -1;
- if (cmd->args[1].v.i == 1) {
- t->no_default = true;
- } else {
- if (mpctx->playback_initialized) {
- mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
- } else {
- opts->stream_id[0][t->type] = t->user_tid;
+
+ for (int n = first; n < mpctx->num_tracks; n++) {
+ struct track *t = mpctx->tracks[n];
+ if (cmd->args[1].v.i == 1){
+ t->no_default = true;
+ } else if (n == first) {
+ if (mpctx->playback_initialized) {
+ mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
+ } else {
+ opts->stream_id[0][t->type] = t->user_tid;
+ }
}
+ char *title = cmd->args[2].v.s;
+ if (title && title[0])
+ t->title = talloc_strdup(t, title);
+ char *lang = cmd->args[3].v.s;
+ if (lang && lang[0])
+ t->lang = talloc_strdup(t, lang);
}
- char *title = cmd->args[2].v.s;
- if (title && title[0])
- t->title = talloc_strdup(t, title);
- char *lang = cmd->args[3].v.s;
- if (lang && lang[0])
- t->lang = talloc_strdup(t, lang);
+
if (mpctx->playback_initialized)
print_track_list(mpctx, "Track added:");
break;
@@ -5338,14 +5343,15 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
}
int type = cmd->id == MP_CMD_SUB_RELOAD ? STREAM_SUB : STREAM_AUDIO;
struct track *t = mp_track_by_tid(mpctx, type, cmd->args[0].v.i);
- struct track *nt = NULL;
+ int nt_num = -1;
if (t && t->is_external && t->external_filename) {
char *filename = talloc_strdup(NULL, t->external_filename);
mp_remove_track(mpctx, t);
- nt = mp_add_external_file(mpctx, filename, type);
+ nt_num = mp_add_external_file(mpctx, filename, type);
talloc_free(filename);
}
- if (nt) {
+ if (nt_num >= 0) {
+ struct track *nt = mpctx->tracks[nt_num];
mp_switch_track(mpctx, nt->type, nt, 0);
print_track_list(mpctx, "Reloaded:");
return 0;