mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.29k stars 574 forks source link

HTC Connect AirPlay (U Play) - silence and cracks when playing #517

Closed sergiuburian closed 7 years ago

sergiuburian commented 7 years ago

First of all: Thanks for the great work here; I am using it (older version) with piCorePlayer since some time now. Thanks! I am trying to stream Amazon Music from my Android mobile to my stereo equipment avoiding bluetooth. As Amazon does not support DLNA or Chromecast in their app, I am trying to use AirPlay capabilities of the underlying HTC Android to achieve that , i.e. HTC Connect.

The problem is that the music gets silent for a couple of seconds every now and then, like every 15 -20 secs. It turns silent for 1-2 seconds, and then is audible again with a small crack. Please note that the players still plays on the device, so it is not a short stop of the stream, but a short silence. I have tried both piCorePlayer 3.20 with shairport-sync 2.8.6 as well as Volumio 2 with both packaged shairport-sync 2.4, as well as with the self compiled and upgraded 3.0.2(?). In all cases the same. As HW, I have tried both RPi 1 + HIFI Berry DAC and RPi2 (I thought more CPU would help) with on-board sound jack.

I am also trying with Apple devices (iPhone 5 with iOS 10.3.1: For Volumio 2 with shairport-play 2.4 it behaves the same, but if I use shairport-sync 2.8.6 or 3.0.2(?) - streaming from Apple works well.

Also, when trying with piCorePlayer, I have streamed FLAC via LMS Squeezebox server onto the device, no single issue. So I guess it is not a problem of network card (EDIMAX) or networking in general (the phenomenon happens also via LAN).

I assume, there is an incompatibility issue with HTC flavour of AirPlay. Any idea? Another problem that I have sometimes is the loss of volume control capabilities and a very low level which cannot be changed; however, not so much of a problem since I set the shairport-sync.conf to ignore the volume control, and it is then sounding loud.

Thanks a lot in advance,

Sergiu

mikebrady commented 7 years ago

Hi Sergiu, and thanks for the post. I'd suggest you stick with the latest Shairport Sync. If you go into the configuration file and turn off resynchronisation, does the problem go away? To turn off resync:

    resync_threshold_in_seconds = 0.0;

Remember to uncomment this line too!

sergiuburian commented 7 years ago

Here's the output from shairport-sync:

Output device name is "plughw:0,0".
Version: "3.0.2-OpenSSL-Avahi-ALSA-soxr-metadata-sysconfdir:/etc"
statistics_requester status is 0.
daemon status is 0.
rtsp listening port is 5000.
udp base port is 6001.
udp port range is 100.
Shairport Sync player name is "Volumio".
Audio Output name is "(null)".
on-start action is "/usr/bin/mpc stop".
on-stop action is "(null)".
wait-cmd status is 0.
mdns backend "(null)".
stuffing option is "1" (0-basic, 1-soxr).
resync time is 0.050000 seconds.
allow a session to be interrupted: 1.
busy timeout time is 120.
drift tolerance is 0.001995 seconds.
password is "(null)".
ignore_volume_control is 1.
volume_max_db is not set
playback_mode is 0 (0-stereo, 1-mono, 1-reverse_stereo, 2-both_left, 3-both_right).
disable_synchronization is 0.
use_mmap_if_available is 1.
output_rate is 44100.
output_format is 3 (0-unknown, 1-S8, 2-U8, 3-S16, 4-S24, 5-S24_3LE, 6-S24_3BE, 7-S32).
audio backend desired buffer length is 0.150000 seconds.
audio backend latency offset is 0.000000 seconds.
volume range in dB (zero means use the range specified by the mixer): 0.
zeroconf regtype is "_raop._tcp".
decoders_supported field is 1.
use_apple_decoder is 0.
no special mdns service interface was requested.
configuration file name "/etc/shairport-sync.conf" resolves to "/etc/shairport-sync.conf".
metdata enabled is 0.
metadata pipename is "(null)".
metadata socket address is "(null)" port 0.
metadata socket packet size is "500".
get-coverart is 0.
Successful Startup
avahi: avahi_register.
avahi: register_service.
avahi: request to add "_raop._tcp" service without metadata
avahi: service '04255CB411F0@Volumio' successfully added.
 New RTSP connection from 192.168.178.117:47351 to self at 192.168.178.55:5000.
Play connection from user agent "iTunes/10.6 (Macintosh; Intel Mac OS X 10.7.3) AppleWebKit/535.18.5".
Active-Remote string seen: "1986535575".
DACP-ID string seen: "56B29BB6CB904862".
Set up play connection from 192.168.178.117 to self at 192.168.178.55.
Output sample ratio is 1.
Output frame bytes is 4.
Output bit depth is 16.
volume: 97%   repeat: off   random: off   single: off   consume: off
Hammerton Decoder used on unencrypted audio.
Output sample ratio is 1
Output written using MMAP
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Lost sync with source for 4 consecutive packets -- flushing and resyncing. Error: -2319.
Output sample ratio is 1
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -32 writing 353 samples in play(): "Broken pipe".
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
Error -- ALSA device in incorrect state (4) for play.
mikebrady commented 7 years ago

Hmm, I notice that it's not outputting to a real hardware device, instead to a virtual device, which might be causing problems. Also, what happens if you make that setting change?

sergiuburian commented 7 years ago

Just seen your comment, after I have posted the log. I have changed this setting right now as you suggested. Will let it run and let you know.

Thanks,

Sergiu

mikebrady commented 7 years ago

Thanks!

sergiuburian commented 7 years ago

For Info: The log above is with RPi 2, the on-board sound card, with the Volumio 2 config and WiFi Edimax.

sergiuburian commented 7 years ago

These are the moments when I miss a live chat function in GitHub :) Thanks for spending so much time with my post ;)

mikebrady commented 7 years ago

Indeed. Lots of people are using Shairport Sync with Volume, so I guess I wouldn't be in a hurry to change the plughw setting. But the resync setting should be interesting.

sergiuburian commented 7 years ago

It works! Thanks a lot!

It works both with Shairport-sync 3.0.2 on RPi2 with on-board sound, Edimax WiFi and Volumio2, as well as with Shairport-sync 2.8.6 on RPi1 with HiFiBerry DAC, Edimax WiFi and piCorePlayer 3.20. I have also tested what happens if I stream alternatively from iPhone 5 iOS 10.3.1 and with HTC U Play Android 6 via HTC Connect. It works!!! I can see a delay in reaction (play, stop), but this does not bother me personally at all. Here's the config I have used for the RPi1 based setup, as this is my preferred one (please be aware that piCorePlayer package also specifies some params as command line, but I have replicated them here as well):

general = { name = "%H"; interpolation = "soxr"; output_backend = "alsa"; resync_threshold = 0; ignore_volume_control = "yes"; };

alsa =
{
output_device = "hw:CARD=sndrpihifiberry"; audio_backend_buffer_desired_length = 44100; disable_synchronization = "yes"; };

A big thank you!!!! Now I can enjoy both my FLAC collection (via Squeezelite) as well as Amazon Music (via AirPlay) on my HiFi, controlled from a single HTC U Play mobile device.

Sergiu

mikebrady commented 7 years ago

I'm glad it's worked out for you.