volumio / Volumio2

Volumio 2 - Audiophile Music Player
http://volumio.org
Other
1.37k stars 316 forks source link

Digital audio output has glitches #2140

Open manrand opened 3 years ago

manrand commented 3 years ago

(copy/pasting from: https://github.com/mikebrady/shairport-sync/issues/1278)

Hi,

I'm using shairport-sync within Volumio (but I've tried also with Moodeaudio), and I'm experiencing audio glitches on the digital output. I've read most if not all discussions about related problems and have tried with disable_synchronisation = yes as well as other parameters, but I always get issues.

Has anybody been able setup a RPi Zero W shairport-sync over Optical Audio out without audio glitches? and if so, what am I doing wrong?

I'm sharing my config to see if somebody could help me: HW:

SW:

diagnostics = { log_verbosity = 1; statistics = "yes"; disable_resend_requests = "yes"; };

alsa = { output_device = "plughw:2,0"; disable_synchronization = "yes"; };

sessioncontrol = { allow_session_interruption = "yes"; run_this_before_play_begins= "/usr/local/bin/volumio startairplayplayback"; run_this_after_play_ends = "/usr/local/bin/volumio stopairplayplayback"; run_this_before_entering_active_state="/usr/local/bin/volumio airplayactive"; run_this_after_exiting_active_state="/usr/local/bin/volumio airplayinactive"; };

metadata = { enabled = "yes"; include_cover_art = "no"; //pipe_name = "/tmp/shairport-sync-metadata"; //pipe_timeout = 5000; socket_address = "127.0.0.1"; socket_port = 5555; };


Others issues I noticed (which may or may not be related)
- I cannot send Mac system audio, for instance selecting "Volumio" as output device on the system audio panel. Only way to play audio from Mac seems to be from iTunes
- Moodeaudio works even worse than Volumio, as it essentially does 1 sec on, 1 sec off or something

Other remarks:
- the optical output is properly setup because it works just fine: Volumio can play other sources, it is just AirPlay that has audio glitches
- I believe the audio glitches may be harder to hear if using analog output, although I have no way to confirm. The reason I make this hypothesis is that many people get it working, but most of them are using analog out, and the output filters/capacitors may be hiding the glitches.
- with `disable_synchronization = yes` it seems to improve, but I do get some glitches further down, like if it skipped part of a song
- The optical output is connected to an old HiFi system

From the logs it appears that there is packet loss (resend), empty frames, and drift, but that seems like a lot of issues for a default config, while many people appear to have succeeded using the RPi Zero W for Airplay with `shairport-sync` (regardless of distro)

Other weird things (to me):
1)

volumio shairport-sync[14817]: 1.359341298 "audio_alsa.c:530" alsa: output format chosen is "S32". volumio shairport-sync[14817]: 0.003040983 "audio_alsa.c:570" alsa: output speed chosen is 44100.


2) HW config is different between web radio playback and `shairport-sync`
- web radio playback

volumio@volumio:~$ cat /proc/asound/sndrpihifiberry/pcm0p/sub0/hw_params access: RW_INTERLEAVED format: S24_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 4410 buffer_size: 22050

volumio@volumio:~$ cat /proc/asound/sndrpihifiberry/pcm0p/sub0/sw_params tstamp_mode: NONE period_step: 1 avail_min: 4410 start_threshold: 17640 stop_threshold: 22050 silence_threshold: 0 silence_size: 0 boundary: 1445068800


- `shairport-sync` AirPlay playback:

volumio@volumio:~# cat /proc/asound/sndrpihifiberry/pcm0p/sub0/hw_params access: MMAP_INTERLEAVED format: S24_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 256 buffer_size: 65536

volumio@volumio:~# cat /proc/asound/sndrpihifiberry/pcm0p/sub0/sw_params
tstamp_mode: ENABLE period_step: 1 avail_min: 256 start_threshold: 1 stop_threshold: 65536 silence_threshold: 0 silence_size: 0 boundary: 1073741824


3) Log with the config mentioned further above

Jul 02 12:38:45 volumio shairport-sync[17589]: 8.256483000 "player.c:1969" Player has supplied a silent frame, (possibly frame 9170) for play number 30809, status 0x11 after 7 resend requests. Jul 02 12:38:45 volumio shairport-sync[17589]: 0.003868000 "player.c:1969" Player has supplied a silent frame, (possibly frame 9171) for play number 30810, status 0x11 after 7 resend requests. Jul 02 12:38:47 volumio shairport-sync[17589]: 2.269939000 "player.c:2726" 0.00, 31093, 13, 0, 0, 0, 218, 519, 44213.17, 44103.32, -47.01, 35 Jul 02 12:38:55 volumio shairport-sync[17589]: 8.168548000 "player.c:2726" 0.00, 32096, 13, 0, 0, 0, 221, 246, 44125.68, 44092.77, -46.91, 37 Jul 02 12:39:04 volumio shairport-sync[17589]: 8.794668000 "player.c:2726" 0.00, 33099, 13, 0, 0, 0, 245, 344, 44114.01, 44092.77, -46.92, 38 Jul 02 12:39:13 volumio shairport-sync[17589]: 8.794760000 "player.c:2726" 0.00, 34102, 13, 0, 0, 0, 344, 443, 44108.58, 44094.07, -46.92, 38 Jul 02 12:39:14 volumio shairport-sync[17589]: 0.848276000 "player.c:1969" Player has supplied a silent frame, (possibly frame 12559) for play number 34198, status 0x5 after 7 resend requests. Jul 02 12:39:14 volumio shairport-sync[17589]: 0.002847000 "player.c:1969" Player has supplied a silent frame, (possibly frame 12560) for play number 34199, status 0x5 after 7 resend requests. Jul 02 12:39:22 volumio shairport-sync[17589]: 7.943234000 "player.c:2726" 0.00, 35105, 15, 0, 0, 0, 442, 542, 44105.72, 44094.15, -46.80, 40 Jul 02 12:39:31 volumio shairport-sync[17589]: 8.795334000 "player.c:2726" 0.00, 36108, 15, 0, 0, 0, 541, 641, 44103.96, 44093.73, -46.79, 41 Jul 02 12:39:39 volumio shairport-sync[17589]: 8.806750000 "player.c:2726" 0.00, 37111, 15, 0, 0, 0, 640, 739, 44102.88, 44093.45, -47.60, 42 Jul 02 12:39:40 volumio shairport-sync[17589]: 0.453279000 "player.c:1969" Player has supplied a silent frame, (possibly frame 15526) for play number 37165, status 0x5 after 7 resend requests. Jul 02 12:39:48 volumio shairport-sync[17589]: 8.341479000 "player.c:2726" 0.00, 38114, 16, 0, 0, 0, 739, 838, 44101.98, 44093.80, -47.55, 45 Jul 02 12:39:57 volumio shairport-sync[17589]: 8.794738000 "player.c:2726" 0.00, 39117, 16, 0, 0, 0, 837, 937, 44101.31, 44093.70, -47.55, 45 Jul 02 12:40:05 volumio shairport-sync[17589]: 7.666311000 "player.c:954" Aliasing of buffer index -- reset. Jul 02 12:40:07 volumio shairport-sync[17589]: 1.809527000 "audio_alsa.c:1674" alsa: underrun while writing 352 samples to alsa device. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.021446000 "audio_alsa.c:1702" alsa: device status returns fault status -32 and SND_PCMSTATE 3 for play. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.010307000 "audio_alsa.c:1674" alsa: underrun while writing 352 samples to alsa device. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.024008000 "audio_alsa.c:1674" alsa: underrun while writing 352 samples to alsa device. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.016400000 "audio_alsa.c:1702" alsa: device status returns fault status -32 and SND_PCMSTATE 3 for play. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.003579000 "audio_alsa.c:1674" alsa: underrun while writing 352 samples to alsa device. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.020200000 "audio_alsa.c:1674" alsa: underrun while writing 352 samples to alsa device. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.032100000 "audio_alsa.c:1702" alsa: device status returns fault status -32 and SND_PCMSTATE 3 for play. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.002808000 "audio_alsa.c:1674" alsa: underrun while writing 352 samples to alsa device. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.067154000 "audio_alsa.c:1702" alsa: device status returns fault status -32 and SND_PCMSTATE 3 for play. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.002796000 "audio_alsa.c:1674" alsa: underrun while writing 352 samples to alsa device. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.015077000 "audio_alsa.c:1702" alsa: device status returns fault status -32 and SND_PCMSTATE* 3 for play. Jul 02 12:40:07 volumio shairport-sync[17589]: 0.004315000 "audio_alsa.c:1674" alsa: underrun while writing 352 samples to alsa device. Jul 02 12:40:08 volumio shairport-sync[17589]: 0.796903000 "player.c:2726" 0.00, 40120, 16, 0, 0, 0, 224, 1023, 44100.73, 44094.12, -48.72, 48 Jul 02 12:40:16 volumio shairport-sync[17589]: 8.006924000 "player.c:2726" 0.00, 41123, 16, 0, 0, 0, 222, 227, 44100.36, 44093.99, -48.50, 50 Jul 02 12:40:16 volumio shairport-sync[17589]: 0.003641000 "player.c:1969" Player has supplied a silent frame, (possibly frame 20509) for play number 41124, status 0x15 after 7 resend requests. Jul 02 12:40:16 volumio shairport-sync[17589]: 0.029811000 "player.c:1969" Player has supplied a silent frame, (possibly frame 20513) for play number 41128, status 0x15 after 7 resend requests.

manrand commented 3 years ago

I cannot send Mac system audio, for instance selecting "Volumio" as output device on the system audio panel. Only way to play audio from Mac seems to be from iTunes

About that issue in particular: after more tests apparently it was a firewall issue on the Mac.

You need to allow incoming connections to AirPlayXPCHelper or something similar. Actually I got the dialog only once and I don't find it listed anywhere, but I did allow it and now it works just fine. I do find a process called AirPlayXPCHelper (= /usr/libexec/AirPlayXPCHelper?)

I'm surprised that a source needs to allow incoming connections for this to work, while iTunes does not need this. Does anybody has a clue? Seems like a potential security issue.