我試圖做一個簡單的計時器,當它的時間到來時觸發特定的回調。 我寫了這個代碼:pjsip pj_timer_heap_schedule崩潰
void testTimer()
{
pj_timer_heap_t *timer_heap;
pj_timer_entry registrationTimer;
char *username="test_data";
pj_timer_entry_init(®istrationTimer, 50, username, &on_timer_event);
pj_time_val delay;
delay.sec = 5;
delay.msec = 0;
pj_status_t status = pj_timer_heap_create(global.pool, 256, &timer_heap);
status=pj_timer_heap_schedule(timer_heap,®istrationTimer, &delay);
}
我不知道什麼是錯的代碼。此代碼在pj_timer_heap_schedule
上崩潰。我無法弄清楚缺少什麼。請幫助。
你說的*崩潰意味着*? – nouney
我正在導出一個包含一些方法作爲DLL文件的類,我從C#應用程序中使用它,當我調用testTimer()時,我的C sharp應用程序崩潰。 –
對'pj_timer_heap_create'的調用失敗,並且你正在將'timer_heap'傳遞給'pj_timer_heap_schedule'?除此之外,您可能想嘗試pjsua_schedule_timer(請參閱http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__BASE.htm#ga4b3f7529ece820df563c4b1a4f4a649b)。使用更簡單。最後,我認爲你的代碼有另一個bug:'registrationTimer'將會超出範圍,而且我記得,它必須保持有效,直到回調觸發。 – chr