Skip to content

Commit

Permalink
player/client: reduce log level for hooks not sent to clients
Browse files Browse the repository at this point in the history
If a hook event can't be sent to a client because it no longer exists,
stop logging it as a warning, as there is no way for a client to remove
hooks, so it is expected that the hook can't be sent. This is documented
in libmpv/client.h.

If the hook event can't be sent because the event queue is full, stop
removing the hook, and keep logging the warning.
  • Loading branch information
guidocella committed Nov 2, 2024
1 parent d09145a commit 83dc82a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,13 @@ static int invoke_hook_handler(struct MPContext *mpctx, struct hook_handler *h)
char *name = mp_tprintf(22, "@%"PRIi64, h->client_id);
int r = mp_client_send_event(mpctx, name, reply_id, MPV_EVENT_HOOK, m);
if (r < 0) {
MP_WARN(mpctx, "Sending hook command failed. Removing hook.\n");
hook_remove(mpctx, h);
mp_wakeup_core(mpctx); // repeat next iteration to finish
if (mp_client_id_exists(mpctx, h->client_id)) {
MP_VERBOSE(mpctx, "Sending hook command failed. Removing hook.\n");
hook_remove(mpctx, h);
} else {
MP_WARN(mpctx, "Sending hook command failed.\n");
mp_wakeup_core(mpctx); // repeat next iteration to finish
}
}
return r;
}
Expand Down

0 comments on commit 83dc82a

Please sign in to comment.