summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2014-12-09 18:11:49 -0800
committerJean-Michel Trivi <jmtrivi@google.com>2014-12-09 18:46:19 -0800
commit1767df778e20c1395afc63b3a0479bd903e7b9f0 (patch)
tree13cc4ca445421ccc4679f03262098bbfe1043027 /services
parent1487d270e86845e93a9abd1af020b45d6799b257 (diff)
downloadframeworks_av-1767df778e20c1395afc63b3a0479bd903e7b9f0.zip
frameworks_av-1767df778e20c1395afc63b3a0479bd903e7b9f0.tar.gz
frameworks_av-1767df778e20c1395afc63b3a0479bd903e7b9f0.tar.bz2
AudioPolicyManager: distinguish between mirroring and rerouting
In the screen mirroring case, the notification manager queries the policy to see if media "is playing remotely": if yes, it will not request audio focus before playing a notification. This is the correct behavior for screen mirroring, but doesn't work when audio is rerouted to an external policy. This change consists in not reporting "remote" activity when playing to a mix of an external policy by looking at the address of the output on which playback is active for the given stream type. Bug 16009464 Change-Id: Iebbf5a8c738ab36c1cf2055e921c0a3472503125
Diffstat (limited to 'services')
-rw-r--r--services/audiopolicy/AudioPolicyManager.cpp8
-rw-r--r--services/audiopolicy/AudioPolicyManager.h2
2 files changed, 8 insertions, 2 deletions
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp
index 68f3802..9918b6f 100644
--- a/services/audiopolicy/AudioPolicyManager.cpp
+++ b/services/audiopolicy/AudioPolicyManager.cpp
@@ -921,7 +921,6 @@ status_t AudioPolicyManager::getOutputForAttr(const audio_attributes_t *attr,
ALOGV("getOutputForAttr() usage=%d, content=%d, tag=%s flags=%08x",
attributes.usage, attributes.content_type, attributes.tags, attributes.flags);
- // TODO this is where filtering for custom policies (rerouting, dynamic sources) will go
routing_strategy strategy = (routing_strategy) getStrategyForAttr(&attributes);
audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
@@ -1962,7 +1961,12 @@ bool AudioPolicyManager::isStreamActiveRemotely(audio_stream_type_t stream,
const sp<AudioOutputDescriptor> outputDesc = mOutputs.valueAt(i);
if (((outputDesc->device() & APM_AUDIO_OUT_DEVICE_REMOTE_ALL) != 0) &&
outputDesc->isStreamActive(stream, inPastMs, sysTime)) {
- return true;
+ // only consider empty or "0" address to only qualify the screen mirroring case
+ // as "remote playback" (vs rerouting when the output is going to a dynamic policy)
+ if (outputDesc->mPolicyMixAddress == String8("")
+ || outputDesc->mPolicyMixAddress == String8("0")) {
+ return true;
+ }
}
}
return false;
diff --git a/services/audiopolicy/AudioPolicyManager.h b/services/audiopolicy/AudioPolicyManager.h
index 4214131..3eef8fe 100644
--- a/services/audiopolicy/AudioPolicyManager.h
+++ b/services/audiopolicy/AudioPolicyManager.h
@@ -155,6 +155,8 @@ public:
// return whether a stream is playing remotely, override to change the definition of
// local/remote playback, used for instance by notification manager to not make
// media players lose audio focus when not playing locally
+ // For the base implementation, "remotely" means playing during screen mirroring which
+ // uses an output for playback with a non-empty, non "0" address.
virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const;
virtual bool isSourceActive(audio_source_t source) const;