Commit 22c75a69 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

add "no-video" when playing as audio, to prevent video decoding when we don't display it

parent bf06caea
......@@ -40,7 +40,7 @@
#define AOUT_AUDIOTRACK_JAVA 1
#define AOUT_OPENSLES 2
libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring fileLocation, bool noOmx)
libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring fileLocation, bool noOmx, bool noVideo)
{
libvlc_instance_t *libvlc = (libvlc_instance_t*)instance;
jboolean isCopy;
......@@ -67,6 +67,8 @@ libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring file
libvlc_media_add_option(p_md, ":network-caching=1500");
libvlc_media_add_option(p_md, ":codec=iomx,all");
}
if (noVideo)
libvlc_media_add_option(p_md, ":no-video");
}
return p_md;
}
......@@ -436,7 +438,7 @@ jobjectArray Java_org_videolan_vlc_LibVLC_readMediaMeta(JNIEnv *env,
(*env)->FindClass(env, "java/lang/String"),
(*env)->NewStringUTF(env, ""));
libvlc_media_t *m = new_media(instance, env, thiz, mrl, false);
libvlc_media_t *m = new_media(instance, env, thiz, mrl, false, false);
if (!m)
{
LOGE("readMediaMeta: Could not create the media!");
......@@ -472,13 +474,13 @@ jobjectArray Java_org_videolan_vlc_LibVLC_readMediaMeta(JNIEnv *env,
}
void Java_org_videolan_vlc_LibVLC_readMedia(JNIEnv *env, jobject thiz,
jint instance, jstring mrl)
jint instance, jstring mrl, jboolean novideo)
{
/* Release previous media player, if any */
releaseMediaPlayer(env, thiz);
/* Create a new item */
libvlc_media_t *m = new_media(instance, env, thiz, mrl, false);
libvlc_media_t *m = new_media(instance, env, thiz, mrl, false, novideo);
if (!m)
{
LOGE("readMedia: Could not create the media!");
......@@ -530,7 +532,7 @@ jboolean Java_org_videolan_vlc_LibVLC_hasVideoTrack(JNIEnv *env, jobject thiz,
jint i_instance, jstring fileLocation)
{
/* Create a new item and assign it to the media player. */
libvlc_media_t *p_m = new_media(i_instance, env, thiz, fileLocation, false);
libvlc_media_t *p_m = new_media(i_instance, env, thiz, fileLocation, false, false);
if (p_m == NULL)
{
LOGE("Could not create the media!");
......@@ -577,7 +579,7 @@ jobjectArray Java_org_videolan_vlc_LibVLC_readTracksInfo(JNIEnv *env, jobject th
}
/* Create a new item and assign it to the media player. */
libvlc_media_t *p_m = new_media(instance, env, thiz, mrl, false);
libvlc_media_t *p_m = new_media(instance, env, thiz, mrl, false, false);
if (p_m == NULL)
{
LOGE("Could not create the media!");
......@@ -667,7 +669,7 @@ jlong Java_org_videolan_vlc_LibVLC_getLengthFromLocation(JNIEnv *env, jobject th
monitor->length_changed = false;
/* Create a new item and assign it to the media player. */
libvlc_media_t *m = new_media(i_instance, env, thiz, fileLocation, false);
libvlc_media_t *m = new_media(i_instance, env, thiz, fileLocation, false, false);
if (m == NULL)
{
LOGE("Could not create the media to play!");
......
......@@ -133,7 +133,7 @@ jbyteArray Java_org_videolan_vlc_LibVLC_getThumbnail(JNIEnv *env, jobject thiz,
/* Create a media player playing environment */
sys->mp = libvlc_media_player_new(libvlc);
libvlc_media_t *m = new_media(instance, env, thiz, filePath, true);
libvlc_media_t *m = new_media(instance, env, thiz, filePath, true, false);
if (m == NULL)
{
LOGE("Could not create the media to play!");
......
......@@ -21,7 +21,7 @@
#ifndef LIBVLCJNI_UTILS_H
#define LIBVLCJNI_UTILS_H
libvlc_media_t *new_media(jint libvlc, JNIEnv *env, jobject thiz, jstring filePath, bool noOmx);
libvlc_media_t *new_media(jint libvlc, JNIEnv *env, jobject thiz, jstring filePath, bool noOmx, bool noVideo);
#endif // LIBVLCJNI_UTILS_H
......@@ -292,7 +292,7 @@ public class AudioService extends Service {
return;
}
}
mLibVLC.readMedia(mCurrentMedia.getLocation());
mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
mHandler.sendEmptyMessage(SHOW_PROGRESS);
showNotification();
updateWidget(this);
......@@ -306,7 +306,7 @@ public class AudioService extends Service {
mCurrentMedia = mMediaList.get(index - 1);
else
return;
mLibVLC.readMedia(mCurrentMedia.getLocation());
mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
mHandler.sendEmptyMessage(SHOW_PROGRESS);
showNotification();
updateWidget(this);
......@@ -483,7 +483,7 @@ public class AudioService extends Service {
}
if (mCurrentMedia != null)
mLibVLC.readMedia(mCurrentMedia.getLocation());
mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
showNotification();
}
......
......@@ -221,9 +221,9 @@ public class LibVLC {
/**
* Read a media.
*/
public void readMedia(String mrl) {
public void readMedia(String mrl, boolean novideo) {
Log.v(TAG, "Reading " + mrl);
readMedia(mLibVlcInstance, mrl);
readMedia(mLibVlcInstance, mrl, novideo);
}
public String[] readMediaMeta(String mrl) {
......@@ -272,7 +272,7 @@ public class LibVLC {
* @param instance: the instance of libVLC
* @param mrl: the media mrl
*/
private native void readMedia(int instance, String mrl);
private native void readMedia(int instance, String mrl, boolean novideo);
/**
* Return true if there is currently a running media player.
......
......@@ -807,7 +807,7 @@ public class VideoPlayerActivity extends Activity {
}
if (location != null && location.length() > 0) {
mLibVLC.readMedia(location);
mLibVLC.readMedia(location, false);
if (!mWakeLock.isHeld())
mWakeLock.acquire();
......
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