This commit is contained in:
2026-02-23 19:00:25 +01:00
parent 3439bd8fdc
commit 7807a7a209
3 changed files with 13 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
flac-read flac-read
flac-read-meta flac-read-meta
flac-stream-state flac-stream-state
flac-stop
(all-from-out "flac-definitions.rkt") (all-from-out "flac-definitions.rkt")
kinds kinds
last-buffer last-buf-len last-buffer last-buf-len
@@ -79,6 +80,7 @@
(define (flac-read handle) (define (flac-read handle)
(let* ((ffi-handler (flac-handle-ffi-decoder-handler handle)) (let* ((ffi-handler (flac-handle-ffi-decoder-handler handle))
(state (ffi-handler 'state))) (state (ffi-handler 'state)))
(set-flac-handle-stop-reading! handle #f)
(letrec ((reader (lambda (frame-nr) (letrec ((reader (lambda (frame-nr)
(let* ((st (ffi-handler 'state))) (let* ((st (ffi-handler 'state)))
(ffi-handler 'process-single) (ffi-handler 'process-single)
@@ -88,6 +90,8 @@
(format "Now in state ~a (frame-nr = ~a) (int-state = ~a)" (format "Now in state ~a (frame-nr = ~a) (int-state = ~a)"
st frame-nr (ffi-handler 'int-state))) st frame-nr (ffi-handler 'int-state)))
) )
(when (flac-handle-stop-reading handle)
'stopped-reading)
(when (ffi-handler 'has-errno?) (when (ffi-handler 'has-errno?)
(displayln (displayln
(format "Error in stream: ~a" (ffi-handler 'errno))) (format "Error in stream: ~a" (ffi-handler 'errno)))
@@ -124,5 +128,8 @@
(lambda (meta) (process-meta handle meta))) (lambda (meta) (process-meta handle meta)))
(flac-handle-stream-info handle)) (flac-handle-stream-info handle))
#f))) #f)))
(define (flac-stop handle)
(set-flac-handle-stop-reading! handle #t))
); end of module ); end of module

View File

@@ -13,6 +13,8 @@
set-flac-handle-cb-stream-info! set-flac-handle-cb-stream-info!
flac-handle-cb-audio flac-handle-cb-audio
set-flac-handle-cb-audio! set-flac-handle-cb-audio!
flac-handle-stop-reading
set-flac-handle-stop-reading!
flac-handle->string flac-handle->string
@@ -94,6 +96,7 @@
[cb-stream-info #:auto #:mutable] [cb-stream-info #:auto #:mutable]
[cb-audio #:auto #:mutable] [cb-audio #:auto #:mutable]
[stream-info #:auto #:mutable] [stream-info #:auto #:mutable]
[stop-reading #:auto #:mutable]
) )
#:auto-value #f #:auto-value #f
;#:transparent ;#:transparent

View File

@@ -73,9 +73,11 @@
(displayln meta)) (displayln meta))
(define (play) (define (play)
(set! ao-h #f)
(let ((flac-h (flac-open test-file3 flac-meta flac-play))) (let ((flac-h (flac-open test-file3 flac-meta flac-play)))
(flac-read flac-h) (flac-read flac-h)
(ao-close ao-h))) (ao-close ao-h)
(set! ao-h #f)))
;(sleep 1.0) ;(sleep 1.0)
;(play))) ;(play)))