@@ -121,16 +121,15 @@ type Stream struct {
121121 BytesDropped int64 // Track total bytes dropped due to slow listeners
122122 CurrentSong string
123123 Public bool
124- Visible bool
125- IsTranscoded bool // True if this stream is an output of a transcoder
126- IsOggStream bool // Pre-calculated for speed
127-
128- LastDataReceived time.Time
129-
130-
131- OggHead []byte // Store Ogg headers for Opus/Ogg streams
132- OggHeaderOffset int64 // Absolute buffer offset where headers end
133- LastPageOffset int64 // Absolute offset of the last valid Ogg page start
124+ Visible bool
125+ IsTranscoded bool // True if this stream is an output of a transcoder
126+ IsOggStream bool // Pre-calculated for speed
127+
128+ LastDataReceived time.Time
129+
130+ OggHead []byte // Store Ogg headers for Opus/Ogg streams
131+ OggHeaderOffset int64 // Absolute buffer offset where headers end
132+ LastPageOffset int64 // Absolute offset of the last valid Ogg page start
134133 PageOffsets []int64 // Circular list of last ~100 page starts
135134 PageIndex int
136135
@@ -152,7 +151,7 @@ func (r *StreamReader) Read(p []byte) (int, error) {
152151 for {
153152 n , next , skipped := r .Stream .Buffer .ReadAt (r .Offset , p )
154153 if skipped && r .Stream .IsOggStream {
155- // If we were skipped forward because the buffer wrapped around,
154+ // If we were skipped forward because the buffer wrapped around,
156155 // we MUST re-align to the next Ogg page start.
157156 r .Offset = r .Stream .Buffer .FindNextPageBoundary (next )
158157 continue // Retry read at aligned offset
@@ -248,9 +247,8 @@ func (r *Relay) GetStream(mount string) (*Stream, bool) {
248247}
249248
250249func (r * Relay ) UpdateMetadata (mount , song string ) {
251- if st , ok := r .GetStream (mount ); ok {
252- st .SetCurrentSong (song , r )
253- }
250+ st := r .GetOrCreateStream (mount )
251+ st .SetCurrentSong (song , r )
254252}
255253
256254// IsOgg returns true if the stream is Ogg-based (Ogg/Vorbis, Ogg/Opus, etc)
@@ -346,15 +344,19 @@ func (s *Stream) Subscribe(id string, burstSize int) (int64, chan struct{}) {
346344 // For Ogg/Opus, align to the oldest known page boundary within the valid buffer range
347345 if s .IsOggStream {
348346 validStart := s .Buffer .Head - s .Buffer .Size
349- if validStart < 0 { validStart = 0 }
350-
351- // If we have an OggHead persistent storage, we want to start reading
347+ if validStart < 0 {
348+ validStart = 0
349+ }
350+
351+ // If we have an OggHead persistent storage, we want to start reading
352352 // from the Buffer AFTER the initial headers to avoid duplicates.
353353 if s .OggHeaderOffset > start {
354354 start = s .OggHeaderOffset
355355 }
356356
357- if start < validStart { start = validStart }
357+ if start < validStart {
358+ start = validStart
359+ }
358360
359361 bestAlign := s .LastPageOffset
360362 found := false
@@ -373,7 +375,7 @@ func (s *Stream) Subscribe(id string, burstSize int) (int64, chan struct{}) {
373375 start = s .Buffer .Head // Fallback to now if nothing valid found
374376 }
375377 }
376-
378+
377379 // Ensure we don't go back further than the buffer allows
378380 if s .Buffer .Head - start > s .Buffer .Size {
379381 start = s .Buffer .Head - s .Buffer .Size
@@ -498,7 +500,7 @@ func (s *Stream) Snapshot() StreamStats {
498500
499501 bi := atomic .LoadInt64 (& s .BytesIn )
500502 bd := atomic .LoadInt64 (& s .BytesDropped )
501-
503+
502504 // Health calculation
503505 // 1. Loss-based health
504506 health := 100.0
@@ -548,7 +550,6 @@ func (s *Stream) Snapshot() StreamStats {
548550 }
549551}
550552
551-
552553// uptimeLocked returns the formatted uptime string assuming the lock is already held
553554func (s * Stream ) uptimeLocked () string {
554555 d := time .Since (s .Started ).Round (time .Second )
0 commit comments