cpal icon indicating copy to clipboard operation
cpal copied to clipboard

cpal 0.12 macOS stream callback isn't executed when winit event loop is running

Open slmjkdbtl opened this issue 5 years ago • 4 comments

In 0.12 the stream callback is only executed if I call thread::sleep() or loop {} after stream.play(), it doesn't get called if I spawn a winit window after. I had no problem with 0.11 when I spawn my own audio thread.

Minimal example (modified from beep example): https://gist.github.com/slmjkdbtl/61aab267bae59907ada0d6296682a40d Currently can't test on other platforms so not sure if I'm just doing it wrong

slmjkdbtl avatar Aug 21 '20 04:08 slmjkdbtl

Your gist isn't accessible to me. FWIW I'm on MacOS and found this issue when searching because I was seeing something similar, but then I realised that because stream.play() is non-blocking, my thread was terminating. I think that's expected though.

curlywurlycraig avatar Dec 12 '20 14:12 curlywurlycraig

@curlywurlycraig Sorry I accidentally deleted the code yesterday. In my case application / windowing main loop is blocking the main thread after I call stream.play(). I remember it's something like

stream.play();
while (true) {} // this blocks and works
stream.play();
start_winit_main_loop(); // this blocks but doesn't work

slmjkdbtl avatar Dec 12 '20 16:12 slmjkdbtl

I'm afraid I can't help then. My issue was just that I wasn't blocking the main thread.

curlywurlycraig avatar Dec 12 '20 17:12 curlywurlycraig

@curlywurlycraig NP. Thanks for replying. (I'm not even sure if this problem still exists, haven't tried in some time and there're updates to both libs)

slmjkdbtl avatar Dec 12 '20 17:12 slmjkdbtl