From f0206427b09b490bcf079a3036b5a5ebe9f2d2c3 Mon Sep 17 00:00:00 2001 From: weitianhua Date: Mon, 3 Aug 2020 20:50:33 +0800 Subject: [PATCH] Rewrite av clean_up procedure --- .../bluedroid/btc/profile/std/a2dp/btc_av.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/components/bt/bluedroid/btc/profile/std/a2dp/btc_av.c b/components/bt/bluedroid/btc/profile/std/a2dp/btc_av.c index f428150bae..e61126dff2 100644 --- a/components/bt/bluedroid/btc/profile/std/a2dp/btc_av.c +++ b/components/bt/bluedroid/btc/profile/std/a2dp/btc_av.c @@ -1039,22 +1039,22 @@ static void clean_up(int service_id) tle_av_open_on_rc = NULL; } #endif /* BTC_AV_SRC_INCLUDED */ + btc_dm_disable_service(BTA_A2DP_SOURCE_SERVICE_ID); } - btc_dm_disable_service(BTA_A2DP_SOURCE_SERVICE_ID); - - if (service_id == BTA_A2DP_SINK_SERVICE_ID) { - btc_dm_disable_service(BTA_A2DP_SINK_SERVICE_ID); - } - - /* Also shut down the AV state machine */ - btc_sm_shutdown(btc_av_cb.sm_handle); - btc_av_cb.sm_handle = NULL; - if (service_id == BTA_A2DP_SINK_SERVICE_ID) { #if BTC_AV_SINK_INCLUDED btc_a2dp_sink_shutdown(); #endif /* BTC_AV_SINK_INCLUDED */ + btc_dm_disable_service(BTA_A2DP_SINK_SERVICE_ID); + } + + if (btc_av_cb.sm_handle) { + /* Also shut down the AV state machine */ + btc_sm_shutdown(btc_av_cb.sm_handle); + btc_av_cb.sm_handle = NULL; + } else { + BTC_TRACE_WARNING("AV sm handle already free\n"); } }