Commit cdad953f authored by Edward Wang's avatar Edward Wang
Browse files

equalizer: make applyEqualizer private

The equalizer is now applied automatically with the media player, so it is no longer needed to call applyEqualizer() manually.
parent 89ce945d
...@@ -89,10 +89,10 @@ jfloatArray Java_org_videolan_libvlc_LibVLC_getPreset(JNIEnv *env, jobject thiz, ...@@ -89,10 +89,10 @@ jfloatArray Java_org_videolan_libvlc_LibVLC_getPreset(JNIEnv *env, jobject thiz,
* apply equalizer settings (param bands is float[] (first element is preamp, then bands)) * apply equalizer settings (param bands is float[] (first element is preamp, then bands))
*/ */
//"--audio-filter=equalizer", "--equalizer-bands=-3.5 -4.5 -1 0 0 5 8 8 8 8", //"--audio-filter=equalizer", "--equalizer-bands=-3.5 -4.5 -1 0 0 5 8 8 8 8",
jint Java_org_videolan_libvlc_LibVLC_setNativeEqualizer(JNIEnv *env, jobject thiz, jfloatArray bands) jint Java_org_videolan_libvlc_LibVLC_setNativeEqualizer(JNIEnv *env, jobject thiz, jlong media_player, jfloatArray bands)
{ {
jint res = -1; jint res = -1;
libvlc_media_player_t *mp = getMediaPlayer(env, thiz); libvlc_media_player_t *mp = (libvlc_media_player_t*)(intptr_t)media_player;
if (!mp) if (!mp)
return res; return res;
......
...@@ -332,7 +332,6 @@ static void create_player_and_play(JNIEnv* env, jobject thiz, ...@@ -332,7 +332,6 @@ static void create_player_and_play(JNIEnv* env, jobject thiz,
/* Create a media player playing environment */ /* Create a media player playing environment */
libvlc_media_player_t *mp = libvlc_media_player_new((libvlc_instance_t*)(intptr_t)instance); libvlc_media_player_t *mp = libvlc_media_player_new((libvlc_instance_t*)(intptr_t)instance);
jobject myJavaLibVLC = (*env)->NewGlobalRef(env, thiz); jobject myJavaLibVLC = (*env)->NewGlobalRef(env, thiz);
//if AOUT_AUDIOTRACK_JAVA, we use amem //if AOUT_AUDIOTRACK_JAVA, we use amem
...@@ -363,6 +362,10 @@ static void create_player_and_play(JNIEnv* env, jobject thiz, ...@@ -363,6 +362,10 @@ static void create_player_and_play(JNIEnv* env, jobject thiz,
/* Keep a pointer to this media player */ /* Keep a pointer to this media player */
setLong(env, thiz, "mInternalMediaPlayerInstance", (jlong)(intptr_t)mp); setLong(env, thiz, "mInternalMediaPlayerInstance", (jlong)(intptr_t)mp);
cls = (*env)->GetObjectClass(env, thiz);
jmethodID methodID = (*env)->GetMethodID(env, cls, "applyEqualizer", "()V");
(*env)->CallVoidMethod(env, thiz, methodID);
setInt(env, thiz, "mInternalMediaPlayerIndex", (jint)position); setInt(env, thiz, "mInternalMediaPlayerIndex", (jint)position);
libvlc_media_list_lock(p_mlist); libvlc_media_list_lock(p_mlist);
libvlc_media_t* p_md = libvlc_media_list_item_at_index(p_mlist, position); libvlc_media_t* p_md = libvlc_media_list_item_at_index(p_mlist, position);
......
...@@ -301,10 +301,11 @@ public class LibVLC { ...@@ -301,10 +301,11 @@ public class LibVLC {
applyEqualizer(); applyEqualizer();
} }
public void applyEqualizer() private void applyEqualizer()
{ {
setNativeEqualizer(this.equalizer); setNativeEqualizer(mInternalMediaPlayerInstance, this.equalizer);
} }
private native int setNativeEqualizer(long mediaPlayer, float[] bands);
public boolean frameSkipEnabled() { public boolean frameSkipEnabled() {
return frameSkip; return frameSkip;
...@@ -649,6 +650,4 @@ public class LibVLC { ...@@ -649,6 +650,4 @@ public class LibVLC {
public native String[] getPresets(); public native String[] getPresets();
public native float[] getPreset(int index); public native float[] getPreset(int index);
private native int setNativeEqualizer(float[] bands);
} }
...@@ -752,7 +752,6 @@ public class AudioService extends Service { ...@@ -752,7 +752,6 @@ public class AudioService extends Service {
mLibVLC.playIndex(mCurrentIndex); mLibVLC.playIndex(mCurrentIndex);
} }
mLibVLC.applyEqualizer();
mHandler.sendEmptyMessage(SHOW_PROGRESS); mHandler.sendEmptyMessage(SHOW_PROGRESS);
setUpRemoteControlClient(); setUpRemoteControlClient();
showNotification(); showNotification();
...@@ -786,7 +785,6 @@ public class AudioService extends Service { ...@@ -786,7 +785,6 @@ public class AudioService extends Service {
} }
mLibVLC.playIndex(mCurrentIndex); mLibVLC.playIndex(mCurrentIndex);
mLibVLC.applyEqualizer();
mHandler.sendEmptyMessage(SHOW_PROGRESS); mHandler.sendEmptyMessage(SHOW_PROGRESS);
setUpRemoteControlClient(); setUpRemoteControlClient();
showNotification(); showNotification();
...@@ -968,7 +966,6 @@ public class AudioService extends Service { ...@@ -968,7 +966,6 @@ public class AudioService extends Service {
mLibVLC.getMediaList().getEventHandler().addHandler(mListEventHandler); mLibVLC.getMediaList().getEventHandler().addHandler(mListEventHandler);
mLibVLC.playIndex(mCurrentIndex); mLibVLC.playIndex(mCurrentIndex);
mLibVLC.applyEqualizer();
setUpRemoteControlClient(); setUpRemoteControlClient();
showNotification(); showNotification();
updateWidget(AudioService.this); updateWidget(AudioService.this);
...@@ -994,7 +991,6 @@ public class AudioService extends Service { ...@@ -994,7 +991,6 @@ public class AudioService extends Service {
mEventHandler.addHandler(mVlcEventHandler); mEventHandler.addHandler(mVlcEventHandler);
mLibVLC.playIndex(mCurrentIndex); mLibVLC.playIndex(mCurrentIndex);
mLibVLC.applyEqualizer();
setUpRemoteControlClient(); setUpRemoteControlClient();
showNotification(); showNotification();
updateWidget(AudioService.this); updateWidget(AudioService.this);
......
...@@ -1510,7 +1510,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -1510,7 +1510,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
savedIndexPosition = mLibVLC.getMediaList().size() - 1; savedIndexPosition = mLibVLC.getMediaList().size() - 1;
mLibVLC.playIndex(savedIndexPosition); mLibVLC.playIndex(savedIndexPosition);
} }
mLibVLC.applyEqualizer();
if (mLocation != null && mLocation.length() > 0 && !dontParse) { if (mLocation != null && mLocation.length() > 0 && !dontParse) {
// restore last position // restore last position
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment