diff options
author | wm4 <wm4@nowhere> | 2020-03-21 17:45:30 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-03-21 19:33:03 +0100 |
commit | 7e885a3bc3af4df93681b6e760a34e59e2f47ef7 (patch) | |
tree | c2687c6b364a2e5aeef0c466fb04988bafc35ab3 /common | |
parent | 956a5d9ac61ffe4034abcc81405e8ecdacac8b36 (diff) | |
download | mpv-7e885a3bc3af4df93681b6e760a34e59e2f47ef7.tar.bz2 mpv-7e885a3bc3af4df93681b6e760a34e59e2f47ef7.tar.xz |
client API: add a playlist entry unique ID
This should make dealing with some async. things easier.
It's intentionally not a globally unique ID.
Diffstat (limited to 'common')
-rw-r--r-- | common/playlist.c | 2 | ||||
-rw-r--r-- | common/playlist.h | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/common/playlist.c b/common/playlist.c index 89c644dc33..d7c752ad8d 100644 --- a/common/playlist.c +++ b/common/playlist.c @@ -66,6 +66,7 @@ void playlist_add(struct playlist *pl, struct playlist_entry *add) MP_TARRAY_APPEND(pl, pl->entries, pl->num_entries, add); add->pl = pl; add->pl_index = pl->num_entries - 1; + add->id = ++pl->id_alloc; talloc_steal(pl, add); } @@ -250,6 +251,7 @@ static void playlist_transfer_entries_to(struct playlist *pl, int dst_index, struct playlist_entry *e = source_pl->entries[n]; e->pl = pl; e->pl_index = dst_index + n; + e->id = ++pl->id_alloc; pl->entries[e->pl_index] = e; talloc_steal(pl, e); } diff --git a/common/playlist.h b/common/playlist.h index 8b014e864d..f8dfbb2ba2 100644 --- a/common/playlist.h +++ b/common/playlist.h @@ -30,6 +30,8 @@ struct playlist_entry { struct playlist *pl; int pl_index; + uint64_t id; + char *filename; struct playlist_param *params; @@ -71,6 +73,8 @@ struct playlist { // current_was_replaced is set to true. struct playlist_entry *current; bool current_was_replaced; + + uint64_t id_alloc; }; void playlist_entry_add_param(struct playlist_entry *e, bstr name, bstr value); |