Commit 9aefb516 authored by François Grisez's avatar François Grisez

Add comments

parent 1f8f597e
......@@ -4,7 +4,19 @@
#include <jni.h>
#include "belle-sip/defs.h"
/**
* Initialize the Android wake lock system inside Belle-SIP.
* This function must be called only once when the program starts.
* @param env A JNI environment
* @parma pm An android.os.PowerManager java object.
*/
BELLESIP_EXPORT void bellesip_wake_lock_init(JNIEnv *env, jobject pm);
/**
* Uninit the the Android wake lock system. This function may be called
* while the program stopping.
* @param env A JNI environment.
*/
BELLESIP_EXPORT void bellesip_wake_lock_uninit(JNIEnv *env);
#endif // WALE_LOCK_H
......@@ -39,7 +39,7 @@ void bellesip_wake_lock_init(JNIEnv *env, jobject pm) {
belle_sip_message("bellesip_wake_lock_init(): initialization succeed");
} else {
belle_sip_error("bellesip_wake_lock_init(): the wakelock system has already been initialized");
belle_sip_warning("bellesip_wake_lock_init(): the wakelock system has already been initialized");
}
}
......@@ -51,6 +51,11 @@ void bellesip_wake_lock_uninit(JNIEnv *env) {
}
}
/**
* @brief Callback called when a thread terminates it-self.
* It detaches the thread from the JVM.
* @param data Unused.
*/
static void jni_key_cleanup(void *data) {
belle_sip_message("Thread end. Cleanup wake lock jni environment");
JNIEnv *env = pthread_getspecific(ctx.jniEnvKey);
......@@ -64,6 +69,13 @@ static void jni_key_cleanup(void *data) {
}
}
/**
* @brief Get a JNI environment.
* Get a JNI by attaching the current thread
* to the internaly stored JVM. That function can be safely
* called several times.
* @return JNI environement pointer. NULL if the function fails.
*/
static JNIEnv *get_jni_env(void) {
JNIEnv *jenv = NULL;
if(ctx.jvm != NULL) {
......
#include "belle-sip/wakelock.h"
/**
* @brief Acquire a wake lock.
* Ask to Android to prevent the system sleeping. That function
* do nothing if the wake lock system has not been initialized
* by the function bellesip_wake_lock_init().
* @param tag
* @return An ID that anthentificates the taken wake lock.
*/
extern unsigned long wake_lock_acquire(const char *tag);
/**
* @brief Release a wake lock.
* Ask to Android to release a prevously aquired
* wake lock. After calling this function, the system
* can sleep again.
* @param id ID of the wake lock to release.
*/
extern void wake_lock_release(unsigned long id);
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