summaryrefslogtreecommitdiffstats
path: root/audio/audio_policy_hal.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-12-14 18:18:36 -0800
committerEric Laurent <elaurent@google.com>2012-01-17 16:00:01 -0800
commitc6f331b3f48455c9a9cdf00fc82894badd0a7da6 (patch)
treee5f93ad7a7e9ebb225b0a8b37bdb0021cde4270d /audio/audio_policy_hal.cpp
parentd97809bca3b086fe85475f462b6fdba6775f5ae1 (diff)
downloadhardware_libhardware_legacy-c6f331b3f48455c9a9cdf00fc82894badd0a7da6.zip
hardware_libhardware_legacy-c6f331b3f48455c9a9cdf00fc82894badd0a7da6.tar.gz
hardware_libhardware_legacy-c6f331b3f48455c9a9cdf00fc82894badd0a7da6.tar.bz2
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
Diffstat (limited to 'audio/audio_policy_hal.cpp')
-rw-r--r--audio/audio_policy_hal.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/audio/audio_policy_hal.cpp b/audio/audio_policy_hal.cpp
index a229ea9..eed3d0e 100644
--- a/audio/audio_policy_hal.cpp
+++ b/audio/audio_policy_hal.cpp
@@ -215,7 +215,8 @@ static int ap_set_stream_volume_index(struct audio_policy *pol,
{
struct legacy_audio_policy *lap = to_lap(pol);
return lap->apm->setStreamVolumeIndex((AudioSystem::stream_type)stream,
- index);
+ index,
+ AUDIO_DEVICE_OUT_DEFAULT);
}
static int ap_get_stream_volume_index(const struct audio_policy *pol,
@@ -224,7 +225,30 @@ static int ap_get_stream_volume_index(const struct audio_policy *pol,
{
const struct legacy_audio_policy *lap = to_clap(pol);
return lap->apm->getStreamVolumeIndex((AudioSystem::stream_type)stream,
- index);
+ index,
+ AUDIO_DEVICE_OUT_DEFAULT);
+}
+
+static int ap_set_stream_volume_index_for_device(struct audio_policy *pol,
+ audio_stream_type_t stream,
+ int index,
+ audio_devices_t device)
+{
+ struct legacy_audio_policy *lap = to_lap(pol);
+ return lap->apm->setStreamVolumeIndex((AudioSystem::stream_type)stream,
+ index,
+ device);
+}
+
+static int ap_get_stream_volume_index_for_device(const struct audio_policy *pol,
+ audio_stream_type_t stream,
+ int *index,
+ audio_devices_t device)
+{
+ const struct legacy_audio_policy *lap = to_clap(pol);
+ return lap->apm->getStreamVolumeIndex((AudioSystem::stream_type)stream,
+ index,
+ device);
}
static uint32_t ap_get_strategy_for_stream(const struct audio_policy *pol,
@@ -319,6 +343,8 @@ static int create_legacy_ap(const struct audio_policy_device *device,
lap->policy.init_stream_volume = ap_init_stream_volume;
lap->policy.set_stream_volume_index = ap_set_stream_volume_index;
lap->policy.get_stream_volume_index = ap_get_stream_volume_index;
+ lap->policy.set_stream_volume_index_for_device = ap_set_stream_volume_index_for_device;
+ lap->policy.get_stream_volume_index_for_device = ap_get_stream_volume_index_for_device;
lap->policy.get_strategy_for_stream = ap_get_strategy_for_stream;
lap->policy.get_devices_for_stream = ap_get_devices_for_stream;
lap->policy.get_output_for_effect = ap_get_output_for_effect;