juhovh / shairplay

Apple airplay and raop protocol server
Other
1.35k stars 228 forks source link

iTunes doesn't recognize extra Shairplay instances coming from the same machine #13

Closed rubin110 closed 11 years ago

rubin110 commented 11 years ago

I've got shairplay running twice on one machine, streaming to two different audio devices and running on two different ports. Avahi lists out...

Sadly iTunes only displays the first instance and not the second. I'm guessing this is an issue with iTunes as there's no Apple hardware/software that I know of that runs multiple AirPlay "speakers" from a single device.

rubin110 commented 11 years ago

On iTunes 11, OSX 10.6.8.

juhovh commented 11 years ago

This is probably because the same hardware address is used for both shairplay instances. I should probably make this configurable...

If you want to experiment, you can compile two shairplay binaries and try to run them on the same machine and see if iTunes detects them correctly. The relevant part of the code is at src/shairplay.c:

    const char hwaddr[] = { 0x48, 0x5d, 0x60, 0x7c, 0xee, 0x22 };

My guess is that changing that hwaddr to anything else will make iTunes detect them as separate instances. If you can confirm this, I can commit a patch that makes it configurable.

rubin110 commented 11 years ago

I've gone through and build a new binary with a different hardware address. Sadly I've broken something else along the way and can't get the second instance to see my USB audio device. Would appreciate some documentation on how to address pulseaudio sinks. Thanks!

juhovh commented 11 years ago

Try starting with ./shairplay --ao_driver=pulse --ao_devicename=sinkname and replace the sinkname parameter with the sink you are using.

rubin110 commented 11 years ago

Still seeing Error opening audio device 5...

20130729-223217 rubin110@mime:~/temp/shairplay$ pactl list short 0 module-alsa-card device_id="0" name="pci-0000_00_1b.0" card_name="alsa_card.pci-0000_00_1b.0" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes card_properties="module-udev-detect.discovered=1" 1 module-alsa-card device_id="1" name="usb-0d8c_Generic_USB_Audio_Device-00-Device" card_name="alsa_card.usb-0d8c_Generic_USB_Audio_Device-00-Device" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes card_properties="module-udev-detect.discovered=1" 2 module-udev-detect 3 module-esound-protocol-unix 4 module-native-protocol-unix 5 module-stream-restore 6 module-device-restore 7 module-default-device-restore 8 module-dbus-protocol access=local 9 module-rescue-streams 10 module-always-sink 11 module-suspend-on-idle 12 module-position-event-sounds 13 module-esound-protocol-tcp auth-ip-acl=127.0.0.1;10.110.0.0/24 14 module-native-protocol-tcp auth-ip-acl=127.0.0.1;10.110.0.0/24 15 module-zeroconf-publish 0 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 1 alsa_output.usb-0d8c_Generic_USB_Audio_Device-00-Device.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 0 alsa_output.pci-0000_00_1b.0.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 1 alsa_input.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 2 alsa_output.usb-0d8c_Generic_USB_Audio_Device-00-Device.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 3 alsa_input.usb-0d8c_Generic_USB_Audio_Device-00-Device.analog-mono module-alsa-card.c s16le 1ch 44100Hz SUSPENDED 191 0 277 protocol-native.c s16le 2ch 44100Hz 200 1 303 protocol-native.c s16le 2ch 44100Hz 201 0 305 protocol-native.c s16le 2ch 44100Hz 128 3 302 protocol-native.c s16le 1ch 44100Hz 129 1 304 protocol-native.c s16le 2ch 44100Hz 277 protocol-native.c threaded-ml 302 protocol-native.c pulseaudio 303 protocol-native.c pulseaudio 304 protocol-native.c pulseaudio 305 protocol-native.c pulseaudio 306 protocol-native.c pactl 0 alsa_card.pci-0000_00_1b.0 module-alsa-card.c 1 alsa_card.usb-0d8c_Generic_USB_Audio_Device-00-Device module-alsa-card.c 20130729-223224 rubin110@mime:~/temp/shairplay$ shairplay --ao_driver=pulse --ao_devicename=pci-0000_00_1b.0 Error opening audio device 5 Please check your libao settings and try again 20130729-223244 rubin110@mime:~/temp/shairplay$ shairplay --ao_driver=pulse --ao_devicename=usb-0d8c_Generic_USB_Audio_Device-00-Device Error opening audio device 5 Please check your libao settings and try again 20130729-223308 rubin110@mime:~/temp/shairplay$ shairplay --ao_driver=pulse --ao_devicename=alsa_card.pci-0000_00_1b.0 Error opening audio device 5 Please check your libao settings and try again 20130729-223322 rubin110@mime:~/temp/shairplay$ shairplay --ao_driver=pulse --ao_devicename=alsa_card.usb-0d8c_Generic_USB_Audio_Device-00-Device Error opening audio device 5 Please check your libao settings and try again

juhovh commented 11 years ago

The number 5 in the error refers to AO_EOPENDEVICE which may happen with an error in the options or on actual opening of the device. I removed the hardcoded option "client_name", which might help. Please test this.

EBADBEEF commented 11 years ago

I can confirm changing hwaddr allows two shairplay instances to be seen. src/shairplay.c - const char hwaddr[] = { 0x48, 0x5d, 0x60, 0x7c, 0xee, 0x22 };

Without modifying hwaddr, only one instance shows up in iTunes. For the record, I changed 0x22 to 0x23.

juhovh commented 11 years ago

Do multiple pulseaudio sound cards work as well now? I just added a commit that makes hwaddr configurable, so you can start two instances with for example:

src/shairplay --hwaddr=48:5d:60:7c:ee:22 src/shairplay --hwaddr=48:5d:60:7c:ee:23

And they should show up as two different instances in iTunes. Thank you for your help in debugging and patience in fixing this issue.

EBADBEEF commented 11 years ago

Multiple pulseaudio outputs works. I used the syntax "--ao_driver=pulse --ao_devicename=0". According to http://www.xiph.org/ao/doc/drivers.html, pulse "dev" can be the sink number or name, so I used the number. As you mentioned before, 'pactl list short' is a good way to get a list of all sinks.

I also tested one pulse output and one alsa output, which worked as well.

Thanks!

juhovh commented 11 years ago

Ok, in that case I consider this issue resolved.