Open ValonPrime opened 7 months ago
It's surprising that the audio stops when you pause on a sleep call, but this is because every single thread in your program gets paused whenever a breakpoint is hit.
If you're using GDB, you may want to look at Non-Stop Mode.
I'm using ASIO on Windows and I don't have the issue where audio from other programs is blocked.
To troubleshoot this further you could look at a few different things:
beep.rs
should tell you this)If you are in fact using PipeWire, it would be helpful to know how PipeWire is expected to behave when you block in the callback.
My system sound (as well as the beep) continues when breaking while Non-Stop Mode is on.
The output of beep.rs:
Output device: default
Default output config: SupportedStreamConfig { channels: 2, sample_rate: SampleRate(44100), buffer_size: Range { min: 1, max: 4194304 }, sample_format: F32 }
Process finished with exit code 0
I also tried this with separate devices (external interface, BT headphones and frontpanel audio). All yield the same behavior.
About trying different libs: Using "Soloud" with the following code worked as expected. The mp3 stopped playing but my system (Firefox) continued to output sound.
use soloud::*;
fn main() {
let sl = Soloud::default().unwrap();
let mut wav = Wav::default();
wav.load_mem(include_bytes!("../creepypasta.mp3")).unwrap();
sl.play(&wav);
while sl.voice_count() > 0 {
// Breakpoint here
std::thread::sleep(std::time::Duration::from_millis(100));
}
}
I dont have nearly enough knowledge to pinpoint the source of the Problem (CPAL or PipeWire or ...). But I think using Non-Stop mode is just a workaround. Especially because I dont know how to enable it in Rustrover ... ðŸ˜
It seems like cpal doesn't suppport pulseaudio. From the readme:
Currently, supported hosts include:
Linux (via ALSA or JACK)
edit: ref #259
I've run into the same thing, I think when you connect to ALSA, it commandeers the whole audio system and prevents other programs from using it.
This seems to have been fixed in Pipewire at some point. I was able to reproduce this bug back in August but now I'm on Pipewire 1.2.5 and other programs continue to play sound when debugging.
~It's been fixed for me as well with pipewire 1.0.8 I suspect (it wasn't working with 1.0.7).~
Turns out it has stopped working again despite having pipewire 1.0.8.
Hello everyone,
my entire system sounds mutes when debugging while a sound plays.
using gdb to break in the Beep-Example at line 123 causes all other programs (Firefox...) to mute / no longer output any audio:
rust-gdb target
b beep.rs:123
r
https://github.com/RustAudio/cpal/blob/2ec761d30b35dbbacfecb41a2f5985781a7d52d1/examples/beep.rs#L123I dont expect that my programs audio continues (because execution is suspended). But at least other programs should be able to continue to output audio.
pactl info | grep "Server Name"
:Server Name: PulseAudio (on PipeWire 0.3.79)