mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-02 05:04:19 +01:00
feat(power): ride out sleep, lock and display changes
Docking, sleep and lock are where komorebi bugs show up, so the recording carries on through them. On Windows a hidden window hears suspend, resume, the lid, the displays and session lock as Windows delivers them; on a Mac a sleep is found because the host clock pauses while the wall clock does not, and the lock is polled on both hosts. A tracker turns these into reactions: a display that is gone has its video finalized at once, one that returns starts a new segment, and every stream is started afresh after a wake instead of trusting the old one.
This commit is contained in:
1 parent
fb11cb2db9
commit
383cc3c3db
13 files changed
+1142
No files matched your search
@@ -83,6 +83,11 @@ one segment to a file: a display that is unplugged and returns starts a new segm
|
||||
The recorder starts its sources in an order that makes the sources that are not video a superset of the video's span
|
||||
(the clock anchor, the OS trace streams, the subscription to komorebi and its first `State`, komorebi's log offset, and
|
||||
last the video), and stops them in the reverse order.
|
||||
While it runs, the machine is docked, undocked, put to sleep, woken with the lid opened and locked, and none of that may
|
||||
lose what was already captured. A tracker turns what the OS says (or, on a Mac, what the two clocks disagree about) into
|
||||
reactions: a display that is gone has its video finalized at once, one that returns starts a new segment, and every
|
||||
stream is started afresh after a wake. The capture backend is a trait, so that these policies are tested with a scripted
|
||||
backend that docks and undocks without hardware.
|
||||
|
||||
## Rules and the layer that enforces them
|
||||
|
||||
|
||||
@@ -46,6 +46,18 @@ Video frame times and the OS trace are on the master clock already on both hosts
|
||||
`machTimestamp` on a Mac; Windows.Graphics.Capture on Windows). The field names ending in `_mach_ns` are spelled that way
|
||||
on every host: see [the architecture](ARCHITECTURE.md#the-master-clock).
|
||||
|
||||
### Noticing sleep, wake, lock and display changes
|
||||
|
||||
| | macOS | Windows |
|
||||
|---|---|---|
|
||||
| a sleep | found afterwards: the master clock pauses while the wall clock does not, which the recording loop sees by comparing the two many times a second | heard as it happens, from a hidden window on a thread of its own that receives suspend and resume; the lid, the displays' power state and session lock are registered for |
|
||||
| the screen locked | polled: CoreGraphics' session dictionary | polled: being refused the input desktop means a lock screen or a UAC prompt, and the screen cannot be captured then either way |
|
||||
| displays added, removed, resized | polled: `CGGetActiveDisplayList` and `CGDisplayIsAsleep`, which are cheap and need no permission | polled, and heard as a display-change message |
|
||||
|
||||
Windows is told when the lock happens as well as polling for it. What is done about each of these, on both hosts, is the
|
||||
same: a display that is gone has its video finalized at once, a display that returns starts a new segment, and every
|
||||
stream is started afresh after a wake instead of trusting the old one.
|
||||
|
||||
### Capturing the screen
|
||||
|
||||
| | macOS | Windows |
|
||||
|
||||
Reference in new issue
Block a user