diff options
author | Matthieu Bouron <matthieu.bouron@stupeflix.com> | 2016-07-01 09:59:13 +0200 |
---|---|---|
committer | Matthieu Bouron <matthieu.bouron@stupeflix.com> | 2016-07-27 15:43:39 +0200 |
commit | 376d8fb2c5742e6718323d6a69479c6ee68dd75b (patch) | |
tree | bcf8a1bc9c40fd3b46359cc481632fad95855082 /libavcodec/ffjni.h | |
parent | 293676c476733e81d7b596736add6cd510eb6960 (diff) |
lavc/ffjni: replace ff_jni_{attach,detach} with ff_jni_get_env
If a JNI environment is not already attached to the thread where the
MediaCodec calls are made the current implementation will attach /
detach an environment for each MediaCodec call wasting some CPU time.
ff_jni_get_env replaces ff_jni_{attach,detach} by permanently attaching
an environment (if it is not already the case) to the current thread.
The environment will be automatically detached at the thread destruction
using a pthread_key callback.
Saves around 5% of CPU time (out of 20%) while decoding a stream with
MediaCodec.
Diffstat (limited to 'libavcodec/ffjni.h')
-rw-r--r-- | libavcodec/ffjni.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/libavcodec/ffjni.h b/libavcodec/ffjni.h index 990c7b9c3f..6027bac0ab 100644 --- a/libavcodec/ffjni.h +++ b/libavcodec/ffjni.h @@ -26,7 +26,10 @@ #include <jni.h> /* - * Attach a JNI environment to the current thread. + * Attach permanently a JNI environment to the current thread and retrieve it. + * + * If successfully attached, the JNI environment will automatically be detached + * at thread destruction. * * @param attached pointer to an integer that will be set to 1 if the * environment has been attached to the current thread or 0 if it is @@ -34,15 +37,7 @@ * @param log_ctx context used for logging, can be NULL * @return the JNI environment on success, NULL otherwise */ -JNIEnv *ff_jni_attach_env(int *attached, void *log_ctx); - -/* - * Detach the JNI environment from the current thread. - * - * @param log_ctx context used for logging, can be NULL - * @return 0 on success, < 0 otherwise - */ -int ff_jni_detach_env(void *log_ctx); +JNIEnv *ff_jni_get_env(void *log_ctx); /* * Convert a jstring to its utf characters equivalent. |