am f1761254: am abc55c69: AudioPolicyManager supports querying active record sources

* commit 'f1761254147f61f503d0de1627d9c06b40ef861f':
  AudioPolicyManager supports querying active record sources
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp
index c7519c9..cacc37d 100644
--- a/audio/AudioPolicyManagerBase.cpp
+++ b/audio/AudioPolicyManagerBase.cpp
@@ -1159,6 +1159,19 @@
     return false;
 }
 
+bool AudioPolicyManagerBase::isSourceActive(audio_source_t source) const
+{
+    for (size_t i = 0; i < mInputs.size(); i++) {
+        const AudioInputDescriptor * inputDescriptor = mInputs.valueAt(i);
+        if ((inputDescriptor->mInputSource == (int) source)
+                && (inputDescriptor->mRefCount > 0)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+
 
 status_t AudioPolicyManagerBase::dump(int fd)
 {
diff --git a/audio/audio_policy_hal.cpp b/audio/audio_policy_hal.cpp
index 9e29bc4..bff6b74 100644
--- a/audio/audio_policy_hal.cpp
+++ b/audio/audio_policy_hal.cpp
@@ -302,6 +302,12 @@
     return lap->apm->isStreamActive((int) stream, in_past_ms);
 }
 
+static bool ap_is_source_active(const struct audio_policy *pol, audio_source_t source)
+{
+    const struct legacy_audio_policy *lap = to_clap(pol);
+    return lap->apm->isSourceActive(source);
+}
+
 static int ap_dump(const struct audio_policy *pol, int fd)
 {
     const struct legacy_audio_policy *lap = to_clap(pol);
@@ -352,6 +358,7 @@
     lap->policy.unregister_effect = ap_unregister_effect;
     lap->policy.set_effect_enabled = ap_set_effect_enabled;
     lap->policy.is_stream_active = ap_is_stream_active;
+    lap->policy.is_source_active = ap_is_source_active;
     lap->policy.dump = ap_dump;
 
     lap->service = service;
diff --git a/include/hardware_legacy/AudioPolicyInterface.h b/include/hardware_legacy/AudioPolicyInterface.h
index 3ff68b9..51f4822 100644
--- a/include/hardware_legacy/AudioPolicyInterface.h
+++ b/include/hardware_legacy/AudioPolicyInterface.h
@@ -157,6 +157,7 @@
     virtual status_t setEffectEnabled(int id, bool enabled) = 0;
 
     virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const = 0;
+    virtual bool isSourceActive(audio_source_t source) const = 0;
 
     //dump state
     virtual status_t    dump(int fd) = 0;
diff --git a/include/hardware_legacy/AudioPolicyManagerBase.h b/include/hardware_legacy/AudioPolicyManagerBase.h
index f110c20..4eefc0a 100644
--- a/include/hardware_legacy/AudioPolicyManagerBase.h
+++ b/include/hardware_legacy/AudioPolicyManagerBase.h
@@ -133,6 +133,7 @@
         virtual status_t setEffectEnabled(int id, bool enabled);
 
         virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const;
+        virtual bool isSourceActive(audio_source_t source) const;
 
         virtual status_t dump(int fd);