explicit info in GUI for playlist

This commit is contained in:
Dmitry Sergeev
2026-09-01 23:59:45 +03:00
parent 841c14f497
commit ea8c9eeddd
5 changed files with 125 additions and 19 deletions
+42 -8
View File
@@ -17,6 +17,7 @@ const (
type PlaylistEvent struct {
Revision uint64
Kind PlaylistEventKind
Failure Status
}
// PlaylistReadiness is retained as an alias for callers that only publish
@@ -47,13 +48,24 @@ type PlaylistController struct {
mu sync.RWMutex
snapshot PlaylistSnapshot
hasSnapshot bool
failure PlaylistFailure
}
type PlaylistFailure struct {
EntryIndex int
EntryName string
Revision uint64
Policy PlaylistFailurePolicy
Status Status
}
type PlaylistSnapshot struct {
State PlaylistState
Entry PlaylistEntry
Revision uint64
Timing PlaylistTimingState
State PlaylistState
Entry PlaylistEntry
Revision uint64
Timing PlaylistTimingState
Failure PlaylistFailure
HasFailure bool
}
var (
@@ -155,6 +167,7 @@ func (c *PlaylistController) Run(
continue
}
if apply {
c.clearFailure()
stopTimer()
select {
case <-ctx.Done():
@@ -179,6 +192,13 @@ func (c *PlaylistController) Run(
continue
}
stopTimer()
c.setFailure(PlaylistFailure{
EntryIndex: state.CurrentIndex,
EntryName: c.playlist.Entries[state.CurrentIndex].Name,
Revision: revision,
Policy: c.playlist.OnFailure,
Status: ready.Failure,
})
// A failed entry must not retain a live or apparently active
// duration clock, even when the policy is to wait.
timing = NewPlaylistTiming(revision, timing.Duration)
@@ -285,15 +305,29 @@ func (c *PlaylistController) publish(
c.mu.Lock()
c.snapshot = PlaylistSnapshot{
State: state,
Entry: entry,
Revision: revision,
Timing: timing,
State: state,
Entry: entry,
Revision: revision,
Timing: timing,
Failure: c.failure,
HasFailure: c.failure.Revision != 0,
}
c.hasSnapshot = true
c.mu.Unlock()
}
func (c *PlaylistController) setFailure(failure PlaylistFailure) {
c.mu.Lock()
c.failure = failure
c.mu.Unlock()
}
func (c *PlaylistController) clearFailure() {
c.mu.Lock()
c.failure = PlaylistFailure{}
c.mu.Unlock()
}
func stopPlaylistTimer(timer playlistTimer) {
if timer == nil || timer.Stop() {
return