/* Start recording
* setpriority(PRIO_PROCESS,
0, -19); //ANDROID_PRIORITY_AUDIO
* set priority is probably
not enough because it does not change the thread
* group in scheduler
* Temporary solution is to
call the java api to set the thread priority.
* A cool solution would be
to port (if possible) the code from the
* android os regarding
set_sched groups
*/
set_android_thread_priority(THREAD_PRIORITY_URGENT_AUDIO);
(*jni_env)->CallVoidMethod(jni_env, stream->record, record_method);
while (!stream->quit_flag) {
pjmedia_frame frame;
pj_status_t status;
int bytesRead;
if
(!stream->running) {
(*jni_env)->CallVoidMethod(jni_env, stream->record, stop_method);
pj_sem_wait(stream->rec_sem);
if
(stream->quit_flag)
break;
(*jni_env)->CallVoidMethod(jni_env, stream->record, record_method);
}
bytesRead =
(*jni_env)->CallIntMethod(jni_env, stream->record,
read_method, inputBuffer,
0, size);
------>
if (bytesRead <=
0 || bytesRead != size) {
PJ_LOG
(4, (THIS_FILE, "Record thread : error %d reading data",
bytesRead));
continue;
}
--------->
buf =
(*jni_env)->GetByteArrayElements(jni_env, inputBuffer, 0);
frame.type =
PJMEDIA_FRAME_TYPE_AUDIO;
frame.size =
size;
frame.bit_info = 0;
frame.buf = (void
*)buf;
frame.timestamp.u64
= stream->rec_timestamp.u64;
status =
(*stream->rec_cb)(stream->user_data, &frame);
(*jni_env)->ReleaseByteArrayElements(jni_env, inputBuffer, buf,
JNI_ABORT);
if (status != PJ_SUCCESS ||
stream->quit_flag)
break;
stream->rec_timestamp.u64 += stream->param.samples_per_frame /
stream->param.channel_count;
}
(*jni_env)->DeleteLocalRef(jni_env,
inputBuffer);
on_return:
detach_jvm(attached);
PJ_LOG(5, (THIS_FILE,
"Recorder thread stopped"));
stream->rec_thread_exited = 1;
return 0;
}
_______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@xxxxxxxxxxxxxxx http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org