diff options
author | wm4 <wm4@nowhere> | 2019-12-19 11:11:51 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-12-19 11:11:51 +0100 |
commit | 2c5cb2c53f38580696af4085bb257f0112e92a42 (patch) | |
tree | b0e82776c032818fcee418179d427d894af8ba1f /common | |
parent | f719b638402ca6b26759f23785f2dd46d31ee085 (diff) | |
download | mpv-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 'common')
0 files changed, 0 insertions, 0 deletions