コード例 #1
0
ファイル: svp.c プロジェクト: 4leavedclover/userland
/** Callback from video decode output port. */
static void svp_bh_output_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buf)
{
   SVP_T *svp = (SVP_T *)port->userdata;

   if (buf->length == 0)
   {
      LOG_TRACE("%s: zero-length buffer => EOS", port->name);
      svp_set_stop(svp, SVP_STOP_EOS); // This shouldn't be necessary, but it is ...
      mmal_buffer_header_release(buf);
   }
   else if (buf->data == NULL)
   {
      LOG_ERROR("%s: zero buffer handle", port->name);
      mmal_buffer_header_release(buf);
   }
   else
   {
      /* Reset watchdog timer */
      vcos_timer_set(&svp->wd_timer, SVP_WATCHDOG_TIMEOUT_MS);

      /* Enqueue the decoded frame so we can return quickly to MMAL core */
      mmal_queue_put(svp->queue, buf);
   }

   /* Notify worker */
   vcos_semaphore_post(&svp->sema);
}
コード例 #2
0
ファイル: timer.c プロジェクト: cgjones/brcm_usrlib_dag
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;
}
コード例 #3
0
void _vcos_task_timer_set(void (*pfn)(void*), void *cxt, VCOS_UNSIGNED ms)
{
   VCOS_THREAD_T *thread = vcos_thread_current();
   VCOS_STATUS_T status;
   status = vcos_timer_create(&thread->task_timer, "vcos_task_timer", pfn, cxt);
   vcos_assert(status == VCOS_SUCCESS);
   vcos_timer_set(&thread->task_timer, ms);
}
コード例 #4
0
ファイル: svp.c プロジェクト: 4leavedclover/userland
/* Start SVP. Enables MMAL connection + creates worker thread. */
int svp_start(SVP_T *svp)
{
   MMAL_STATUS_T st;
   VCOS_STATUS_T vst;

   /* Ensure SVP is stopped first */
   svp_stop(svp);

   /* Reset the worker thread stop status, before enabling ports that might trigger a stop */
   svp_reset_stop(svp);

   if (svp->connection)
   {
      /* Enable reader->decoder connection */
      st = mmal_connection_enable(svp->connection);
      CHECK_STATUS(st, "Failed to create connection");
   }

   /* Enable video output port */
   st = svp_port_enable(svp, svp->video_output, svp_bh_output_cb);
   CHECK_STATUS(st, "Failed to enable output port");

   /* Reset stats */
   svp->stats.video_frame_count = 0;

   /* Create worker thread */
   vst = vcos_thread_create(&svp->thread, "svp-worker", NULL, svp_worker, svp);
   CHECK_STATUS((vst == VCOS_SUCCESS ? MMAL_SUCCESS : MMAL_ENOMEM), "Failed to create connection");

   svp->created |= SVP_CREATED_THREAD;

   /* Set timer */
   if (svp->camera)
   {
      unsigned ms = svp->opts.duration_ms;
      vcos_timer_set(&svp->timer, ((ms == 0) ? SVP_CAMERA_DURATION_MS : ms));
   }

   /* Start watchdog timer */
   vcos_timer_set(&svp->wd_timer, SVP_WATCHDOG_TIMEOUT_MS);

   return 0;

error:
   return -1;
}
コード例 #5
0
void _vcos_task_timer_set(void (*pfn)(void *), void *cxt, VCOS_UNSIGNED ms)
{
   VCOS_THREAD_T *self = vcos_thread_current();
   vcos_assert(self);
   vcos_assert(self->_timer.pfn == NULL);

   vcos_timer_create( &self->_timer.timer, "TaskTimer", pfn, cxt );
   vcos_timer_set(&self->_timer.timer, ms);
}
void _vcos_task_timer_set(void (*pfn)(void*), void *cxt, VCOS_UNSIGNED ms)
{
   VCOS_THREAD_T *self = vcos_thread_current();
   vcos_assert(self);
   vcos_assert(self->_timer.pfn == NULL);
   self->_timer.pfn = pfn;
   self->_timer.cxt = cxt;
   vcos_timer_set(&self->_timer.timer, ms);
}
コード例 #7
0
ファイル: timer.c プロジェクト: cgjones/brcm_usrlib_dag
/* 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;
}
コード例 #8
0
void _vcos_task_timer_set(void (*pfn)(void*), void *cxt, VCOS_UNSIGNED ms)
{
   VCOS_THREAD_T *thread = vcos_thread_current();

   if (thread == NULL)
      return;

   vcos_assert(thread->orig_task_timer_expiration_routine == NULL);

   if (!thread->task_timer_created)
   {
      VCOS_STATUS_T st = vcos_timer_create(&thread->task_timer, NULL,
                                _task_timer_expiration_routine, thread);
      (void)st;
      vcos_assert(st == VCOS_SUCCESS);
      thread->task_timer_created = 1;
   }

   thread->orig_task_timer_expiration_routine = pfn;
   thread->orig_task_timer_context = cxt;

   vcos_timer_set(&thread->task_timer, ms);
}
コード例 #9
0
ファイル: vcos_pthreads.c プロジェクト: MHesham/bsp
void vcos_timer_reset(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay_ms)
{
   vcos_timer_set(timer, delay_ms);
}