vidforward: simplify manager file save/load

When saving and loading manager state to and from file, we don't
need to worry about the slate exit signals. Now that we have
broadcast status i.e. "play" or "slate", we can derive whether we
need an exit signal based only on that.

Approved-by: Trek Hopton
This commit is contained in:
Saxon Milton 2023-09-18 23:25:28 +00:00
parent db84c5bfcf
commit 4087be907a
1 changed files with 16 additions and 21 deletions

View File

@ -52,7 +52,6 @@ type BroadcastBasic struct {
// marshal/unmarshal overriding.
type ManagerBasic struct {
Broadcasts map[MAC]*Broadcast
SlateExitSignals []MAC
}
// MarshalJSON calls the default marshalling behaviour for the BroadcastBasic
@ -94,14 +93,7 @@ func (b *Broadcast) UnmarshalJSON(data []byte) error {
// MarshalJSON calls the default marshaller for a ManagerBasic value using data
// from a broadcastManager value.
func (m *broadcastManager) MarshalJSON() ([]byte, error) {
var signals []MAC
for k := range m.slateExitSignals {
signals = append(signals, k)
}
return json.Marshal(ManagerBasic{
Broadcasts: m.broadcasts,
SlateExitSignals: signals,
})
return json.Marshal(ManagerBasic{Broadcasts: m.broadcasts})
}
// UnmarshalJSON populates a ManagerBasic value from the provided data and then
@ -123,7 +115,8 @@ func (m *broadcastManager) UnmarshalJSON(data []byte) error {
}
m.dogNotifier = notifier
for _, mac := range mb.SlateExitSignals {
for mac, b := range m.broadcasts {
if b.status == statusSlate {
sigCh := make(chan struct{})
m.slateExitSignals[mac] = sigCh
rv := m.getPipeline(mac)
@ -137,6 +130,8 @@ func (m *broadcastManager) UnmarshalJSON(data []byte) error {
}
}
}
}
return nil
}