1

I've come across a problem that has me completely stumped. First; some system info

Linux quasar-nixos-tr 4.19.87 #1-NixOS SMP Sun Dec 1 08:17:47 UTC 2019 x86_64 GNU/Linux

Now; I'm playing with a sound generating/music library called csound and I'm seeing a strange issue.

I'm using a layer over csound via Haskell; the library is called csound-expression and it merely generates a csound file based on some Haskell code, and then runs it via csound.

As per my understanding; csound then routes the audio to Alsa, which on my system, attempts to route it via PulseAudio's default device.

Now, something strange happens on my system.

  1. After a fresh boot, if I run the csound related code, I hear sound. But, once I've stopped that piece of code from running, no other application seems to be able to connect to PA anymore. Checking with systemctl --user status pulseaudio.service pulsaudio.socket reveals that the service is dead and it has exhausted the max. no. of tries to start up.
  2. After a fresh boot; if I run some other application, say pavucontrol; I can now connect to the PA service but my haskell csound code can no longer connect. It instead, exits with:

    λ> dac . osc $ 200 
    0dBFS level = 32768.0
    --Csound version 6.13 (double samples) Jan  1 1970
    [commit: none]
    libsndfile-1.0.28
    UnifiedCSD:  tmp.csd
    STARTING FILE
    Creating options
    Creating orchestra
    closing tag
    Creating score
    rtaudio: ALSA module enabled
    rtmidi: ALSA Raw MIDI module enabled
    Elapsed time at end of orchestra compile: real: 0.001s, CPU: 0.001s
    sorting score ...
        ... done
    Elapsed time at end of score sort: real: 0.001s, CPU: 0.001s
    displays suppressed
    0dBFS level = 1.0
    orch now loaded
    audio buffered in 256 sample-frame blocks
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
     *** Cannot open device 'default' for audio input: Connection refused
    Failed to initialise real time audio input
    inactive allocs returned to freespace
    end of score.          overall amps:  0.00000
           overall samples out of range:        0
    1 errors in performance
    Elapsed time at end of performance: real: 0.169s, CPU: 0.004s
    

In case 1 (above); I see something interesting in the logs but I'm limited by my understanding of how PA works, how Alsa works and how both of these work together:

Dec 16 09:28:16 quasar-nixos-tr systemd[1708]: Starting Sound Service...
Dec 16 09:28:16 quasar-nixos-tr pulseaudio[2382]: E: [pulseaudio] socket-server.c: bind(): Address already in use
Dec 16 09:28:16 quasar-nixos-tr pulseaudio[2382]: E: [pulseaudio] module.c: Failed to load module "module-esound-protocol-unix" (argument: ""): initialization failed.
Dec 16 09:28:16 quasar-nixos-tr pulseaudio[2382]: E: [pulseaudio] main.c: D-Bus name org.PulseAudio1 already taken.
Dec 16 09:28:16 quasar-nixos-tr systemd[1708]: pulseaudio.service: Main process exited, code=exited, status=1/FAILURE
Dec 16 09:28:16 quasar-nixos-tr systemd[1708]: pulseaudio.service: Failed with result 'exit-code'.
Dec 16 09:28:16 quasar-nixos-tr systemd[1708]: Failed to start Sound Service.
Dec 16 09:28:16 quasar-nixos-tr systemd[1708]: pulseaudio.service: Service RestartSec=500ms expired, scheduling restart.
Dec 16 09:28:16 quasar-nixos-tr systemd[1708]: pulseaudio.service: Scheduled restart job, restart counter is at 4.
Dec 16 09:28:16 quasar-nixos-tr systemd[1708]: Stopped Sound Service.
Dec 16 09:28:16 quasar-nixos-tr systemd[1708]: Starting Sound Service...
Dec 16 09:28:17 quasar-nixos-tr pulseaudio[2390]: E: [pulseaudio] socket-server.c: bind(): Address already in use
Dec 16 09:28:17 quasar-nixos-tr pulseaudio[2390]: E: [pulseaudio] module.c: Failed to load module "module-esound-protocol-unix" (argument: ""): initialization failed.
Dec 16 09:28:17 quasar-nixos-tr pulseaudio[2390]: E: [pulseaudio] main.c: D-Bus name org.PulseAudio1 already taken.
Dec 16 09:28:17 quasar-nixos-tr systemd[1708]: pulseaudio.service: Main process exited, code=exited, status=1/FAILURE
Dec 16 09:28:17 quasar-nixos-tr systemd[1708]: pulseaudio.service: Failed with result 'exit-code'.
Dec 16 09:28:17 quasar-nixos-tr systemd[1708]: Failed to start Sound Service.
Dec 16 09:28:17 quasar-nixos-tr systemd[1708]: pulseaudio.service: Service RestartSec=500ms expired, scheduling restart.
Dec 16 09:28:17 quasar-nixos-tr systemd[1708]: pulseaudio.service: Scheduled restart job, restart counter is at 5.
Dec 16 09:28:17 quasar-nixos-tr systemd[1708]: Stopped Sound Service.
Dec 16 09:28:17 quasar-nixos-tr systemd[1708]: pulseaudio.service: Start request repeated too quickly.
Dec 16 09:28:17 quasar-nixos-tr systemd[1708]: pulseaudio.service: Failed with result 'exit-code'.

The user here is in the audio and sound groups and I'm using NixOS; which likely has no bearing on this issue.

Can anyone help with what could be going on here?


Also note that; in case 2; alsamixer lists all devices correctly.

1 Answer 1

0

I've finally found the issue; I've described it here in case anyone else stumbles across this in future.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .