summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/AudioSystem.h2
-rw-r--r--include/media/IAudioPolicyService.h1
-rw-r--r--media/libmedia/AudioSystem.cpp9
-rw-r--r--media/libmedia/IAudioPolicyService.cpp17
-rw-r--r--services/audioflinger/AudioPolicyService.cpp12
-rw-r--r--services/audioflinger/AudioPolicyService.h1
6 files changed, 42 insertions, 0 deletions
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index da4645a..49e1afc 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -70,6 +70,8 @@ public:
// returns true in *state if tracks are active on the specified stream or has been active
// in the past inPastMs milliseconds
static status_t isStreamActive(audio_stream_type_t stream, bool *state, uint32_t inPastMs = 0);
+ // returns true in *state if a recorder is currently recording with the specified source
+ static status_t isSourceActive(audio_source_t source, bool *state);
// set/get audio hardware parameters. The function accepts a list of parameters
// key value pairs in the form: key1=value1;key2=value2;...
diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h
index fb556af..cc2e069 100644
--- a/include/media/IAudioPolicyService.h
+++ b/include/media/IAudioPolicyService.h
@@ -88,6 +88,7 @@ public:
virtual status_t unregisterEffect(int id) = 0;
virtual status_t setEffectEnabled(int id, bool enabled) = 0;
virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0;
+ virtual bool isSourceActive(audio_source_t source) const = 0;
virtual status_t queryDefaultPreProcessing(int audioSession,
effect_descriptor_t *descriptors,
uint32_t *count) = 0;
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 5624df4..207f96f 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -735,6 +735,15 @@ status_t AudioSystem::isStreamActive(audio_stream_type_t stream, bool* state, ui
return NO_ERROR;
}
+status_t AudioSystem::isSourceActive(audio_source_t stream, bool* state)
+{
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ if (aps == 0) return PERMISSION_DENIED;
+ if (state == NULL) return BAD_VALUE;
+ *state = aps->isSourceActive(stream);
+ return NO_ERROR;
+}
+
int32_t AudioSystem::getPrimaryOutputSamplingRate()
{
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
diff --git a/media/libmedia/IAudioPolicyService.cpp b/media/libmedia/IAudioPolicyService.cpp
index 31c5d27..401437c 100644
--- a/media/libmedia/IAudioPolicyService.cpp
+++ b/media/libmedia/IAudioPolicyService.cpp
@@ -52,6 +52,7 @@ enum {
REGISTER_EFFECT,
UNREGISTER_EFFECT,
IS_STREAM_ACTIVE,
+ IS_SOURCE_ACTIVE,
GET_DEVICES_FOR_STREAM,
QUERY_DEFAULT_PRE_PROCESSING,
SET_EFFECT_ENABLED
@@ -329,6 +330,15 @@ public:
return reply.readInt32();
}
+ virtual bool isSourceActive(audio_source_t source) const
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
+ data.writeInt32((int32_t) source);
+ remote()->transact(IS_SOURCE_ACTIVE, data, &reply);
+ return reply.readInt32();
+ }
+
virtual status_t queryDefaultPreProcessing(int audioSession,
effect_descriptor_t *descriptors,
uint32_t *count)
@@ -592,6 +602,13 @@ status_t BnAudioPolicyService::onTransact(
return NO_ERROR;
} break;
+ case IS_SOURCE_ACTIVE: {
+ CHECK_INTERFACE(IAudioPolicyService, data, reply);
+ audio_source_t source = (audio_source_t) data.readInt32();
+ reply->writeInt32( isSourceActive(source));
+ return NO_ERROR;
+ }
+
case QUERY_DEFAULT_PRE_PROCESSING: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
int audioSession = data.readInt32();
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 155a0b8..8b99bd2 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -483,6 +483,18 @@ bool AudioPolicyService::isStreamActive(audio_stream_type_t stream, uint32_t inP
return mpAudioPolicy->is_stream_active(mpAudioPolicy, stream, inPastMs);
}
+bool AudioPolicyService::isSourceActive(audio_source_t source) const
+{
+ if (mpAudioPolicy == NULL) {
+ return false;
+ }
+ if (mpAudioPolicy->is_source_active == 0) {
+ return false;
+ }
+ Mutex::Autolock _l(mLock);
+ return mpAudioPolicy->is_source_active(mpAudioPolicy, source);
+}
+
status_t AudioPolicyService::queryDefaultPreProcessing(int audioSession,
effect_descriptor_t *descriptors,
uint32_t *count)
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index a086734..63f9549 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -104,6 +104,7 @@ public:
virtual status_t unregisterEffect(int id);
virtual status_t setEffectEnabled(int id, bool enabled);
virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const;
+ virtual bool isSourceActive(audio_source_t source) const;
virtual status_t queryDefaultPreProcessing(int audioSession,
effect_descriptor_t *descriptors,