queue_data_s *qd;
LOG_DEBUG("wait for data...");
- qd = g_async_queue_pop(webrtc->snapshot.queue);
+ if (!(qd = g_async_queue_pop(webrtc->snapshot.queue))) {
+ LOG_ERROR("qd is NULL");
+ break;
+ }
LOG_INFO("process qd[%p, vbuffer:%p, target_format:%s, exit:%d]",
qd, qd->vbuffer, __get_format_str((webrtc_snapshot_format_e)qd->target_format), qd->exit);
if (qd->exit) {
int _init_convert_thread(webrtc_s *webrtc)
{
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(webrtc->snapshot.queue != NULL, WEBRTC_ERROR_INVALID_OPERATION, "snapshot.queue is not NULL");
+ RET_VAL_IF(webrtc->snapshot.thread != NULL, WEBRTC_ERROR_INVALID_OPERATION, "snapshot.thread is not NULL");
+
+ webrtc->snapshot.queue = g_async_queue_new_full(__release_queue_data);
if (!(webrtc->snapshot.thread = g_thread_try_new("convert_thread", __convert_thread, (gpointer)webrtc, NULL))) {
LOG_ERROR("failed to g_thread_try_new()");
+ g_async_queue_unref(webrtc->snapshot.queue);
+ webrtc->snapshot.queue = NULL;
return WEBRTC_ERROR_INVALID_OPERATION;
}
- webrtc->snapshot.queue = g_async_queue_new_full(__release_queue_data);
-
return WEBRTC_ERROR_NONE;
}
queue_data_s *qd;
RET_IF(webrtc == NULL, "webrtc is NULL");
+ RET_IF(webrtc->snapshot.queue == NULL, "snapshot.queue is NULL");
+ RET_IF(webrtc->snapshot.thread == NULL, "snapshot.thread is NULL");
qd = g_new0(queue_data_s, 1);
qd->exit = true;
LOG_DEBUG("convert thread exits");
g_async_queue_unref(webrtc->snapshot.queue);
+
+ webrtc->snapshot.queue = NULL;
+ webrtc->snapshot.thread = NULL;
}
int _capture_video_frame(webrtc_gst_slot_s *sink)