jbclements / RSound

A cross-platform sound library for DrRacket
http://www.brinckerhoff.org/clements
Other
45 stars 11 forks source link

command line racket terminates before audio is finished playing #23

Closed benoid closed 7 years ago

benoid commented 7 years ago

When executing rsound programs with racket on the command line, the programs have a tendency to terminate before the audio is finished playing. The issue does not occur in drracket, on the command line repl, or when there is another thread keeping the program open .

I've noticed some of the example files include (sleep 60) to keep the program from exiting right away, but this is not a sufficient workaround for circumstances where audio is being looped or generated indefinitely.

Is this functionality intended? Is there a way to fix the issue so that racket will not terminate until all pstream queues are empty?

jbclements commented 7 years ago

One way to do it would be to use a semaphore. Each time you queue a sound, increment the semaphore, and use pstream-queue-callback to decrement the semaphore when the sound is scheduled to end. Then, just end your program with a semahpore-wait.

It might also just be easier to end the program with a (read-line), so that the program waits until the user hits return.

benoid commented 7 years ago

Thanks!