Re-introduced modified mqueue usage for ua_stop_all

This commit is contained in:
Juha Heinanen
2022-06-22 12:21:40 +03:00
parent 4f29159f57
commit 509b6722eb
+20 -3
View File
@@ -364,6 +364,16 @@ enum {
ID_UA_STOP_ALL ID_UA_STOP_ALL
}; };
static struct mqueue *mq;
static void mqueue_handler(int id, void *data, void *arg)
{
if (id == ID_UA_STOP_ALL) {
LOGD("calling ua_stop_all with force %u\n", (unsigned)(uintptr_t)data);
ua_stop_all((bool)(uintptr_t)data);
}
}
#include <unistd.h> #include <unistd.h>
static int pfd[2]; static int pfd[2];
@@ -521,6 +531,13 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
goto out; goto out;
} }
err = mqueue_alloc(&mq, mqueue_handler, NULL);
if (err) {
LOGW("mqueue_alloc failed (%d)\n", err);
strcpy(start_error, "mqueue_alloc");
goto out;
}
jmethodID startedId = (*env)->GetMethodID(env, g_ctx.mainActivityClz, "started", "()V"); jmethodID startedId = (*env)->GetMethodID(env, g_ctx.mainActivityClz, "started", "()V");
(*env)->CallVoidMethod(env, g_ctx.mainActivityObj, startedId); (*env)->CallVoidMethod(env, g_ctx.mainActivityObj, startedId);
@@ -536,6 +553,8 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
LOGI("main loop exit\n"); LOGI("main loop exit\n");
} }
mq = mem_deref(mq);
LOGD("closing ..."); LOGD("closing ...");
ua_close(); ua_close();
module_app_unload(); module_app_unload();
@@ -566,9 +585,7 @@ JNIEXPORT void JNICALL
Java_com_tutpro_baresip_BaresipService_baresipStop(JNIEnv *env, jobject thiz, jboolean force) Java_com_tutpro_baresip_BaresipService_baresipStop(JNIEnv *env, jobject thiz, jboolean force)
{ {
LOGD("ua_stop_all upon baresipStop"); LOGD("ua_stop_all upon baresipStop");
re_thread_enter(); mqueue_push(mq, ID_UA_STOP_ALL, (void *)((long)force));
ua_stop_all(force);
re_thread_leave();
} }
JNIEXPORT jstring JNICALL JNIEXPORT jstring JNICALL