nrkno / sofie-atem-connection

Sofie ATEM Connection: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
129 stars 36 forks source link

Is running macro - state #118

Closed DPCLive closed 1 year ago

DPCLive commented 3 years ago
Julusian commented 1 year ago

I have finally gotten around to testing this, and if a macro has no sleeps, then yeah it often doesn't ever show as isRunning in the state. This is happening because the macro is so short, so the started and stopped commands are often in the same packet, meaning we apply them to the state at the same time (to avoid emitting a new state 50 times within a couple of ms when making larger changes).
Occasionally, these started and stopped commands end up in different packets, causing a blink in the state.

I don't see a good solution for changing how this state is built, without this becoming a breaking change and likely noticably impacting performance.
Perhaps a proper solution would be to provide some way of subscribing to individual properties in the state? Observing at that granularity would not need the batching.

A solution which is possible today would be to listen to the receivedCommands event, and to filter the provided commands to look for any MacroActionCommand in there, to listen for the specific state changes you need.
Or if you make sure that your macros have a sleep in them (1 frame should be sufficient), then the two commands should be guaranteed to be in different packets, which will result in the state updating as you are wanting.

I am going to close this for now, as this is an old issue without much activity, there is a workaround, and a proper solution is rather costly and unlikely to be done unless it becomes a wider problem