:: Re: [DNG] Sound recently stopped
Top Page
Delete this message
Reply to this message
Author: Steve Litt
Date:  
To: dng
Subject: Re: [DNG] Sound recently stopped
Rob via Dng said on Fri, 15 Dec 2023 01:10:47 +0000


[snip long description of alsa-only system not making sound]

>Run alsamixer in terminal and hit F6 key
>This should list cards available on your system. On mine I have HDA
>Nvidia and HD Audio generic. If you have more than 1 card listed arrow
>down and hit enter to select one of the cards. Esc key exits
>alsamixer. Run speaker-test. If no sound run alsamixer again and
>select next card. Repeat speaker-test. Rob


The preceding is incomplete. Not an insult, just a comment that will
save those who read this from frustration. I'm pretty sure Rob didn't
mean that hitting Enter on something in alsamixer would effect the
speaker-test program, but a casual reading of Rob's technique could
seem like like that, so I use aplay -l
instead of alsamixer. This way I don't need to remember to exit
alsamixer, because having alsamixer running will screw up your
diagnostic tests.

Also, Rob's process doesn't isolate out your ~/.asoundrc , which could
absolutely be causing the problem. So the following is a much more
complete description of the procedure...

* aplay -l in order to list the devices.

* Pick the correct device out of the list. Note the device's card
number and device number, both of which are numbers, probably single
digits. If you don't know which is the correct device, you'll need to
repeat the rest of this procedure for every device. Please be aware
that the card number and device number might change following reboots.

* speaker-test -D hw:mycardnum,mydevicenum , where mycardnum is the
numeric card number listed by aplay -l, and mydevicenum is the device
number listed by same. If this sends sound out your speakers, skip to
MAKE .asoundrc

* If speaker-test tells you something like "Channels count (1) not
  available for playbacks: Invalid argument", you need to add a -c
  option whose argument is the number of channels. My setup is 2
  speaker stereo, so for me it's -c2. The   following is the command I
  use:
  speaker-test -D hw:2,0 -c2
  I use this command because my sound card is a 2 channel USB sound
  card whose card number is 2 and device number is 0.
    NOTE: The command in this step is independent of your ~/.asoundrc,
    so you can more easily rule things out.


* If the proper speaker-test command errors with
"Playback open error: -16,Device or resource busy", some software is
hogging ALSA and must be shut down. Perform the following command to
determine which programs to terminate:
lsof /dev/snd/*
Kill all the listed programs and the proper speaker-test command
should work. Please note that both alsamixer and speaker-test can hog
ALSA, so if you have alsamixer running or have another speaker-test
running, your new speaker-test command throws the "Device or resource
busy" error.

* You might need to restart ALSA after the preceding step. How to do
this varies with distro. Try sudo alsa force-reload . If this doesn't
work, ask authorities on your distro.

* Once the proper speaker-test command outputs the proper thing to the
screen, namely a repeated naming of a speaker such as "front left"
and "front right", speaker-test is working, which means your ALSA
sound system is working. If you still hear no sound, raise the volume
on the proper card,device in alsamixer, and try again. If this still
doesn't work, check your speakers, your speaker connections, and any
intermediate amplifiers or preamplifiers.

MAKING .asoundrc

OK, speaker-test has proven that you have a working audio card. That's
part of the battle. However, many programs won't connect to ALSA
unless you have a properly configured ~/.asoundrc file. This should be
relatively easy because you now know your ALSA and sound card are
working. The following is a skeleton of what works on my machine. It
will probably work on yours, but remember to change the "pcm hw:2,0" to
whatever your card number and device number are respectively, as shown
on aplay -l


=======================================
# CRITICAL!!!    For "hw:num:othernum" in slave, 
# match num to card number and othernum to 
# device number, both from the aplay -l command.


pcm.!default {
        # Must be type plug
        type plug
        slave.pcm "my_arbitrary_name"
}


pcm.my_arbitrary_name  {
        # Must be type dmix
        type dmix
        # Must be ipc_key 1024, I don't know why
        ipc_key 1024
        slave {
                pcm "hw:2,0"


                # Following stuff probably unnecessary, possibly
                # harmful, but might help with certain songs
                #period_time 0
                #period_size 1024
                #buffer_size 4096
                #rate 44100
        }
}
=======================================


In the preceding, notice that the pcm "hw:2,0" corresponds to the
-D hw:2,0 in speaker-test, and the fact that my card number and device
number are 2 and 0 respectively as shown in aplay -l .

If you need to troubleshoot sound on an ALSA-only computer, the
preceding steps are the real way to do it. If Pulseaudio is involved, I
can't help you, because Pulseaudio is the land of a thousand mutes.

If you follow the procedure in this email and something goes wrong,
please email me either on or off list so we can explore it together.

HTH,

SteveT

Steve Litt

Autumn 2023 featured book: Rapid Learning for the 21st Century
http://www.troubleshooters.com/rl21