mirror of
https://gitee.com/openharmony/multimedia_audio_standard
synced 2024-12-04 02:42:55 +00:00
Add audio stream use for only one volume bar of a device
Signed-off-by: zhujie <zhujie81@huawei.com>
This commit is contained in:
parent
61b42f20b2
commit
f908838c68
@ -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);
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user