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

View File

@ -364,6 +364,16 @@ enum {
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>
static int pfd[2];
@ -521,6 +531,13 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
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");
(*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");
}
mq = mem_deref(mq);
LOGD("closing ...");
ua_close();
module_app_unload();
@ -566,9 +585,7 @@ JNIEXPORT void JNICALL
Java_com_tutpro_baresip_BaresipService_baresipStop(JNIEnv *env, jobject thiz, jboolean force)
{
LOGD("ua_stop_all upon baresipStop");
re_thread_enter();
ua_stop_all(force);
re_thread_leave();
mqueue_push(mq, ID_UA_STOP_ALL, (void *)((long)force));
}
JNIEXPORT jstring JNICALL