Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command: make playlist writable #14990

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zsugabubus
Copy link

An attempt to improve #14939. It enhances the playlist property by making it writable: it allows reordering, removing and loading new playlist entries in one go. Thanks na-na-hi for the idea.

Compared to my previous approach it adds much more code but I hope the added functionality justifies it (though most of it is just copy-pasted hash map implementation).

I couldn't find too much prior work on tests so I came up with a custom script. Not sure whether this was the correct way to do it.

@guidocella
Copy link
Contributor

Can av_dict be used instead of adding khash?

@zsugabubus
Copy link
Author

av_dict is O(n) and uses string comparison.

#endif
#ifndef kfree
#define kfree(P) free(P)
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundling khash seems hefty. Either way this should be defined to use talloc_ as everything else in mpv.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure if we should include whole khash implementation just for a single property use.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The obvious advantage of playlist_entry_id over index is that it's unique so if parallel modifications happen it will not mess up the playlist. Users could be thankful for the extra safety and khash basically requires no maintenance on the developer's end.

However (AFAIK) no other mpv API supports this kind of ID addressing so even though it sounds great, maybe it's useless to be too smart here.

The only thing I'm not sure about whether a simple set_property("playlist", get_property("playlist")) should work. If ID lookup gets removed users have to manually hack an index for each entry (that may or may not be an issue since they already transform the playlist by some code).

test/test.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants