[Home]

Summary:ASTERISK-13633: Chan Alsa reports that the audio device is busy when using Pulseaudio
Reporter:Thomas Kilbride (obnauticus)Labels:
Date Opened:2009-02-23 17:20:43.000-0600Date Closed:2011-06-07 14:07:54
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_alsa
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:I have recently installed pulseaudio on my system with alsa, aplay -Dpulse [a wave file] seems to work through pulseaudio, however asterisk doesn't want to function with it, instead it consistently says the card is in use.

Whenever I try to load the module chan_alsa Asterisk CLI gives me the following error:

asterisk*CLI> module load chan_alsa.so
[2009-02-23 15:07:10] ERROR[8569]: chan_alsa.c:368 alsa_card_init: snd_pcm_open failed: Device or resource busy
[2009-02-23 15:07:10] ERROR[8569]: chan_alsa.c:368 alsa_card_init: snd_pcm_open failed: Device or resource busy
[2009-02-23 15:07:10] ERROR[8569]: chan_alsa.c:486 soundcard_init: Problem opening alsa I/O devices

Here are the users who are currently accessing my sound devices:

(~)-(root@asterisk)--> fuser /dev/snd/* /dev/dsp /dev/snd
/dev/snd/controlC0:   3250
/dev/snd/pcmC0D0c:    3250m
/dev/snd/pcmC0D0p:    3250m
(~)-(root@asterisk)--> ps aux | grep 3250
root      3250  0.6  1.7   8108  2812 pts/1    S+   00:04   6:03 pulseaudio

My overall goal and reasoning for installing pulseaudio was to have mpg123-alsa be able write to the output on my sound card (speaker out) while I am listening to the audio from the radio's output on asterisk in real time (i.e. line-in on the sound card). The best solution I found which was an Abstraction layer which controlled access to the audio devices, this would make it so I could have access read from the card's input, and have mpg123-alsa write to the output. However, Asterisk keeps saying the device is busy.

****** ADDITIONAL INFORMATION ******

---conf: `~/.asoundrc`:---



# Part I directly from ALSA Dmix Wiki

pcm.paul { # paul is my name, you can use your name, just make sure you use it below too
   type dmix
   ipc_key 1024
   slave {
       pcm "hw:0,0"
       period_time 0
       period_size 1024
       buffer_size 8192
      #format "S32_LE"
      #periods 128
       rate 44100
   }
}

pcm.dsp0 {
   type plug
   slave.pcm "paul"
}

# This following device can fool some applications into using pulseaudio
pcm.dsp1 {
   type plug
   slave.pcm "pulse"
}

ctl.mixer0 {
   type hw
   card 0
}

# Part II directly from Pulseaudio Wiki

pcm.pulse {
   type pulse
}

ctl.pulse {
   type pulse
}

# Optional, set defaults

pcm.!default {
   type pulse
}

ctl.!default {
   type pulse
}



---conf: `/etc/pulse/default.pa`---



#!/usr/bin/pulseaudio -nF

#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.


### Load audio drivers statically
#load-module module-alsa-sink device=plughw:0,0
#load-module module-alsa-source device=plughw:0,0
#load-module module-native-protocol-tcp listen=127.0.0.1
#load-module module-alsa-sink device=hw:0
#load-module module-alsa-source device=hw:0
#load-module module-waveout
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

.ifexists /usr/lib/pulse-0.9/modules/module-hal-detect.so

### Automatically load driver modules depending on the hardware available
load-module module-hal-detect

.else

### Alternatively use the static hardware detection module (for systems that
### lack HAL support
load-module module-detect

.endif

### Load audio drivers automatically on access
#add-autoload-sink output module-oss device="/dev/dsp" sink_name=output source_name=input
#add-autoload-source input module-oss device="/dev/dsp" sink_name=output source_name=input
#add-autoload-sink output module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#add-autoload-source input module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#add-autoload-sink output module-alsa-sink sink_name=output
#add-autoload-source input module-alsa-source source_name=input

.ifexists /usr/lib/pulse-0.9/modules/module-esound-protocol-unix.so

### Load esound protocol
load-module module-esound-protocol-unix

.endif

### Load native protocol
load-module module-native-protocol-unix

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
#load-module module-zeroconf-publish

### Load the RTP reciever module (also configured via paprefs, see above)
#load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 description="RTP Multicast Sink"
#load-module module-rtp-send source=rtp.monitor

### Automatically restore the volume of playback streams
load-module module-volume-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make some devices default
#set-default-sink output
#set-default-source input

.nofail

### Load something to the sample cache
load-sample x11-bell /usr/share/sounds/gtk-events/activate.wav
#load-sample-dir-lazy /usr/share/sounds/*.wav

### Load X11 bell module
load-module module-x11-bell sample=x11-bell

### Publish connection data in the X11 root window
# load-module module-x11-publish

### Load additional modules from GConf settings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
load-module module-gconf



---general information from pulseaudio:---



main.c: This program is not intended to be run as root (unless --system is specified).
Welcome to PulseAudio! Use "help" for usage information.
>>> info
Memory blocks currently allocated: 0, size: 0 B.
Memory blocks allocated during the whole lifetime: 0, size: 0 B.
Memory blocks imported from other processes: 0, size: 0 B.
Memory blocks exported to other processes: 0, size: 0 B.
Total sample cache size: 0 B.
Default sample spec: s16le 2ch 44100Hz
Default sink name: (null)
Default source name: (null)
Memory blocks of type POOL: 0 allocated/0 accumulated.
Memory blocks of type POOL_EXTERNAL: 0 allocated/0 accumulated.
Memory blocks of type APPENDED: 0 allocated/0 accumulated.
Memory blocks of type USER: 0 allocated/0 accumulated.
Memory blocks of type FIXED: 0 allocated/0 accumulated.
Memory blocks of type IMPORTED: 0 allocated/0 accumulated.
1 module(s) loaded.
   index: 0
       name: <module-cli>
       argument: <exit_on_eof=1>
       used: -1
       auto unload: no
0 sink(s) available.
0 source(s) available.
1 client(s) logged in.
   index: 0
       name: <STDIN/STDOUT client>
       driver: <pulsecore/cli.c>
       owner module: <0>
0 sink input(s) available.
0 source outputs(s) available.
0 cache entries available.
0 autoload entries available.


Comments:By: Jason Parker (jparker) 2009-06-25 13:51:26

Per pulseaudio folks, the issue appears to be with you not using "default" as the sound device in /etc/asterisk/alsa.conf.  If you are using "default", then it is likely an issue in your alsa setup.

If you get past the error on snd_pcm_open, then we can look at it further.