Tune sync delay to 10s, fix countdown during transitions, add buffer bloat monitor

- Set *browser-buffer-seconds* to 10 (5s=23s early, 23s=14s late)
- Hide countdown timer during title transition window (titles mismatch)
- Add client-side buffer bloat monitor: logs buffer size every 30s,
  auto-reconnects if buffer exceeds 15s to prevent drift
- Reduce buffer monitor log spam (only log when >5s, check every 30s)
- Update cl-streamer submodule ref
This commit is contained in:
Glenn Thompson 2026-04-09 17:12:15 +01:00
parent 10c75f04e1
commit 20ed7ecb02
3 changed files with 23 additions and 20 deletions

@ -1 +1 @@
Subproject commit 8a5dde598370b13965317f456999a85096832be6 Subproject commit cc4215d1c663c5aed4e9758c755a944016fa6aaa

View File

@ -779,12 +779,12 @@
(when (and (not (ps:@ audio-element paused)) (when (and (not (ps:@ audio-element paused))
(not *is-reconnecting*)) (not *is-reconnecting*))
(let ((ahead (get-buffer-ahead audio-element))) (let ((ahead (get-buffer-ahead audio-element)))
(when (and ahead (> ahead 0)) (when (and ahead (> ahead 5))
(ps:chain console (log (+ "[BUFFER] " (ps:chain ahead (to-fixed 1)) "s ahead"))) (ps:chain console (log (+ "[BUFFER] " (ps:chain ahead (to-fixed 1)) "s ahead"))))
(when (> ahead *max-buffer-seconds*) (when (and ahead (> ahead *max-buffer-seconds*))
(ps:chain console (log (+ "[BUFFER] Bloat detected (" (ps:chain ahead (to-fixed 1)) "s), resetting stream"))) (ps:chain console (log (+ "[BUFFER] Bloat detected (" (ps:chain ahead (to-fixed 1)) "s), resetting stream")))
(reconnect-stream)))))) (reconnect-stream)))))
10000))) 30000)))
;; Attach event listeners to audio element ;; Attach event listeners to audio element
(defun attach-audio-listeners (audio-element) (defun attach-audio-listeners (audio-element)

View File

@ -212,23 +212,26 @@
(listeners (cl-streamer:pipeline-listener-count *harmony-pipeline*)) (listeners (cl-streamer:pipeline-listener-count *harmony-pipeline*))
(track-id (or (find-track-by-title display-title) (track-id (or (find-track-by-title display-title)
(find-track-by-file-path (getf track-info :file)))) (find-track-by-file-path (getf track-info :file))))
(pipeline-title (getf track-info :display-title))
(raw-remaining (cl-streamer/harmony:pipeline-track-remaining *harmony-pipeline*)) (raw-remaining (cl-streamer/harmony:pipeline-track-remaining *harmony-pipeline*))
;; Adjust for browser buffer delay - listener is further behind than pipeline (titles-match (or (null listener-title)
(remaining (when raw-remaining (null pipeline-title)
(let ((adjusted (+ raw-remaining cl-streamer::*browser-buffer-seconds*))) (string= listener-title pipeline-title)))
(max 0 (floor adjusted)))))) ;; Only show remaining when titles match (delay has passed).
;; Diagnostic: log when listener-title differs from pipeline title ;; During the transition window the countdown would be inaccurate.
(let ((pipeline-title (getf track-info :display-title))) (remaining (when (and raw-remaining titles-match)
(max 0 (floor raw-remaining)))))
;; Diagnostic: log when listener-title differs from pipeline title
(when (and listener-title pipeline-title (when (and listener-title pipeline-title
(not (string= listener-title pipeline-title))) (not (string= listener-title pipeline-title)))
(log:info "[SYNC-DIAG] API returning ~S (pipeline has ~S, delay=~As)" (log:info "[SYNC-DIAG] API returning ~S (pipeline has ~S, delay=~As)"
listener-title pipeline-title cl-streamer::*browser-buffer-seconds*))) listener-title pipeline-title cl-streamer::*browser-buffer-seconds*))
`((:listenurl . ,(format nil "~A/~A" *stream-base-url* mount)) `((:listenurl . ,(format nil "~A/~A" *stream-base-url* mount))
(:title . ,display-title) (:title . ,display-title)
(:listeners . ,(or listeners 0)) (:listeners . ,(or listeners 0))
(:track-id . ,track-id) (:track-id . ,track-id)
(:favorite-count . ,(or (get-track-favorite-count display-title) 0)) (:favorite-count . ,(or (get-track-favorite-count display-title) 0))
,@(when remaining `((:remaining . ,remaining))))))) ,@(when remaining `((:remaining . ,remaining)))))))
;;; ---- Pipeline Lifecycle ---- ;;; ---- Pipeline Lifecycle ----