client API: disallow masking MPV_EVENT_SHUTDOWN

This makes no sense, because the client is obligated to react to this
event.

This also happens to fix a deadlock with JSON IPC clients sending
"disable_event all", because MPV_EVENT_SHUTDOWN was used to stop the
thread driving the socket connection (fixes #2558).
This commit is contained in:
wm4 2015-12-02 23:08:39 +01:00
parent 344d44681e
commit 57e691b901
1 changed files with 2 additions and 0 deletions

View File

@ -711,6 +711,8 @@ int mpv_request_event(mpv_handle *ctx, mpv_event_id event, int enable)
{ {
if (!mpv_event_name(event) || enable < 0 || enable > 1) if (!mpv_event_name(event) || enable < 0 || enable > 1)
return MPV_ERROR_INVALID_PARAMETER; return MPV_ERROR_INVALID_PARAMETER;
if (event == MPV_EVENT_SHUTDOWN && !enable)
return MPV_ERROR_INVALID_PARAMETER;
assert(event < (int)INTERNAL_EVENT_BASE); // excluded above; they have no name assert(event < (int)INTERNAL_EVENT_BASE); // excluded above; they have no name
pthread_mutex_lock(&ctx->lock); pthread_mutex_lock(&ctx->lock);
uint64_t bit = 1ULL << event; uint64_t bit = 1ULL << event;