js: events registration: clarify breakage/fix

This commit is mainly for correcting the previous commit message.

The previous commit fixed an issue where [un]registering events above
the first event ID "hole" is not requested from libmpv, and that's
indeed true.

However, this had nearly zero impact in practice, because libmpv
enables all events by default anyway (except TICK).

Therefore, above the first ID "hole" [un]register requests are not
sent to libmpv, and the events just keep arriving.

But the callback functions are still added/removed correctly (at
defaults.js), and so the script is not called back even if unregister
did not actually happen with libmpv.

The only event which was affected is TICK - which is not enabled by
default as it's deprecated, and before the previous commit could not
be enabled.

So the fix is more a general correctness fix now that the IDs array
can have "holes", but with effctively no impact in practice.
This commit is contained in:
Avi Halachmi (:avih) 2021-12-26 20:20:46 +02:00
parent 5c5e35c1bc
commit 2157bb1995
1 changed files with 1 additions and 0 deletions

View File

@ -611,6 +611,7 @@ static void script__request_event(js_State *J)
bool enable = js_toboolean(J, 2); bool enable = js_toboolean(J, 2);
for (int n = 0; n < 256; n++) { for (int n = 0; n < 256; n++) {
// some n's may be missing ("holes"), returning NULL
const char *name = mpv_event_name(n); const char *name = mpv_event_name(n);
if (name && strcmp(name, event) == 0) { if (name && strcmp(name, event) == 0) {
push_status(J, mpv_request_event(jclient(J), n, enable)); push_status(J, mpv_request_event(jclient(J), n, enable));