0

I am writing an application that uses alsa. I have to kill pulseaudio each time I run my program, otherwise I have a "ressource busy" error message. I use the "default" device in my alsa program.

Here is my asoundrc:

pcm.!default {
type plug
slave.pcm "dmixer"
}

pcm.dmixer  {
type dmix
ipc_key 1024
slave {
    pcm "hw:1,0"
    period_time 0
    period_size 1024
    buffer_size 4096
    rate 44100
}
bindings {
    0 0
    1 1
}
}

ctl.dmixer {
type hw
card 1
}
Brahim
  • 808
  • 1
  • 8
  • 17

2 Answers2

0

Your .asoundrc explicitly bypasses PulseAudio.

The purpose of these definitions is to do software mixing, and to use the second card by default. Both can be done with PulseAudio, so just remove this file.

CL.
  • 173,858
  • 17
  • 217
  • 259
0

To suspend (without killing nor uninstalling) pulseaudio to run a program use the pasuspender application. Like so :

pasuspender -- program args

For example, with aplay :

pasuspender -- aplay music.wav

There is a second potential problem in that pulse audio can override your asoundrc default device. This is a problem on some Linux distributions when you want to run ALSA applications using the default device in the ~/.asoundrc file. For some reason, ALSA still decides to override our default specification (in the ~/.asoundrc file) and use pulse instead.

The reason why this happens on some distributions is that alsa.conf searches many places for configuration files (as well as your ~/.asoundrc file). One of the places it searchs is /etc/alsa/conf.d/. On my system /etc/alsa/conf.d/ has the file 99-pulseaudio-default.conf.example which seems to be processed last and overrides any personal choices for default. The 99-pulseaudio-default.conf.example file sets the following :

pcm.!default pulse

One way to override pulse as your default device (without uninstalling pulseaudio) is to put a load hook into your ~/.asoundrc file. At the top of your ~/.asoundrc file, instruct ALSA to re-load the config file ~/.asoundrc. An example ~/.asoundrc file is as follows :

@hooks [
    {
        func load
        files [
            "~/.asoundrc"
        ]
        errors false
    }
]

pcm.!default {
    type hw
    card "AudioInjector.Pro"
}

ctl.!default {
    type hw
    card "AudioInjector.Pro"
}
Matt
  • 509
  • 2
  • 14