diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-10-21 04:55:41 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-11-05 17:36:17 +0000 |
commit | 174df99ffa53f1091589eaa4fa0c16cdd55a9326 (patch) | |
tree | 3a60d45615f18beed98a9b08267c28ed7e05dd5f /misc/jni.c | |
parent | 3a8b107f6216b38a151d5ca1e9d4f2727e3418f5 (diff) | |
download | mpv-174df99ffa53f1091589eaa4fa0c16cdd55a9326.tar.bz2 mpv-174df99ffa53f1091589eaa4fa0c16cdd55a9326.tar.xz |
ALL: use new mp_thread abstraction
Diffstat (limited to 'misc/jni.c')
-rw-r--r-- | misc/jni.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/misc/jni.c b/misc/jni.c index 3f76f379cb..82f63565b5 100644 --- a/misc/jni.c +++ b/misc/jni.c @@ -22,15 +22,15 @@ #include <libavcodec/jni.h> #include <libavutil/mem.h> #include <libavutil/bprint.h> -#include <pthread.h> #include <stdlib.h> #include "jni.h" +#include "osdep/threads.h" static JavaVM *java_vm; static pthread_key_t current_env; -static pthread_once_t once = PTHREAD_ONCE_INIT; -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +static mp_once once = MP_STATIC_ONCE_INITIALIZER; +static mp_static_mutex lock = MP_STATIC_MUTEX_INITIALIZER; static void jni_detach_env(void *data) { @@ -49,7 +49,7 @@ JNIEnv *mp_jni_get_env(struct mp_log *log) int ret = 0; JNIEnv *env = NULL; - pthread_mutex_lock(&lock); + mp_mutex_lock(&lock); if (java_vm == NULL) { java_vm = av_jni_get_java_vm(NULL); } @@ -59,7 +59,7 @@ JNIEnv *mp_jni_get_env(struct mp_log *log) goto done; } - pthread_once(&once, jni_create_pthread_key); + mp_exec_once(&once, jni_create_pthread_key); if ((env = pthread_getspecific(current_env)) != NULL) { goto done; @@ -86,7 +86,7 @@ JNIEnv *mp_jni_get_env(struct mp_log *log) } done: - pthread_mutex_unlock(&lock); + mp_mutex_unlock(&lock); return env; } |