Open zhuangguangkang0013 opened 2 weeks ago
this call android record and playtrack. c file . https://github.com/pjsip/pjproject/blob/master/pjmedia/src/pjmedia-audiodev/android_jni_dev.c
"stream->running" may be need add mutx lock ? ` / API: start stream. / static pj_status_t strm_start(pjmedia_aud_stream s) { struct extern_aud_stream stream = (struct extern_aud_stream*)s; PJ_LOG(5, (THIS_FILE, "Recorder call start method %d",stream->running)); pj_mutex_lock(stream->lock); if (!stream->running) { stream->running = PJ_TRUE; if (stream->record) pj_sem_post(stream->rec_sem); if (stream->track) pj_sem_post(stream->play_sem); } pj_mutex_unlock(stream->lock); PJ_LOG(4, (THIS_FILE, "Extern Audio JNI stream started"));
return PJ_SUCCESS;
}
/ API: stop stream. / static pj_status_t strm_stop(pjmedia_aud_stream s) { struct extern_aud_stream stream = (struct extern_aud_stream*)s; PJ_LOG(5, (THIS_FILE, "Recorder call stop2 method %d",stream->running)); pj_mutex_lock(stream->lock); if (!stream->running){ pj_mutex_unlock(stream->lock); return PJ_SUCCESS; } stream->running = PJ_FALSE; pj_mutex_unlock(stream->lock); PJ_LOG(4,(THIS_FILE, "Extern Audio JNI stream stopped"));
return PJ_SUCCESS;
}`
Because stream can be started and stopped (strm_start()
and strm_stop()
).
e.g.:
On stream stop/strm_stop()
:
stream->running
= PJ_FALSE;strm_start()
is called.因为流可以启动和停止(
strm_start()
和strm_stop()
)。 例如: 在流停止/上strm_stop()
:
stream->running
=PJ_FALSE;- AndroidRecorderCallback() 将进入 (!stream->running) 块并等待直到流恢复/
strm_start()
被调用。
This will cause repeated callbacks when first started. It will continuously call back start, stop, start. The MIC device will be restarted and turned on and off many times. Maybe there should be a different way to control the pause of the call mic?
I can only see the record_method()
called once at the start of the thread. It should be no issue when the stream is started.
Is there any negative impact to application with one extra call to the record_method()
?
I can only see the
record_method()
called once at the start of the thread. It should be no issue when the stream is started. Is there any negative impact to application with one extra call to therecord_method()
?
If other functions use MIC and need to mutually exclude SIP calls, then turn off other occupancy when MIC is ready to be turned on. If there are multiple callbacks, other functions will be turned on and off multiple times.
Describe the bug
pjsip for android .android audioRecord jni .may be call two count.this is bug?why in while check?
Steps to reproduce
When the call is connected, the startrecord method may be executed twice in succession, once to startrecord and once to stop. Then execute start again. When I comment out this code in the while loop, it seems to be normal. When making an outgoing call, execute start once, and execute stop and release after hanging up. When receiving an incoming call, execute start once after answering the call, and execute stop and release after hanging up. It will no longer execute startrecord once, then stop once, and then start again when making a call.
https://github.com/pjsip/pjproject/blob/master/pjmedia/src/pjmedia-audiodev/android_jni_dev.c `static int AndroidRecorderCallback(void userData) { ........... / Start recording / pj_thread_set_prio(NULL, THREAD_PRIORITY_URGENT_AUDIO); (jni_env)->CallVoidMethod(jni_env, stream->record, record_method);
on_return: detach_jvm(attached); PJ_LOG(5, (THIS_FILE, "Recorder thread stopped")); stream->rec_thread_exited = 1;
}`
PJSIP version
2.12
Context
os:android os version:8.1 pjsip version:2.12
Log, call stack, etc