mirror of https://bitbucket.org/ausocean/av.git
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:
parent
db84c5bfcf
commit
4087be907a
|
@ -51,8 +51,7 @@ type BroadcastBasic struct {
|
|||
// ManagerBasic is a crude version of the BroadcastManager struct use to simplify
|
||||
// marshal/unmarshal overriding.
|
||||
type ManagerBasic struct {
|
||||
Broadcasts map[MAC]*Broadcast
|
||||
SlateExitSignals []MAC
|
||||
Broadcasts map[MAC]*Broadcast
|
||||
}
|
||||
|
||||
// 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,20 +115,23 @@ func (m *broadcastManager) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
m.dogNotifier = notifier
|
||||
|
||||
for _, mac := range mb.SlateExitSignals {
|
||||
sigCh := make(chan struct{})
|
||||
m.slateExitSignals[mac] = sigCh
|
||||
rv := m.getPipeline(mac)
|
||||
if rv == nil {
|
||||
panic("no pipeline for MAC")
|
||||
}
|
||||
if !inTest {
|
||||
err := writeSlateAndCheckErrors(rv, sigCh, m.log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't write slate for MAC %v: %w", mac, err)
|
||||
for mac, b := range m.broadcasts {
|
||||
if b.status == statusSlate {
|
||||
sigCh := make(chan struct{})
|
||||
m.slateExitSignals[mac] = sigCh
|
||||
rv := m.getPipeline(mac)
|
||||
if rv == nil {
|
||||
panic("no pipeline for MAC")
|
||||
}
|
||||
if !inTest {
|
||||
err := writeSlateAndCheckErrors(rv, sigCh, m.log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't write slate for MAC %v: %w", mac, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue