[Android] Add an option to use time-stretching audio

Edward Wang git at videolan.org
Sun Jul 29 21:52:01 CEST 2012


android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Jul 29 14:46:46 2012 -0400| [2bf1fc1e7fd3ff26a6091d546d4005fa776fa8e0] | committer: Edward Wang

Add an option to use time-stretching audio

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=2bf1fc1e7fd3ff26a6091d546d4005fa776fa8e0
---

 vlc-android/jni/libvlcjni.c                  |    4 ++++
 vlc-android/res/values/strings.xml           |    2 ++
 vlc-android/res/xml/preferences.xml          |    8 ++++++--
 vlc-android/src/org/videolan/vlc/LibVLC.java |    5 +++++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index b72a866..29a2976 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -289,6 +289,9 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz, jboolean
     jmethodID methodId = (*env)->GetMethodID(env, cls, "getAout", "()I");
     bool use_opensles = (*env)->CallIntMethod(env, thiz, methodId) == AOUT_OPENSLES;
 
+    methodId = (*env)->GetMethodID(env, cls, "timeStretchingEnabled", "()Z");
+    bool enable_time_stretch = (*env)->CallBooleanMethod(env, thiz, methodId);
+
     verbosity = verbose;
     libvlc_log_subscribe(&debug_subscriber, debug_log, &verbosity);
 
@@ -301,6 +304,7 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz, jboolean
         "--no-plugins-cache",
         "--no-drop-late-frames",
         "--avcodec-fast",
+        enable_time_stretch ? "--audio-time-stretch" : "--no-audio-time-stretch",
         use_opensles ? "--aout=opensles" : "--aout=android_audiotrack",
     };
     libvlc_instance_t *instance = libvlc_new(sizeof(argv) / sizeof(*argv), argv);
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 7044608..84d12fa 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -130,6 +130,8 @@
     <string name="aout_audiotrack">AudioTrack (native)</string>
     <string name="aout_audiotrack_java">AudioTrack (Java)</string>
     <string name="aout_opensles">OpenSL ES</string>
+    <string name="enable_time_stretching_audio">Enable time-stretching audio</string>
+    <string name="enable_time_stretching_audio_detail">Speed up and slow down audio without changing the pitch (requires a fast device)</string>
     <string-array name="aouts_froyo">
         <item>@string/aout_audiotrack_java</item>
         <item>@string/aout_audiotrack</item>
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index 7f9a74f..ffa92ce 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -46,8 +46,12 @@
         <ListPreference
             android:key="aout"
             android:defaultValue="@string/aout_audiotrack_java"
-            android:title="@string/aout" >
-        </ListPreference>
+            android:title="@string/aout" />
+        <CheckBoxPreference
+            android:key="enable_time_stretching_audio"
+            android:title="@string/enable_time_stretching_audio"
+            android:summary="@string/enable_time_stretching_audio_detail"
+            android:defaultValue="false" />
         <PreferenceScreen android:title="@string/advanced_debugging">
             <Preference
                 android:title="@string/quit"
diff --git a/vlc-android/src/org/videolan/vlc/LibVLC.java b/vlc-android/src/org/videolan/vlc/LibVLC.java
index e6fdbd5..6ec031e 100644
--- a/vlc-android/src/org/videolan/vlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/vlc/LibVLC.java
@@ -176,6 +176,11 @@ public class LibVLC {
         }
     }
 
+    public boolean timeStretchingEnabled() {
+        SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
+        return p.getBoolean("enable_time_stretching_audio", false);
+    }
+
     /**
      * Initialize the libVLC class
      */



More information about the Android mailing list