View previous topic :: View next topic |
Author |
Message |
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 6:16 am Post subject: ALSA default playback issue |
|
|
When I try to run anything like mpv, speaker-test, aplay they don't work unless I specify the card and device. For example:
Code: |
$ speaker-test
speaker-test 1.2.11
Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Playback open error: -2,No such file or directory
|
I have searched for a long time but none of the solutions seem to work.
Any help is appreciated. |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5093 Location: Bavaria
|
Posted: Wed Jun 19, 2024 9:46 am Post subject: |
|
|
sakey,
Welcome to Gentoo Forums !
I am using also a pure ALSA installation (no pulseaudio; no pipewire) and use my monitor speakers as output ... and must use a /etc/asound.conf
These steps I did with my installation:
Code: | # emerge -pv alsa-utils
# rc-update add alsasound boot
! Unmute channels with:
# alsamixer
! Be sure to unmute all (also SPDIF): It must be OO and not MM
! I tested ALSA with:
# speaker-test -t wav -c 2
-> Failed
# aplay -l
->
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: PCH [HDA Intel PCH], Gerät 0: ALC897 Analog [ALC897 Analog]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 0: PCH [HDA Intel PCH], Gerät 1: ALC897 Digital [ALC897 Digital]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 0: PCH [HDA Intel PCH], Gerät 3: HDMI 0 [Acer ET430K]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 0: PCH [HDA Intel PCH], Gerät 7: HDMI 1 [HDMI 1]
Sub-Geräte: 1/1
[...]
<-
! Configure default device: my monitor (HDMI 0) ->
# nano -w /etc/asound.conf
=>
defaults.pcm.card 0
defaults.pcm.device 3
<=
# speaker-test -t wav -c 2
-> now ok |
_________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
soundrolf Tux's lil' helper
Joined: 08 Sep 2016 Posts: 131 Location: Cologne / Germany
|
Posted: Wed Jun 19, 2024 1:15 pm Post subject: |
|
|
Please check this:
Code: | cat /proc/asound/cards |
On my gentoobox:
Quote: |
0 [HDMI ]: HDA-Intel - HDA ATI HDMI
HDA ATI HDMI at 0xfcf40000 irq 63
1 [Generic ]: HDA-Intel - HD-Audio Generic
HD-Audio Generic at 0xfcc00000 irq 64
|
_________________ Regards
soundrolf
MOBO: ASUS PRIME B550M-K BIOS 3607 03/18/2024
CPU: AMD Ryzen 7 5800X 8-Core Processor (16) @ 3800 MHz
GPU: NVIDIA GK208B [GeForce GT 710] driver: nvidia v: 470.256.02
RAM: 80GB crucial DDR4 3200 MHz 2x8GB 2x32GB |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 3:00 pm Post subject: |
|
|
Thanks for the answer, Pietinger, but unfortunately it has not worked.
Here is my /proc/asound/cards:
Code: |
$ cat /proc/asound/cards
0 [PCH ]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xf7410000 irq 40
1 [NVidia ]: HDA-Intel - HDA NVidia
HDA NVidia at 0xf7080000 irq 17
|
|
|
Back to top |
|
|
lars_the_bear Guru
Joined: 05 Jun 2024 Posts: 517
|
Posted: Wed Jun 19, 2024 3:04 pm Post subject: |
|
|
I confess that this is something that has always baffled me a little. I also have an ALSA-only system, with (usually) only the built-in audio device. I find that 'aplay', 'speaker-test', etc., work fine, and play through my built-in speakers. I haven't created asound.conf.
But in the past I've found that I have had to create this file.
Still, if you're getting a 'file not found' error message from 'speaker-test', that kind-of suggests that the 'default' device is actually not installed, doesn't it?
As well as `cat /proc/asound/cards`, It would be good to see `aplay --list-devices` and `aplay --list-pcms`. Still, when I've had this problem in the past, I've generally just created asound.conf, rather than trying to track down the cause.
BR, Lars. |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 3:07 pm Post subject: |
|
|
Code: |
$ aplay --list-devices
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
|
Code: |
$ aplay --list-pcms
null
Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=PCH
HDA Intel PCH, ALC662 rev1 Analog
Default Audio Device
front:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev1 Analog
Front output / input
surround21:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev1 Analog
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev1 Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev1 Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev1 Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev1 Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev1 Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=NVidia,DEV=0
HDA NVidia, HDMI 0
HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
HDA NVidia, HDMI 1
HDMI Audio Output
hdmi:CARD=NVidia,DEV=2
HDA NVidia, HDMI 2
HDMI Audio Output
hdmi:CARD=NVidia,DEV=3
HDA NVidia, HDMI 3
HDMI Audio Output
|
|
|
Back to top |
|
|
lars_the_bear Guru
Joined: 05 Jun 2024 Posts: 517
|
Posted: Wed Jun 19, 2024 6:38 pm Post subject: |
|
|
There's no 'default' entry in --list-pcms. I think that's likely to be a matter of configuration.
I can't reproduce this on Gentoo, but I see the same problem on my Raspberry Pi boards. The default contents of /etc/asound.conf are:
Code: |
pcm.!default {
type hw
card 0
device 0
}
ctl.!default {
type hw
card 0
}
|
and this doesn't give me a default device. If I use the settings described by @pietinger -- removing all the other stuff -- then I do get a default. In fact, I can just keep this file empty in my case, because I only have the built-in sound hardware (only one card, at the ALSA level).
I think that /etc/asound.conf is read by users of the ALSA libraries, not by anything in the ALSA kernel modules. So I think it's plausible (sadly) that different sound utilities will interpret these settings in different ways.
I can't begin to understand all the different configuration files that ALSA uses, or how they're structured. I use ALSA exclusively, but I can't say that I've ever understood it. I never rely on defaults -- I always specify the exact device.
BR, Lars. |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5093 Location: Bavaria
|
Posted: Wed Jun 19, 2024 6:52 pm Post subject: |
|
|
sakey wrote: | Thanks for the answer, Pietinger, but unfortunately it has not worked. |
What exactly has not worked ? Your test with "speaker-test" ?
You said you get a sound if you test it with "speaker-test" AND specifying card and device ... so, what was your exact command ?
... And what you have set now in /etc/asound.conf ?
(Have you really used the filename /etc/asound.conf ? I ask, because when I had the first time a problem (before many years) and read some articles in the internet, there was always the file named "/etc/asound.rc" ... which is WRONG for Gentoo ... ) _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 7:33 pm Post subject: |
|
|
Code: |
$ cat /etc/asound.conf
defaults.pcm.!card PCH
defaults.pcm.device 1
defaults.ctl.!card PCH
|
My card has a name so that is why I am using !card instead of card |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 7:35 pm Post subject: |
|
|
My command is usually just but variations with -t wav and -c [#] dont work either |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5093 Location: Bavaria
|
Posted: Wed Jun 19, 2024 7:41 pm Post subject: |
|
|
sakey wrote: | Code: |
$ cat /etc/asound.conf
defaults.pcm.!card PCH
defaults.pcm.device 1
defaults.ctl.!card PCH
|
My card has a name so that is why I am using !card instead of card |
Every card has a number ... it is 0 for your PCH ... and this:
Code: | card 0: PCH [HDA Intel PCH], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog] |
tells me the device number is also 0 and not 1 ... what happens if you use:
Code: | $ cat /etc/asound.conf
defaults.pcm.card 0
defaults.pcm.device 0 |
? _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 7:44 pm Post subject: |
|
|
Same error -2. I forgot to say, default device works as root |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5093 Location: Bavaria
|
Posted: Wed Jun 19, 2024 7:48 pm Post subject: |
|
|
sakey wrote: | Same error -2. I forgot to say, default device works as root |
what are the permissions on this file? It should be readable by everyone:
Code: | -rw-r--r-- 1 root root 42 18. Mai 2023 asound.conf |
_________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 7:52 pm Post subject: |
|
|
Code: |
$ ls asound.conf -l
.rw-r--r-- 62 sakey 19 Jun 20:42 asound.conf
|
It is owned by my user account. Does root have to own it? |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5093 Location: Bavaria
|
Posted: Wed Jun 19, 2024 8:05 pm Post subject: |
|
|
sakey wrote: | It is owned by my user account. Does root have to own it? |
I dont think so ... BUT ... is your user in the audio group ? _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 8:10 pm Post subject: |
|
|
Yes, it is |
|
Back to top |
|
|
lars_the_bear Guru
Joined: 05 Jun 2024 Posts: 517
|
Posted: Wed Jun 19, 2024 9:05 pm Post subject: |
|
|
sakey wrote: | Same error -2. I forgot to say, default device works as root |
In that case, I'd guess that either one or more of the config files, or one or more of the devices in /dev/snd, are not readable for your user.
It's usual to have something like this:
Code: |
$ ls -l /dev/snd/
drwxr-xr-x 2 root root 60 May 14 09:17 by-path
crw-rw---- 1 root audio 116, 0 May 14 09:17 controlC0
crw-rw---- 1 root audio 116, 16 May 14 09:17 pcmC0D0p
crw-rw---- 1 root audio 116, 1 May 14 09:17 seq
crw-rw---- 1 root audio 116, 33 May 14 09:17 timer
|
with group 'audio' and mode 664. So long as the user is a member of the 'audio' group, that should all be fine.
If the problem isn't just permissions, I think I'd 'strace speaker-test' and try to see exactly what files and devices are being read, and what the results are. But this kind of output isn't particularly easy to interpret.
BR, Lars. |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 9:08 pm Post subject: |
|
|
Code: |
$ /bin/ls -l
total 0
crw-rw---- 1 root audio 116, 7 Jun 19 15:51 controlC0
crw-rw---- 1 root audio 116, 13 Jun 19 15:51 controlC1
crw-rw---- 1 root audio 116, 5 Jun 19 15:51 hwC0D2
crw-rw---- 1 root audio 116, 6 Jun 19 15:51 hwC0D3
crw-rw---- 1 root audio 116, 12 Jun 19 15:51 hwC1D0
crw-rw---- 1 root audio 116, 3 Jun 19 15:51 pcmC0D0c
crw-rw---- 1 root audio 116, 2 Jun 19 20:42 pcmC0D0p
crw-rw---- 1 root audio 116, 4 Jun 19 15:51 pcmC0D2c
crw-rw---- 1 root audio 116, 8 Jun 19 15:51 pcmC1D3p
crw-rw---- 1 root audio 116, 9 Jun 19 15:51 pcmC1D7p
crw-rw---- 1 root audio 116, 10 Jun 19 15:51 pcmC1D8p
crw-rw---- 1 root audio 116, 11 Jun 19 15:51 pcmC1D9p
crw-rw---- 1 root audio 116, 33 Jun 19 15:51 timer
|
I will try strace but I seem to be missing some files that you have |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 9:15 pm Post subject: |
|
|
I won't send the whole output unless you want me to but it seems that it is trying to open ControlC3 which doesn't exist
Code: |
open("/dev/snd/controlC3", O_RDWR|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/dev/snd/controlC3", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/dev/aloadC3", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/dev/snd/controlC3", O_RDWR|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
writev(1, [{iov_base="Playback open error: -2,No such "..., iov_len=49}, {iov_base="\n", iov_len=1}], 2Playback open error: -2,No such file or directory
) = 50
exit_group(1) = ?
+++ exited with 1 +++
|
|
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22619
|
Posted: Wed Jun 19, 2024 9:49 pm Post subject: |
|
|
sakey wrote: | Code: | $ ls asound.conf -l
.rw-r--r-- 62 sakey 19 Jun 20:42 asound.conf | It is owned by my user account. Does root have to own it? | This looks weird to me. If the file is owned by your user, then it should be in your home directory, and be named .asoundrc or in your ~/.config/alsa/ directory and named asoundrc. If the file is in /etc, it should be owned by root and be named asound.conf. lars_the_bear wrote: | It's usual to have something like this: Code: | $ ls -l /dev/snd/
drwxr-xr-x 2 root root 60 May 14 09:17 by-path
crw-rw---- 1 root audio 116, 0 May 14 09:17 controlC0
crw-rw---- 1 root audio 116, 16 May 14 09:17 pcmC0D0p
crw-rw---- 1 root audio 116, 1 May 14 09:17 seq
crw-rw---- 1 root audio 116, 33 May 14 09:17 timer | with group 'audio' and mode 664. | Mode 664 or mode 660? You show 660, and that is what I have on my system. You wrote 664.
sakey: when run as your user, what is the output of namei -l /etc/asound.conf ~/.asoundrc ~/.config/alsa/asoundrc ; for f in /etc/asound.conf ~/.asoundrc ~/.config/alsa/asoundrc; do echo "$f"; cat -n "$f"; done? |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 10:03 pm Post subject: |
|
|
Code: |
$ namei -l /etc/asound.conf ~/.asoundrc ~/.config/alsa/asoundrc ; for f in /etc/asound.conf ~/.asoundrc ~/.config/alsa/asoundrc; do echo "$f"; cat -n "$f"; done
f: /etc/asound.conf
drwxr-xr-x root root /
drwxr-xr-x root root etc
-rw-r--r-- sakey sakey asound.conf
f: /home/sakey/.asoundrc
drwxr-xr-x root root /
drwxr-xr-x root root home
drwx------ sakey sakey sakey
.asoundrc - No such file or directory
f: /home/sakey/.config/alsa/asoundrc
drwxr-xr-x root root /
drwxr-xr-x root root home
drwx------ sakey sakey sakey
drwxr-xr-x sakey sakey .config
drwxr-xr-x sakey sakey alsa
-rw-r--r-- sakey sakey asoundrc
/etc/asound.conf
1 defaults.pcm.card 0
2 defaults.pcm.device 0
3 defaults.ctl.card 0
/home/sakey/.asoundrc
cat: /home/sakey/.asoundrc: No such file or directory
/home/sakey/.config/alsa/asoundrc
1 pcm.!default {
2 type hw
3 card 3
4 device 1
5
|
I didn't even know I had a ~/.config/alsa/asoundrc. I will try deleting that and see what happens; it is probably the problem. |
|
Back to top |
|
|
sakey n00b
Joined: 17 Jun 2024 Posts: 16
|
Posted: Wed Jun 19, 2024 10:07 pm Post subject: |
|
|
Thank you Hu, pietinger, lars_the_bear and soundrolf for helping me. I knew it would be something small I'd missed like that.
|
|
Back to top |
|
|
ormorph n00b
Joined: 18 Jun 2024 Posts: 27
|
Posted: Thu Jun 20, 2024 3:45 am Post subject: |
|
|
If you're interested, I posted the asoundconf ebuild to create ~/.asoundrc. I don’t know if it works or not, since I switched to Pipewire. You just need to run asoundconf-gtk. This is just a collection of ebuilds, this ebuild needs to be placed in your local overlay. |
|
Back to top |
|
|
|