You are not logged in.

#1 2014-01-28 02:24:03

Zopiac
Member
Registered: 2010-05-12
Posts: 7

[Solved] ALSA with multiple applications

I know this issue has been dealt with many times before, but I can't figure out how to conform those fixes to my use case.

I rebuilt my computer today (old motherboard died). Sound worked fine out of box on the old onboard -- I didn't even have an /etc/asound.conf or ~/.asoundrc -- but on this motherboard I'm encountering the problem with ALSA only allowing one process to output sound.

lspci -vvv output:

00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD] FCH Azalia Controller (rev 01)
	Subsystem: Biostar Microtech Int'l Corp Device 8228
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=slow >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 32, Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 16
	Region 0: Memory at fef40000 (64-bit, non-prefetchable) [size=16K]
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel

I have a 5.1 setup on device 1 that works perfectly fine with whatever audio stream has managed to grab the device. I have looked at breb's asoundrc and changed "card 0" to "card 1" but noticed no change at all, and I don't know enough about the structure of the rc to know if there is anything else to change (although I did also replace all "hw:0" with "hw:1" to no avail). In order to get audio working at all I found a post instructing to put the following in my /etc/asound.conf:

pcm.!default {
	type hw
	card 1
}

ctl.!default {
	type hw           
	card 1
}

I went back to the Arch Wiki and reread the notice: "For ALSA 1.0.9rc2 and higher on analog sound outputs you do not need to setup dmix. Dmix is enabled as default for soundcards which do not support hardware mixing." This is probably what made my last install run without hitches, I am guessing. It then says that if you are still having issues with mixing, to manually add dmix to your asoundrc. So I did that, and my .asoundrc simply looks like:

pcm.dsp {
    type plug
    slave.pcm "dmix"
}

I don't know what to do at this point. The only thought I have is that maybe the dmix only mixes to card 0 (which is my disabled HDMI output) and not card 1 (which is my analog out).

aplay -l output (like I said, I have HDMI output disabled in BIOS. After I post this I can reboot to re-enable it just in case it makes a difference, but by all means if it does then there has to be some sort of issue there with how either dmix works or with how this sound card deals with its mixing or something).

**** List of PLAYBACK Hardware Devices ****
card 1: Generic [HD-Audio Generic], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Also, for instance, when I have mpd running, and try to open a video in VLC, I get this error:

Audio output failed:
The audio device "sysdefault:CARD=Generic" could not be used:
Device or resource busy.

and in mpv (I don't know how much of this is relevant. Probably only the bit after "Selected audio codec..." but here's the whole thing:

The round option must be an integer: 16/9
Error parsing option round (option parameter could not be parsed)
Option vf: Error while parsing expand parameter round (16/9)
Error parsing option vf (option parameter could not be parsed)
/etc/mpv/mpv.conf:24: setting option vf='expand=::::1:16/9:16' failed.
Option af-add: pan has only 2 params, so you can't give more than 2 unnamed params.
Error parsing option af-add (parameter is outside values allowed for option)
/etc/mpv/mpv.conf:58: setting option af-add='pan=6:1:0:.4:0:.6:2:0:1:0:.4:.6:2' failed.
Option af-add: pan has only 2 params, so you can't give more than 2 unnamed params.
Error parsing option af-add (parameter is outside values allowed for option)
/etc/mpv/mpv.conf:63: setting option af-add='pan=2:0.7:0:0:0.7:0.5:0:0:0.5:0.6:0.6:0:0' failed.
Playing: /media/Videos/Other/Samsung_Galaxy_Note_3_4K_Video_sample-XgalnuBlSNE.mp4
Detected file format: QuickTime / MOV (libavformat)
Clip info:
 major_brand: mp42
 minor_version: 0
 compatible_brands: isommp42
 creation_time: 2013-09-30 13:12:57
[stream] Video (+) --vid=1 (*) (h264)
[stream] Audio (+) --aid=1 --alang=und (*) (aac)
Selected video codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [lavc:h264]
Selected audio codec: AAC (Advanced Audio Coding) [lavc:aac]
[ao/alsa] Playback open error: Device or resource busy
[ao] Failed to initialize audio driver 'alsa'
[ao/oss] Can't open audio device /dev/dsp: No such file or directory
[ao] Failed to initialize audio driver 'oss'
Could not open/initialize audio device -> no sound.
Audio: no audio
Audio: no audio
VO: [xv] 3840x2160 => 3840x2160 420p
V: 00:00:05 / 00:00:38 (12%)

Last edited by Zopiac (2014-01-28 16:57:49)

Offline

#2 2014-01-28 02:34:56

Zopiac
Member
Registered: 2010-05-12
Posts: 7

Re: [Solved] ALSA with multiple applications

Apparently I knew less than I thought I did about the HDMI out and device numbers. Here's the aplay -l output after re-enabling HDMI out:

**** List of PLAYBACK Hardware Devices ****
card 1: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Generic [HD-Audio Generic], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Generic [HD-Audio Generic], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I am currently getting nothing out of my speakers (lsof /dev/snd/* shows no processes using the soundcard even though mpd is "playing" (also ncmpcpp shows "Vol: n/a")). Even after I switched my /etc/asound.conf to "card 2" I get nothing. I am wondering if I needed what I already have in there after all. Maybe I added that and then rebooted, switching off the HDMI out as I did so. I'll check...

Edit: Nope. As I understand it, in order to have sound at all I need to have HDMI out disabled in BIOS and asound.conf set with the two clauses with "card 1", and I then encounter the singe process ALSA problem.

Last edited by Zopiac (2014-01-28 02:40:17)

Offline

#3 2014-01-28 12:22:59

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [Solved] ALSA with multiple applications

I would refrain from using type hw in defaults, instead define, if you must, a new pcm and ctl device and then plug to it in defaults. Do not use card numbers as reference, but use the names instead ("Generic" in your case).
  However first read on wiki about modules and setting the default card:
Alsa wiki, then delete your /etc/asound.conf and ~/.asoundrc, ultimately edit /etc/modprobe.d/alsa-base.conf or similar and set your analog card as default one. If that does not help, then create ~/.asoundrc with a new pcm/ctl and defaults.
  Yes, dmix is used by default before hardware layer, you are however addressing hardware directly (type hw) and therefore blocking the device from further streams.

Offline

#4 2014-01-28 13:27:16

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] ALSA with multiple applications

You say you have a 5.1 setup, but were only redefining the PCM named "default" - well, that's meant for *stereo*, not 5.1. This is why I had to go through horrible pain & suffering to learn how to get dmix reliable with 5.1 - as in the config in my sig.

Use one of the many ways to set your default card.

Offline

#5 2014-01-28 16:57:17

Zopiac
Member
Registered: 2010-05-12
Posts: 7

Re: [Solved] ALSA with multiple applications

emeres wrote:

I would refrain from using type hw in defaults, instead define, if you must, a new pcm and ctl device and then plug to it in defaults. Do not use card numbers as reference, but use the names instead ("Generic" in your case).

Well it's in the Arch wiki a few sections down (Alternative Methods) and it's the only thing I was able to do that got any sound.

Thanks for linking that again, though, because apparently my skull's too thick to notice that it says that the setup they give is for a dual card setup  (snd-mia vs snd-hda-intel) and mia is selected as 0. Took out that module's code entirely (yes, I just copied and pasted verbatim like an idiot) and set snd-hda-intel to 0, deleted my /etc/asound.conf, rebooted, and it worked fine.


Nothing to see here folks, just another case of user error that could have been  prevented by reading closer.

Offline

Board footer

Powered by FluxBB