summaryrefslogtreecommitdiffstats
path: root/player/client.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-19 11:11:51 +0100
committerwm4 <wm4@nowhere>2019-12-19 11:11:51 +0100
commit2c5cb2c53f38580696af4085bb257f0112e92a42 (patch)
treeb0e82776c032818fcee418179d427d894af8ba1f /player/client.h
parentf719b638402ca6b26759f23785f2dd46d31ee085 (diff)
downloadmpv-2c5cb2c53f38580696af4085bb257f0112e92a42.tar.bz2
mpv-2c5cb2c53f38580696af4085bb257f0112e92a42.tar.xz
client API: rewrite property observation (again)
I intend to rewrite this code approximately every 2 months. Last time, I did this in commit d66eb93e5d4 (and 065c307e8e7 and b2006eeb74f). It was intended to remove the roundabout synchronous thread "ping pong" when observing properties. At first, the original async. code was replaced with some nice mostly synchronous code. But then an async. code path had to be added for vo_libmpv, and finally the sync. code was dropped because it broke in other obscure cases (like the Objective-C Cocoa backend). Try again. This time, update properties entirely on the main thread. Updates get batched out on every playloop iteration. (At first I wanted it to make it every time the player goes to sleep, but that might starve API clients if the playloop get saturated.) One nice thing is that clients only get woken up once all changed events have been sent, which might reduce overhead. While this sounds simple, it's not. The main problem is that reading properties must not block the client API, i.e. no client API locks can be held while reading the property. Maybe eventually we can avoid this requirement, but currently it's just a fact. This means we have to iterate over all clients and then over all properties (of each client), all while releasing all locks when updating a property. Solve this by rechecking on each iteration whether the list changed, and if so, aborting the iteration and redo it "next time". High risk change, expect bugs such as crashes and missing property updates.
Diffstat (limited to 'player/client.h')
-rw-r--r--player/client.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/player/client.h b/player/client.h
index 186238396d..3408ff17f0 100644
--- a/player/client.h
+++ b/player/client.h
@@ -30,6 +30,7 @@ int mp_client_send_event(struct MPContext *mpctx, const char *client_name,
int mp_client_send_event_dup(struct MPContext *mpctx, const char *client_name,
int event, void *data);
void mp_client_property_change(struct MPContext *mpctx, const char *name);
+void mp_client_send_property_changes(struct MPContext *mpctx);
struct mpv_handle *mp_new_client(struct mp_client_api *clients, const char *name);
void mp_client_set_weak(struct mpv_handle *ctx);