mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.17k stars 569 forks source link

[Problem] : Why do I not encounter any problems with iPhone while on the Mac I experience delays in the controls? #1882

Closed luvingiane closed 1 month ago

luvingiane commented 2 months ago

What happened?

as i said in the title, i found this delay on my mac (MBA M1; MacOS Sequoia Beta 3) which has about 2 seconds of delay, but no issues on iPhone 13 (17.5 - 21F79) : no lagging, works like a charm. Log below, "unità cinofila 13" is the iphone.
So, why? what am i missing on configuration? Any advice is appreciated.

Relevant log output

pi@raspberry:~ $ shairport-sync -v
         0.003409115 "shairport.c:2278" Startup in AirPlay 2 mode, with features 0x405c4a00,0x1c340 on device "MAC REDACTED".
         0.000212500 "shairport.c:2317" Version String: "4.3.4-AirPlay2-smi10-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc"
         0.000041458 "shairport.c:2336" Command Line: "shairport-sync -v".
         0.000695469 "shairport.c:2372" Log Verbosity is 1.
         0.000115417 "audio_alsa.c:1082" alsa: alsa_maximum_stall_time of 0.200000 sec.
         0.000089583 "audio_alsa.c:1371" alsa: disable_standby_mode is "never".
         0.000041979 "audio_alsa.c:1375" alsa: disable_standby_mode_silence_threshold is 0.040000 seconds.
         0.000032760 "audio_alsa.c:1377" alsa: disable_standby_mode_silence_scan_interval is 0.004000 seconds.
         0.000087709 "audio_alsa.c:1417" alsa: output device name is "hw:Headphones".
         0.000456823 "shairport.c:2440" disable_resend_requests is off.
         0.000078541 "shairport.c:2441" diagnostic_drop_packet_fraction is 0.000000. A value of 0.0 means no packets will be dropped deliberately.
         0.000044011 "shairport.c:2445" statistics_requester status is 0.
         0.000033333 "shairport.c:2450" rtsp listening port is 7000.
         0.000029740 "shairport.c:2451" udp base port is 6001.
         0.000023854 "shairport.c:2452" udp port range is 10.
         0.000023542 "shairport.c:2453" player name is "HP E243m".
         0.000023281 "shairport.c:2454" backend is "alsa".
         0.000023750 "shairport.c:2455" run_this_before_play_begins action is "(null)".
         0.000063541 "shairport.c:2456" run_this_after_play_ends action is "(null)".
         0.000027865 "shairport.c:2457" wait-cmd status is 0.
         0.000024323 "shairport.c:2458" run_this_before_play_begins may return output is 0.
         0.000024323 "shairport.c:2459" run_this_if_an_unfixable_error_is_detected action is "(null)".
         0.000027864 "shairport.c:2461" run_this_before_entering_active_state action is  "(null)".
         0.000090782 "shairport.c:2463" run_this_after_exiting_active_state action is  "(null)".
         0.000114583 "shairport.c:2465" active_state_timeout is  10.000000 seconds.
         0.000089740 "shairport.c:2466" mdns backend "(null)".
         0.000077968 "shairport.c:2468" interpolation setting is "auto".
         0.000106355 "shairport.c:2472" interpolation soxr_delay_threshold is 30000000.
         0.000080052 "shairport.c:2473" resync time is 0.050000 seconds.
         0.000106458 "shairport.c:2474" resync recovery time is 0.100000 seconds.
         0.000104167 "shairport.c:2475" allow a session to be interrupted: 0.
         0.000076875 "shairport.c:2476" busy timeout time is 120.
         0.000099270 "shairport.c:2477" drift tolerance is 0.002000 seconds.
         0.000101771 "shairport.c:2478" password is not set.
         0.000036459 "shairport.c:2479" default airplay volume is: -24.000000.
         0.000033020 "shairport.c:2480" high threshold airplay volume is: -16.000000.
         0.000050678 "shairport.c:2482" check for higher-than-threshold volume for new play session is disabled.
         0.000026041 "shairport.c:2488" ignore_volume_control is 0.
         0.000023750 "shairport.c:2492" volume_max_db is not set
         0.000022552 "shairport.c:2493" volume range in dB (zero means use the range specified by the mixer): 0.
         0.000025104 "shairport.c:2495" volume_range_combined_hardware_priority (1 means hardware mixer attenuation is used first) is 0.
         0.000025521 "shairport.c:2499" playback_mode is 0 (0-stereo, 1-mono, 1-reverse_stereo, 2-both_left, 3-both_right).
         0.000024948 "shairport.c:2501" disable_synchronization is 0.
         0.000022761 "shairport.c:2502" use_mmap_if_available is 1.
         0.000022812 "shairport.c:2503" output_format automatic selection is enabled.
         0.000023177 "shairport.c:2507" output_rate automatic selection is enabled.
         0.000023021 "shairport.c:2511" audio backend desired buffer length is 0.200000 seconds.
         0.000026615 "shairport.c:2513" audio_backend_buffer_interpolation_threshold_in_seconds is 0.120000 seconds.
         0.000028125 "shairport.c:2515" audio backend latency offset is 0.000000 seconds.
         0.000026614 "shairport.c:2517" audio backend silence lead-in time is "auto".
         0.000022969 "shairport.c:2521" zeroconf regtype is "_raop._tcp".
         0.000022865 "shairport.c:2522" decoders_supported field is 1.
         0.000022500 "shairport.c:2523" use_apple_decoder is 0.
         0.000022395 "shairport.c:2524" alsa_use_hardware_mute is 0.
         0.000022552 "shairport.c:2528" no special mdns service interface was requested.
         0.000063594 "shairport.c:2531" configuration file name "/etc/shairport-sync.conf" resolves to "/etc/shairport-sync.conf".
         0.000030104 "shairport.c:2561" loudness is 0.
         0.000023698 "shairport.c:2562" loudness reference level is -20.000000
         0.001963959 "shairport.c:2689" NQPTP is online.
         1.506766978 "shairport.c:255" "soxr" interpolation has been chosen.
         2.584859478 "rtsp.c:2896" Connection 1: AP2 PTP connection from REDACTED ("Matt's Macbook") to self at REDACTED:7000.
         0.500445313 "rtsp.c:3253" Connection 1: SETUP AP2 no Active-Remote information  the SETUP Record.
         0.000151562 "rtsp.c:3272" Connection 1: SETUP AP2 doesn't include DACP-ID string information.
         0.000066302 "rtsp.c:3287" Connection 1. AP2 Realtime Audio Stream.
         0.072285156 "rtp.c:1738" AP2 Realtime Clock receiver initialised.
         5.169693436 "rtsp.c:3253" Connection 1: SETUP AP2 no Active-Remote information  the SETUP Record.
         0.000153385 "rtsp.c:3272" Connection 1: SETUP AP2 doesn't include DACP-ID string information.
         0.000061146 "rtsp.c:3287" Connection 1. AP2 Realtime Audio Stream.
         4.238619269 "rtsp.c:3253" Connection 1: SETUP AP2 no Active-Remote information  the SETUP Record.
         0.000158803 "rtsp.c:3272" Connection 1: SETUP AP2 doesn't include DACP-ID string information.
         0.000066770 "rtsp.c:3287" Connection 1. AP2 Realtime Audio Stream.
         8.876274007 "rtsp.c:3253" Connection 1: SETUP AP2 no Active-Remote information  the SETUP Record.
         0.000159636 "rtsp.c:3272" Connection 1: SETUP AP2 doesn't include DACP-ID string information.
         0.000063125 "rtsp.c:3287" Connection 1. AP2 Realtime Audio Stream.
        17.901586451 "rtsp.c:2896" Connection 2: AP2 PTP connection from REDACTED ("Unità Cinofila 13") to self at REDACTED:7000.
         1.601489166 "rtsp.c:3253" Connection 2: SETUP AP2 no Active-Remote information  the SETUP Record.
         0.000153386 "rtsp.c:3272" Connection 2: SETUP AP2 doesn't include DACP-ID string information.

System Information.

Device : Raspberry PI 2 B+ tested devices : M1 Macbook Air on Sonoma beta 3 , iPhone 13 on iOS 17.5

Screenshot 2024-07-21 alle 21 10 57

shairport-sync.conf.zip

Configuration Information.

basic ./configure as described in guide , also, Pi is running without a desktop environment and is totally controlled by SSH.

PulseAudio or PipeWire installed?

How did you install Shairport Sync?

Built from source

Check previous issues

mikebrady commented 2 months ago

Thanks for the post. It looks as if Shairport Sync is running properly!

Let me explain: AirPlay 2 seems to have two modes of operation -- Buffered Audio and Realtime Audio. Both modes introduce a delay. For buffered audio it's less than about half a second; for realtime audio it's about two seconds. The mode used is chosen by the source.

Normally one doesn't notice the delay -- the video and audio are synchronised to one another. For example, if you play a video, the video should be delayed to match the delayed audio. Many apps, including Safari, do that, but some apps don't.

Another place you'll notice the delay is if you use an AirPlay 2 device as the Mac's system output. The realtime audio mode is chosen and beeps are delayed by two seconds.

Does that explain what you are experiencing?

luvingiane commented 1 month ago

Hi! That makes sense, i've tested on Mac with Apple Music and choosing speaker from it (instead of audio source) delay is 0.5s (buffered mode). And yes, shairport-sync works like a charm, i'm so happy how it works, thanks a lot for your help.

Matt