-
Notifications
You must be signed in to change notification settings - Fork 3.2k
DOCS/man/input: don't discourage hook usage #17038
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
Conversation
Dudemanguy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah no point in scaring people.
DOCS/man/input.rst
Outdated
| no API stability guarantees made. Not following the protocol exactly can make | ||
| the player freeze randomly. Basically, nobody should use this API. | ||
| events are supposed to be asynchronous, and the hook API provides a way to | ||
| handle events that require stricter coordination. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not following the protocol exactly can make the player freeze randomly.
Should be left intact. The hook api may be used, but is still dangerous tool in hands on scripts, and should be used with caution.
Not following the protocol exactly can make the player freeze randomly. Use with caution, avoid if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would it freeze randomly though? We even call yt-dlp in a hook and it doesn't freeze.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't trigger next hook from script it will wait and hang forever. Generally scripts shouldn't be able to interrupt main player loop.
(I think in lua the process is mostly automatic, but hooks in general require careful use)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently in the C api you have to call mpv_hook_continue but this is done automatically in scripts. But I think "randomly" makes it sound like it will occasionally break unpredictably. If you don't continue mpv will freeze, it is not random.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message can be changed to:
Not following the protocol exactly can make the player freeze. Use with caution, avoid if synchronous event handling is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's much better.
This paragraph was added 10 years ago in f8dc5db. Hooks are now commonly used both in internal (ytdl_hook, auto_profiles) and external scripts (e.g. https://github.com/mpv-player/mpv/issues?q=mp.add_hook). They are the only way to handle events synchronously and nobody is just going to change the API and break all scripts at this point, so remove the warning.
This paragraph was added 10 years ago in f8dc5db. Hooks are now commonly used both in internal (ytdl_hook, auto_profiles) and external scripts (e.g. https://github.com/mpv-player/mpv/issues?q=mp.add_hook). They are the only way to handle events synchronously and nobody is just going to change the API and break all scripts at this point, so remove the warning.