seeking support
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -596,7 +596,7 @@
|
||||
[(eq? cmd 'process-meta-data) (process-meta-data (car args))]
|
||||
[(eq? cmd 'process-write-data) (process-write-data (car args))]
|
||||
[(eq? cmd 'errno) error-no]
|
||||
|
||||
|
||||
[(eq? cmd 'seek-to-sample) (seek-to-sample (car args))]
|
||||
[(eq? cmd 'file) flac-file]
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
(let* ((buf-size (ao-bufsize-async ao-h))
|
||||
(buf-seconds (exact->inexact (/ buf-size bytes-per-sample-all-channels rate))))
|
||||
(second-printer buf-seconds)
|
||||
(when (> buf-seconds 5)
|
||||
(when (> buf-seconds 30)
|
||||
(letrec ((waiter (λ ()
|
||||
(let ((buf-seconds-left (exact->inexact
|
||||
(/ (ao-bufsize-async ao-h)
|
||||
@@ -66,7 +66,7 @@
|
||||
(if (< buf-seconds-left 2.0)
|
||||
(displayln (format "Seconds in buffer left: ~a" buf-seconds-left))
|
||||
(begin
|
||||
(sleep 0.5)
|
||||
(sleep 1)
|
||||
(second-printer buf-seconds)
|
||||
(waiter)))))
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user