From 131769ff4d63b01127629ae8643f147d2e9ca81f Mon Sep 17 00:00:00 2001 From: philippe44 Date: Sun, 24 Nov 2019 15:37:34 -0800 Subject: [PATCH] BT & AirPlay switch fix - release --- components/driver_bt/bt_app_sink.c | 3 ++- components/raop/rtp.c | 8 +++++++- components/squeezelite-ota/squeezelite-ota.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/driver_bt/bt_app_sink.c b/components/driver_bt/bt_app_sink.c index 95086132..7d7771ed 100644 --- a/components/driver_bt/bt_app_sink.c +++ b/components/driver_bt/bt_app_sink.c @@ -156,7 +156,8 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param) s_audio_state = a2d->audio_stat.state; if (ESP_A2D_AUDIO_STATE_STARTED == a2d->audio_stat.state) { (*bt_app_a2d_cmd_cb)(BT_SINK_PLAY); - } else if (ESP_A2D_AUDIO_STATE_STOPPED == a2d->audio_stat.state) { + } else if (ESP_A2D_AUDIO_STATE_STOPPED == a2d->audio_stat.state || + ESP_A2D_AUDIO_STATE_REMOTE_SUSPEND == a2d->audio_stat.state) { (*bt_app_a2d_cmd_cb)(BT_SINK_STOP); } break; diff --git a/components/raop/rtp.c b/components/raop/rtp.c index cb0d537d..b4661a98 100644 --- a/components/raop/rtp.c +++ b/components/raop/rtp.c @@ -637,6 +637,12 @@ static void *rtp_thread_func(void *arg) { u64_t remote = (((u64_t) ntohl(*(u32_t*)(pktp+8))) << 32) + ntohl(*(u32_t*)(pktp+12)); u32_t rtp_now = ntohl(*(u32_t*)(pktp+16)); u16_t flags = ntohs(*(u16_t*)(pktp+2)); + u32_t remote_gap = NTP2MS(remote - ctx->timing.remote); + + if (remote_gap > 10000) { + LOG_WARN("discarding remote timing information %u", remote_gap); + break; + } pthread_mutex_lock(&ctx->ab_mutex); @@ -646,7 +652,7 @@ static void *rtp_thread_func(void *arg) { if (ctx->latency < MIN_LATENCY) ctx->latency = MIN_LATENCY; else if (ctx->latency > MAX_LATENCY) ctx->latency = MAX_LATENCY; ctx->synchro.rtp = rtp_now - ctx->latency; - ctx->synchro.time = ctx->timing.local + (u32_t) NTP2MS(remote - ctx->timing.remote); + ctx->synchro.time = ctx->timing.local + remote_gap; // now we are synced on RTP frames ctx->synchro.status |= RTP_SYNC; diff --git a/components/squeezelite-ota/squeezelite-ota.c b/components/squeezelite-ota/squeezelite-ota.c index 51aeebf3..bb2e6dd0 100644 --- a/components/squeezelite-ota/squeezelite-ota.c +++ b/components/squeezelite-ota/squeezelite-ota.c @@ -298,7 +298,7 @@ static esp_err_t _http_handle_response_code(esp_http_client_handle_t http_client } ESP_LOGD(TAG, "Redirection done, checking if we need to read the data. "); if (process_again(status_code)) { - //char * local_buff = heap_caps_malloc(ota_config.buffer_size, MALLOC_CAP_INTERNAL); + //char * local_buff = heap_caps_malloc(ota_config.buffer_size+1, MALLOC_CAP_INTERNAL); char * local_buff = malloc(ota_config.buffer_size+1); if(local_buff==NULL){ ESP_LOGE(TAG,"Failed to allocate internal memory buffer for http processing");