From 04cf70afbf4cdf7d6b187064562b2aca4f9a3182 Mon Sep 17 00:00:00 2001 From: zhuchaochao Date: Mon, 11 Dec 2023 07:33:29 +0000 Subject: [PATCH] fix sco bug Signed-off-by: zhuchaochao Change-Id: I2dad5c8191f7faead450a0712cf9d74c8d8bcda9 --- .../bluetoothclient/audio_bluetooth_manager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frameworks/native/bluetoothclient/audio_bluetooth_manager.cpp b/frameworks/native/bluetoothclient/audio_bluetooth_manager.cpp index 5a0551cc11..1ba04dceee 100644 --- a/frameworks/native/bluetoothclient/audio_bluetooth_manager.cpp +++ b/frameworks/native/bluetoothclient/audio_bluetooth_manager.cpp @@ -282,8 +282,10 @@ int32_t AudioHfpManager::ConnectScoWithAudioScene(AudioScene scene) AUDIO_INFO_LOG("Entered %{public}s,\ new audioScene is %{public}d, last audioScene is %{public}d", __func__, scene, scene_); std::lock_guard sceneLock(g_audioSceneLock); - if (scene_ == scene) { - AUDIO_DEBUG_LOG("Current scene is not changed, ignore connectSco operation."); + int8_t lastScoCategory = GetScoCategoryFromScene(scene_); + int8_t newScoCategory = GetScoCategoryFromScene(scene); + if (lastScoCategory == newScoCategory) { + AUDIO_DEBUG_LOG("AudioScene category is not changed, ignore ConnectScoWithAudioScene operation."); return SUCCESS; } std::lock_guard hfpLock(g_hfpInstanceLock); @@ -293,15 +295,14 @@ int32_t AudioHfpManager::ConnectScoWithAudioScene(AudioScene scene) return SUCCESS; } int32_t ret; - int8_t lastScoCategory = GetScoCategoryFromScene(scene_); if (lastScoCategory != ScoCategory::SCO_DEFAULT) { + AUDIO_INFO_LOG("Entered to disConnectSco for last audioScene category."); ret = hfpInstance_->DisconnectSco(static_cast(lastScoCategory)); CHECK_AND_RETURN_RET_LOG(ret == 0, ERROR, "ConnectScoWithAudioScene failed as the last SCO failed to be disconnected, result: %{public}d", ret); } - int8_t newScoCategory = GetScoCategoryFromScene(scene); if (newScoCategory != ScoCategory::SCO_DEFAULT) { - AUDIO_INFO_LOG("Entered to connectSco."); + AUDIO_INFO_LOG("Entered to connectSco for new audioScene category."); ret = hfpInstance_->ConnectSco(static_cast(newScoCategory)); CHECK_AND_RETURN_RET_LOG(ret == 0, ERROR, "ConnectScoWithAudioScene failed, result: %{public}d", ret); } -- Gitee