summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-09-24 17:32:30 -0700
committerGlenn Kasten <gkasten@google.com>2012-09-25 17:01:40 -0700
commitc6c4365ddb0213c548b055f257dc8077389224fb (patch)
treee1055bd0e39b7b7035adefb810d325cd0a495f4f
parent282c51d3912995308901b45d22d1801eec50df41 (diff)
downloadframeworks_base-c6c4365ddb0213c548b055f257dc8077389224fb.zip
frameworks_base-c6c4365ddb0213c548b055f257dc8077389224fb.tar.gz
frameworks_base-c6c4365ddb0213c548b055f257dc8077389224fb.tar.bz2
Implement android.media.AudioManager.getProperty()
Bug: 6635041 Change-Id: I0e7d53b99559cdc89f2f107f23048e4b1a8dd383
-rw-r--r--core/jni/android_media_AudioSystem.cpp14
-rw-r--r--media/java/android/media/AudioManager.java12
-rw-r--r--media/java/android/media/AudioSystem.java5
3 files changed, 29 insertions, 2 deletions
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index f522a9a..56db116 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -242,6 +242,18 @@ android_media_AudioSystem_getDevicesForStream(JNIEnv *env, jobject thiz, jint st
return (jint) AudioSystem::getDevicesForStream(static_cast <audio_stream_type_t>(stream));
}
+static jint
+android_media_AudioSystem_getPrimaryOutputSamplingRate(JNIEnv *env, jobject clazz)
+{
+ return (jint) AudioSystem::getPrimaryOutputSamplingRate();
+}
+
+static jint
+android_media_AudioSystem_getPrimaryOutputFrameCount(JNIEnv *env, jobject clazz)
+{
+ return (jint) AudioSystem::getPrimaryOutputFrameCount();
+}
+
// ----------------------------------------------------------------------------
static JNINativeMethod gMethods[] = {
@@ -263,6 +275,8 @@ static JNINativeMethod gMethods[] = {
{"setMasterMute", "(Z)I", (void *)android_media_AudioSystem_setMasterMute},
{"getMasterMute", "()Z", (void *)android_media_AudioSystem_getMasterMute},
{"getDevicesForStream", "(I)I", (void *)android_media_AudioSystem_getDevicesForStream},
+ {"getPrimaryOutputSamplingRate", "()I", (void *)android_media_AudioSystem_getPrimaryOutputSamplingRate},
+ {"getPrimaryOutputFrameCount", "()I", (void *)android_media_AudioSystem_getPrimaryOutputFrameCount},
};
int register_android_media_AudioSystem(JNIEnv *env)
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 270c88f..ee17bd3 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -2474,8 +2474,16 @@ public class AudioManager {
* or null if there is no value for that key.
*/
public String getProperty(String key) {
- // implementation to be written
- return null;
+ if (PROPERTY_OUTPUT_SAMPLE_RATE.equals(key)) {
+ int outputSampleRate = AudioSystem.getPrimaryOutputSamplingRate();
+ return outputSampleRate > 0 ? Integer.toString(outputSampleRate) : null;
+ } else if (PROPERTY_OUTPUT_FRAMES_PER_BUFFER.equals(key)) {
+ int outputFramesPerBuffer = AudioSystem.getPrimaryOutputFrameCount();
+ return outputFramesPerBuffer > 0 ? Integer.toString(outputFramesPerBuffer) : null;
+ } else {
+ // null or unknown key
+ return null;
+ }
}
}
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 129e84f..2cff4ff 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -381,4 +381,9 @@ public class AudioSystem
public static native int setMasterMute(boolean mute);
public static native boolean getMasterMute();
public static native int getDevicesForStream(int stream);
+
+ // helpers for android.media.AudioManager.getProperty(), see description there for meaning
+ public static native int getPrimaryOutputSamplingRate();
+ public static native int getPrimaryOutputFrameCount();
+
}