You are not logged in.

#1 2014-08-21 01:42:34

Kaonashi
Member
Registered: 2012-12-11
Posts: 26

Sound working with pulse audio, but not with alsa

Hello, i have finally decided to fully convert to arch on my main machine, installed fine and everything. after installing, speaker-test was returning this:

ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave

after reading around google looking for fixes, i tried messing with my .asoundrc file and setting it to this:

pcm.!default {
        type hw
        card 1
}

ctl.!default {
        type hw
        card 0
}

And now speaker-test returns this:

[orion@arch ~]$ speaker-test

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Channels count (1) not available for playbacks: Invalid argument

The wierd part is, pulseaudio works fine. I can use CMUS, play a steam game (native) and talk on skype at the same time. but alsa doesnt work for some reason, which is a problem because i am trying to run Counter-Strike Global Offensive through wine. (which is a game where sound is very important). Any ideas?

output from cat /proc/asound/cards :

[orion@arch ~]$ sudo cat /proc/asound/cards 
[sudo] password for orion: 
 0 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xf7080000 irq 17
 1 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf7210000 irq 45

i think the nvidia card might have something to do with this but i am unsure.

thanks for your help in advance, guys.

Offline

#2 2014-08-21 01:59:11

headkase
Member
Registered: 2011-12-06
Posts: 1,873

Re: Sound working with pulse audio, but not with alsa

Have you installed "pulseaudio-alsa"?  That is required to use ALSA in a Pulse environment.  If you haven't installed it, install it, reboot, and try again.

Offline

#3 2014-08-21 02:13:50

Kaonashi
Member
Registered: 2012-12-11
Posts: 26

Re: Sound working with pulse audio, but not with alsa

headkase wrote:

Have you installed "pulseaudio-alsa"?  That is required to use ALSA in a Pulse environment.  If you haven't installed it, install it, reboot, and try again.

Yes i have, and i reinstalled it just in case, and rebooted. However i stil get the same errors.

Offline

#4 2014-08-21 03:00:33

headkase
Member
Registered: 2011-12-06
Posts: 1,873

Re: Sound working with pulse audio, but not with alsa

Rename/delete your .asoundrc file so you start without ALSA configs to confuse Pulse, and install pavucontrol and use that to see if manually choosing your audio output helps.  Beyond that there isn't much I can suggest - perhaps someone else will chime in.

Offline

#5 2014-08-21 13:58:59

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

Re: Sound working with pulse audio, but not with alsa

emeres wrote:

Your speaker-tests use card 0 device 0 by default and since your HDMI probably does not have a device 0, but highly likely does have device 3, it cannot be opened. For further explanation take a look here, recent thread with probably the same problem.

It is easier to quote myself. Look here and here. So this ~/.asoundrc should make the HDMI work properly with alsa only, pulseaudio will probably not respect it and pulseaudio-alsa will interfere with it:

defaults.pcm.device 3

The number comes from 'aplay -l' output listing devices for HDMI card, I assume you have a device 3. Testing with 'speaker-test -t wav -c 2 -D plughw:NVidia,3' should also work, unless the device is busy.

You should set the PCH as default, a more universal approach, which is described in the links provided and their further references. Again the issue for alsa is, that device 0 is not present on many HDMI cards. While you are at it, try also this, but make sure that nothing uses sound first with 'fuser -v /dev/snd/*' first, then run speaker-test:

defaults.pcm.device -1

I wonder if it finds the first device available. For all of this PA should be killed and pulseaudio-alsa not present, since it overwrites pcm.default.

Just to make sure that others get the message, the alsa configuration you provided is very restrictive and not recommended. It is way better to use defaults.pcm node as described on alsa wiki

Offline

#6 2014-08-22 00:53:04

Kaonashi
Member
Registered: 2012-12-11
Posts: 26

Re: Sound working with pulse audio, but not with alsa

emeres wrote:
emeres wrote:

Your speaker-tests use card 0 device 0 by default and since your HDMI probably does not have a device 0, but highly likely does have device 3, it cannot be opened. For further explanation take a look here, recent thread with probably the same problem.

It is easier to quote myself. Look here and here. So this ~/.asoundrc should make the HDMI work properly with alsa only, pulseaudio will probably not respect it and pulseaudio-alsa will interfere with it:

defaults.pcm.device 3

The number comes from 'aplay -l' output listing devices for HDMI card, I assume you have a device 3. Testing with 'speaker-test -t wav -c 2 -D plughw:NVidia,3' should also work, unless the device is busy.

You should set the PCH as default, a more universal approach, which is described in the links provided and their further references. Again the issue for alsa is, that device 0 is not present on many HDMI cards. While you are at it, try also this, but make sure that nothing uses sound first with 'fuser -v /dev/snd/*' first, then run speaker-test:

defaults.pcm.device -1

I wonder if it finds the first device available. For all of this PA should be killed and pulseaudio-alsa not present, since it overwrites pcm.default.

Just to make sure that others get the message, the alsa configuration you provided is very restrictive and not recommended. It is way better to use defaults.pcm node as described on alsa wiki

but i dont think im trying to use the hdmi device, i am trying t use the realtek one unless i am wrong, then i feel really stupid. ill look into this fix tho, i dont think im trying to use that card

Offline

#7 2014-08-22 01:01:03

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

Re: Sound working with pulse audio, but not with alsa

Kaonashi wrote:

but i dont think im trying to use the hdmi device, i am trying t use the realtek one unless i am wrong, then i feel really stupid. ill look into this fix tho, i dont think im trying to use that card

No, not with alsa. Post 'aplay -l'.

Last edited by emeres (2014-08-22 01:04:32)

Offline

#8 2014-08-22 03:53:12

Kaonashi
Member
Registered: 2012-12-11
Posts: 26

Re: Sound working with pulse audio, but not with alsa

orion@arch> aplay -l                                                                 ~
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC1150 Analog [ALC1150 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 1: ALC1150 Digital [ALC1150 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
orion@arch>                                                                          ~

my card is the ALC1150

Offline

#9 2014-08-22 04:01:31

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

Re: Sound working with pulse audio, but not with alsa

I explained it pretty well I would argue, reread my previous post. The situation is exactly as I described it, at least for alsa. Again I recommend setting PCH as default using modprobe options, see the links I provided to the other threads.

Offline

#10 2014-08-23 00:48:48

Kaonashi
Member
Registered: 2012-12-11
Posts: 26

Re: Sound working with pulse audio, but not with alsa

emeres wrote:

I explained it pretty well I would argue, reread my previous post. The situation is exactly as I described it, at least for alsa. Again I recommend setting PCH as default using modprobe options, see the links I provided to the other threads.

after some messing around with aplay and my asoundrc and looking at the posts you linked, i did aplay -L and got this output:

orion@arch> aplay -L                                                                 ~
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault:CARD=PCH
    HDA Intel PCH, ALC1150 Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC1150 Analog
    Front speakers
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, ALC1150 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC1150 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC1150 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC1150 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC1150 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC1150 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
    HDA Intel PCH, ALC1150 Digital
    IEC958 (S/PDIF) Digital Audio Output
orion@arch>                                                                          ~

and found that using "speaker-test -c2" now works. but when ever i have pulse audio running it still throws me

orion@arch> speaker-test -c2                                                         ~

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Playback open error: -16,Device or resource busy

pulseaudio-alsa is installed.

[1] orion@arch> sudo pacman -S pulseaudio-alsa                                       ~
[sudo] password for orion: 
warning: pulseaudio-alsa-2-3 is up to date -- reinstalling

any thoughts?

Last edited by Kaonashi (2014-08-23 00:49:19)

Offline

#11 2014-08-23 01:00:17

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

Re: Sound working with pulse audio, but not with alsa

Pulseaudio runs on top of alsa, ergo it uses alsa. So when it runs the device is occupied, this is expected behaviour*. Do you want to run pulseaudio in parallel to alsa? This might add latency and may have some other issues, but is possible. Read this part of the wiki.

Edit: So you do not have an ~/.asoundrc file? I have seen it. Try running

speaker-test -c 2 -t wav -D plug:"dmix:{CARD PCH DEV 0}"
#this should work without pa
speaker-test -c 2 -t wav -D plug:default
#this should work with pa and pulseaudio-alsa, unless overwritten by ~/.asoundrc

Edit2: You probably still have the PCH as secondary card, why are you unwilling to change that? The link I posted now, should work, but when the default sound card is compatible with the default alsa setup.

To recap, I would set PCH as default first using modprobe options, reboot. Disable ~/.asoundrc, run speaker-test. Change the configuration of pa to use dmix and dsnoop, then both should work, alsa directly and pulseaudio.

Should you want to send alsa through pulseaudio, then something else is interfering, since pulseaudio-alsa should provide that bridge. Is module-suspend-on-idle loaded? If so, disable and unload it.

Edit3: *I guess I was too quick here. Speaker-test should send sound through pulseaudio back to alsa, but this would mean it tries to access hardware directly or does not respect /etc/asound.conf.

Last edited by emeres (2014-08-23 01:30:04)

Offline

#12 2014-08-24 23:18:26

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

Re: Sound working with pulse audio, but not with alsa

There is a program in qastools called qasconfig. It is capable of showing the current alsa configuration. You may want to look at it. I would still set PCH as default. How is PA started?

Offline

#13 2014-08-25 00:05:19

Kaonashi
Member
Registered: 2012-12-11
Posts: 26

Re: Sound working with pulse audio, but not with alsa

emeres wrote:

There is a program in qastools called qasconfig. It is capable of showing the current alsa configuration. You may want to look at it. I would still set PCH as default. How is PA started?

how do i set pch as default? i thought i already did

Offline

#14 2014-08-25 00:14:41

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

Re: Sound working with pulse audio, but not with alsa

Sysdefault could be set independently*. Through modprobe options. Does 'aplay -l' list PCH as card 0 or 'cat /proc/asound/card*/id' list the PCH first? If so, then you are right, PCH is default and the ~/.asoundrc with defaults.pcm.device 3 is not only unnecessary, but could be also troublesome.
So with PA running, pulseaudio-alsa installed and PCH as default with no further configuration 'speaker-test -c 2 -t wav -D plug:default' should go through PA.

Edit: * pcm.sysdefault refers to cards.pcm.default .

Last edited by emeres (2014-08-25 00:17:09)

Offline

#15 2014-08-25 01:02:38

Kaonashi
Member
Registered: 2012-12-11
Posts: 26

Re: Sound working with pulse audio, but not with alsa

orion@arch> aplay -l                                                                                              ~/Downloads/qastools
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC1150 Analog [ALC1150 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC1150 Digital [ALC1150 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
orion@arch>                                                                                                       ~/Downloads/qastools

yep, pch is 0.

still getting this when i try speaker-test:

orion@arch> speaker-test -c 2 -t wav -D plug:default                                                              ~/Downloads/qastools

speaker-test 1.0.28

Playback device is plug:default
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Playback open error: -16,Device or resource busy
[1] orion@arch>                                              

Offline

#16 2014-08-25 08:53:33

cirrus
Member
From: Glasgow Scotland
Registered: 2012-08-24
Posts: 322
Website

Re: Sound working with pulse audio, but not with alsa

Just thought it might be relevant = on 4 of my arch installs alsa stopped working yesterday ( bare alsa ) i took the cowardly way out and just installed pulseaudio.


Registered Linux User #544546
   Time you enjoyed wasting was not wasted. --John Lennon.

Offline

#17 2014-08-25 09:57:40

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

Re: Sound working with pulse audio, but not with alsa

cirrus wrote:

Just thought it might be relevant = on 4 of my arch installs alsa stopped working yesterday ( bare alsa ) i took the cowardly way out and just installed pulseaudio.

Pulseaudio runs on top of alsa, in most cases at least, so this does not really make sense. The order of the sound cards might have changed, maybe due an update.

@Kaonashi When you run speaker-test run also 'fuser -v /dev/snd/*'.

emeres wrote:

Is module-suspend-on-idle loaded? If so, disable and unload it.

Where did your hdmi/nvidia go? It is not listed at all and it was before.

Edit: I thought you wanted to keep the nvidia enabled.

Last edited by emeres (2014-08-25 10:07:17)

Offline

#18 2014-08-25 13:19:08

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

Re: Sound working with pulse audio, but not with alsa

Kaonashi wrote:

Playback open error: -16,Device or resource busy

See what's opened the device:

fuser -fv /dev/snd/*

Regardless, set pulseaudio to use dmix, so that pulseaudio does not monopolize the audio device.

Also, if you're using more than 2 speakers, then use a PROPER DMIX SETUP, as shown in my sig.

Offline

#19 2014-08-25 13:23:09

cirrus
Member
From: Glasgow Scotland
Registered: 2012-08-24
Posts: 322
Website

Re: Sound working with pulse audio, but not with alsa

@emress im aware of the relationship between pulse audio and alsa, note i said ( bare alsa ) which means i had only alsa installed in conjunction with an /etc/modprobe.d/alsa-base.conf file. Strange i had issue on four out of five x86_64 arch installs which leads me to believe it could be an AUR installed pkg which caused it.


Registered Linux User #544546
   Time you enjoyed wasting was not wasted. --John Lennon.

Offline

#20 2014-08-25 14:03:27

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

Re: Sound working with pulse audio, but not with alsa

cirrus wrote:

Just thought it might be relevant = on 4 of my arch installs alsa stopped working yesterday ( bare alsa ) i took the cowardly way out and just installed pulseaudio.

If alsa stops working and pulseaudio runs on top of it, how does that make sense? If you meant something else, why write it in this way? I would check the order of cards, you probably have and hdmi, which probably is the default one now.

@brebs
Did you measure any significant latency with PA using dmix? Also, since you are here, do you know of a method to dump the current alsa configuration in text form?

Offline

#21 2014-08-25 14:58:45

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

Re: Sound working with pulse audio, but not with alsa

For configuration, ask people to run alsa-info.sh

Regarding latency - I barely use pulseaudio (only compiled 32-bit, for skype, linked into dmix), so I don't know/care. I haven't come across any good evidence that latency is a factor, FWIW.

I reckon that what's far more important is all the *other* things that can go wrong, e.g. using a wrong bdl_pos_adj or position_fix parameter with the snd-hda-intel module. And of course finding the optimum period_size and buffer_size in ~/.asoundrc, which can vary between sound hardware. This takes lots of experimentation.

Offline

#22 2014-08-25 15:12:15

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

Re: Sound working with pulse audio, but not with alsa

 Alsa-info.sh only reads/cats configuration files, that does not really help, since it does not respect overwrites. I mean something like qasconfig that would parse the whole current final configuration, but preferably in text form. Maybe some hacking will help.
 As for dmix, adding channels to runtime arguments and defaults.pcm.dmix.channels, should solve the issue.

defaults.pcm.dmix.channels 8

pcm.!dmix {
	@args [ CARD DEV SUBDEV FORMAT RATE CHANNELS ]
	@args.CARD {
		type string
		default {
			@func refer
			name defaults.pcm.dmix.card
		}
	}
	@args.DEV {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.device
		}
	}
	@args.SUBDEV {
		type integer
		default 0
	}
	@args.FORMAT {
		type string
		default {
			@func refer
			name defaults.pcm.dmix.format
		}
	}
	@args.RATE {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.rate
		}
	}
	@args.CHANNELS {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.channels
		}
	}
	type dmix
	ipc_key {
		@func refer
		name defaults.pcm.ipc_key
	}
	ipc_gid {
		@func refer
		name defaults.pcm.ipc_gid
	}
	ipc_perm {
		@func refer
		name defaults.pcm.ipc_perm
	}
	slave {
		pcm {
			type hw
			card $CARD
			device $DEV
			subdevice $SUBDEV
		}
		format $FORMAT
		rate $RATE
		channels $CHANNELS
		period_size {
			@func refer
			name {
				@func concat
				strings [
					"defaults.dmix."
					{
						@func card_driver
						card $CARD
					}
					".period_size"
				]
			}
			default 1024
		}		
		period_time {
			@func refer
			name {
				@func concat
				strings [
					"defaults.dmix."
					{
						@func card_driver
						card $CARD
					}
					".period_time"
				]
			}
			default -1
		}		
		periods {
			@func refer
			name {
				@func concat
				strings [
					"defaults.dmix."
					{
						@func card_driver
						card $CARD
					}
					".periods"
				]
			}
			default 16
		}
	}
	hint {
		show {
			@func refer
			name defaults.namehint.extended
		}
		description "Direct sample mixing device"
		device $DEV
	}
}

The default value probably should be set to 2, but it would be beneficiary if it could be detected automatically.

Offline

#23 2014-08-25 17:16:21

cirrus
Member
From: Glasgow Scotland
Registered: 2012-08-24
Posts: 322
Website

Re: Sound working with pulse audio, but not with alsa

emeres wrote:

If alsa stops working and pulseaudio runs on top of it, how does that make sense? If you meant something else, why write it in this way? I would check the order of cards, you probably have and hdmi, which probably is the default one now.

Emeres,  Not sure if being pedantic,  it turns out it was a BIOS setting hmm  My 4  Arch installs on internal SATA HDD's gave alsa errors, (only browser had audio out) one Arch install on a USB stick on same computer with very same configuration (alsa-base.conf) worked fine , that confused me. I will attempt to be more specific in future.


Registered Linux User #544546
   Time you enjoyed wasting was not wasted. --John Lennon.

Offline

#24 2014-08-26 03:00:45

Kaonashi
Member
Registered: 2012-12-11
Posts: 26

Re: Sound working with pulse audio, but not with alsa

emeres wrote:

 Alsa-info.sh only reads/cats configuration files, that does not really help, since it does not respect overwrites. I mean something like qasconfig that would parse the whole current final configuration, but preferably in text form. Maybe some hacking will help.
 As for dmix, adding channels to runtime arguments and defaults.pcm.dmix.channels, should solve the issue.

defaults.pcm.dmix.channels 8

pcm.!dmix {
	@args [ CARD DEV SUBDEV FORMAT RATE CHANNELS ]
	@args.CARD {
		type string
		default {
			@func refer
			name defaults.pcm.dmix.card
		}
	}
	@args.DEV {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.device
		}
	}
	@args.SUBDEV {
		type integer
		default 0
	}
	@args.FORMAT {
		type string
		default {
			@func refer
			name defaults.pcm.dmix.format
		}
	}
	@args.RATE {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.rate
		}
	}
	@args.CHANNELS {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.channels
		}
	}
	type dmix
	ipc_key {
		@func refer
		name defaults.pcm.ipc_key
	}
	ipc_gid {
		@func refer
		name defaults.pcm.ipc_gid
	}
	ipc_perm {
		@func refer
		name defaults.pcm.ipc_perm
	}
	slave {
		pcm {
			type hw
			card $CARD
			device $DEV
			subdevice $SUBDEV
		}
		format $FORMAT
		rate $RATE
		channels $CHANNELS
		period_size {
			@func refer
			name {
				@func concat
				strings [
					"defaults.dmix."
					{
						@func card_driver
						card $CARD
					}
					".period_size"
				]
			}
			default 1024
		}		
		period_time {
			@func refer
			name {
				@func concat
				strings [
					"defaults.dmix."
					{
						@func card_driver
						card $CARD
					}
					".period_time"
				]
			}
			default -1
		}		
		periods {
			@func refer
			name {
				@func concat
				strings [
					"defaults.dmix."
					{
						@func card_driver
						card $CARD
					}
					".periods"
				]
			}
			default 16
		}
	}
	hint {
		show {
			@func refer
			name defaults.namehint.extended
		}
		description "Direct sample mixing device"
		device $DEV
	}
}

The default value probably should be set to 2, but it would be beneficiary if it could be detected automatically.


this solved my issue it seems. thanks to all of you who halped, this was giving me a headache

Offline

#25 2014-08-26 05:23:58

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 17,265

Re: Sound working with pulse audio, but not with alsa

Excellent.  (I was, of course, of no help)  But please, edit the first post and mark the thread as solved if it is indeed solved.  Thanks


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB