From 582f3f7cc01f81345df5c20a012b1f47587e6a97 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 28 Dec 2019 21:12:02 +0100 Subject: 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. --- demux/demux_playlist.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'demux/demux_playlist.c') diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index b40beda980..417642e75a 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -462,8 +462,7 @@ static int open_file(struct demuxer *demuxer, enum demux_check check) bool ok = fmt->parse(p) >= 0 && !p->error; if (p->add_base) playlist_add_base_path(p->pl, mp_dirname(demuxer->filename)); - for (struct playlist_entry *e = p->pl->first; e; e = e->next) - e->stream_flags = demuxer->stream_origin; + playlist_set_stream_flags(p->pl, demuxer->stream_origin); demuxer->playlist = talloc_steal(demuxer, p->pl); demuxer->filetype = p->format ? p->format : fmt->name; demuxer->fully_read = true; -- cgit v1.2.3