summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2012-04-19 09:09:06 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-04-19 09:09:06 -0700
commit5cef554cc857b2b542d2c62f8cd0c36d62e1bb9b (patch)
tree4faa94cede52e04a34ab1d5da4217177f41d4317 /media
parent9afbfb5e1339a63cff5dbe72eae02d703c9bd62f (diff)
parente1123e7f36723a8b888501c9a22a589297849ca2 (diff)
downloadframeworks_base-5cef554cc857b2b542d2c62f8cd0c36d62e1bb9b.zip
frameworks_base-5cef554cc857b2b542d2c62f8cd0c36d62e1bb9b.tar.gz
frameworks_base-5cef554cc857b2b542d2c62f8cd0c36d62e1bb9b.tar.bz2
Merge "Add support for scaling mode parameter in Visualizer effect"
Diffstat (limited to 'media')
-rwxr-xr-xmedia/java/android/media/audiofx/Visualizer.java56
-rw-r--r--media/jni/audioeffect/android_media_Visualizer.cpp23
2 files changed, 79 insertions, 0 deletions
diff --git a/media/java/android/media/audiofx/Visualizer.java b/media/java/android/media/audiofx/Visualizer.java
index 91d0add..47c0d57 100755
--- a/media/java/android/media/audiofx/Visualizer.java
+++ b/media/java/android/media/audiofx/Visualizer.java
@@ -81,6 +81,20 @@ public class Visualizer {
*/
public static final int STATE_ENABLED = 2;
+ // to keep in sync with system/media/audio_effects/include/audio_effects/effect_visualizer.h
+ /**
+ * @hide
+ * Defines a capture mode where amplification is applied based on the content of the captured
+ * data. This is the default Visualizer mode, and is suitable for music visualization.
+ */
+ public static final int SCALING_MODE_NORMALIZED = 0;
+ /**
+ * @hide
+ * Defines a capture mode where the playback volume will affect (scale) the range of the
+ * captured data. A low playback volume will lead to low sample and fft values, and vice-versa.
+ */
+ public static final int SCALING_MODE_AS_PLAYED = 1;
+
// to keep in sync with frameworks/base/media/jni/audioeffect/android_media_Visualizer.cpp
private static final int NATIVE_EVENT_PCM_CAPTURE = 0;
private static final int NATIVE_EVENT_FFT_CAPTURE = 1;
@@ -302,6 +316,44 @@ public class Visualizer {
}
/**
+ * @hide
+ * Set the type of scaling applied on the captured visualization data.
+ * @param mode see {@link #SCALING_MODE_NORMALIZED}
+ * and {@link #SCALING_MODE_AS_PLAYED}
+ * @return {@link #SUCCESS} in case of success,
+ * {@link #ERROR_BAD_VALUE} in case of failure.
+ * @throws IllegalStateException
+ */
+ public int setScalingMode(int mode)
+ throws IllegalStateException {
+ synchronized (mStateLock) {
+ if (mState == STATE_UNINITIALIZED) {
+ throw(new IllegalStateException("setScalingMode() called in wrong state: "
+ + mState));
+ }
+ return native_setScalingMode(mode);
+ }
+ }
+
+ /**
+ * @hide
+ * Returns the current scaling mode on the captured visualization data.
+ * @return the scaling mode, see {@link #SCALING_MODE_NORMALIZED}
+ * and {@link #SCALING_MODE_AS_PLAYED}.
+ * @throws IllegalStateException
+ */
+ public int getScalingMode()
+ throws IllegalStateException {
+ synchronized (mStateLock) {
+ if (mState == STATE_UNINITIALIZED) {
+ throw(new IllegalStateException("getScalingMode() called in wrong state: "
+ + mState));
+ }
+ return native_getScalingMode();
+ }
+ }
+
+ /**
* Returns the sampling rate of the captured audio.
* @return the sampling rate in milliHertz.
*/
@@ -588,6 +640,10 @@ public class Visualizer {
private native final int native_getCaptureSize();
+ private native final int native_setScalingMode(int mode);
+
+ private native final int native_getScalingMode();
+
private native final int native_getSamplingRate();
private native final int native_getWaveForm(byte[] waveform);
diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp
index f015afb..c2655c7 100644
--- a/media/jni/audioeffect/android_media_Visualizer.cpp
+++ b/media/jni/audioeffect/android_media_Visualizer.cpp
@@ -491,6 +491,27 @@ android_media_visualizer_native_getCaptureSize(JNIEnv *env, jobject thiz)
}
static jint
+android_media_visualizer_native_setScalingMode(JNIEnv *env, jobject thiz, jint mode)
+{
+ Visualizer* lpVisualizer = getVisualizer(env, thiz);
+ if (lpVisualizer == NULL) {
+ return VISUALIZER_ERROR_NO_INIT;
+ }
+
+ return translateError(lpVisualizer->setScalingMode(mode));
+}
+
+static jint
+android_media_visualizer_native_getScalingMode(JNIEnv *env, jobject thiz)
+{
+ Visualizer* lpVisualizer = getVisualizer(env, thiz);
+ if (lpVisualizer == NULL) {
+ return -1;
+ }
+ return lpVisualizer->getScalingMode();
+}
+
+static jint
android_media_visualizer_native_getSamplingRate(JNIEnv *env, jobject thiz)
{
Visualizer* lpVisualizer = getVisualizer(env, thiz);
@@ -582,6 +603,8 @@ static JNINativeMethod gMethods[] = {
{"getMaxCaptureRate", "()I", (void *)android_media_visualizer_native_getMaxCaptureRate},
{"native_setCaptureSize", "(I)I", (void *)android_media_visualizer_native_setCaptureSize},
{"native_getCaptureSize", "()I", (void *)android_media_visualizer_native_getCaptureSize},
+ {"native_setScalingMode", "(I)I", (void *)android_media_visualizer_native_setScalingMode},
+ {"native_getScalingMode", "()I", (void *)android_media_visualizer_native_getScalingMode},
{"native_getSamplingRate", "()I", (void *)android_media_visualizer_native_getSamplingRate},
{"native_getWaveForm", "([B)I", (void *)android_media_visualizer_native_getWaveForm},
{"native_getFft", "([B)I", (void *)android_media_visualizer_native_getFft},