diff options
author | Eric Laurent <elaurent@google.com> | 2011-11-18 16:43:31 -0800 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2012-01-17 15:15:04 -0800 |
commit | 83844cc2f95dc279015b47fd1e18c7cb4eabe9a1 (patch) | |
tree | 3e9f329efec962076a0904ce7f093a9a51bac6b1 /media/libmedia | |
parent | 263709e7be37c7040aaef385bc5c9389a9b5f514 (diff) | |
download | frameworks_av-83844cc2f95dc279015b47fd1e18c7cb4eabe9a1.zip frameworks_av-83844cc2f95dc279015b47fd1e18c7cb4eabe9a1.tar.gz frameworks_av-83844cc2f95dc279015b47fd1e18c7cb4eabe9a1.tar.bz2 |
audio framework: manage stream volume per device
Improve volume management by keeping track of volume for each type
of device independently.
Volume for each stream (MUSIC, RINGTONE, VOICE_CALL...) is now maintained
per device.
The main changes are:
- AudioService now keeps tracks of stream volumes per device:
volume indexes are kept in a HashMap < device , index>.
active device is queried from policy manager when a volume change request
is received
initalization, mute and unmute happen on all device simultaneously
- Settings: suffixes is added to volume keys to store each device
volume independently.
- AudioSystem/AudioPolicyService/AudioPolicyInterface: added a device argument
to setStreamVolumeIndex() and getStreamVolumeIndex() to address each
device independently.
- AudioPolicyManagerBase: keep track of stream volumes for each device
and apply volume according to current device selection.
Change-Id: I61ef1c45caadca04d16363bca4140e0f81901b3f
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/AudioSystem.cpp | 12 | ||||
-rw-r--r-- | media/libmedia/IAudioPolicyService.cpp | 19 |
2 files changed, 23 insertions, 8 deletions
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp index 5193848..d52f8f8 100644 --- a/media/libmedia/AudioSystem.cpp +++ b/media/libmedia/AudioSystem.cpp @@ -668,18 +668,22 @@ status_t AudioSystem::initStreamVolume(audio_stream_type_t stream, return aps->initStreamVolume(stream, indexMin, indexMax); } -status_t AudioSystem::setStreamVolumeIndex(audio_stream_type_t stream, int index) +status_t AudioSystem::setStreamVolumeIndex(audio_stream_type_t stream, + int index, + audio_devices_t device) { const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service(); if (aps == 0) return PERMISSION_DENIED; - return aps->setStreamVolumeIndex(stream, index); + return aps->setStreamVolumeIndex(stream, index, device); } -status_t AudioSystem::getStreamVolumeIndex(audio_stream_type_t stream, int *index) +status_t AudioSystem::getStreamVolumeIndex(audio_stream_type_t stream, + int *index, + audio_devices_t device) { const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service(); if (aps == 0) return PERMISSION_DENIED; - return aps->getStreamVolumeIndex(stream, index); + return aps->getStreamVolumeIndex(stream, index, device); } uint32_t AudioSystem::getStrategyForStream(audio_stream_type_t stream) diff --git a/media/libmedia/IAudioPolicyService.cpp b/media/libmedia/IAudioPolicyService.cpp index 67d9c45..952d7b2 100644 --- a/media/libmedia/IAudioPolicyService.cpp +++ b/media/libmedia/IAudioPolicyService.cpp @@ -240,21 +240,28 @@ public: return static_cast <status_t> (reply.readInt32()); } - virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index) + virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, + int index, + audio_devices_t device) { Parcel data, reply; data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); data.writeInt32(static_cast <uint32_t>(stream)); data.writeInt32(index); + data.writeInt32(static_cast <uint32_t>(device)); remote()->transact(SET_STREAM_VOLUME, data, &reply); return static_cast <status_t> (reply.readInt32()); } - virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index) + virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, + int *index, + audio_devices_t device) { Parcel data, reply; data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); data.writeInt32(static_cast <uint32_t>(stream)); + data.writeInt32(static_cast <uint32_t>(device)); + remote()->transact(GET_STREAM_VOLUME, data, &reply); int lIndex = reply.readInt32(); if (index) *index = lIndex; @@ -525,7 +532,10 @@ status_t BnAudioPolicyService::onTransact( audio_stream_type_t stream = static_cast <audio_stream_type_t>(data.readInt32()); int index = data.readInt32(); - reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, index))); + audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); + reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, + index, + device))); return NO_ERROR; } break; @@ -533,8 +543,9 @@ status_t BnAudioPolicyService::onTransact( CHECK_INTERFACE(IAudioPolicyService, data, reply); audio_stream_type_t stream = static_cast <audio_stream_type_t>(data.readInt32()); + audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); int index; - status_t status = getStreamVolumeIndex(stream, &index); + status_t status = getStreamVolumeIndex(stream, &index, device); reply->writeInt32(index); reply->writeInt32(static_cast <uint32_t>(status)); return NO_ERROR; |