diff --git a/src/outputs.c b/src/outputs.c index ab12921c..455edb83 100644 --- a/src/outputs.c +++ b/src/outputs.c @@ -703,6 +703,21 @@ outputs_device_add(struct output_device *add, bool new_deselect) break; } + // This is relevant for Airplay 1 and 2 where the same device can support both + if (device && device->type != add->type) + { + if (outputs_priority(device) < outputs_priority(add)) + { + DPRINTF(E_DBG, L_PLAYER, "Ignoring type %s for device '%s', will use type %s\n", add->type_name, add->name, device->type_name); + outputs_device_free(add); + return NULL; + } + + // Remove existing device, higher priority device will be added below + outputs_device_remove(device); + device = NULL; + } + // New device if (!device) { diff --git a/src/outputs.h b/src/outputs.h index 9a9f8a53..9a534098 100644 --- a/src/outputs.h +++ b/src/outputs.h @@ -195,7 +195,9 @@ struct output_definition // Type of output enum output_types type; - // Priority to give this output when autoselecting an output, 1 is highest + // Priority to give this output when autoselecting an output, or when + // selectinga which output definition to use for a device that has multiple, + // e.g. AirPlay 1 and 2. // 1 = highest priority, 0 = don't autoselect int priority; @@ -285,7 +287,7 @@ outputs_cb(int callback_id, uint64_t device_id, enum output_device_state); // Ownership of *add is transferred, so don't address after calling. Instead you // can address the return value (which is not the same if the device was already -// in the list. +// in the list). struct output_device * outputs_device_add(struct output_device *add, bool new_deselect); diff --git a/src/outputs/airplay.c b/src/outputs/airplay.c index c4d8baa1..c86de8fb 100644 --- a/src/outputs/airplay.c +++ b/src/outputs/airplay.c @@ -2690,22 +2690,6 @@ Bit Value Type 31 0x80000000 AAC-ELD/44100/1 32 0x100000000 AAC-ELD/48000/1 */ - - -// {'streams': [{'audioFormat': 262144, -// 'audioMode': 'default', -// 'controlPort': 60242, -// 'ct': 2, -// 'isMedia': True, -// 'latencyMax': 88200, -// 'latencyMin': 11025, -// 'shk': b'\xdbc\x9b,\xdb\x15\x82\x19\x0b\xbf\xd3\xd0\x81\xc5\x7f7' -// b'\xaf\x7f\xb2l\xec\xca\xc8\xd0\x8d\x9d\x1d\xa8' -// b'\xda\xa2\xf7\xd0', -// 'spf': 352, -// 'supportsDynamicStreamID': True, -// 'type': 96}]} - static int payload_make_setup_stream(struct evrtsp_request *req, struct airplay_session *rs, void *arg) { @@ -4409,7 +4393,7 @@ struct output_definition output_airplay = { .name = "AirPlay 2", .type = OUTPUT_TYPE_AIRPLAY, - .priority = 1, + .priority = 2, // AirPlay 1 has priority for the time being .disabled = 0, .init = airplay_init, .deinit = airplay_deinit,