Make sure that when only reading metadata of the flac stream, and issuing flac-stop, the flac decoder is really finished and deleted.

This commit is contained in:
2026-06-24 14:30:35 +02:00
parent 9748882ee0
commit 492c538db1
+11 -4
View File
@@ -171,14 +171,21 @@
(define (flac-stop handle)
(let ((ct (current-milliseconds)))
(dbg-sound "requesting stop at: ~a" ct)
(set-flac-handle-stop-reading! handle #t)
(while (flac-handle-reading handle)
(sleep 0.01))
(if (flac-handle-reading handle)
(begin ; in reading
(set-flac-handle-stop-reading! handle #t)
(while (flac-handle-reading handle)
(sleep 0.01)))
(begin ; never starte reading, or reading finished
(dbg-sound "not reading flac, need to finish flac")
(let ((ffi-handler (flac-handle-ffi-decoder-handler handle)))
(unless (eq? ffi-handler #f)
(ffi-handle 'delete))))
)
(let ((ct* (current-milliseconds)))
(dbg-sound "stop came back at: ~a" ct*)
(dbg-sound "flac-stop took: ~a ms" (- ct* ct)))
)
)
); end of module