summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-09-12 19:20:28 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-12 19:20:28 +0000
commite9923dca4b7f49e7f127ac4bfa5bbe9eda6acea3 (patch)
tree871032eeacbf96bc1dd9c878608e8d9dea0db8f1
parent615602a95590803e3dfe8e2ed204808a5f4e36e7 (diff)
parente21b7cd8feb7e9468c932609c53a114b1680a012 (diff)
downloadframeworks_av-e9923dca4b7f49e7f127ac4bfa5bbe9eda6acea3.zip
frameworks_av-e9923dca4b7f49e7f127ac4bfa5bbe9eda6acea3.tar.gz
frameworks_av-e9923dca4b7f49e7f127ac4bfa5bbe9eda6acea3.tar.bz2
am e21b7cd8: am 2f875dc8: Merge "AudioPolicyManager: Use "safe" speaker for notifications if available" into lmp-dev
* commit 'e21b7cd8feb7e9468c932609c53a114b1680a012': AudioPolicyManager: Use "safe" speaker for notifications if available
-rw-r--r--services/audiopolicy/AudioPolicyManager.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp
index 6adcde4..22c4e04 100644
--- a/services/audiopolicy/AudioPolicyManager.cpp
+++ b/services/audiopolicy/AudioPolicyManager.cpp
@@ -64,6 +64,7 @@ struct StringToEnum {
const StringToEnum sDeviceNameToEnumTable[] = {
STRING_TO_ENUM(AUDIO_DEVICE_OUT_EARPIECE),
STRING_TO_ENUM(AUDIO_DEVICE_OUT_SPEAKER),
+ STRING_TO_ENUM(AUDIO_DEVICE_OUT_SPEAKER_SAFE),
STRING_TO_ENUM(AUDIO_DEVICE_OUT_WIRED_HEADSET),
STRING_TO_ENUM(AUDIO_DEVICE_OUT_WIRED_HEADPHONE),
STRING_TO_ENUM(AUDIO_DEVICE_OUT_BLUETOOTH_SCO),
@@ -3824,6 +3825,14 @@ audio_devices_t AudioPolicyManager::getDevicesForStream(audio_stream_type_t stre
break;
}
}
+
+ /*Filter SPEAKER_SAFE out of results, as AudioService doesn't know about it
+ and doesn't really need to.*/
+ if (devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) {
+ devices |= AUDIO_DEVICE_OUT_SPEAKER;
+ devices &= ~AUDIO_DEVICE_OUT_SPEAKER_SAFE;
+ }
+
return devices;
}
@@ -3926,12 +3935,20 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
// the isStreamActive() method only informs about the activity of a stream, not
// if it's for local playback. Note also that we use the same delay between both tests
device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/);
+ //user "safe" speaker if available instead of normal speaker to avoid triggering
+ //other acoustic safety mechanisms for notification
+ if (device == AUDIO_DEVICE_OUT_SPEAKER && (availableOutputDeviceTypes & AUDIO_DEVICE_OUT_SPEAKER_SAFE))
+ device = AUDIO_DEVICE_OUT_SPEAKER_SAFE;
} else if (isStreamActive(AUDIO_STREAM_MUSIC, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)) {
// while media is playing (or has recently played), use the same device
device = getDeviceForStrategy(STRATEGY_MEDIA, false /*fromCache*/);
} else {
// when media is not playing anymore, fall back on the sonification behavior
device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/);
+ //user "safe" speaker if available instead of normal speaker to avoid triggering
+ //other acoustic safety mechanisms for notification
+ if (device == AUDIO_DEVICE_OUT_SPEAKER && (availableOutputDeviceTypes & AUDIO_DEVICE_OUT_SPEAKER_SAFE))
+ device = AUDIO_DEVICE_OUT_SPEAKER_SAFE;
}
break;
@@ -4668,6 +4685,10 @@ audio_devices_t AudioPolicyManager::getDeviceForVolume(audio_devices_t device)
}
}
+ /*SPEAKER_SAFE is an alias of SPEAKER for purposes of volume control*/
+ if (device == AUDIO_DEVICE_OUT_SPEAKER_SAFE)
+ device = AUDIO_DEVICE_OUT_SPEAKER;
+
ALOGW_IF(popcount(device) != 1,
"getDeviceForVolume() invalid device combination: %08x",
device);