From f908838c68c509fdaca087d101554f4cb76debc2 Mon Sep 17 00:00:00 2001 From: zhujie Date: Tue, 26 Apr 2022 15:12:01 +0800 Subject: [PATCH] Add audio stream use for only one volume bar of a device Signed-off-by: zhujie --- .../audiomanager/include/audio_system_manager.h | 8 +++----- .../audio_service/client/audio_system_manager.cpp | 14 ++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/interfaces/inner_api/native/audiomanager/include/audio_system_manager.h b/interfaces/inner_api/native/audiomanager/include/audio_system_manager.h index fb5fe70..b715d0c 100644 --- a/interfaces/inner_api/native/audiomanager/include/audio_system_manager.h +++ b/interfaces/inner_api/native/audiomanager/include/audio_system_manager.h @@ -177,11 +177,9 @@ public: */ STREAM_ALL = 100 }; - static AudioVolumeType GetStreamAllVolumeTypes[] = { STREAM_MUSIC, - STREAM_RING, - STREAM_NOTIFICATION, - STREAM_VOICE_CALL, - STREAM_VOICE_ASSISTANT}; + static AudioVolumeType GetStreamAllVolumeTypes[] = { + STREAM_MUSIC, STREAM_RING, STREAM_NOTIFICATION, STREAM_VOICE_CALL, STREAM_VOICE_ASSISTANT + }; static AudioSystemManager *GetInstance(); static float MapVolumeToHDI(int32_t volume); static int32_t MapVolumeFromHDI(float volume); diff --git a/services/src/audio_service/client/audio_system_manager.cpp b/services/src/audio_service/client/audio_system_manager.cpp index d3cb40d..d6ec8d5 100644 --- a/services/src/audio_service/client/audio_system_manager.cpp +++ b/services/src/audio_service/client/audio_system_manager.cpp @@ -252,16 +252,15 @@ int32_t AudioSystemManager::SetVolume(AudioSystemManager::AudioVolumeType volume } if (volumeType == STREAM_ALL) { - int32_t flag = AUDIO_CLIENT_SUCCESS; for (auto &&audioVolumeType : GetAllVolumeTypes) { AudioStreamType StreamVolType = (AudioStreamType)audioVolumeType; float volumeToHdi = MapVolumeToHDI(volume); int32_t setResult = AudioPolicyManager::GetInstance().SetStreamVolume(StreamVolType, volumeToHdi); - if (setResult != flat) { - flag = setResult; + if (setResult != SUCCESS) { + return ERROR; } } - return flag; + return SUCCESS; } /* Call Audio Policy SetStreamVolume */ @@ -346,16 +345,15 @@ int32_t AudioSystemManager::SetMute(AudioSystemManager::AudioVolumeType volumeTy } if (volumeType == STREAM_ALL) { - int32_t flag = AUDIO_CLIENT_SUCCESS; for (auto &&audioVolumeType : GetAllVolumeTypes) { AudioStreamType StreamVolType = (AudioStreamType)audioVolumeType; float volumeToHdi = MapVolumeToHDI(volume); int32_t setResult = AudioPolicyManager::GetInstance().SetStreamVolume(StreamVolType, volumeToHdi); - if (setResult != flat) { - flag = setResult; + if (setResult != SUCCESS) { + return ERROR; } } - return flag; + return SUCCESS; } /* Call Audio Policy SetStreamMute */