diff --git a/ffmpeg-definitions.rkt b/ffmpeg-definitions.rkt index af5e6e9..2f1d257 100644 --- a/ffmpeg-definitions.rkt +++ b/ffmpeg-definitions.rkt @@ -1378,15 +1378,12 @@ (define (call-with-swr-output-buffer max-bytes proc) (early-return ;; Both allocations are native because swr_convert reads/writes C pointers. - ((tmp (malloc max-bytes 'raw) ? (eq? tmp #f) => #f) - (out-planes (malloc _pointer 1 'raw) - ? (eq? out-planes #f) => #f - ~ (free tmp)) + ((tmp (malloc max-bytes 'atomic-interior) ? (eq? tmp #f) => #f) + (out-planes (malloc _pointer 1 'atomic-interior) + ? (eq? out-planes #f) => #f) ;; Interleaved output has one plane; out-planes[0] points to tmp. (do (ptr-set! out-planes _pointer 0 tmp)) (result (proc tmp out-planes))) - (free out-planes) - (free tmp) result) ) @@ -1511,27 +1508,20 @@ ? (<= delay 0) => produced) (max-bytes (av_samples_get_buffer_size #f channels delay FMPG_OUTPUT_FMT 1) ? (<= max-bytes 0) => produced) - (tmp (malloc max-bytes 'raw) + (tmp (malloc max-bytes 'atomic-interior) ? (eq? tmp #f) => -1) - (out-planes (malloc _pointer 1 'raw) - ? (eq? out-planes #f) => -1 - ~ (free tmp)) + (out-planes (malloc _pointer 1 'atomic-interior) + ? (eq? out-planes #f) => -1) (do (ptr-set! out-planes _pointer 0 tmp)) ;; Null input with 0 samples asks swresample to flush delayed output. (out-samples (swr_convert swr-ctx out-planes delay #f 0) - ? (<= out-samples 0) => produced - ~ (begin - (free out-planes) - (free tmp))) + ? (<= out-samples 0) => produced) (used-bytes (av_samples_get_buffer_size #f channels out-samples FMPG_OUTPUT_FMT 1) - ? (< used-bytes 0) => produced - ~ (begin - (free out-planes) - (free tmp))) + ? (< used-bytes 0) => produced) ;; If this is the first output, the buffer belongs to the current next-sample-pos. (do @@ -1542,17 +1532,12 @@ sample-rate*))))) (appended? (append-bytes! dec tmp used-bytes) - ? (not appended?) => -1 - ~ (begin - (free out-planes) - (free tmp))) + ? (not appended?) => -1) ) (ds-last-samples! dec (+ (ds-last-samples dec) out-samples)) (ds-next-sample-pos! dec (+ (ds-next-sample-pos dec) out-samples)) - (free out-planes) - (free tmp) (loop 1)) ) )