pause functionality

This commit is contained in:
2026-05-11 09:21:37 +02:00
parent 788af0f7aa
commit a6318d7a2f
2 changed files with 19 additions and 3 deletions
+12 -3
View File
@@ -57,6 +57,7 @@
(define (check-ao-handle)
(when (eq? ao-handle #f)
(dbg-rktplayer "ao-handle equals #f")
(unless (or (= current-rate 0) (= current-bits 0) (= current-channels 0))
(dbg-rktplayer "current-rate = ~a, current-bits = ~a, current-channels = ~a, ao-handle = ~a"
current-rate current-bits current-channels ao-handle)
@@ -121,10 +122,13 @@
(unless (stream-equal? rate bits-per-sample channels)
(dbg-rktplayer "Stream has changed to ~a ~a ~a" rate bits-per-sample channels)
(unless (eq? ao-handle #f)
(dbg-rktplayer "Waiting for play buffer to reach empty state")
(dbg-rktplayer "Waiting for play buffer to reach empty state, buf-size = ~a" (ao-bufsize-async ao-handle))
(while (> (ao-bufsize-async ao-handle) 0)
(sleep 0.25)
(dbg-rktplayer "buffer size: ~a" (ao-bufsize-async ao-handle))
(sleep 1.0) ;0.25)
)
(dbg-rktplayer "buffer size: ~a" (ao-bufsize-async ao-handle))
(dbg-rktplayer "Empty state reached")
(dbg-rktplayer "Closing ao-handle")
(ao-close ao-handle)
(set! ao-handle #f))
@@ -146,11 +150,13 @@
bytes-per-sample-all-channels
rate)))))
(when (> (buf-seconds-left) buffer-max-seconds)
(dbg-rktplayer "waiting for buffer to get below ~as" buffer-min-seconds)
(while (and (not (eq? ao-handle #f))
(not closing)
(not pause)
(> (buf-seconds-left) buffer-min-seconds))
(sleep 0.25))))
(sleep 0.25))
(dbg-rktplayer "under ~a seconds" buffer-min-seconds)))
(when (not (eq? ao-handle #f))
(ao-play ao-handle current-track-id second duration buffer buf-len ao-type)
@@ -239,6 +245,7 @@
(set! current-track -1)
(set! closing #f)
(dbg-rktplayer "done close-player*")
)
(define (quit-player)
@@ -247,12 +254,14 @@
)
(define (stop-and-clear)
(info-rktplayer "STOP AND CLEAR")
(when pause
(set! stop-in-pause 'stop-request)
(set! pause #f)
(while (not (eq? stop-in-pause 'stop-ack))
(sleep 0.2)))
(set-state! 'stopped)
(info-rktplayer "calling close-player*")
(close-player*)
)
+7
View File
@@ -39,6 +39,13 @@
(define rktplayer-window #f)
(define rktplayer-tray #f)
(define (close-off)
(send rktplayer-tray close)
(send rktplayer-window close)
(exit)
)
(define (run . no-exit)
(let* ((ini (new ini% [file 'rktplayer]))
(context (new wv-context%