Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Multimedia
  • Search

ALSA default playback issue

Help with creation, editing, or playback of sounds, images, or video. Amarok, audacious, mplayer, grip, cdparanoia and anything else that makes a sound or plays a video.
Post Reply
Advanced search
23 posts • Page 1 of 1
Author
Message
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

ALSA default playback issue

  • Quote

Post by sakey » Wed Jun 19, 2024 6:16 am

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: Select all

$ 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.
Top
pietinger
Moderator
Moderator
Posts: 6609
Joined: Tue Oct 17, 2006 5:11 pm
Location: Bavaria

  • Quote

Post by pietinger » Wed Jun 19, 2024 9:46 am

sakey,

Welcome to Gentoo Forums ! :D

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: Select all

# 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 --> https://wiki.gentoo.org/wiki/User:Pieti ... _at_Gentoo
Top
soundrolf
Apprentice
Apprentice
Posts: 158
Joined: Thu Sep 08, 2016 3:57 pm
Location: Cologne / Germany

  • Quote

Post by soundrolf » Wed Jun 19, 2024 1:15 pm

Please check this:

Code: Select all

cat /proc/asound/cards
On my gentoobox:
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 4101 10/16/2025
CPU: AMD Ryzen 9 5900X 12-Core Processor (24) @ 3800 MHz
GPU: AMD Navi 24 [Radeon RX 6400/6500 XT/6500M] driver: amdgpu
RAM: 80GB crucial DDR4 3200 MHz 2x8GB 2x32GB
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 3:00 pm

Thanks for the answer, Pietinger, but unfortunately it has not worked.

Here is my /proc/asound/cards:

Code: Select all

$ 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
Top
lars_the_bear
Guru
Guru
Posts: 537
Joined: Wed Jun 05, 2024 7:04 am

  • Quote

Post by lars_the_bear » Wed Jun 19, 2024 3:04 pm

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.
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 3:07 pm

Code: Select all

$ 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: Select all

$ 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
Top
lars_the_bear
Guru
Guru
Posts: 537
Joined: Wed Jun 05, 2024 7:04 am

  • Quote

Post by lars_the_bear » Wed Jun 19, 2024 6:38 pm

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: Select all

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.
Top
pietinger
Moderator
Moderator
Posts: 6609
Joined: Tue Oct 17, 2006 5:11 pm
Location: Bavaria

  • Quote

Post by pietinger » Wed Jun 19, 2024 6:52 pm

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 ... :lol: )
https://wiki.gentoo.org/wiki/User:Pietinger --> https://wiki.gentoo.org/wiki/User:Pieti ... _at_Gentoo
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 7:33 pm

Code: Select all

$ 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
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 7:35 pm

My command is usually just

Code: Select all

speaker-test
but variations with -t wav and -c [#] dont work either
Top
pietinger
Moderator
Moderator
Posts: 6609
Joined: Tue Oct 17, 2006 5:11 pm
Location: Bavaria

  • Quote

Post by pietinger » Wed Jun 19, 2024 7:41 pm

sakey wrote:

Code: Select all

$ 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: Select all

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: Select all

$ cat /etc/asound.conf
defaults.pcm.card 0
defaults.pcm.device 0
?
https://wiki.gentoo.org/wiki/User:Pietinger --> https://wiki.gentoo.org/wiki/User:Pieti ... _at_Gentoo
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 7:44 pm

Same error -2. I forgot to say, default device works as root
Top
pietinger
Moderator
Moderator
Posts: 6609
Joined: Tue Oct 17, 2006 5:11 pm
Location: Bavaria

  • Quote

Post by pietinger » Wed Jun 19, 2024 7:48 pm

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: Select all

-rw-r--r--  1 root    root        42 18. Mai 2023  asound.conf
https://wiki.gentoo.org/wiki/User:Pietinger --> https://wiki.gentoo.org/wiki/User:Pieti ... _at_Gentoo
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 7:52 pm

Code: Select all

$ 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?
Top
pietinger
Moderator
Moderator
Posts: 6609
Joined: Tue Oct 17, 2006 5:11 pm
Location: Bavaria

  • Quote

Post by pietinger » Wed Jun 19, 2024 8:05 pm

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 --> https://wiki.gentoo.org/wiki/User:Pieti ... _at_Gentoo
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 8:10 pm

Yes, it is
Top
lars_the_bear
Guru
Guru
Posts: 537
Joined: Wed Jun 05, 2024 7:04 am

  • Quote

Post by lars_the_bear » Wed Jun 19, 2024 9:05 pm

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: Select all

$ 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.
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 9:08 pm

Code: Select all

$ /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
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 9:15 pm

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: Select all

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 +++
Top
Hu
Administrator
Administrator
Posts: 24380
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Wed Jun 19, 2024 9:49 pm

sakey wrote:

Code: Select all

$ 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: Select all

$ 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?
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 10:03 pm

Code: Select all

$ 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.
Top
sakey
n00b
n00b
Posts: 16
Joined: Mon Jun 17, 2024 3:04 pm

  • Quote

Post by sakey » Wed Jun 19, 2024 10:07 pm

Thank you Hu, pietinger, lars_the_bear and soundrolf for helping me. I knew it would be something small I'd missed like that.
:D
Top
ormorph
n00b
n00b
Posts: 27
Joined: Tue Jun 18, 2024 6:51 pm

  • Quote

Post by ormorph » Thu Jun 20, 2024 3:45 am

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.
Top
Post Reply

23 posts • Page 1 of 1

Return to “Multimedia”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy