Changeset 4927


Ignore:
Timestamp:
Sep 23, 2014 4:13:40 AM (6 years ago)
Author:
ming
Message:

Fixed #1792: Create generic JNI OnLoad? function

Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/os_core_unix.c

    r4728 r4927  
    4949#define SIGNATURE1  0xDEAFBEEF 
    5050#define SIGNATURE2  0xDEADC0DE 
     51 
     52#ifndef PJ_JNI_HAS_JNI_ONLOAD 
     53#  define PJ_JNI_HAS_JNI_ONLOAD    PJ_ANDROID 
     54#endif 
     55 
     56#if defined(PJ_JNI_HAS_JNI_ONLOAD) && PJ_JNI_HAS_JNI_ONLOAD != 0 
     57 
     58#include <jni.h> 
     59 
     60JavaVM *pj_jni_jvm = NULL; 
     61 
     62JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) 
     63{ 
     64    pj_jni_jvm = vm; 
     65     
     66    return JNI_VERSION_1_4; 
     67} 
     68#endif 
    5169 
    5270struct pj_thread_t 
  • pjproject/trunk/pjmedia/src/pjmedia-audiodev/android_jni_dev.c

    r4896 r4927  
    142142}; 
    143143 
    144 JavaVM *android_jvm; 
    145  
    146 JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) 
    147 { 
    148     android_jvm = vm; 
    149      
    150     return JNI_VERSION_1_4; 
    151 } 
     144extern JavaVM *pj_jni_jvm; 
    152145 
    153146static pj_bool_t attach_jvm(JNIEnv **jni_env) 
    154147{ 
    155     if ((*android_jvm)->GetEnv(android_jvm, (void **)jni_env, 
     148    if ((*pj_jni_jvm)->GetEnv(pj_jni_jvm, (void **)jni_env, 
    156149                               JNI_VERSION_1_4) < 0) 
    157150    { 
    158         if ((*android_jvm)->AttachCurrentThread(android_jvm, jni_env, NULL) < 0) 
     151        if ((*pj_jni_jvm)->AttachCurrentThread(pj_jni_jvm, jni_env, NULL) < 0) 
    159152        { 
    160153            jni_env = NULL; 
     
    169162#define detach_jvm(attached) \ 
    170163    if (attached) \ 
    171         (*android_jvm)->DetachCurrentThread(android_jvm); 
     164        (*pj_jni_jvm)->DetachCurrentThread(pj_jni_jvm); 
    172165 
    173166/* Thread priority utils */ 
Note: See TracChangeset for help on using the changeset viewer.