evision-safe playlist timing
This commit is contained in:
@@ -17,8 +17,9 @@ type PlaylistController struct {
|
||||
}
|
||||
|
||||
type PlaylistSnapshot struct {
|
||||
State PlaylistState
|
||||
Entry PlaylistEntry
|
||||
State PlaylistState
|
||||
Entry PlaylistEntry
|
||||
Revision uint64
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -51,7 +52,8 @@ func (c *PlaylistController) Run(
|
||||
commands <-chan PlaylistCommand,
|
||||
) error {
|
||||
state := PlaylistState{}
|
||||
c.publish(state)
|
||||
revision := uint64(0)
|
||||
c.publish(state, revision)
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -78,10 +80,11 @@ func (c *PlaylistController) Run(
|
||||
return ctx.Err()
|
||||
case c.sessions <- sessionCommand:
|
||||
}
|
||||
revision++
|
||||
}
|
||||
|
||||
state = next
|
||||
c.publish(state)
|
||||
c.publish(state, revision)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,11 +95,15 @@ func (c *PlaylistController) Snapshot() (PlaylistSnapshot, bool) {
|
||||
return c.snapshot, c.hasSnapshot
|
||||
}
|
||||
|
||||
func (c *PlaylistController) publish(state PlaylistState) {
|
||||
func (c *PlaylistController) publish(state PlaylistState, revision uint64) {
|
||||
entry, _ := state.Entry(c.playlist)
|
||||
|
||||
c.mu.Lock()
|
||||
c.snapshot = PlaylistSnapshot{State: state, Entry: entry}
|
||||
c.snapshot = PlaylistSnapshot{
|
||||
State: state,
|
||||
Entry: entry,
|
||||
Revision: revision,
|
||||
}
|
||||
c.hasSnapshot = true
|
||||
c.mu.Unlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user