cpal icon indicating copy to clipboard operation
cpal copied to clipboard

`cpal` blocking window rendering of `ggez`

Open arminveres opened this issue 2 years ago • 2 comments

I am currently working on an algorithm visualization tool, asking to this for a university project, hence why the repo is private at the moment. My goal is to output a tone between a certain range when sorting a bar.

I integrated the bleep example into my logic and while it works for very low frame rates, say 1-5 fps, it blocks the drawing of the window otherwise. I am assuming this is caused by std::thread::sleep.

Is there an other non blocking way to output a tone, as if I remove the sleep duration, no tone is output at all. i am calling run mutliple times in each frame.

If necessary, I can make the repository public.

If relevant: OS: Fedora Workstation 38

  • ggez 0.9.0-rc0
  • cpal 0.15.2

arminveres avatar May 12 '23 12:05 arminveres

Did you try running the tone generating code in another thread than the gui code?

dheijl avatar May 12 '23 13:05 dheijl

I haven't managed to put it into another thread yet, although I would prefer to keep it single threaded for the moment, if possible. EDIT: I.e., I would like for it to be synchronous, whereas with separate threads I am sure that it would not be. I made an implementation with message passing, which works, but it's completely asynchronous. I'd really appreciate, if someone could point me in the right direction.

arminveres avatar May 12 '23 13:05 arminveres