Bug 3352047 Wrong message when adjusting volume
Add hidden AudioManager.getDevicesForStream and output device codes.
Change-Id: I4d1c1d3b6a077cd117720817d1f733dda557b947
diff --git a/services/audioflinger/AudioPolicyManagerBase.cpp b/services/audioflinger/AudioPolicyManagerBase.cpp
index 04d63e6..58e9b08 100644
--- a/services/audioflinger/AudioPolicyManagerBase.cpp
+++ b/services/audioflinger/AudioPolicyManagerBase.cpp
@@ -1543,6 +1543,20 @@
return (uint32_t)getStrategy(stream);
}
+uint32_t AudioPolicyManagerBase::getDevicesForStream(AudioSystem::stream_type stream) {
+ uint32_t devices;
+ // By checking the range of stream before calling getStrategy, we avoid
+ // getStrategy's behavior for invalid streams. getStrategy would do a LOGE
+ // and then return STRATEGY_MEDIA, but we want to return the empty set.
+ if (stream < (AudioSystem::stream_type) 0 || stream >= AudioSystem::NUM_STREAM_TYPES) {
+ devices = 0;
+ } else {
+ AudioPolicyManagerBase::routing_strategy strategy = getStrategy(stream);
+ devices = getDeviceForStrategy(strategy, true);
+ }
+ return devices;
+}
+
AudioPolicyManagerBase::routing_strategy AudioPolicyManagerBase::getStrategy(
AudioSystem::stream_type stream) {
// stream to strategy mapping
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 953ddac..b614c48 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -365,6 +365,14 @@
return mpPolicyManager->getStrategyForStream(stream);
}
+uint32_t AudioPolicyService::getDevicesForStream(AudioSystem::stream_type stream)
+{
+ if (mpPolicyManager == NULL) {
+ return 0;
+ }
+ return mpPolicyManager->getDevicesForStream(stream);
+}
+
audio_io_handle_t AudioPolicyService::getOutputForEffect(effect_descriptor_t *desc)
{
if (mpPolicyManager == NULL) {
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index 4749b8b..faad893 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -86,6 +86,7 @@
virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index);
virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream);
+ virtual uint32_t getDevicesForStream(AudioSystem::stream_type stream);
virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
virtual status_t registerEffect(effect_descriptor_t *desc,