Add audio stream used for onlyone volume bar of a device

Signed-off-by: zhujie <zhujie81@h-partners.com>
This commit is contained in:
zhujie 2022-04-25 16:37:36 +08:00
parent 06ba7986d2
commit d436874478
3 changed files with 21 additions and 1 deletions

View File

@ -171,7 +171,11 @@ public:
/**
* Indicates audio streams used for prompts in terms of accessibility.
*/
STREAM_ACCESSIBILITY = 12
STREAM_ACCESSIBILITY = 12,
/**
* Indicates audio streams used for only one volume bar of a device.
*/
STREAM_ALL = 100,
};
static AudioSystemManager *GetInstance();

0
services/BUILD.gn Executable file → Normal file
View File

View File

@ -244,12 +244,23 @@ int32_t AudioSystemManager::SetVolume(AudioSystemManager::AudioVolumeType volume
case STREAM_NOTIFICATION:
case STREAM_VOICE_CALL:
case STREAM_VOICE_ASSISTANT:
case STREAM_ALL:
break;
default:
AUDIO_ERR_LOG("SetVolume volumeType=%{public}d not supported", volumeType);
return ERR_NOT_SUPPORTED;
}
if (volumeType == STREAM_ALL) {
AudioVolumeType audioVolumeTypes[] = { STREAM_MUSIC, STREAM_RING, STREAM_NOTIFICATION, STREAM_VOICE_CALL, STREAM_VOICE_ASSISTANT};
for (auto &&audioVolumeType : AudioVolumeTypes) {
AudioStreamType StreamVolType = (AudioStreamType)audioVolumeType;
float volumeToHdi = MapVolumeToHDI(volume);
AudioPolicyManager::GetInstance().SetStreamVolume(StreamVolType, volumeToHdi);
}
return 0;
}
/* Call Audio Policy SetStreamVolume */
AudioStreamType StreamVolType = (AudioStreamType)volumeType;
float volumeToHdi = MapVolumeToHDI(volume);
@ -264,12 +275,17 @@ int32_t AudioSystemManager::GetVolume(AudioSystemManager::AudioVolumeType volume
case STREAM_NOTIFICATION:
case STREAM_VOICE_CALL:
case STREAM_VOICE_ASSISTANT:
case STREAM_ALL:
break;
default:
AUDIO_ERR_LOG("GetVolume volumeType=%{public}d not supported", volumeType);
return (float)ERR_NOT_SUPPORTED;
}
if (volumeType == STREAM_ALL) {
volumeType = STREAM_MUSIC;
}
/* Call Audio Policy SetStreamMute */
AudioStreamType StreamVolType = (AudioStreamType)volumeType;
float volumeFromHdi = AudioPolicyManager::GetInstance().GetStreamVolume(StreamVolType);