mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.26k stars 573 forks source link

Unable to get HDMI Output with ALSA on rasberry pi 3B. #1828

Closed aditya-gitte closed 7 months ago

aditya-gitte commented 7 months ago

What happened?

Options: -h, --help show this help. -d, --daemon daemonise. -j, --justDaemoniseNoPIDFile daemonise without a PID file. -k, --kill kill the existing shairport daemon. -V, --version show version information. -c, --configfile=FILE read configuration settings from FILE. Default is /etc/shairport-sync.conf.

The following general options are for backward compatibility. These and all new options have settings in the configuration file, by default /etc/shairport-sync.conf: -v, --verbose -v print debug information; -vv more; -vvv lots. -p, --port=PORT set RTSP listening port. -a, --name=NAME set advertised name. -L, --latency=FRAMES [Deprecated] Set the latency for audio sent from an unknown device. The default is to set it automatically. -S, --stuffing=MODE set how to adjust current latency to match desired latency, where "basic" inserts or deletes audio frames from packet frames with low processor overhead, and "soxr" uses libsoxr to minimally resample packet frames -- moderate processor overhead. "soxr" option only available if built with soxr support. -B, --on-start=PROGRAM run PROGRAM when playback is about to begin. -E, --on-stop=PROGRAM run PROGRAM when playback has ended. For -B and -E options, specify the full path to the program, e.g. /usr/bin/logger. Executable scripts work, but must have the appropriate shebang (#!/bin/sh) in the headline. -w, --wait-cmd wait until the -B or -E programs finish before continuing. -o, --output=BACKEND select audio output method. -m, --mdns=BACKEND force the use of BACKEND to advertize the service. if no mdns provider is specified, shairport tries them all until one works. -r, --resync=THRESHOLD [Deprecated] resync if error exceeds this number of frames. Set to 0 to stop resyncing. -t, --timeout=SECONDS go back to idle mode from play mode after a break in communications of this many seconds (default 120). Set to 0 never to exit play mode. --statistics print some interesting statistics -- output to the logfile if running as a daemon. --tolerance=TOLERANCE [Deprecated] allow a synchronization error of TOLERANCE frames (default 88) before trying to correct it. --password=PASSWORD require PASSWORD to connect. Default is not to require a password. --logOutputLevel log the output level setting -- useful for setting maximum volume. -M, --metadata-enable ask for metadata from the source and process it. --metadata-pipename=PIPE send metadata to PIPE, e.g. --metadata-pipename=/tmp/shairport-sync-metadata. The default is /tmp/shairport-sync-metadata. -g, --get-coverart send cover art through the metadata pipe. -u, --use-stderr log messages through STDERR rather than the system log.

Available mDNS backends: avahi

Available audio backends: alsa (default) pa jack pipe stdout dummy

Settings and options for the audio backend "alsa": -d output-device set the output device, default is "default". -c mixer-control set the mixer control name, default is to use no mixer. -m mixer-device set the mixer device, default is the output device. -i mixer-index set the mixer index, default is 0. hardware output devices: "hw:Headphones" "hw:vc4hdmi"

There are no settings or options for the audio backend "pa".

There are no settings or options for the audio backend "jack".

Settings and options for the audio backend "pipe": specify the pathname of the pipe to write to.

There are no settings or options for the audio backend "stdout".

There are no settings or options for the audio backend "dummy".


- The required output is `hw:vc4hdmi`. So I went to the config file (`/etc/shairport-sync.conf`) and updated this info there along with the name of the speaker

// General Settings general = { name = "Kitchen"; // This means "Hostname" -- see below. This is the name the service will advertise to iTunes. } alsa = { output_device = "hw:vc4hdmi"; }


- Next I when I connect to the device and try to play using airplay no sound is played. Here are the logs that `shairport-sync -v` shows

shairport-sync -v 0.002857130 "shairport.c:1729" Started! 0.000145721 "shairport.c:1756" software version: "3.3.7-libdaemon-OpenSSL-Avahi-ALSA-jack-pa-dummy-stdout-pipe-soxr-convolution-metadata-mqtt-dbus-mpris-sysconfdir:/etc" 0.000025415 "shairport.c:1762" log verbosity is 1. 0.000049373 "audio_alsa.c:1015" alsa: alsa_maximum_stall_time of 0.200000 sec. 0.000056194 "audio_alsa.c:1299" alsa: disable_standby_mode is "never". 0.000018697 "audio_alsa.c:1303" alsa: disable_standby_mode_silence_threshold is 0.040000 seconds. 0.000020780 "audio_alsa.c:1305" alsa: disable_standby_mode_silence_scan_interval is 0.004000 seconds. 0.000021197 "audio_alsa.c:1345" alsa: output device name is "hw:vc4hdmi". 0.000232591 "shairport.c:1810" disable resend requests is off. 0.000025780 "shairport.c:1811" diagnostic_drop_packet_fraction is 0.000000. A value of 0.0 means no packets will be dropped deliberately. 0.000022238 "shairport.c:1815" statistics_requester status is 0. 0.000018228 "shairport.c:1817" daemon status is 0. 0.000019270 "shairport.c:1818" daemon pid file path is "/run/shairport-sync/shairport-sync.pid". 0.000018332 "shairport.c:1820" rtsp listening port is 5000. 0.000018020 "shairport.c:1821" udp base port is 6001. 0.000017395 "shairport.c:1822" udp port range is 10. 0.000017187 "shairport.c:1823" player name is "Kitchen". 0.000017342 "shairport.c:1824" backend is "alsa". 0.000017187 "shairport.c:1825" run_this_before_play_begins action is "(null)". 0.000018072 "shairport.c:1826" run_this_after_play_ends action is "(null)". 0.000017863 "shairport.c:1827" wait-cmd status is 0. 0.000017447 "shairport.c:1828" run_this_before_play_begins may return output is 0. 0.000018072 "shairport.c:1829" run_this_if_an_unfixable_error_is_detected action is "(null)". 0.000018333 "shairport.c:1830" run_this_before_entering_active_state action is "(null)". 0.000017915 "shairport.c:1831" run_this_after_exiting_active_state action is "(null)". 0.000018020 "shairport.c:1832" active_state_timeout is 10.000000 seconds. 0.000022030 "shairport.c:1833" mdns backend "(null)". 0.000017343 "shairport.c:1835" interpolation setting is "auto". 0.000017915 "shairport.c:1838" interpolation soxr_delay_threshold is 30. 0.000017656 "shairport.c:1839" resync time is 0.050000 seconds. 0.000018540 "shairport.c:1840" allow a session to be interrupted: 0. 0.000017551 "shairport.c:1841" busy timeout time is 120. 0.000017343 "shairport.c:1842" drift tolerance is 0.001995 seconds. 0.000018801 "shairport.c:1843" password is "(null)". 0.000016874 "shairport.c:1844" ignore_volume_control is 0. 0.000017760 "shairport.c:1848" volume_max_db is not set 0.000017342 "shairport.c:1849" volume range in dB (zero means use the range specified by the mixer): 0. 0.000018958 "shairport.c:1851" volume_range_combined_hardware_priority (1 means hardware mixer attenuation is used first) is 0. 0.000018644 "shairport.c:1855" playback_mode is 0 (0-stereo, 1-mono, 1-reverse_stereo, 2-both_left, 3-both_right). 0.000018906 "shairport.c:1857" disable_synchronization is 0. 0.000017342 "shairport.c:1858" use_mmap_if_available is 1. 0.000017395 "shairport.c:1859" output_format automatic selection is enabled. 0.000018176 "shairport.c:1863" output_rate automatic selection is enabled. 0.000018176 "shairport.c:1867" audio backend desired buffer length is 0.200000 seconds. 0.000019270 "shairport.c:1869" audio_backend_buffer_interpolation_threshold_in_seconds is 0.120000 seconds. 0.000020155 "shairport.c:1871" audio backend latency offset is 0.000000 seconds. 0.000018957 "shairport.c:1873" audio backend silence lead-in time is "auto". 0.000017135 "shairport.c:1877" zeroconf regtype is "_raop._tcp". 0.000017499 "shairport.c:1878" decoders_supported field is 1. 0.000017395 "shairport.c:1879" use_apple_decoder is 0. 0.000017082 "shairport.c:1880" alsa_use_hardware_mute is 0. 0.000017499 "shairport.c:1884" no special mdns service interface was requested. 0.000050362 "shairport.c:1887" configuration file name "/etc/shairport-sync.conf" resolves to "/etc/shairport-sync.conf". 0.000022030 "shairport.c:1894" metadata enabled is 1. 0.000017863 "shairport.c:1895" metadata pipename is "/tmp/shairport-sync-metadata". 0.000018645 "shairport.c:1896" metadata socket address is "(null)" port 0. 0.000018385 "shairport.c:1898" metadata socket packet size is "500". 0.000017707 "shairport.c:1899" get-coverart is 1. 0.000017239 "shairport.c:1902" mqtt is disabled. 0.000017134 "shairport.c:1903" mqtt hostname is (null), port is 1883. 0.000018072 "shairport.c:1904" mqtt topic is /Kitchen. 0.000017134 "shairport.c:1905" mqtt will not publish raw metadata. 0.000017760 "shairport.c:1906" mqtt will not publish parsed metadata. 0.000018020 "shairport.c:1907" mqtt will not publish cover Art. 0.000017447 "shairport.c:1908" mqtt remote control is disabled. 0.000017394 "shairport.c:1912" convolution is 0. 0.000017083 "shairport.c:1913" convolution IR file is "(null)" 0.000017707 "shairport.c:1914" convolution max length 8192 0.000017343 "shairport.c:1915" convolution gain is 0.000000 0.000018384 "shairport.c:1917" loudness is 0. 0.000016874 "shairport.c:1918" loudness reference level is -20.000000 0.000176761 "rtsp.c:1665" metadata pipe name is "/tmp/shairport-sync-metadata". 0.013374036 "dbus-service.c:1053" warning: could not acquire a Shairport Sync native D-Bus interface "org.gnome.ShairportSync.i4441" on the system bus. 0.000613090 "mpris-service.c:348" warning: could not acquire an MPRIS interface named "org.mpris.MediaPlayer2.ShairportSync.i4441" on the system bus. 0.003696771 "mdns_avahi.c:375" avahi_dacp_monitor_start Avahi DACP monitor successfully started 1.492173982 "shairport.c:200" "soxr" interpolation has been chosen. 17.618914231 "rtsp.c:1057" Connection 1: SETUP DACP-ID "2CE75D2E91F786E0" from 2405:201:1007:30c8:740f:c238:9f7a:4959 to 2405:201:1007:30c8:90a9:4485:d212:31f9 with UDP ports Control: 6001, Timing: 6002 and Audio: 6003. ALSA lib conf.c:1970:(_snd_config_load_with_include) toplevel:18:1:Unexpected char ALSA lib conf.c:3817:(config_file_open) /home/adipi/.asoundrc may be old or corrupted: consider to remove or fix it ALSA lib conf.c:3739:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument ALSA lib conf.c:4203:(snd_config_update_r) hooks failed, removing configuration 0.015487141 "audio_alsa.c:441" *warning: alsa: error -22 ("Invalid argument") opening alsa device "hw:vc4hdmi". ALSA lib conf.c:1970:(_snd_config_load_with_include) toplevel:18:1:Unexpected char ALSA lib conf.c:3817:(config_file_open) /home/adipi/.asoundrc may be old or corrupted: consider to remove or fix it ALSA lib conf.c:3739:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument ALSA lib conf.c:4203:(snd_config_update_r) hooks failed, removing configuration


- Am I missing something here? I don't have any preference for audio backends, so if there is something that handles HDMI output, please do suggest. Thank you in advance

### Relevant log output

_No response_

### System Information.

Device: Raspberry Pi 3B (1GB RAM)
OS: Raspberry pi os lite 32 bit (headless)

### Configuration Information.

```shell
uname: Linux raspberrypi 6.1.21-v7+ #1642 SMP Mon Apr  3 17:20:52 BST 2023 armv7l GNU/Linux
shairport-sync -V: 3.3.7-libdaemon-OpenSSL-Avahi-ALSA-jack-pa-dummy-stdout-pipe-soxr-convolution-metadata-mqtt-dbus-mpris-sysconfdir:/etc

PulseAudio or PipeWire installed?

How did you install Shairport Sync?

A package manager (apt, apt install, yum, pkg, etc.)

Check previous issues

MRIO commented 7 months ago

Howdy! I was able to get it working by using in General Settings the long name of the output device that is listed in aplay -L

output_device = "hdmi:CARD=vc4hdmi1,DEV=0"; 
mikebrady commented 7 months ago

Howdy! I was able to get it working by using in General Settings the long name of the output device that is listed in aplay -L

output_device = "hdmi:CARD=vc4hdmi1,DEV=0"; 

Thanks for this @MRIO. I tried it on my own Raspberry Pi 3B and had to make two small modifications before it would work:

  1. On my system, the card address is"hdmi:CARD=vc4hdmi,DEV=0", slightly different to yours. For reference, the version of the operating systems is:
    $ uname -a
    Linux RaspberryPi3B 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux
  2. For Shairport Sync to work, the HDMI output had to be connected to a HDMI system (in my case a TV) and that system had to be powered up. One other thing is that the HDMI receiving system must be capable of accepting audio at 44,100 frames per second.

The version of Shairport Sync in use is 3.3.7, which is pretty ancient; many improvements and important updates have been made since, so it would be well worthwhile updating to the latest.

MRIO commented 7 months ago

Hi @mikebrady, FYI, differently than OP I'm running 4.3.2, and I was having the no sound issue on a pi4:

$ uname -a Linux raspberrypi 6.6.22-v8+ #1746 SMP PREEMPT Wed Mar 20 17:19:49 GMT 2024 aarch64 GNU/Linux

$ shairport-sync -V 4.3.2-2-g165431a8-AirPlay2-smi10-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc

Keep up the amazing work!

aditya-gitte commented 7 months ago

Hi @mikebrady and @MRIO, the above solution does work for me as well. Thanks a lot and keep up the amazing work!

rayduui commented 5 months ago

Howdy! I was able to get it working by using in General Settings the long name of the output device that is listed in aplay -L

output_device = "hdmi:CARD=vc4hdmi1,DEV=0"; 

Step 1 Run shairport-sync -h

You should see result, copy the device with hdmi, for me it's hw:vc4hdmi


Settings and options for the audio backend "alsa":
    -d output-device    set the output device, default is "default".
    -c mixer-control    set the mixer control name, default is to use no mixer.
    -m mixer-device     set the mixer device, default is the output device.
    -i mixer-index      set the mixer index, default is 0.
    hardware output devices:
      "hw:Headphones"
      "hw:vc4hdmi"

Step 2 Edit /etc/shairport-sync.conf, so you have the output device from step 1 (exclude hw:)

alsa = 
{
        output_device = "hdmi:CARD=vc4hdmi,DEV=0"; 
}

Step 3 Restart the service

systemctl restart shairport-sync