Distorted Audio iPhone to macOS
Closed this issue · 3 comments
The problem
Hello openairplay community,
I'm trying to run airplay2-receiver on macOS 12.2.1.
Installed it like this:
brew install python3
brew install portaudio
virtualenv -p /usr/local/bin/python3 proto
source proto/bin/activate
pip install -r requirements.txt
pip install --global-option=build_ext --global-option="-I/usr/local/Cellar/portaudio/19.6.0/include" --global-option="-L/usr/local/Cellar/portaudio/19.6.0/lib" pyaudiopython ap2-receiver.py -m myap2 --netiface=en0
Managed to get it running, name shows up as "none" on my iPhone which seems weird but works.
Audio playback is distorted and jagged and breaks down after around 30s.
Any Ideas?
Thank you very much
Tiziano
[Receiver]: Name: None
[Receiver]: Enabled features: 0001c300405f4200
[Receiver]: FeatureFlags.Ft48TransientPairing|Ft47PeerManagement|Ft46HomeKitPairing|Ft41_PTPClock|Ft40BufferedAudio|Ft30UnifiedAdvertisingInfo|Ft22AudioUnencrypted|Ft20ReceiveAudioAAC_LC|Ft19ReceiveAudioALAC|Ft18ReceiveAudioPCM|Ft17AudioMetaTxtDAAP|Ft16AudioMetaProgress|Ft14MFiSoft_FairPlay|Ft09AirPlayAudio
[Receiver]: Interface: en0
[Receiver]: Mac: 24:4f:27:5c:8b:b2
[Receiver]: IPv4: 192.168.178.20
[Receiver]: IPv6: fe70::1c23:b1e4:3b9f:611d
[Receiver]:
[asyncio]: Using selector: KqueueSelector
[Receiver]: mDNS: service registered
[Receiver]: Starting RTSP server, press Ctrl-C to exit...
[Receiver]: serving on 192.168.178.20:7000
[AP2Server: 192.168.178.20:7000]: Opened connection from 192.168.178.21:50315
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: {'qualifier': ['txtAirPlay']}
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: Sending our device info
[AP2Server: 192.168.178.20:7000]: Thread-2: Opened HAPSocket from 192.168.178.21:50315
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SETUP: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]:
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: GET_PARAMETER: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: GET_PARAMETER: b'volume'
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: RECORD: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SETPEERS: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: ['192.168.178.20', '192.168.178.21', 'fe80::85f:6486:795a:c12b']
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SETUP: rtsp://192.168.178.20/6306729490375921051
[utils] removing StreamHandler from Audio.debug file logger
[Audio.debug] file logging level: DEBUG
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]:
[asyncio]: Using selector: KqueueSelector
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: b'progress' => b' 633735024/650449316/647859945'
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: FLUSH: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: DMAP:
dmap.persistentid: 0x49922e063b9651f0
daap.songalbum: Lonerism
daap.songartist: Tame Impala
dmap.itemname: Sun's Coming Up[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: DMAP:
dmap.persistentid: 0x49922e063b9651f0
daap.songalbum: Lonerism
daap.songartist: Tame Impala
dmap.itemname: Sun's Coming Up
dacp.playerstate: Playing[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: b'progress' => b' 637874142/650455300/651999063'
[AudioRealtime]: audioDevicelatency (sec): 0.00108
[AudioRealtime]: pyAudioDelay (sec): 0.00447
[AudioRealtime]: Total sample_delay (sec): 0.00755
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: b'volume' => b' -15.075000'
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: b'volume' => b' -16.950001'
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: rtsp://192.168.178.20/6306729490375921051
[AP2Handler: 192.168.178.20:7000<=>192.168.178.21:50315; Thread-2]: SET_PARAMETER: b'volume' => b' -18.825001'
[AudioRealtime]: requesting resend of sequence_no 47621; amt 7
[AudioRealtime]: requesting resend of sequence_no 47635; amt 7
[AudioRealtime]: requesting resend of sequence_no 49789; amt 2
Exception in thread Thread-2: (relative to self)
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/Users/tiziano/Downloads/airplay2-receiver-master/ap2/connections/audio.py", line 738, in play
pkt = RTP_REALTIME(data)
File "/Users/tiziano/Downloads/airplay2-receiver-master/ap2/connections/audio.py", line 123, in init
fbit = extra_hdr[0] & 0b10000000
IndexError: index out of range
[AudioRealtime]: requesting resend of sequence_no 49798; amt 1
[AudioRealtime]: requesting resend of sequence_no 49807; amt 7
What commit exhibits the issue?
master
Was there a last known working commit?
No response
What type of installation are you running?
virtualenv
With which python3 version do you run Receiver?
python3
OS the receiver runs on
macOS 12.2.1
OS the sender runs
iPhone iOS 13
Which sender client was used
Spotify
Command invocation
python ap2-receiver.py -m myap2 --netiface=en0
Please include --debug output which helps to illustrate the problem
No response
Additional information
No response
At last - a coherent bug report :)
I would hazard a guess that your WiFi channel is very noisy. real-time playback is most sensitive and susceptible to packet loss, which the log messages requesting resend
indicate. If it's possible to have your receiver device on a wired connection, many problems should disappear. People with noisy WiFi areas (built up residential blocks) might suffer, here.
What's weird is the trace-back indicates that you are in a code-path unreachable if you are not using a flag for audio redundancy, which is off by default. This suggests a corrupted packet arrived...? I will put packet handling within a try..except clause to improve things there.
You might also look in audio around line 520 for
audioDevicelatency = \
self.pa.get_default_output_device_info()['defaultLowOutputLatency']
and change to defaultHighOutputLatency
if any problems persist.
What is your router - and does it have WMM extensions on?
Curious also ios subversion.
@tiziano149: Have you seen the last comment of @systemcrash?