architecture cleanup
This commit is contained in:
@@ -20,10 +20,6 @@ type PlaylistEvent struct {
|
||||
Failure Status
|
||||
}
|
||||
|
||||
// PlaylistReadiness is retained as an alias for callers that only publish
|
||||
// ready events. Its zero Kind is PlaylistEventReady.
|
||||
type PlaylistReadiness = PlaylistEvent
|
||||
|
||||
type playlistTimer interface {
|
||||
C() <-chan time.Time
|
||||
Stop() bool
|
||||
@@ -100,7 +96,7 @@ func NewPlaylistController(
|
||||
func (c *PlaylistController) Run(
|
||||
ctx context.Context,
|
||||
commands <-chan PlaylistCommand,
|
||||
readiness <-chan PlaylistReadiness,
|
||||
events <-chan PlaylistEvent,
|
||||
) error {
|
||||
state := PlaylistState{}
|
||||
revision := uint64(0)
|
||||
@@ -182,13 +178,13 @@ func (c *PlaylistController) Run(
|
||||
state = next
|
||||
c.publish(state, revision, timing)
|
||||
|
||||
case ready, ok := <-readiness:
|
||||
case event, ok := <-events:
|
||||
if !ok {
|
||||
readiness = nil
|
||||
events = nil
|
||||
continue
|
||||
}
|
||||
if ready.Kind == PlaylistEventFailed {
|
||||
if ready.Revision != revision {
|
||||
if event.Kind == PlaylistEventFailed {
|
||||
if event.Revision != revision {
|
||||
continue
|
||||
}
|
||||
stopTimer()
|
||||
@@ -197,7 +193,7 @@ func (c *PlaylistController) Run(
|
||||
EntryName: c.playlist.Entries[state.CurrentIndex].Name,
|
||||
Revision: revision,
|
||||
Policy: c.playlist.OnFailure,
|
||||
Status: ready.Failure,
|
||||
Status: event.Failure,
|
||||
})
|
||||
// A failed entry must not retain a live or apparently active
|
||||
// duration clock, even when the policy is to wait.
|
||||
@@ -228,8 +224,11 @@ func (c *PlaylistController) Run(
|
||||
c.publish(state, revision, timing)
|
||||
continue
|
||||
}
|
||||
if event.Kind != PlaylistEventReady {
|
||||
continue
|
||||
}
|
||||
if timing.Paused &&
|
||||
ready.Revision == timing.Revision &&
|
||||
event.Revision == timing.Revision &&
|
||||
timing.Duration > 0 &&
|
||||
!timing.Expired {
|
||||
timing.Ready = true
|
||||
@@ -238,7 +237,7 @@ func (c *PlaylistController) Run(
|
||||
}
|
||||
nextTiming, started := StartPlaylistTiming(
|
||||
timing,
|
||||
ready.Revision,
|
||||
event.Revision,
|
||||
c.now(),
|
||||
)
|
||||
if !started {
|
||||
|
||||
Reference in New Issue
Block a user