No audio over AirTunes (AirPlay w/ video works)

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
dirzys Offline
Junior Member
Posts: 3
Joined: Aug 2012
Reputation: 0
Post: #1
Hi guys,

I have a raspberry pi, with installed:
Code:
XBMC 12.0-ALPHA4
OpenELEC Version: devel-20120802201339-r11708
OpenELEC git: 76dd7bf53c7ae40a7c8e2ca289c7a4579664a672


And I can't hear any sound when I AirTune music. It doesn't work neither from iPhone nor from iTunes. Though AirPlay video (w/ sound) works without bigger problems.

I tried to look into the xbmc.log, and that's what I found:
Code:
23:49:10 T:1184887904   DEBUG: CecLogMessage - transmitting delayed activate source command
23:49:10 T:1184887904   DEBUG: CecLogMessage - << 10:04
23:49:10 T:1184887904   DEBUG: CecLogMessage - sending data: len = 1, payload = 10:04
23:49:10 T:1139700832   DEBUG: CecLogMessage - received data: header:01020001 p0:00000410 p1:00000000 p2:00000000 p3:00000000 reason:1
23:49:10 T:1184887904   DEBUG: CecLogMessage - command 'image view on' was not acked by the controller
23:49:10 T:1184887904   DEBUG: CecLogMessage - << 10:04
23:49:10 T:1184887904   DEBUG: CecLogMessage - sending data: len = 1, payload = 10:04
23:49:10 T:1139700832   DEBUG: CecLogMessage - received data: header:01020001 p0:00000410 p1:00000000 p2:00000000 p3:00000000 reason:1
23:49:11 T:1184887904   DEBUG: CecLogMessage - command 'image view on' was not acked by the controller
23:49:11 T:1184887904   DEBUG: CecLogMessage - failed to make 'Recorder 1' the active source. will retry later

Please for advice, if anyone knows how to make AirTunes working.

PS.: AirTune works when I stream music from my iPhone to XBMC installed on my Mac. So it shouldn't be my iPhones problem.
find quote
Memphiz Offline
Kodi MVP
Posts: 16,020
Joined: Feb 2011
Reputation: 225
Location: germany
Post: #2
post a full debug log to pastebin and put the link here. These cec messages are unrelated to airtunes.

AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
find quote
dirzys Offline
Junior Member
Posts: 3
Joined: Aug 2012
Reputation: 0
Post: #3
Here is the xbmc.log

http://pastebin.com/0j7zdUAK

Please let me know if you need more information.
find quote
Memphiz Offline
Kodi MVP
Posts: 16,020
Joined: Feb 2011
Reputation: 225
Location: germany
Post: #4
Its fixed in mainline. Whenever openelec updates its sources the problem should be solved. thx to gimli

AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
find quote
ribbon10 Offline
Junior Member
Posts: 5
Joined: Oct 2012
Reputation: 0
Post: #5
Long time since last post here. But AirTunes/AirPlay music support is still broken with openelec. Last build i tested was with xbmc-frodo-35d401b source.
At least there are 2 problems at the moment with a OpenELEC build.
  1. They apply libshairport 09_fix_ipv6.patch on rpi. This will break AirTunes server from opening the server port.
  2. They try to open the stream with OMXPlayer available (I do not know if PAPlayer will work also on rpi. But they use OMXPlayer for everything, music and video.). But AirTunesServer delivers data with mime/type audio/x-xbmc-pcm and OMXPlayer (to be more precise the demuxer it uses) doesn't know what to do with this.
If thats is really true, for me, both problems should be fixed within xbmc.

There is a git branch available that also discovered the problem and begun to fix these 2 issues. https://github.com/NikNakk/xbmc-rbp.git . But music is not playing well there.
So here is a adapted patch for the demuxer problem. It is ugly, but it works on rpi. Sure that a xbmc expert can do better work ;-) . I am just a beginner... .

Code:
From 87f88669ebc0a38c25d273b28956343ef78da909 Mon Sep 17 00:00:00 2001
From: ribbon10 <ribbon10>
Date: Thu, 4 Oct 2012 20:49:06 +0200
Subject: [PATCH] adaptions so that "audio/x-xbmc-pcm" can also be played in
OMXPlayer what is generated by AirTunesServer. This should
also make DVDPlayer capable of playing AirTunes music
streams.

---
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
index 7c0ab03..6c7c012 100644
--- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -394,6 +394,8 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
           iformat = m_dllAvFormat.av_find_input_format("flv");
         else if( content.compare("video/x-flv") == 0 )
           iformat = m_dllAvFormat.av_find_input_format("flv");
+        else if( content.compare("audio/x-xbmc-pcm") == 0 )
+          iformat = m_dllAvFormat.av_find_input_format("s16le");
       }

       if (!iformat)
@@ -954,6 +956,12 @@ void CDVDDemuxFFmpeg::AddStream(int iId)
       {
         CDemuxStreamAudioFFmpeg* st = new CDemuxStreamAudioFFmpeg(this, pStream);
         m_streams[iId] = st;
+        // adaptions an Airtunes
+        if( m_pInput->GetContent().compare("audio/x-xbmc-pcm") == 0 ) {
+          pStream->codec->channels = 2; // 2 channels
+          pStream->codec->sample_rate = 44100; // sample rate 44.1kHz
+          pStream->codec->bits_per_coded_sample = 16; // 16 Bit
+        }
         st->iChannels = pStream->codec->channels;
         st->iSampleRate = pStream->codec->sample_rate;
         st->iBlockAlign = pStream->codec->block_align;
--
1.7.11.1

Another idea could be to adapt the AirTunesServer so that it delivers the ALAC stream. Perhaps FFmpeg can demux this without the adaption in DVDDemuxFFmpeg.
find quote
gimli Offline
Team-XBMC Developer
Posts: 445
Joined: Jun 2009
Reputation: 9
Post: #6
The patch is the wrong aproach. I have something better Big Grin

https://github.com/huceke/xbmc/commits/bxa
(This post was last modified: 2012-10-05 22:40 by gimli.)
find quote
ribbon10 Offline
Junior Member
Posts: 5
Joined: Oct 2012
Reputation: 0
Post: #7
Mh, what should i write...

Oh YEAH!!!!

Going to test this immediately.
find quote
ribbon10 Offline
Junior Member
Posts: 5
Joined: Oct 2012
Reputation: 0
Post: #8
i have tested the new demuxer and can confirm that it is doing very well. i am very happy now.

it is a really clever and cool way. all stream info is read from bxa header and the demuxer is small and simple.

thanks! learned a lot about xbmc on this little journey.
find quote
Memphiz Offline
Kodi MVP
Posts: 16,020
Joined: Feb 2011
Reputation: 225
Location: germany
Post: #9
Well done Gimli Smile

AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
find quote
PeteUKinUSA Offline
Junior Member
Posts: 6
Joined: Oct 2012
Reputation: 0
Post: #10
+10 cool points to Gimli. I pulled the latest from Git, added the above patch and files and it works like a champ. Can't thank you enough.
find quote
gimli Offline
Team-XBMC Developer
Posts: 445
Joined: Jun 2009
Reputation: 9
Post: #11
AirTunes support for the PI is now in master.
find quote
ribbon10 Offline
Junior Member
Posts: 5
Joined: Oct 2012
Reputation: 0
Post: #12
Once again thanks for the Demuxer. But the libshairport problem with the ipv6 patch is still present. This is not part of xbmc itself but the patch is deliverd in the xbmc sources.

So the problem occures on machines that have AF_INET6 defined during compilation but IPv6 is not available on runtime. Here are the relavant xbmc.log entries with a little bit extra enabled debug output. It was captured on an OpenELEC build that have the above preconditions. What should be the default at the moment.

Code:
root ~ # cat .xbmc/temp/xbmc.log | grep AIR
20:07:04 T:1075663376    INFO: AIRPLAY Server: Successfully initialized
20:07:04 T:1075663376   DEBUG: AIRTUNES: initializing shairport
20:07:04 T:1075663376   DEBUG: AIRTUNES: LogLevel: 0
20:07:04 T:1075663376   DEBUG: AIRTUNES: AirName: ShairPort
20:07:04 T:1075663376   DEBUG: AIRTUNES: HWID: '????
20:07:04 T:1075663376   DEBUG: AIRTUNES: HWID_Hex(12): XXXXXXXXXXXX
20:07:04 T:1075663376   DEBUG: AIRTUNES: Starting connection server: specified server port: 36666
20:07:04 T:1075663376   DEBUG: AIRTUNES: Listening on IPv6 Socket
20:07:04 T:1075663376   DEBUG: AIRTUNES: Failed to create ipv6 socket. Trying ipv4
20:07:04 T:1075663376   DEBUG: AIRTUNES: Error: Could not bind socket
20:07:04 T:1075663376   DEBUG: AIRTUNES: Error setting up server socket on port 36666, try specifying a different port

Have made a minimal invasive patch that fixes the problem. But I am not happy with the libshairport src/socketlib.c code at all.
The patch is a a little bit hard to read because it is a patch for the ipv6 patch.

Code:
From ea7356a62cac8f232d1043e055c8dd857f7eaa99 Mon Sep 17 00:00:00 2001
From: ribbon10 <ribbon10>
Date: Sun, 7 Oct 2012 21:53:26 +0200
Subject: [PATCH] libshairport server now starts on system where ipv4 is
enabled on compile time but not on runtime.

---
tools/rbp/depends/libshairport/009_fix_ipv6.patch | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/rbp/depends/libshairport/009_fix_ipv6.patch b/tools/rbp/depends/libshairport/009_fix_ipv6.patch
index 01ff026..a728718 100644
--- a/tools/rbp/depends/libshairport/009_fix_ipv6.patch
+++ b/tools/rbp/depends/libshairport/009_fix_ipv6.patch
@@ -1,5 +1,5 @@
---- src/socketlib.c    2012-01-04 20:41:05.000000000 +0100
-+++ src/socketlib.c    2012-01-04 20:35:53.000000000 +0100
+--- src/socketlib.c    2012-10-07 21:20:09.000000000 +0200
++++ src/socketlib.c    2012-10-07 21:47:37.000000000 +0200
@@ -48,7 +48,7 @@
    if((tSock==-1) && (pAddrInfo->ai_family == AF_INET6) && (errno == EAFNOSUPPORT))
    {
@@ -9,7 +9,15 @@
      pAddrInfo->ai_family = AF_INET;
      tSock = socket(pAddrInfo->ai_family, pAddrInfo->ai_socktype, 0);
    }
-@@ -158,8 +158,8 @@
+@@ -118,6 +118,7 @@
+
+   int tEnable = 1;
+   setsockopt(tSock, SOL_SOCKET, SO_REUSEADDR, &tEnable, sizeof (tEnable));
++  server_addr->ai_addr->sa_family = server_addr->ai_family; // ensure that server_addr has same famliy than the socket
+   if (bind(tSock, server_addr->ai_addr, server_addr->ai_addrlen) < 0)
+   {
+     close(tSock);
+@@ -158,8 +159,8 @@
      sprintf(tService, "%d", pPort); // copies port to string
      int tFamily = AF_INET;
      #ifdef AF_INET6
--
1.7.11.1
(This post was last modified: 2012-10-07 22:08 by ribbon10.)
find quote
Memphiz Offline
Kodi MVP
Posts: 16,020
Joined: Feb 2011
Reputation: 225
Location: germany
Post: #13
We are not happy with libshairports code aswell - but thats what we got for supporting airtunes. We want to switch over to libshairplay after frodo and moving all the airplaycode to an addon aswell. Until then i will try to remember to test and add your patch before frodo.

thx

AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
find quote
sraue Offline
Team-XBMC Developer
Posts: 997
Joined: Oct 2009
Reputation: 16
Location: Switzerland, Solothurn
Post: #14
(2012-10-04 21:18)ribbon10 Wrote:  Long time since last post here. But AirTunes/AirPlay music support is still broken with openelec. Last build i tested was with xbmc-frodo-35d401b source.

(2012-10-07 08:01)PeteUKinUSA Wrote:  +10 cool points to Gimli. I pulled the latest from Git, added the above patch and files and it works like a champ. Can't thank you enough.

(2012-10-07 09:17)gimli Wrote:  AirTunes support for the PI is now in master.

updated in OpenELEC r12055, see:
http://forum.xbmc.org/showthread.php?tid...pid1208536

greetings, Stephan

[Image: userbar-openelec-001.gif]
[Image: project_thin_badge.gif]
find quote
Memphiz Offline
Kodi MVP
Posts: 16,020
Joined: Feb 2011
Reputation: 225
Location: germany
Post: #15
@ribbon10

Patch can be watched here https://github.com/xbmc/xbmc/pull/1573

thx again. (though i didn't test because everything is ipv6 enabled here - at least it didn't break it. But i just try to trust in you that you have verified it. Well once in a time i try to trust Wink ).

AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
find quote
Post Reply