From d4f19639bd4c7094a8e146f27427b8ebe033a499 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 25 Apr 2021 14:24:07 -0400 Subject: audio: Fix looping of streaming sources. This was completely broken before. --- chickadee/audio.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chickadee/audio.scm b/chickadee/audio.scm index 61d033b..86b52b2 100644 --- a/chickadee/audio.scm +++ b/chickadee/audio.scm @@ -377,7 +377,9 @@ data." (unless (source-playing? source) (openal:source-play (source-openal-source source)) (when (streaming-source? source) - (add-streaming-source (current-sound-system) source)))) + (add-streaming-source (current-sound-system) source)) + (openal:set-source-looping! (source-openal-source source) + (and (static-source? source) (source-loop? source))))) (define (source-pause source) "Pause playback of SOURCE." @@ -423,8 +425,7 @@ sources." (define (set-source-loop! source loop?) "Configure whether or not SOURCE should loop the audio stream." - (%set-source-pitch! source loop?) - (openal:set-source-looping! (source-openal-source source) loop?)) + (%set-source-loop! source loop?)) (define (set-source-pitch! source pitch) "Set the pitch multiplier for SOURCE to PITCH." @@ -544,7 +545,7 @@ listener. Otherwise, the position is in absolute coordinates." (openal:set-buffer-data! buffer chunk length format sample-rate) (openal:source-queue-buffer (source-openal-source source) buffer) (when (source-stopped? source) - (source-play source)) + (openal:source-play (source-openal-source source))) #t)) ((source-loop? source) ;; Reset back to the beginning and try again. -- cgit v1.2.3