/* Destroy SVP instance. svp may be NULL. */ void svp_destroy(SVP_T *svp) { if (svp) { MMAL_COMPONENT_T *components[] = { svp->reader, svp->video_decode, svp->camera }; MMAL_COMPONENT_T **comp; /* Stop thread, disable connection and components */ svp_stop(svp); for (comp = components; comp < components + vcos_countof(components); comp++) { mmal_component_disable(*comp); } /* Destroy connection + components */ if (svp->connection) { mmal_connection_destroy(svp->connection); } for (comp = components; comp < components + vcos_countof(components); comp++) { mmal_component_destroy(*comp); } /* Free remaining resources */ if (svp->out_pool) { mmal_pool_destroy(svp->out_pool); } if (svp->queue) { mmal_queue_destroy(svp->queue); } if (svp->created & SVP_CREATED_WD_TIMER) { vcos_timer_delete(&svp->wd_timer); } if (svp->created & SVP_CREATED_TIMER) { vcos_timer_delete(&svp->timer); } if (svp->created & SVP_CREATED_MUTEX) { vcos_mutex_delete(&svp->mutex); } if (svp->created & SVP_CREATED_SEM) { vcos_semaphore_delete(&svp->sema); } vcos_free(svp); } }
static int multiple_timer_test(void) { int passed; VCOS_TIMER_T timers[32]; int i; memset(results,0,sizeof(results)); for (i=0; i<32; i++) { VCOS_STATUS_T st = vcos_timer_create(timers+i,"test",multi_pfn,&results[i]); if (st != VCOS_SUCCESS) return 0; } for (i=0; i<32; i++) { vcos_timer_set(timers+i,1+i*10); } vcos_sleep(i*20); /* check each timer fired */ passed = 1; for (i=0; i<32; i++) { if (!results[i]) { vcos_log("timer %d failed to go off", i); passed = 0; } vcos_timer_delete(timers+i); } return passed; }
static void delete_base(VCOS_THREAD_T *thread) { if (CREATE_THREAD_TIMER) vcos_timer_delete(&thread->_timer.timer); vcos_semaphore_delete(&thread->suspend); vcos_semaphore_delete(&thread->wait); }
static void vcos_thread_cleanup(VCOS_THREAD_T *thread) { vcos_semaphore_delete(&thread->suspend); if (thread->task_timer_created) { vcos_timer_delete(&thread->task_timer); } }
void _vcos_task_timer_cancel(void) { VCOS_THREAD_T *thread = vcos_thread_current(); if (thread->task_timer.pfn) { thread->task_timer.pfn = NULL; vcos_timer_delete(&thread->task_timer); } }
void _vcos_task_timer_cancel(void) { VCOS_THREAD_T *self = vcos_thread_current(); if (self->_timer.timer.linux_timer.function) { vcos_timer_cancel(&self->_timer.timer); vcos_timer_delete(&self->_timer.timer); } }
void vcos_thread_join(VCOS_THREAD_T *thread, void **pData) { pthread_join(thread->thread, pData); vcos_semaphore_delete(&thread->suspend); if (thread->task_timer_created) { vcos_timer_delete(&thread->task_timer); } }
void vcos_thread_join(VCOS_THREAD_T *thread, void **pData) { pthread_join(thread->thread, pData); vcos_semaphore_delete(&thread->suspend); /* Delete the task timer, if present */ _vcos_task_timer_cancel(); if (thread->task_timer.pfn) { vcos_timer_delete(&thread->task_timer); thread->task_timer.pfn = NULL; } }
/* create a single timer, and check it does as expected */ static int basic_timer_test(void) { VCOS_TIMER_T timer; VCOS_STATUS_T status = vcos_timer_create(&timer, "test", basic_pfn, (void*)42); basic_cxt = 0; if (status != VCOS_SUCCESS) return 0; vcos_timer_set(&timer, 100); vcos_sleep(200); if (basic_cxt != (void*)42) return 0; vcos_timer_delete(&timer); return 1; }