summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2012-06-01 19:00:32 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-01 19:00:32 -0700
commit28002b37cc448020f9335052d1df115ee246881a (patch)
tree35d53719c4e54b92e57993341554c14716b59642
parent6510f7ac893e2912be0c3b06088e9e8a77105270 (diff)
parent4660455366d2ee64cb65f0ecd6f7ddeb1c17bac6 (diff)
downloadhardware_libhardware_legacy-28002b37cc448020f9335052d1df115ee246881a.zip
hardware_libhardware_legacy-28002b37cc448020f9335052d1df115ee246881a.tar.gz
hardware_libhardware_legacy-28002b37cc448020f9335052d1df115ee246881a.tar.bz2
am 46604553: Ensure global effects are on the correct output
* commit '4660455366d2ee64cb65f0ecd6f7ddeb1c17bac6': Ensure global effects are on the correct output
-rw-r--r--audio/AudioPolicyManagerBase.cpp54
1 files changed, 38 insertions, 16 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp
index bbf200d..8e1281a 100644
--- a/audio/AudioPolicyManagerBase.cpp
+++ b/audio/AudioPolicyManagerBase.cpp
@@ -985,7 +985,18 @@ audio_io_handle_t AudioPolicyManagerBase::getOutputForEffect(effect_descriptor_t
{
ALOGV("getOutputForEffect()");
// apply simple rule where global effects are attached to the same output as MUSIC streams
- return getOutput(AudioSystem::MUSIC);
+
+ routing_strategy strategy = getStrategy(AudioSystem::MUSIC);
+ audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
+ SortedVector<audio_io_handle_t> dstOutputs = getOutputsForDevice(device);
+ int outIdx = 0;
+ for (size_t i = 0; i < dstOutputs.size(); i++) {
+ AudioOutputDescriptor *desc = mOutputs.valueFor(dstOutputs[i]);
+ if (desc->mFlags & AUDIO_OUTPUT_FLAG_DEEP_BUFFER) {
+ outIdx = i;
+ }
+ }
+ return dstOutputs[outIdx];
}
status_t AudioPolicyManagerBase::registerEffect(effect_descriptor_t *desc,
@@ -1691,25 +1702,36 @@ void AudioPolicyManagerBase::checkOutputForStrategy(routing_strategy strategy)
}
// Move effects associated to this strategy from previous output to new output
-//FIXME: removing this code works for effects applied to a particular session as they will be
-// re-connected when the tracks are re-created after being invalidated.
-// However we need to define a policy for global effects when more than one output is possible
-// for (size_t i = 0; i < mEffects.size(); i++) {
-// EffectDescriptor *desc = mEffects.valueAt(i);
-// if (desc->mSession != AudioSystem::SESSION_OUTPUT_STAGE &&
-// desc->mStrategy == strategy &&
-// desc->mIo == srcOutputs[0]) {
-// ALOGV("checkOutputForStrategy() moving effect %d to output %d",
-// mEffects.keyAt(i), dstOutputs[0]);
-// mpClientInterface->moveEffects(desc->mSession, srcOutputs[0], dstOutputs[0]);
-// desc->mIo = dstOutputs[0];
-// }
-// }
+ if (strategy == STRATEGY_MEDIA) {
+ int outIdx = 0;
+ for (size_t i = 0; i < dstOutputs.size(); i++) {
+ AudioOutputDescriptor *desc = mOutputs.valueFor(dstOutputs[i]);
+ if (desc->mFlags & AUDIO_OUTPUT_FLAG_DEEP_BUFFER) {
+ outIdx = i;
+ }
+ }
+ SortedVector<audio_io_handle_t> moved;
+ for (size_t i = 0; i < mEffects.size(); i++) {
+ EffectDescriptor *desc = mEffects.valueAt(i);
+ if (desc->mSession == AUDIO_SESSION_OUTPUT_MIX &&
+ desc->mIo != dstOutputs[outIdx]) {
+ if (moved.indexOf(desc->mIo) < 0) {
+ ALOGV("checkOutputForStrategy() moving effect %d to output %d",
+ mEffects.keyAt(i), dstOutputs[outIdx]);
+ mpClientInterface->moveEffects(AUDIO_SESSION_OUTPUT_MIX, desc->mIo,
+ dstOutputs[outIdx]);
+ moved.add(desc->mIo);
+ }
+ desc->mIo = dstOutputs[outIdx];
+ }
+ }
+ }
// Move tracks associated to this strategy from previous output to new output
for (int i = 0; i < (int)AudioSystem::NUM_STREAM_TYPES; i++) {
if (getStrategy((AudioSystem::stream_type)i) == strategy) {
//FIXME see fixme on name change
- mpClientInterface->setStreamOutput((AudioSystem::stream_type)i, dstOutputs[0]);
+ mpClientInterface->setStreamOutput((AudioSystem::stream_type)i,
+ dstOutputs[0] /* ignored */);
}
}
}