gst/systemclock: wait on each entry individually
authorMatthew Waters <matthew@centricular.com>
Wed, 15 Apr 2020 07:54:21 +0000 (17:54 +1000)
committerMatthew Waters <matthew@centricular.com>
Thu, 16 Apr 2020 01:26:59 +0000 (01:26 +0000)
commit6f9a63a10daf51957ea54edddec5c91d695f27d4
tree7958dcd3fd568e010bbbf8dae6810c59ccdfb416
parent546bf6ec254a642258ba620ddde1e8e90ecfce58
gst/systemclock: wait on each entry individually

Problem:
multiple aggregator elements (audiomixer, compositor) in a live
pipeline use a lot of CPU waiting each other up.  This is because
of the previously unused clock entry unscheduling during regular
operation.

Clock entry unscheduling has the potential to wake up every clock entry
waiting using the system clock which may be a large number.

Solution:
Implement waiting per entry and only wakeup the unscheduled entry.

While this may be possible using GCond, theoretically GCond only gives
us microsecond accuracy and uses relative waits in a number of places.
We can unfortunately do better poking at the platform specifics
ourselves by using futexes on linux and pthread on other unix.  Windows
may have a possible implementation using Waitable timers but that is
not implemented here and instead falls back to the GCond implementation.
GCond waits on Windows is still as accurate as the previous GstPoll-based
implementation.
gst/gst_private.h
gst/gstclock.c
gst/gstsystemclock.c
meson.build