I've found several candidate dupes for this - the one that seems to encompass them all (and more) being this one: How can I use an external USB sound-card and set it as default?
But none of them have helped.
I have a brand new Pi 4, with Raspbian Buster installed via NOOBS 3.3.1 today.
In all cases, when I try
speaker-test -c2 I get a click sound from the speakers, followed by:
Write error: -19,No such device
The speakers work fine when plugged into a different computer, and I consistently see the speakers listed when I run
... card 1: Device [USB2.0 Device], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 ...
Before making any changes, with the
/usr/share/alsa/alsa.conf file still showing:
defaults.ctl.card 0 defaults.pcm.card 0
I could run
speaker-test -c2 and hear audio through my monitor's speakers, via HDMI.
Having changed the above values to 1, when I run it I get the error shown above.
Trying a random
.wav file through mplayer is no more successful:
mplayer http://www2.cs.uic.edu/~i101/SoundFiles/BabyElephantWalk60.wav MPlayer 1.3.0 (Debian), built with gcc-8 (C) 2000-2016 MPlayer Team do_connect: could not connect to socket connect: No such file or directory Failed to open LIRC support. You will not be able to use your remote control. Playing http://www2.cs.uic.edu/~i101/SoundFiles/BabyElephantWalk60.wav. Resolving www2.cs.uic.edu for AF_INET6... Couldn't resolve name for AF_INET6: www2.cs.uic.edu Resolving www2.cs.uic.edu for AF_INET... Connecting to server www2.cs.uic.edu[184.108.40.206]: 80... Cache size set to 320 KBytes Cache fill: 12.44% (40764 bytes) libavformat version 58.20.100 (external) Audio only file format detected. ========================================================================== Opening audio decoder: [pcm] Uncompressed PCM audio decoder AUDIO: 22050 Hz, 1 ch, s16le, 352.8 kbit/100.00% (ratio: 44100->44100) Selected audio codec: [pcm] afm: pcm (Uncompressed PCM) ========================================================================== AO: [pulse] Init failed: Connection refused Failed to initialize audio driver 'pulse' AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample) Video: no video Starting playback... A: 2.0 (02.0) of 60.0 (01:00.0) 0.3% 48% [AO_ALSA] alsa-lib: pcm_hw.c:585:(snd_pcm_hw_status) SNDRV_PCM_IOCTL_STATUS_EXT failed (-19): No such device [AO_ALSA] Cannot get pcm status: No such device [AO_ALSA] alsa-lib: pcm_hw.c:585:(snd_pcm_hw_status) SNDRV_PCM_IOCTL_STATUS_EXT failed (-19): No such device [AO_ALSA] Cannot get pcm status: No such device
with the last two lines repeated constantly until I hit Ctrl-c.
Trying other applications to play the audio gives different errors:
aplay -c2 -D hw:1,0 BabyElephantWalk60.wav Playing WAVE 'BabyElephantWalk60.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono aplay: set_params:1345: Channels count non available
The least unsuccessful is:
omxplayer BabyElephantWalk60.wav Audio codec pcm_s16le channels 1 samplerate 22050 bitspersample 16 Subtitle count: 0, state: off, index: 1, delay: 0 have a nice day ;)
with the "have a nice day ;)" line appearing after about 60 seconds, which is the duration of the file, but no sound comes out of the speaker.
In all cases, reverting
alsa.conf to the defaults of "0" and removing
~/.asoundrc causes the sound to play successfully through my monitor's speakers.
Any advice at all is most welcome. I'm guessing the issue is that I need to do something different either due to the Pi 4 or Buster, but I've no idea where to start.