New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Both blocking and non-blocking examples use 100% CPU #124
Comments
Hmmm I'm not sure. So this only happens for streams that are either duplex or input (i.e. trying to stream data from some input device)? Do you get the same issues when running the sine or saw examples? Or are they fine? What platform are you on? Do you know what the default input device is on your system? Could you perhaps post all of the device info etc that prints to console at the start of the non_blocking.rs example (i.e. here)? And maybe also for the Sorry about all the questions - hopefully we can get to the bottom of it 👍 |
Ok, here we go.
Not at all. I'd like to do some audio stuff in rust, so it would be good if we could get to the bottom of this. Perhaps I should try some examples in C too... Edit: I did manage to get reading from an input stream down to about 4% by adding a sleep function. So I can continue working on my little experiment, but it's not idea |
This is caused by the busy loop checking the stream state. In practice, the stream state doesn't need to be checked as fast as possible. The examples can be modified to run more efficiently, as you found out with the sleep function 😄 FYFI, in asynchronous mode, PortAudio will periodically execute the callback function at the right time, calculating the interval from the given sample rate and buffer state while the stream is active. |
What does that mean? |
@flwrd: FYFI == "For your further information", I believe |
Ok, this doesn't go anywhere. |
When I run the two streaming programs from the examples directory, they take 100% of the CPU. When I limit it to just reading the input, the same happens, and it seems the main loop just gets 0 bytes and keeps looping like mad until finally a full buffer arrives. Is that a problem in rust-portaudio or in the lower portaudio library?
The text was updated successfully, but these errors were encountered: