From 29ca32256da427696e8a55f54e44ba47107aa2b4 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Wed, 22 Feb 2023 13:01:29 +0000 Subject: [PATCH 1/3] Ensure that the PTP clock is restarted on seconds and subsequent plays on the same connection. --- rtsp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rtsp.c b/rtsp.c index ed67c581..f53bd351 100644 --- a/rtsp.c +++ b/rtsp.c @@ -2028,7 +2028,7 @@ void handle_setrateanchori(rtsp_conn_info *conn, rtsp_message *req, rtsp_message pthread_cleanup_push(mutex_unlock, &conn->flush_mutex); conn->ap2_rate = rate; if ((rate & 1) != 0) { - ptp_send_control_message_string("B"); // signify play is "B"eginning or resuming + ptp_send_control_message_string("B"); // signify clock dependability period is "B"eginning (or resuming) debug(2, "Connection %d: Start playing, with anchor clock %" PRIx64 ".", conn->connection_number, conn->networkTimeTimelineID); activity_monitor_signify_activity(1); @@ -2963,7 +2963,6 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) // if it's a full service PTP stream, we get groupUUID, groupContainsGroupLeader and // timingPeerList if (conn->airplay_stream_category == ptp_stream) { - ptp_send_control_message_string("B"); // signify play is "B"eginning if (ptp_shm_interface_open() != 0) // it should be open already, but just in case it isn't... die("Can not access the NQPTP service. Has it stopped running?"); @@ -3079,6 +3078,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) // debug(1,"initial timing peer command: \"%s\".", timing_list_message); // ptp_send_control_message_string(timing_list_message); set_client_as_ptp_clock(conn); + ptp_send_control_message_string("B"); // signify clock dependability period is "B"eginning (or continuing) plist_dict_set_item(timingPeerInfoPlist, "Addresses", addresses); plist_dict_set_item(timingPeerInfoPlist, "ID", plist_new_string(conn->self_ip_string)); plist_dict_set_item(setupResponsePlist, "timingPeerInfo", timingPeerInfoPlist); @@ -3193,6 +3193,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) conn->connection_number, get_category_string(conn->airplay_stream_category)); if (conn->airplay_stream_category == ptp_stream) { // get stream[0] + ptp_send_control_message_string("B"); // signify clock dependability period is "B"eginning (or continuing) plist_t stream0 = plist_array_get_item(streams, 0); plist_t streams_array = plist_new_array(); // to hold the ports and stuff From 6d45657373f396ef407ba8668f114419a4d35a7c Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Wed, 22 Feb 2023 13:14:58 +0000 Subject: [PATCH 2/3] Update RELEASENOTES-DEVELOPMENT.md --- RELEASENOTES-DEVELOPMENT.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASENOTES-DEVELOPMENT.md b/RELEASENOTES-DEVELOPMENT.md index 0a6b4ea7..3a117700 100644 --- a/RELEASENOTES-DEVELOPMENT.md +++ b/RELEASENOTES-DEVELOPMENT.md @@ -1,3 +1,8 @@ +Version 4.1-dev-876-g29ca3225 +==== +**Bug Fix** +* Fix a bug reported in Issue [#1633](https://github.com/mikebrady/shairport-sync/issues/1633). The bug was that when a Realtime Audio stream (e.g. playing from Spotify on iOS or using Shairport Sync as the Sound Output on a Mac) was played, it was fine, but when a second stream was started, it could not be heard. The problem was that the PTP clock was not being correctly revalidated for second and subsequent Realtime Audio streams. The fix was to ensure that the PTP clock is revalidated on second and subsequent plays on the same connection. Thanks again to [David Leibovic](https://github.com/dasl-) for finding the problem. + Version 4.1-dev-874-g551734b3 ==== **Bug Fix** From c62ae679f3b0b66d044a868ba8ba4e0936007ac0 Mon Sep 17 00:00:00 2001 From: hunhejj Date: Tue, 21 Feb 2023 22:19:27 +0100 Subject: [PATCH 3/3] Migrate to new HA mqtt configuration The old way of configuring mqtt entities is not supported anymore since `v2022.12` --- MQTT.md | 81 ++++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 44 deletions(-) diff --git a/MQTT.md b/MQTT.md index 95779c76..7fa56b79 100644 --- a/MQTT.md +++ b/MQTT.md @@ -171,54 +171,47 @@ Examples of consuming "parsed" MQTT data in [Home Assistant](https://www.home-as The `active_start` and `active_end` have good potential use as triggers to turn on and off various connect receivers/zones. The messages published are empty and therefor no "payload_on" is set, "payload_off" however is set to prevent accidental triggering. ```yml -binary_sensor: +mqtt: + binary_sensor: + - name: "shairport active start" + state_topic: "shairport/active_start" + payload_on: "" + payload_off: "OFF" + off_delay: 300 - - platform: mqtt - name: "shairport active start" - state_topic: "shairport/active_start" - payload_on: "" - payload_off: "OFF" - off_delay: 300 - - - platform: mqtt - name: "shairport active end" - state_topic: "shairport/active_end" - payload_on: "" - payload_off: "OFF" - off_delay: 300 + - name: "shairport active end" + state_topic: "shairport/active_end" + payload_on: "" + payload_off: "OFF" + off_delay: 300 ``` Below parsed data is saved into the Home Assistant database as sensor data. Please note the conversion of the volume from dB to percentage. ```yml -sensor: - - platform: mqtt - name: "shairport album" - state_topic: "shairport/album" - expire_after: 600 - - - platform: mqtt - name: "shairport artist" - state_topic: "shairport/artist" - expire_after: 600 - - - platform: mqtt - name: "shairport title" - state_topic: "shairport/title" - expire_after: 600 - - - platform: mqtt - name: "shairport genre" - state_topic: "shairport/genre" - expire_after: 600 - - - platform: mqtt - name: "shairport volume (dB)" - state_topic: "shairport/volume" - - - platform: mqtt - name: "shairport volume (PCT)" - state_topic: "shairport/volume" - value_template: "{{ value | regex_findall_index(find='^(.+?),', index=0, ignorecase=False) | float / 30 + 1 }}" - unit_of_measurement: 'percent' +mqtt: + sensor: + - name: "shairport album" + state_topic: "shairport/album" + expire_after: 600 + + - name: "shairport artist" + state_topic: "shairport/artist" + expire_after: 600 + + - name: "shairport title" + state_topic: "shairport/title" + expire_after: 600 + + - name: "shairport genre" + state_topic: "shairport/genre" + expire_after: 600 + + - name: "shairport volume (dB)" + state_topic: "shairport/volume" + + - name: "shairport volume (PCT)" + state_topic: "shairport/volume" + value_template: "{{ value | regex_findall_index(find='^(.+?),', index=0, ignorecase=False) | float / 30 + 1 }}" + unit_of_measurement: 'percent' ```