owntone / owntone-server

Linux/FreeBSD DAAP (iTunes) and MPD audio server with support for AirPlay 1 and 2 speakers (multiroom), Apple Remote (and compatibles), Chromecast, Spotify and internet radio.
https://owntone.github.io/owntone-server
GNU General Public License v2.0
2.09k stars 237 forks source link

Airplay crashes XBMC clients #18

Closed bosel closed 10 years ago

bosel commented 10 years ago

Selecting an XBMC client as airplay target using IOS7 apple remote immediately crashes the client. Using remote with iTunes library does work as expected.

Please find some info below, and let me know if you need anything else.

Tested with: XBMC 12.3 and 13 beta 2 ubuntu 12.04 and osx 10.9.2 libshairport1 1:1.2.1~git20121216 forked-daapd 708b76ce1e5ab793c94ed52817ff9e175f871044

Mar 25 20:10:41 server kernel: [246712.610271] AirTunesServer[17173]: segfault at c ip 04962ea2 sp a9bf7c30 error 4 in libGL.so.331.49[4925000+d4000]

[2014-03-24 23:09:22] dacp: DACP request: /ctrl-int/1/setspeakers?speaker-id=0x2608dc94ea&session-id=100 [2014-03-24 23:09:22] dacp: Speaker id converted with ret 0, param 0x2608dc94ea, dec val 163357431018. [2014-03-24 23:09:22] player: Speaker set: 1 speakers [2014-03-24 23:09:22] player: Set 163357431018 device 163357431018 [2014-03-24 23:09:22] player: RAOP device XBMC (bo-mbp.lan) selected [2014-03-24 23:09:22] player: Activating RAOP device XBMC (bo-mbp.lan) [2014-03-24 23:09:22] raop: Building OPTIONS for XBMC (bo-mbp.lan) [2014-03-24 23:09:22] player: Set 163357431018 device 36074247548851 [2014-03-24 23:09:22] player: RAOP device XBMC (server) NOT selected [2014-03-24 23:09:22] player: Local audio NOT selected [2014-03-24 23:09:22] player: Deactivating local audio [2014-03-24 23:09:22] player: Local audio stopping [2014-03-24 23:09:23] raop: Local address: 192.168.178.2 (LL: no) port 53875 [2014-03-24 23:09:23] raop: Building ANNOUNCE for XBMC (bo-mbp.lan) [2014-03-24 23:09:23] raop: No CSeq in reply, skipping check [2014-03-24 23:09:23] raop: Building SETUP for XBMC (bo-mbp.lan) [2014-03-24 23:09:23] raop: token: unicast [2014-03-24 23:09:23] raop: token: interleaved [2014-03-24 23:09:23] raop: token: 0-1 [2014-03-24 23:09:23] raop: token: mode [2014-03-24 23:09:23] raop: token: record [2014-03-24 23:09:23] raop: token: control_port [2014-03-24 23:09:23] raop: token: timing_port [2014-03-24 23:09:23] raop: token: server_port [2014-03-24 23:09:23] raop: Negotiated AirTunes v2 UDP streaming session DEADBEEF; ports s=6000 c=57237 t=46572 [2014-03-24 23:09:23] raop: Building RECORD for XBMC (bo-mbp.lan) [2014-03-24 23:09:23] raop: RECORD reply from XBMC (bo-mbp.lan) did not have an Audio-Latency header [2014-03-24 23:09:23] raop: Setting max_volume for device XBMC (bo-mbp.lan) to 11 [2014-03-24 23:09:23] raop: Building SET_PARAMETER for XBMC (bo-mbp.lan) [2014-03-24 23:09:23] raop: Building SET_PARAMETER for XBMC (bo-mbp.lan) [2014-03-24 23:09:23] raop: Building SET_PARAMETER for XBMC (bo-mbp.lan) [2014-03-24 23:09:23] httpd: Found query string [2014-03-24 23:09:23] dacp: DACP request: /ctrl-int/1/getspeakers?session-id=100 [2014-03-24 23:09:23] httpd: Found query string [2014-03-24 23:09:23] dacp: DACP request: /ctrl-int/1/getproperty?properties=dmcp.volume&session-id=100 [2014-03-24 23:09:23] player: Player status: playing [2014-03-24 23:09:23] db: Running query 'SELECT f.* FROM files f WHERE f.id = 4346;' [2014-03-24 23:09:26] raop: ApEx XBMC (bo-mbp.lan) closed RTSP connection [2014-03-24 23:09:26] raop: Cleaning up failed session (deferred) on device XBMC (bo-mbp.lan) [2014-03-24 23:09:26] player: AirPlay device XBMC (bo-mbp.lan) FAILED [2014-03-24 23:09:27] mdns: Avahi Browser: REMOVE service '002608DC94EA@XBMC (bo-mbp.lan)' type '_raop._tcp' proto 1 [2014-03-24 23:09:27] player: Event for AirPlay device 2608dc94ea/XBMC (bo-mbp.lan) (-1) [2014-03-24 23:09:27] mdns: Avahi Browser: REMOVE service '002608DC94EA@XBMC (bo-mbp.lan)' type '_raop._tcp' proto 0 [2014-03-24 23:09:27] player: Event for AirPlay device 2608dc94ea/XBMC (bo-mbp.lan) (-1) [2014-03-24 23:09:27] player: Removing AirPlay device XBMC (bo-mbp.lan); stopped advertising [2014-03-24 23:09:27] db: Running query 'INSERT OR REPLACE INTO speakers (id, selected, volume) VALUES (163357431018, 0, -1);' [2014-03-24 23:09:30] httpd: Found query string [2014-03-24 23:09:30] dacp: DACP request: /ctrl-int/1/getproperty?properties=dacp.playerstate,dacp.nowplaying,dacp.playingtime,dmcp.volume,dacp.volumecontrollable,dacp.availableshufflestates,dacp.availablerepeatstates,dacp.shufflestate,dacp.repeatstate,dacp.fullscreenenabled,dacp.fullscreen,dacp.visualizerenabled,dacp.visualizer,com.apple.itunes.itms-songid,com.apple.itunes.has-chapter-data,com.apple.itunes.mediakind,com.apple.itunes.extended-media-kind&session-id=100 [2014-03-24 23:09:30] player: Player status: playing [2014-03-24 23:09:30] db: Running query 'SELECT f.* FROM files f WHERE f.id = 4346;' [2014-03-24 23:10:00] httpd: Found query string [2014-03-24 23:10:00] dacp: DACP request: /ctrl-int/1/getproperty?properties=dacp.playerstate,dacp.nowplaying,dacp.playingtime,dmcp.volume,dacp.volumecontrollable,dacp.availableshufflestates,dacp.availablerepeatstates,dacp.shufflestate,dacp.repeatstate,dacp.fullscreenenabled,dacp.fullscreen,dacp.visualizerenabled,dacp.visualizer,com.apple.itunes.itms-songid,com.apple.itunes.has-chapter-data,com.apple.itunes.mediakind,com.apple.itunes.extended-media-kind&session-id=100 [2014-03-24 23:10:00] player: Player status: playing [2014-03-24 23:10:00] db: Running query 'SELECT f.* FROM files f WHERE f.id = 4346;'

ejurgensen commented 10 years ago

I'll be happy to adjust forked-daapd to prevent this, but as the xmbc client is just crashing without any error messages there's not a lot to go on. I'm afraid I'm not up to the task of debugging their client. Maybe you can run it in Valgrind and try to find out what is it causing the crash? Or maybe just submit the problem to their devs, so they can at least add some error handling.

Memphiz commented 10 years ago

we don't have any airplay clients in xbmc ... only servers ... what is this about for god sake?

bosel commented 10 years ago

Just thought i'd link the xbmc thread http://forum.xbmc.org/showthread.php?tid=190550 (behaviour not reproducible, might be a problem on my end).

bosel commented 10 years ago

It seems XBMC devs are out of ideas, would you perhaps be able to find something in the attached crash logs?

http://pastebin.com/7VKHdXkt - osx http://pastebin.com/bFPcnN9P- ubuntu 12.04 http://pastebin.com/7u8ZUbhy - second ubuntu box (with stack trace)

Memphiz commented 10 years ago

try taking it to https://github.com/juhovh/shairplay - maybe - the crash is in that 3rd party lib ...

ejurgensen commented 10 years ago

I think I've found the problem and a solution. It seems the version of libshairport that XBMC uses wants the stream to be encrypted, but forked-daapd's default is no encryption for unknown devices. However, a non-encrypted stream crashes libshairport and XBMC. Newer versions of Shairport accept non-encrypted streams.

Encrypting the stream for xbmc is easy, and I'll add it as soon as possible.

Memphiz commented 10 years ago

if you might be able to point me to the relevant change/commit in libshairplay to allow unencrypted streams i can backport the change into xbmc - though i am still wondering that the problem doesn't happen on my test system...

ejurgensen commented 10 years ago

I looked at the newer versions of Shairport, and I was wrong, these versions don't accept non-encrypted either. But because of a slight difference in how they announce themselves and how XBMC's libshairport announces itself, Shairport was getting an encrypted stream whereas XBMC was not.

I've made a fix of that in this branch: https://github.com/ejurgensen/forked-daapd/tree/dev

With this fix I am able to start playback, but there are some remaining issues. Among other things music was choppy and the buffer became huge. EDIT: These issues were with Frodo 12.2 on Apple TV. Just tried Gotham 13.0 on Windows, and it worked much better. Haven't tried on Linux yet.

ejurgensen commented 10 years ago

I'm closing this issue as I've included the fix in the master branch now.

After upgrading my Apple TV to Gotham 13.0 I have music playback working there too. There are perhaps still some remaining issues: artwork and playtime seemed to not be updated, and the music control interface didn't work (as xbmc/libshairport probably does not support dacp, I guess).

bosel commented 10 years ago

Just compiled master, and I no longer experience crashes (it just starts muted). Just wanted to drop a note to say thanks.