changed malloc 'raw to malloc 'atomic-interior

This commit is contained in:
2026-05-19 15:14:23 +02:00
parent 9f5c4d3efc
commit bfed212346
+9 -24
View File
@@ -1378,15 +1378,12 @@
(define (call-with-swr-output-buffer max-bytes proc) (define (call-with-swr-output-buffer max-bytes proc)
(early-return (early-return
;; Both allocations are native because swr_convert reads/writes C pointers. ;; Both allocations are native because swr_convert reads/writes C pointers.
((tmp (malloc max-bytes 'raw) ? (eq? tmp #f) => #f) ((tmp (malloc max-bytes 'atomic-interior) ? (eq? tmp #f) => #f)
(out-planes (malloc _pointer 1 'raw) (out-planes (malloc _pointer 1 'atomic-interior)
? (eq? out-planes #f) => #f ? (eq? out-planes #f) => #f)
~ (free tmp))
;; Interleaved output has one plane; out-planes[0] points to tmp. ;; Interleaved output has one plane; out-planes[0] points to tmp.
(do (ptr-set! out-planes _pointer 0 tmp)) (do (ptr-set! out-planes _pointer 0 tmp))
(result (proc tmp out-planes))) (result (proc tmp out-planes)))
(free out-planes)
(free tmp)
result) result)
) )
@@ -1511,27 +1508,20 @@
? (<= delay 0) => produced) ? (<= delay 0) => produced)
(max-bytes (av_samples_get_buffer_size #f channels delay FMPG_OUTPUT_FMT 1) (max-bytes (av_samples_get_buffer_size #f channels delay FMPG_OUTPUT_FMT 1)
? (<= max-bytes 0) => produced) ? (<= max-bytes 0) => produced)
(tmp (malloc max-bytes 'raw) (tmp (malloc max-bytes 'atomic-interior)
? (eq? tmp #f) => -1) ? (eq? tmp #f) => -1)
(out-planes (malloc _pointer 1 'raw) (out-planes (malloc _pointer 1 'atomic-interior)
? (eq? out-planes #f) => -1 ? (eq? out-planes #f) => -1)
~ (free tmp))
(do (ptr-set! out-planes _pointer 0 tmp)) (do (ptr-set! out-planes _pointer 0 tmp))
;; Null input with 0 samples asks swresample to flush delayed output. ;; Null input with 0 samples asks swresample to flush delayed output.
(out-samples (swr_convert swr-ctx out-planes delay #f 0) (out-samples (swr_convert swr-ctx out-planes delay #f 0)
? (<= out-samples 0) => produced ? (<= out-samples 0) => produced)
~ (begin
(free out-planes)
(free tmp)))
(used-bytes (av_samples_get_buffer_size #f channels out-samples (used-bytes (av_samples_get_buffer_size #f channels out-samples
FMPG_OUTPUT_FMT 1) FMPG_OUTPUT_FMT 1)
? (< used-bytes 0) => produced ? (< used-bytes 0) => produced)
~ (begin
(free out-planes)
(free tmp)))
;; If this is the first output, the buffer belongs to the current next-sample-pos. ;; If this is the first output, the buffer belongs to the current next-sample-pos.
(do (do
@@ -1542,17 +1532,12 @@
sample-rate*))))) sample-rate*)))))
(appended? (append-bytes! dec tmp used-bytes) (appended? (append-bytes! dec tmp used-bytes)
? (not appended?) => -1 ? (not appended?) => -1)
~ (begin
(free out-planes)
(free tmp)))
) )
(ds-last-samples! dec (+ (ds-last-samples dec) out-samples)) (ds-last-samples! dec (+ (ds-last-samples dec) out-samples))
(ds-next-sample-pos! dec (+ (ds-next-sample-pos dec) (ds-next-sample-pos! dec (+ (ds-next-sample-pos dec)
out-samples)) out-samples))
(free out-planes)
(free tmp)
(loop 1)) (loop 1))
) )
) )