From c6f331b3f48455c9a9cdf00fc82894badd0a7da6 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 14 Dec 2011 18:18:36 -0800 Subject: audio policy manager: stream volume per device Improve volume management by keeping track of volume for each type of device independently. AudioPolicyManagerBase now keeps track of stream volumes for each device and apply volume according to current device selection. Methods to set and get stream volume now specify the device class. A value for "default" device is always present for each stream and is used if a device is selected and no specific volume was ever set for this device. Change-Id: I06d8f43aa151a09014f7e47e81304c73ff82e9f8 --- include/hardware_legacy/AudioPolicyManagerBase.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'include/hardware_legacy/AudioPolicyManagerBase.h') diff --git a/include/hardware_legacy/AudioPolicyManagerBase.h b/include/hardware_legacy/AudioPolicyManagerBase.h index 3ab748d..24368e3 100644 --- a/include/hardware_legacy/AudioPolicyManagerBase.h +++ b/include/hardware_legacy/AudioPolicyManagerBase.h @@ -101,8 +101,12 @@ public: virtual void initStreamVolume(AudioSystem::stream_type stream, int indexMin, int indexMax); - virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index); - virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index); + virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, + int index, + audio_devices_t device); + virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, + int *index, + audio_devices_t device); // return the strategy corresponding to a given stream type virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream); @@ -219,14 +223,14 @@ protected: class StreamDescriptor { public: - StreamDescriptor() - : mIndexMin(0), mIndexMax(1), mIndexCur(1), mCanBeMuted(true) {} + StreamDescriptor(); - void dump(char* buffer, size_t size); + int getVolumeIndex(audio_devices_t device); + void dump(int fd); int mIndexMin; // min volume index int mIndexMax; // max volume index - int mIndexCur; // current volume index + KeyedVector mIndexCur; // current volume index per device bool mCanBeMuted; // true is the stream can be muted const VolumeCurvePoint *mVolumeCurve[DEVICE_CATEGORY_CNT]; @@ -340,6 +344,8 @@ protected: // returns the category the device belongs to with regard to volume curve management static device_category getDeviceCategory(uint32_t device); + // extract one device relevant for volume control from multiple device selection + static audio_devices_t getDeviceForVolume(audio_devices_t device); AudioPolicyClientInterface *mpClientInterface; // audio policy client interface audio_io_handle_t mHardwareOutput; // hardware output handler -- cgit v1.1