much work on the player and hunting for a bug, which first seemed to be in ffmpeg-decoder, but eventually was found in a race condition in audio-placed-player.rkt and an allocation problem in libao-async-ffi-racket.rkt

This commit is contained in:
2026-05-15 22:11:25 +02:00
parent 3c18e75cf6
commit c9a91bf2be
11 changed files with 534 additions and 340 deletions
+5 -1
View File
@@ -128,7 +128,9 @@
(ffi-handler 'read
(lambda (info pos buffer size)
(if (eq? info 'done)
(set-ffmpeg-handle-stop! handle #t)
(begin
(dbg-sound "ffmpeg read: ~a ~a ~a" info pos size)
(set-ffmpeg-handle-stop! handle #t))
(give-audio handle info pos buffer size)))
(lambda (pcm-pos rate channels sample-bits sample-bytes pcm-length)
(handle-format handle pcm-pos rate channels sample-bits sample-bytes pcm-length)))
@@ -138,6 +140,7 @@
(ffi-handler 'delete)))
(define (ffmpeg-seek handle percentage)
(dbg-sound "ffmpeg-seek ~a" percentage)
(let ((fmt (ffmpeg-handle-format handle)))
(let ((total-samples (hash-ref fmt 'total-samples 0)))
(unless (or
@@ -149,6 +152,7 @@
(set-ffmpeg-handle-seek! handle sample))))))
(define (ffmpeg-stop handle)
(dbg-sound "ffmpeg-stop called")
(set-ffmpeg-handle-stop! handle #t)
(while (ffmpeg-handle-reading handle)
(sleep 0.01)))