From: penglei <1624952103@qq.com> Date: Thu, 12 Sep 2024 11:53:13 +0000 (+0800) Subject: 优化音量映射 暂时只处理本地媒体音 X-Git-Tag: release_V1.2.70_20241020_135402~485^2^2~1^2~12 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F953%2F1;p=mirrors%2FFD230.git 优化音量映射 暂时只处理本地媒体音 --- diff --git a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiomanager/cpp/audio_manager.cpp b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiomanager/cpp/audio_manager.cpp index dc4e74b2e..137c84d21 100755 --- a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiomanager/cpp/audio_manager.cpp +++ b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiomanager/cpp/audio_manager.cpp @@ -44,30 +44,37 @@ bool AudioManager::SetVolume(AudioStreamType streamType, int32_t volume) { CHK_NULL_RETURN(impl_, false, "impl_ is nullptr"); - if(volume == 0) - volume = 0; - else if(volume <= 1) - volume = 30; - else if(volume > 100) - volume = 70; - else - volume = 30 + (volume - 1) * 40 / 99; - + if(streamType == AUDIO_STREAM_MUSIC) + { + if(volume == 0) + volume = 0; + else if(volume <= 1) + volume = 30; + else if(volume > 100) + volume = 70; + else + volume = 30 + (volume - 1) * 40 / 99; + } return impl_->SetVolume(streamType, volume); } int32_t AudioManager::GetVolume(AudioStreamType streamType) { CHK_NULL_RETURN(impl_, AUDIO_ERROR, "impl_ is nullptr"); - //return impl_->GetVolume(streamType); - int32_t volume = impl_->GetVolume(streamType); - if(volume == 0) - return 0; - if(volume < 30) - return 1; - if (volume > 70) - return 100; - return ((volume - 30) * 99 / 40) + 1; + if(streamType == AUDIO_STREAM_MUSIC) + { + int32_t volume = impl_->GetVolume(streamType); + if(volume == 0) + return 0; + if(volume < 30) + return 1; + if (volume > 70) + return 100; + return ((volume - 30) * 99 / 40) + 1; + } + else + return impl_->GetVolume(streamType); + } int32_t AudioManager::GetMinVolume(AudioStreamType streamType)