RaspOS Lite (Bookworm): HDMI Audio on RPI4
*** Ghadzooks! I just tried this again and it didn't work! Nevermind the fixes on this page until I figure out whats going on ... recently, when/if I don't see hdmi listed as an option in raspi-conf, I simply install pulseaudio-utils and do a "pactl list sinks". Seems to work on latest RaspOS Lite. ***
Fix for a recent Raspberry Pi Struggle: Getting HDMI audio working on latest version of RaspOS Lite (64-bit Bookworm).
Background: Recently installed a software suite (OVOS) that included pipewire for audio processing. Twas a struggle getting HDMI audio to work on a Raspberry Pi 4 because RaspOS Lite only seemed to offer the 3.5mm (bcm2835) audio device in rasp-config, alsa, etc. Likely also a problem on previous generations of RPI's w/ HDMI *and* Headphone jacks using Bookworm/RaspOS Lite 64-bit/Pipewire. Have not tested RaspOS Lite 32-bit but something is not right here on 64-bit Lite!
Fix: After a lot of fumbling and searching here's the quick tweak that worked for me ...
(Hack warning: There may be a better/right way to do this! I am a very inexperienced pipewire plumber!)
The following tweak was preformed after OVOS (and Pipewire) were installed - it assumes pipewire is installed.
Install some pulseaudio helpers to minimally see how things fit together - the utility 'pactl' in particular
Get names & numbers for all audio devices so we can see what we have to work with:
pactl list sinks | grep -e 'Name:' -e 'Description:'
Output looked something little like this:
Name: alsa_output.platform-bcm2835_audio.stereo-fallback
Description: Built-in Audio Stereo
Name: alsa_output.platform-fef00700.hdmi.hdmi-stereo
Description: Built-in Audio Digital Stereo (HDMI)One more raspi-config ... it SHOULD now offer hdmi in System Options -> Audio ... due to pulseaudio-utils(??)
Find the pipewire Node_id of the hdmi device by weeding through the output of pw-cli. Not sure how ID numbers are assigned but they seem to be persistent once assigned.
pw-cli ls Node
Should dump pw guts ...
id 32, type PipeWire:Interface:Node/3
object.serial = "77"
object.path = "alsa:pcm:2:hdmi:2:playback"
factory.id = "18"
client.id = "34"
device.id = "58"
priority.session = "1000"
priority.driver = "1000"
node.description = "Built-in Audio Digital Stereo (HDMI)"
node.name = "alsa_output.platform-fef00700.hdmi.hdmi-stereo"
node.nick = "MAI PCM i2s-hifi-0"
media.class = "Audio/Sink"
Hunt down location of active pipewire service:
sudo find / | grep pipewire.service
Found ... (save a copy of this if your editor doesn't)
/usr/lib/systemd/user/pipewire.service
Edit service and append the following ...
ExecStartPost=/usr/bin/pw-cli set-default-node <Node_id (32 in my step 3 above)>
File should now look something like this:
[Unit]
Description=PipeWire Multimedia Service
# We require pipewire.socket to be active before starting the daemon, because
# while it is possible to use the service without the socket, it is not clear
# why it would be desirable.
#
# A user installing pipewire and doing `systemctl --user start pipewire`
# will not get the socket started, which might be confusing and problematic if
# the server is to be restarted later on, as the client autospawn feature
# might kick in. Also, a start of the socket unit will fail, adding to the
# confusion.
#
# After=pipewire.socket is not needed, as it is already implicit in the
# socket-service relationship, see systemd.socket(5).
Requires=pipewire.socket
ConditionUser=!root
[Service]
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
RestrictNamespaces=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
Type=simple
ExecStart=/usr/bin/pipewire
Restart=on-failure
Slice=session.slice
ExecStartPost=/usr/bin/pw-cli set-default-node 32
[Install]
Also=pipewire.socket
WantedBy=default.target
Simple as THAT!?!? You will need to reload user units and restart pipewire or reboot
systemctl --user daemon-reload
systemctl --user restart pipewire.service
------
Not totally sure if this is a RaspOS issue or the OVOS installer but there HAS to be a better way to deal with this - will update this mess as if I come upon one! In meantime, this worked for me - I hope it helps others ... good luck