From 28f0951e3897184eb67ca8647241677eadee81d7 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Thu, 12 Sep 2024 19:53:13 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E9=9F=B3=E9=87=8F=E6=98=A0?= =?utf8?q?=E5=B0=84=20=E6=9A=82=E6=97=B6=E5=8F=AA=E5=A4=84=E7=90=86?= =?utf8?q?=E6=9C=AC=E5=9C=B0=E5=AA=92=E4=BD=93=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../audiomanager/cpp/audio_manager.cpp | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) 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) -- 2.17.1