From a1163a63376d86af317c3fd83aad2333e1fa5c54 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 2 Feb 2012 18:06:36 +0100 Subject: Support infinite timeouts in the get_next_frame --- ipecamera/events.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ipecamera/events.c b/ipecamera/events.c index 24e588a..dae71e0 100644 --- a/ipecamera/events.c +++ b/ipecamera/events.c @@ -112,18 +112,30 @@ int ipecamera_next_event(pcilib_context_t *vctx, pcilib_timeout_t timeout, pcili #endif /* IPECAMERA_ANNOUNCE_READY */ if (timeout) { - pcilib_calc_deadline(&tv, timeout); + if (timeout == PCILIB_TIMEOUT_INFINITE) { +#ifdef IPECAMERA_ANNOUNCE_READY + while ((((!ctx->preproc)&&(ctx->reported_id == ctx->event_id))||((ctx->preproc)&&(ctx->reported_id == ctx->preproc_id)))) { +#else /* IPECAMERA_ANNOUNCE_READY */ + while ((ctx->reported_id == ctx->event_id)) { +#endif /* IPECAMERA_ANNOUNCE_READY */ + usleep(IPECAMERA_NOFRAME_SLEEP); + } + } else { + pcilib_calc_deadline(&tv, timeout); #ifdef IPECAMERA_ANNOUNCE_READY - while ((pcilib_calc_time_to_deadline(&tv) > 0)&&(((!ctx->preproc)&&(ctx->reported_id == ctx->event_id))||((ctx->preproc)&&(ctx->reported_id == ctx->preproc_id)))) { + while ((pcilib_calc_time_to_deadline(&tv) > 0)&&(((!ctx->preproc)&&(ctx->reported_id == ctx->event_id))||((ctx->preproc)&&(ctx->reported_id == ctx->preproc_id)))) { #else /* IPECAMERA_ANNOUNCE_READY */ - while ((pcilib_calc_time_to_deadline(&tv) > 0)&&(ctx->reported_id == ctx->event_id)) { + while ((pcilib_calc_time_to_deadline(&tv) > 0)&&(ctx->reported_id == ctx->event_id)) { #endif /* IPECAMERA_ANNOUNCE_READY */ usleep(IPECAMERA_NOFRAME_SLEEP); + } } + } if (ctx->reported_id == ctx->event_id) return PCILIB_ERROR_TIMEOUT; + } retry: -- cgit v1.2.3