- use mqueue to execute ua_stop_all Api function on re thread
This commit is contained in:
@ -153,9 +153,9 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
||||
break;
|
||||
case UA_EVENT_AUDIO_ERROR:
|
||||
mem_deref(call);
|
||||
return;
|
||||
goto out;
|
||||
default:
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
event = event_buf;
|
||||
|
||||
@ -166,8 +166,8 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
||||
if (res != JNI_OK) {
|
||||
res = (*javaVM)->AttachCurrentThread(javaVM, &env, NULL);
|
||||
if (JNI_OK != res) {
|
||||
LOGE("failed to AttachCurrentThread, ErrorCode = %d", res);
|
||||
return;
|
||||
LOGE("failed to AttachCurrentThread, ErrorCode = %d\n", res);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
jmethodID methodId = (*env)->GetMethodID(env, pctx->mainActivityClz,
|
||||
@ -183,6 +183,9 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
||||
(*env)->DeleteLocalRef(env, javaUA);
|
||||
(*env)->DeleteLocalRef(env, javaCall);
|
||||
(*env)->DeleteLocalRef(env, javaEvent);
|
||||
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
static void message_handler(struct ua *ua, const struct pl *peer, const struct pl *ctype,
|
||||
@ -204,7 +207,7 @@ static void message_handler(struct ua *ua, const struct pl *peer, const struct p
|
||||
if (res != JNI_OK) {
|
||||
res = (*javaVM)->AttachCurrentThread(javaVM, &env, NULL);
|
||||
if (JNI_OK != res) {
|
||||
LOGE("Failed to AttachCurrentThread, ErrorCode = %d", res);
|
||||
LOGE("failed to AttachCurrentThread, ErrorCode = %d\n", res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -250,7 +253,7 @@ static void send_resp_handler(int err, const struct sip_msg *msg, void *arg)
|
||||
if (res != JNI_OK) {
|
||||
res = (*javaVM)->AttachCurrentThread(javaVM, &env, NULL);
|
||||
if (JNI_OK != res) {
|
||||
LOGE("Failed to AttachCurrentThread, ErrorCode = %d", res);
|
||||
LOGE("failed to AttachCurrentThread, ErrorCode = %d\n", res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -262,6 +265,21 @@ static void send_resp_handler(int err, const struct sip_msg *msg, void *arg)
|
||||
|
||||
}
|
||||
|
||||
enum {
|
||||
ID_UA_STOP_ALL
|
||||
};
|
||||
|
||||
static struct mqueue *mq;
|
||||
|
||||
static void mqueue_handler(int id, void *data, void *arg)
|
||||
{
|
||||
switch (id) {
|
||||
case ID_UA_STOP_ALL:
|
||||
LOGD("calling ua_stop_all with force %u\n", (unsigned)data);
|
||||
ua_stop_all((bool)data);
|
||||
}
|
||||
}
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
static int pfd[2];
|
||||
@ -408,6 +426,11 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
|
||||
(*env)->DeleteLocalRef(env, javaUA);
|
||||
}
|
||||
|
||||
LOGI("allocating mqeue\n");
|
||||
err = mqueue_alloc(&mq, mqueue_handler, NULL);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
LOGI("running main loop ...\n");
|
||||
err = re_main(signal_handler);
|
||||
|
||||
@ -422,6 +445,7 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
|
||||
|
||||
play = mem_deref(play);
|
||||
message = mem_deref(message);
|
||||
mq = mem_deref(mq);
|
||||
|
||||
LOGD("closing ...");
|
||||
ua_close();
|
||||
@ -451,7 +475,7 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_tutpro_baresip_BaresipService_baresipStop(JNIEnv *env, jobject thiz, jboolean force) {
|
||||
LOGD("ua_stop_all upon baresipStop");
|
||||
ua_stop_all(force);
|
||||
mqueue_push(mq, ID_UA_STOP_ALL, (void *)force);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +115,8 @@ class ContactsActivity : AppCompatActivity() {
|
||||
if (parts.size == 3) {
|
||||
val name = parts[1]
|
||||
val uri = parts[2].trim()
|
||||
Api.contact_add("\"$name\" $uri")
|
||||
// Currently no need to make baresip aware of the contact
|
||||
// Api.contact_add("\"$name\" $uri")
|
||||
Contact.contacts().add(Contact(name, uri))
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ class MainActivity : AppCompatActivity() {
|
||||
stopState = "initial"
|
||||
quitTimer = object: CountDownTimer(5000, 1000) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
Log.d("Baresip", "seconds remaining: ${millisUntilFinished/1000}")
|
||||
Log.d("Baresip", "Seconds remaining: ${millisUntilFinished/1000}")
|
||||
}
|
||||
override fun onFinish() {
|
||||
when (stopState) {
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
- peers of calls and messages can be added to contacts by long clicks\n
|
||||
- long clicks can also be used to remove calls, chats, messages, and contacts\n
|
||||
- call click when callee has not been given can be used for re-dial\n
|
||||
- quit without network connectivity may take up to 10 seconds\n
|
||||
</string>
|
||||
<string name="noAccounts">No accounts</string>
|
||||
<string name="dispName">Name (if any) used in From URI of outbound requests.</string>
|
||||
|
||||
Reference in New Issue
Block a user