From e9e93b4dbe748cd341a6fbea355e6ba013ada81b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Mar 2020 17:08:43 +0100 Subject: player: add a number of new playlist contol commands/properties Should give a good deal more explicit control and insight over the player state. Some feel a bit pointless, and/or expose internal weirdness. However, it's not like the existing weirdness didn't exist before, or can be made go away. (In part, the weirdness is because certain in-between states are visible. Hiding them would make things simpler, but less flexible.) Maybe this actually gives users a better idea how the API _should_ look like, too. On a side note, this tries to really guarantee that mpctx->playing is set between playback start/end. For that, the loadfile.c changes assume that mpctx->playing is set (guaranteed by code above the change), and that playing->filename is set (probably could never be false; was broken before and actually would have crashed if that could ever happen; in any case, also add an assert to playlist.c for this). playlist_entry_to_index() now tolerates playlist_entrys that are not part of the playlist. This is also needed for mpctx->playing. --- common/playlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/playlist.c b/common/playlist.c index 1fd202b98f..89c644dc33 100644 --- a/common/playlist.c +++ b/common/playlist.c @@ -62,6 +62,7 @@ static void playlist_update_indexes(struct playlist *pl, int start, int end) void playlist_add(struct playlist *pl, struct playlist_entry *add) { + assert(add->filename); MP_TARRAY_APPEND(pl, pl->entries, pl->num_entries, add); add->pl = pl; add->pl_index = pl->num_entries - 1; @@ -283,9 +284,8 @@ void playlist_append_entries(struct playlist *pl, struct playlist *source_pl) // Return -1 if e is not on the list, or if e is NULL. int playlist_entry_to_index(struct playlist *pl, struct playlist_entry *e) { - if (!e) + if (!e || e->pl != pl) return -1; - assert(e->pl == pl); return e->pl_index; } -- cgit v1.2.3