I'm using an old Raspberry Pi 1 as UPnP music player for my stereo, but had a) cracks when starting playing music the first time after booting up and b) bad overall sound quality when playing music and radio plays.
Many people fixed that problem by buying a cheap USB sound card and using that on their RPi1, and this is what I did. I paid 2€ on ebay and got it 5 days later. (I could have paid 1 US$ on aliexpress, but that would have taken 2 months of shipping time.)
The Debian 9 running on the Pi detected the USB sound card without problems, but I needed to tell alsa to make the USB card default. aplay -l told me the USB card is number 1, so I created /etc/asound.conf:
pcm.!default { type hw card 1 } ctl.!default { type hw card 1 }
When testing that with aplay, I found out that the cheap sound card only supports stereo, not mono:
$ aplay /usr/share/sounds/alsa/Front_Right.wav Playing WAVE '/usr/share/sounds/alsa/Front_Right.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono aplay: set_params:1305: Channels count non available $ aplay -D plughw:1,0 /usr/share/sounds/alsa/Noise.wav (works)
I experimented with different settings until I finally found the solution in the archlinux forums:
pcm.!default { type plug slave { pcm "hw:1,0" } } ctl.!default { type hw card 1 }
gmrender config
I'm using gmrender-resurrect as UPnP renderer, and it did not automatically use the default ALSA card - despite its --gstout-audiodevice=sysdefault option.
With aplay -L (note the uppercase L) I found the card name that I could use and adjusted the systemd init file to use the following options:
--gstout-audiosink=alsasink --gstout-audiodevice=hw:CARD=Device,DEV=0
No cracks anymore! Good sound quality!