summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-09-24 11:27:18 -0700
committerGlenn Kasten <gkasten@google.com>2012-09-25 17:13:18 -0700
commitcc0f1cfb69ce8b8985fc2c0984847a06a13ad22d (patch)
treef3522fd1ad371d1e592c8c8cfd8d0ce1d98f80c2
parentd9aa7b4db46bea5966401f9fcfbecb3269ec55c7 (diff)
downloadframeworks_av-cc0f1cfb69ce8b8985fc2c0984847a06a13ad22d.zip
frameworks_av-cc0f1cfb69ce8b8985fc2c0984847a06a13ad22d.tar.gz
frameworks_av-cc0f1cfb69ce8b8985fc2c0984847a06a13ad22d.tar.bz2
Implement android.media.AudioManager.getProperty()
Bug: 6635041 Change-Id: I3386a4a6c226bc4eceaf65556119e4fb15f73224
-rw-r--r--include/media/AudioSystem.h4
-rw-r--r--include/media/IAudioFlinger.h7
-rw-r--r--media/libmedia/AudioSystem.cpp13
-rw-r--r--media/libmedia/IAudioFlinger.cpp31
-rw-r--r--services/audioflinger/AudioFlinger.cpp18
-rw-r--r--services/audioflinger/AudioFlinger.h7
6 files changed, 78 insertions, 2 deletions
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 932482b..da4645a 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -234,6 +234,10 @@ public:
static const sp<IAudioPolicyService>& get_audio_policy_service();
+ // helpers for android.media.AudioManager.getProperty(), see description there for meaning
+ static int32_t getPrimaryOutputSamplingRate();
+ static int32_t getPrimaryOutputFrameCount();
+
// ----------------------------------------------------------------------------
private:
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index bdd0142..5170a87 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -187,6 +187,13 @@ public:
audio_io_handle_t dstOutput) = 0;
virtual audio_module_handle_t loadHwModule(const char *name) = 0;
+
+ // helpers for android.media.AudioManager.getProperty(), see description there for meaning
+ // FIXME move these APIs to AudioPolicy to permit a more accurate implementation
+ // that looks on primary device for a stream with fast flag, primary flag, or first one.
+ virtual int32_t getPrimaryOutputSamplingRate() = 0;
+ virtual int32_t getPrimaryOutputFrameCount() = 0;
+
};
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 6e0c620..5624df4 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -735,6 +735,19 @@ status_t AudioSystem::isStreamActive(audio_stream_type_t stream, bool* state, ui
return NO_ERROR;
}
+int32_t AudioSystem::getPrimaryOutputSamplingRate()
+{
+ const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+ if (af == 0) return 0;
+ return af->getPrimaryOutputSamplingRate();
+}
+
+int32_t AudioSystem::getPrimaryOutputFrameCount()
+{
+ const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+ if (af == 0) return 0;
+ return af->getPrimaryOutputFrameCount();
+}
void AudioSystem::clearAudioConfigCache()
{
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 71e7c31..ce8ffc4 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -70,7 +70,9 @@ enum {
GET_EFFECT_DESCRIPTOR,
CREATE_EFFECT,
MOVE_EFFECTS,
- LOAD_HW_MODULE
+ LOAD_HW_MODULE,
+ GET_PRIMARY_OUTPUT_SAMPLING_RATE,
+ GET_PRIMARY_OUTPUT_FRAME_COUNT,
};
class BpAudioFlinger : public BpInterface<IAudioFlinger>
@@ -687,6 +689,23 @@ public:
remote()->transact(LOAD_HW_MODULE, data, &reply);
return (audio_module_handle_t) reply.readInt32();
}
+
+ virtual int32_t getPrimaryOutputSamplingRate()
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply);
+ return reply.readInt32();
+ }
+
+ virtual int32_t getPrimaryOutputFrameCount()
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply);
+ return reply.readInt32();
+ }
+
};
IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -1045,6 +1064,16 @@ status_t BnAudioFlinger::onTransact(
reply->writeInt32(loadHwModule(data.readCString()));
return NO_ERROR;
} break;
+ case GET_PRIMARY_OUTPUT_SAMPLING_RATE: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ reply->writeInt32(getPrimaryOutputSamplingRate());
+ return NO_ERROR;
+ } break;
+ case GET_PRIMARY_OUTPUT_FRAME_COUNT: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ reply->writeInt32(getPrimaryOutputFrameCount());
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index dd491f5..599a9e2 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -6903,6 +6903,24 @@ audio_module_handle_t AudioFlinger::loadHwModule_l(const char *name)
}
+// ----------------------------------------------------------------------------
+
+int32_t AudioFlinger::getPrimaryOutputSamplingRate()
+{
+ Mutex::Autolock _l(mLock);
+ PlaybackThread *thread = primaryPlaybackThread_l();
+ return thread != NULL ? thread->sampleRate() : 0;
+}
+
+int32_t AudioFlinger::getPrimaryOutputFrameCount()
+{
+ Mutex::Autolock _l(mLock);
+ PlaybackThread *thread = primaryPlaybackThread_l();
+ return thread != NULL ? thread->frameCountHAL() : 0;
+}
+
+// ----------------------------------------------------------------------------
+
audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,
audio_devices_t *pDevices,
uint32_t *pSamplingRate,
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 8a020fa..45cee0b 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -207,6 +207,9 @@ public:
virtual audio_module_handle_t loadHwModule(const char *name);
+ virtual int32_t getPrimaryOutputSamplingRate();
+ virtual int32_t getPrimaryOutputFrameCount();
+
virtual status_t onTransact(
uint32_t code,
const Parcel& data,
@@ -555,8 +558,10 @@ private:
audio_channel_mask_t channelMask() const { return mChannelMask; }
audio_format_t format() const { return mFormat; }
// Called by AudioFlinger::frameCount(audio_io_handle_t output) and effects,
- // and returns the normal mix buffer's frame count. No API for HAL frame count.
+ // and returns the normal mix buffer's frame count.
size_t frameCount() const { return mNormalFrameCount; }
+ // Return's the HAL's frame count i.e. fast mixer buffer size.
+ size_t frameCountHAL() const { return mFrameCount; }
// Should be "virtual status_t requestExitAndWait()" and override same
// method in Thread, but Thread::requestExitAndWait() is not yet virtual.