I have a binding to libao, but ao_play seems to block the thread it is working in.
I tried using the new parallel threads of racket, but it somehow still blocks, leaving drracket almost unusable and generating a lot of ticks, because the samples are fed to slow, so I eventually created an extra library (not my preference) that I can feed music samples an that are played in a different thread (using real C pthreads).
Using define-runtime-path is the right starting point. If you use it, you should not need to also use the #:get-lib-dirs argument (and including the current directory at runtime there can be dangerous!).
#lang info
;; ... add to existing content ...
(define install-platform #rx"^x86_64-linux(?:-natipkg)?$") ; or whatever is relevant
(define copy-foreign-libs '("libao/lib/libao-play-async.so.0"))
The copy-foreign-libs directive tells raco setup to install the foreign library into an appropriate place, including graceful handling for system linker directives like $ORIGIN and @loader_path. The so variant of define-runtime-path finds libraries that were potentially installed that way, and also records them as dependencies for the executable builder. Altogether, the architecture prepares you for potentially building the foreign library for additional platforms in the future, at which point you may want to organize your packaging so that only code for the relevant platform has to be installed.
This part is surprising, and it's probably worth a look by someone who is more up-to-date than I am on OS parallelism support. As I first guess, have you checked if the unsafe threads from ffi/unsafe/os-thread have the same problems?
Hi Philip, ffi/unsafe/os-thread does the trick. Tested it today in Windows. It's delicate to implement, but I got it working quite easy. This saves me a custom shared library. Thanks a lot!
Unfortunately this way of working, although better in performance, still is too slow; still generating 'ticks' in the audio. So I had to go back to my little C shared library that processes the audio for me in a operating system thread.
I wonder if it helps running your program in a terminal instead of inside DrRacket?
DrRacket adds helpful debug instructions to your program, so potentially things could run faster in the terminal.
Looks like running it using 'racket' on the terminal instead of inside DrRacket works better. However, it seems to trigger memory corruption problems, which I don't get with DrRacket (maybe related with this)?
I also don't get this problem on Windows.
For me it feels like the 'garbage collector' kicks in every now and then. I.e. regarding the ‘audio clicks’.
Yeah. It is my local gitea repo, didn't think I needed to allow other users. I probably need to do som mail configuration. For now I've activated your account manually.