summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-28 21:12:02 +0100
committerwm4 <wm4@nowhere>2019-12-28 21:32:15 +0100
commit582f3f7cc01f81345df5c20a012b1f47587e6a97 (patch)
tree03ddce6c9cc0e5aa48135b5af45a57ec37150355 /options
parent4564a22d13b693efed847ba77361ea4e2448a7bf (diff)
downloadmpv-582f3f7cc01f81345df5c20a012b1f47587e6a97.tar.bz2
mpv-582f3f7cc01f81345df5c20a012b1f47587e6a97.tar.xz
playlist: change from linked list to an array
Although a linked list was ideal at first, there are cases where it sucks, and became increasingly awkward (with the mpv command API preferring integer indexes to access the list). In future, we probably want to add more playlist-related functionality, so better change it to an array now. An array isn't always ideal either. Since playlist entries are still separate objects (because in some cases you need a stable "iterator" to it), but you still need to efficiently get the next/previous playlist entry, there's a pl_index field, that needs to be maintained. E.g. adding an entry at the start of the playlist => update the pl_index field for all other entries. Well, it's not really worth to do something more complicated to avoid these things. This commit is probably buggy as shit. It's not like I bothered to test everything. That's _your_ role.
Diffstat (limited to 'options')
-rw-r--r--options/parse_commandline.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/options/parse_commandline.c b/options/parse_commandline.c
index 711f1f1df5..e89239c33b 100644
--- a/options/parse_commandline.c
+++ b/options/parse_commandline.c
@@ -165,7 +165,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
}
mode = LOCAL;
assert(!local_start);
- local_start = files->last;
+ local_start = playlist_get_last(files);
continue;
}
@@ -179,14 +179,15 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
// the entry _after_ local_start, until the end of the list.
// If local_start is NULL, the list was empty on '{', and we
// want all files in the list.
- struct playlist_entry *cur
- = local_start ? local_start->next : files->first;
+ struct playlist_entry *cur = local_start
+ ? playlist_entry_get_rel(local_start, 1)
+ : playlist_get_first(files);
if (!cur)
MP_WARN(config, "Ignored options!\n");
while (cur) {
playlist_entry_add_params(cur, local_params,
local_params_count);
- cur = cur->next;
+ cur = playlist_entry_get_rel(cur, 1);
}
}
local_params_count = 0;