mirror of
https://gitee.com/openharmony/multimedia_audio_standard
synced 2024-12-11 14:46:40 +00:00
Add audio stream used for onlyone volume bar of a device
Signed-off-by: zhujie <zhujie81@h-partners.com>
This commit is contained in:
parent
06ba7986d2
commit
d436874478
@ -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
0
services/BUILD.gn
Executable file → Normal 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);
|
||||
|
Loading…
Reference in New Issue
Block a user