seeking support

This commit is contained in:
2026-04-14 15:07:12 +02:00
parent ea9432cc37
commit fdba3ad8f8
3 changed files with 17 additions and 3 deletions

View File

@@ -10,6 +10,7 @@
flac-read-meta
flac-stream-state
flac-stop
flac-seek
(all-from-out "flac-definitions.rkt")
kinds
last-buffer last-buf-len
@@ -132,6 +133,19 @@
(flac-handle-stream-info handle))
#f)))
(define (flac-seek handle percentage)
(dbg-sound "seek to percentage ~a" percentage)
(let ((ffi-handler (flac-handle-ffi-decoder-handler handle)))
(let ((total-samples (flac-total-samples handle)))
(unless (eq? total-samples #f)
(let ((sample (inexact->exact (round (* (exact->inexact (/ percentage 100.0)) total-samples)))))
(ffi-handler 'seek-to-sample sample))
)
)
)
)
(define (flac-stop handle)
(let ((ct (current-milliseconds)))
(dbg-sound "requesting stop at: ~a" ct)