You are not logged in.

#1 2015-08-08 22:55:30

kadaver
Member
Registered: 2015-08-08
Posts: 3

ALSA default card only outputs sound if targeted directly

After setting up Arch and ALSA

aplay /some/sound/file.wav
speaker-test

only output sound if I run them like this

aplay -D default:CARD=PCH /some/sound/file.wav
speaker-test -D default:CARD=PCH

If I try running them without -D i get the following errors:

[root@dlaptop ~]# LANG=C aplay /usr/share/sounds/alsa/Front_Center.wav 
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
aplay: main:722: audio open error: No such file or directory
[root@dlaptop ~]# LANG=C speaker-test 

speaker-test 1.0.29

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
Playback open error: -2,No such file or directory

aplay -l:

**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC283 Analog [ALC283 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

aplay -L:

null
    Discard all samples (playback) or generate zero samples (capture)
hdmi:CARD=HDMI,DEV=0
    HDA Intel HDMI, HDMI 0
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=1
    HDA Intel HDMI, HDMI 1
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=2
    HDA Intel HDMI, HDMI 2
    HDMI Audio Output
default:CARD=PCH
    HDA Intel PCH, ALC283 Analog
    Default Audio Device
sysdefault:CARD=PCH
    HDA Intel PCH, ALC283 Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC283 Analog
    Front speakers
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, ALC283 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC283 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC283 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC283 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC283 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC283 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers

lsmod | grep snd:

snd_hda_codec_hdmi     53248  1
snd_soc_sst_acpi       16384  0
snd_hda_codec_realtek    77824  1
snd_hda_codec_generic    69632  1 snd_hda_codec_realtek
snd_soc_rt5640         86016  0
snd_soc_rl6231         16384  1 snd_soc_rt5640
snd_soc_core          159744  1 snd_soc_rt5640
snd_compress           20480  1 snd_soc_core
snd_pcm_dmaengine      16384  1 snd_soc_core
regmap_i2c             16384  1 snd_soc_rt5640
snd_hda_intel          28672  0
snd_hda_controller     28672  1 snd_hda_intel
snd_hda_codec          98304  5 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_intel,snd_hda_controller
snd_hda_core           28672  5 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_codec,snd_hda_controller
snd_hwdep              16384  1 snd_hda_codec
snd_pcm                90112  7 snd_soc_rt5640,snd_soc_core,snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel,snd_hda_controller,snd_pcm_dmaengine
snd_timer              28672  1 snd_pcm
snd                    69632  10 snd_hda_codec_realtek,snd_soc_core,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_hda_codec_generic,snd_hda_codec,snd_hda_intel,snd_compress
soundcore              16384  1 snd
i2c_core               49152  12 drm,i915,i2c_i801,snd_soc_rt5640,i2c_hid,i2c_designware_platform,regmap_i2c,drm_kms_helper,i2c_algo_bit,nvidia,v4l2_common,videodev

I'm not running any other sound related programs. The Kernel is the default Linux Kernel of the Arch ISO.

Thanks in advance!

Offline

#2 2015-08-08 23:10:44

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,648
Website

Re: ALSA default card only outputs sound if targeted directly

The CARD=PCH is the difference.  Without that, asla is trying to use the HDMI output.

Set card 1 as your default in either ~/.asoundrc or /etc/asound.conf as described in the wiki.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2015-08-08 23:44:29

kadaver
Member
Registered: 2015-08-08
Posts: 3

Re: ALSA default card only outputs sound if targeted directly

I set the PCH card as default in /etc/asound.conf, but now I'm getting a new error:
/etc/asound.conf:

pcm.!default{
	type hw
	card PCH
}
ctl.!default{
	type hw
	card PCH
}

Errors:

[root@dlaptop ~]# LANG=C aplay /usr/share/sounds/alsa/Front_Center.wav 
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
aplay: set_params:1239: Channels count non available
[root@dlaptop ~]# LANG=C speaker-test 

speaker-test 1.0.29

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
Setting of hwparams failed: Invalid argument

I tried both commands with the -c option and different channel counts between 1 and 8 but all threw the same error.

Offline

#4 2015-08-09 00:38:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,648
Website

Re: ALSA default card only outputs sound if targeted directly

I'm far from an expert on configuring alsa, but I have a very similar setup to yours (where HDMI was the default primary output and both outputs were Intel).  I also had some trouble trying to use "card PCM" or other variations in ~/asoundrc.  I went with /etc/asound.conf with the following:

defaults.pcm.card 1
defaults.pcm.device 0
defaults.ctl.card 1

You may want to give this a shot.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2015-08-09 01:03:36

Gusar
Member
Registered: 2009-08-25
Posts: 3,605

Re: ALSA default card only outputs sound if targeted directly

Rather than messing with asound.conf, which is basically guaranteed to screw things up, use the index option for the kernel modules. To set HDMI as the second device, this will do (as root):

echo "options snd-hda-intel index=1" > /etc/modprobe.d/alsa.conf

Explanation: Now you have HDMI at index 0, making it the default. The above modprobe config will give it index 1 instead, and so the other device will get index 0.

Offline

#6 2015-08-09 01:15:04

kadaver
Member
Registered: 2015-08-08
Posts: 3

Re: ALSA default card only outputs sound if targeted directly

@ Gusar

Thanks a lot, that fixed it!

Offline

#7 2015-08-09 01:15:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,648
Website

Re: ALSA default card only outputs sound if targeted directly

Both devices use snd-hda-intel, don't they?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2015-08-09 01:17:44

Gusar
Member
Registered: 2009-08-25
Posts: 3,605

Re: ALSA default card only outputs sound if targeted directly

Trilby wrote:

Both devices use snd-hda-intel, don't they?

Yes. My method relies on HDMI always being initialized first, so the option will always apply to it. Which might not sound robust, but it hasn't failed me yet smile

Last edited by Gusar (2015-08-09 01:18:26)

Offline

#9 2015-08-09 01:19:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,648
Website

Re: ALSA default card only outputs sound if targeted directly

Ah, thanks - I'll have to give this a shot on my system.  I've always been confused about how to configure things well when multiple devices use the same driver module.

Last edited by Trilby (2015-08-09 01:20:14)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB