Skip to content
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

Entire system sound mutes while debugging #872

Open
ValonPrime opened this issue Mar 29, 2024 · 3 comments
Open

Entire system sound mutes while debugging #872

ValonPrime opened this issue Mar 29, 2024 · 3 comments

Comments

@ValonPrime
Copy link

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

std::thread::sleep(std::time::Duration::from_millis(1000));

I dont expect that my programs audio continues (because execution is suspended). But at least other programs should be able to continue to output audio.

  • current master-branch
  • Ubuntu 23.10
    • The "Volume Levels" under Settings>Sound>"Volume Levels" still show that Firefox is "Outputing" Sound.
  • pactl info | grep "Server Name": Server Name: PulseAudio (on PipeWire 0.3.79)
@j-n-f
Copy link

j-n-f commented Aug 2, 2024

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:

  1. What device are you using and how is it configured? (the output of beep.rs should tell you this)
  2. Can you use that same device with something other than cpal and get the behaviour you want? (i.e. isolate issue to library or backend; e.g. if you're using PA/PipeWire, find another program that talks to those and try to set a breakpoint in it)

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.

@ValonPrime
Copy link
Author

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 ... 😭

@sullyj3
Copy link

sullyj3 commented Aug 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants