music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.39k stars 51 forks source link

Audio Drops While Streaming via UPnP from Raspberry Pi 5 to Arcam AVR390 #2791

Closed Argeento closed 2 months ago

Argeento commented 2 months ago

What version of Music Assistant has the issue?

2.3.0b2

What version of the Home Assistant Integration have you got installed?

No response

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

I am experiencing an issue while streaming audio using UPnP from my Raspberry Pi 5 to my Arcam AVR390. The audio intermittently cuts out, although the playback in the UI continues to show as playing.

Details:

Troubleshooting Attempts:

How to reproduce

I am unable to provide a specific set of steps to reliably reproduce this issue.

Music Providers

Player Providers

I have only used the UPnP/DLNA Player provider, which results in the issue described. I am not using grouped players.

Full log output

The logs are empty during the occurrence of the issue. No relevant entries are generated at the time of the audio dropouts.

Additional information

No response

What version of Home Assistant Core are your running

2024.8.2

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Raspberry Pi

marcelveldt commented 2 months ago

Sounds like a buffering issue.

A couple of questions:

1) Did you also test with enforcing MA to transcode into MP3 ? Maybe the high quality FLAC stream MA sends by default is just enough to hit some bandwidth issue.

2) Does the Arcam also support other protocols like Airplay ?

3) Does the issue happen regardless of source ? So both with radio streams and e.g. Tidal or local tracks ?

4) Does the audio just stutter/hiccup and then continues or does it stop and just become silent ?

Argeento commented 2 months ago

@marcelveldt Thank you for your suggestions. Here are my answers:

  1. I tried transcoding to MP3, but in this case, the Arcam does not play any audio at all.
  2. The Arcam only supports UPnP.
  3. Yes, the issue occurs regardless of the source - whether it’s local files, radio streams, or Tidal.
  4. The audio suddenly stops and does not resume on its own (I waited about 15 minutes).

Additionally, today I installed Home Assistant + Music Assistant on my old Raspberry Pi 3b. I went to a friend who also has an Arcam AVR390 to test whether the issue is specific to my unit. Unfortunately, the same problem occurs at my friend's place.

marcelveldt commented 2 months ago

So most likely this player can't deal with our chunked audio stream with no size specified, I've heard about that. You'd be surprised to hear that multi thousand dollar streamers/receivers have 25 year old HTTP1 implementation omboard, its awful. Anyways, I will add a few options to the DLNA settings so you can select a profile for your device so we can test some options

Argeento commented 2 months ago

@marcelveldt Thanks!

Also.. After switching log level to debug, I think I found some relevant logs, especially this line:

2024-08-24 12:56:48.015 DEBUG (MainThread) [music_assistant.dlna] Device unavailable: UpnpCommunicationError('ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message=\'Not enough data for satisfy transfer length header.\'>. ConnectionResetError(104, \'Connection reset by peer\')")', None)
marcelveldt commented 2 months ago

I have published a beta version of the MA server which includes some fine grained control over the HTTP streaming. Within the player settings, go to the advanced section and try the HTTP Profiles one by one, starting with the default chunked one.

Available in 2.3.0 beta 4 and above

OzGav commented 2 months ago

@Argeento this will be closed soon assuming fixed due to no followup

Argeento commented 2 months ago

I've checked every HTTP Profile - the issue still occurs. I'll provide MA logs this week

Argeento commented 2 months ago

@marcelveldt logs:

I found some info about my Arcam requesting its IP (maybe some of these will be helpful)

marcelveldt commented 2 months ago

Without actual access to the device I'm afraid there is nothing I can do here. DLNA is a shitty protocol with shitty implementations by manufacturers that don't give a crap about standards/interoperability. Therefore I do not provide any support for DLNA other than best effort and if you may run into issues you'll have to submit a PR yourself.

Foobar2000 is an application that exists for 2 decades already and has all kind of special device-specific treatments. In this case making this work would involve comparing wireshark traces of what foobar is sending against what MA sends, its that awful.

The best advise I can give in this situation is to use a streaming protocol other than DLNA. For example hook up a raspberry pi or esp32 board running squeezelite (slimproto), airplay or snapcast which also gives you the benefit of synced playback. Or a less-DIY and better sounding option is something like a Wiim Pro Plus, Sonos Port or Bluesound Node. Anything other than crappy DLNA with all its quirks.

Don't get me wrong, we also have success stories with DLNA where people are incredible happy with it but looks like you are on the less lucky side.

Argeento commented 2 months ago

Thanks for taking the time to explain everything. I understand that the issue is likely due to DLNA limitations with my arcam.

I really appreciate your insights and the suggestions for other streaming options 🚀

I’m fine with closing this issue. Thanks again for your support!