Unable to force sound to headphone jack RPI 4

Hello, I have a raspberry pi 4 running the latest version of DietPi (v6.31.2). I have it plugged in to my TV through an HDMI cord, and to my speakers through the 3.5mm jack. I would like to force the audio through 3.5mm so that I am able to use shairport-sync and play audio without having to turn on the TV, but I am unable to do so. I have set the audio to force 3.5mm through the use of dietpi-config > audio options > sound card > rip-bcm2835-3.5mm (also see image below), but no sound comes through until I turn on the TV. Is this an issue with shairport-sync that I need to configure, or something else?

I appreciate any help!

Many thanks for your report.

Did you reboot one time after applying the sound card selection?

Can you paste the output of amixer -c 0 contents (in case after reboot if 3.5mm output still does not work).

And in case try to add hdmi_drive=1 to /boot/config.txt and reboot another time. This forces DVI mode which disables HDMI sound from the other side.

I did not reboot, but after doing so I have not been able to force 3.5mm. I’ve added the hdmi_drive=1 line, reboot, and I actually lose all sound coming from the Pi, even when the TV is on.

The contents of amixer -c 0 contents are as follows:

numid=2,iface=MIXER,name='HDMI Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=1,iface=MIXER,name='HDMI Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0
  : values=2
  | dBscale-min=-102.39dB,step=0.01dB,mute=1

Strange. hdmi_drive=1 disables HDMI sound the other way, so it makes sense that you loose all sound then.

What is strange is that numid=2 is not shown in your amixer output as this is what usually switches between 3.5mm, HDMI and auto: https://www.raspberrypi.org/documentation/configuration/audio-config.md

If you again comment/remove the hdmi_drive line, does amixer -c 0 contents still only show those two switches?

And just to assure: dtparam=audio=on is set in config.txt, right?

Yes, I get the same results from amixer after uncommenting the hdmi_drive line

The portion in config.txt is also set to on, as well: dtparam=audio=on

Hmm, probably this needs to be configured differently on RPi4 (although never heard of an 3.5mm issue) or hardware issue?
Btw you can follow any Raspbian/Raspberry Pi OS instructions you find.

Just checked raspi-config and they do the same: https://github.com/RPi-Distro/raspi-config/blob/master/raspi-config#L1724-L1737

Ah did we already check if onboard audio is really card 0 or if something else occupied that ID? Please paste the output of:
aplay -l
aplay -L

Hi, I did not see your reply to this for a long time.

The output of aplay -l is as follows
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
Subdevices: 4/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 4/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3


The output of aplay -L is as follows
null
Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=b1
bcm2835 HDMI 1, bcm2835 HDMI 1
Default Audio Device
dmix:CARD=b1,DEV=0
bcm2835 HDMI 1, bcm2835 HDMI 1
Direct sample mixing device
dsnoop:CARD=b1,DEV=0
bcm2835 HDMI 1, bcm2835 HDMI 1
Direct sample snooping device
hw:CARD=b1,DEV=0
bcm2835 HDMI 1, bcm2835 HDMI 1
Direct hardware device without any conversions
plughw:CARD=b1,DEV=0
bcm2835 HDMI 1, bcm2835 HDMI 1
Hardware device with all software conversions
sysdefault:CARD=Headphones
bcm2835 Headphones, bcm2835 Headphones
Default Audio Device
dmix:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample mixing device
dsnoop:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample snooping device
hw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct hardware device without any conversions
plughw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Hardware device with all software conversions

gofireworks
Meanwhile the issue is known: https://github.com/MichaIng/DietPi/issues/3887
Will be fixed with next release.

If you find time, could you do the following:

G_CONFIG_INJECT 'hdmi_drive:0=' `hdmi_drive:0=1` /boot/config.txt # forces DVI mode on HDMI port 0
G_CONFIG_INJECT 'hdmi_drive:1=' `hdmi_drive:1=1` /boot/config.txt # forces DVI mode on HDMI port 1
reboot # Reboot to make changes becoming effective
cat /proc/asound/cards

I want to assure that all RPi models in such case do not list HDMI as sound “card” anymore but instead the “Headphones” (3.5mm jack) as card 0.

MichaIng
When I copy and paste the command (with and without sudo) I get this error: https://imgur.com/a/7U4NDXk

can you try this as user root pls

I switched to root user with sudo su, and then entered the following commands

G_CONFIG_INJECT 'hdmi_drive:0=' 'hdmi_drive:0=1' /boot/config.txt
G_CONFIG_INJECT 'hdmi_drive:1=' 'hdmi_drive:1=1' /boot/config.txt
reboot
cat /proc/asound/cards

I had to switch the backticks on hdmi_drive:0=1 to single quotes because I was getting an error of bash: hdmi_drive:0=1: command not found.

The output of cat /proc/asound/cards doesn’t seem to have changed, but the output is here

root@Kodi:/home/joshl# cat /proc/asound/cards
 0 [b1             ]: bcm2835_hdmi - bcm2835 HDMI 1
                      bcm2835 HDMI 1
 1 [Headphones     ]: bcm2835_headphonbcm2835 Headphones - bcm2835 Headphones
                      bcm2835 Headphones