From 4d7dc1f258d94fb94ae473b483eb5a638b2ae119 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 27 Jul 2012 13:54:32 +0200 Subject: Bail out from ipecamera_get_next_event if camera is stopped during the wait --- ipecamera/events.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ipecamera/events.c b/ipecamera/events.c index b00f724..33a1e7f 100644 --- a/ipecamera/events.c +++ b/ipecamera/events.c @@ -123,17 +123,18 @@ int ipecamera_next_event(pcilib_context_t *vctx, pcilib_timeout_t timeout, pcili 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 ((ctx->started)&&(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 ((ctx->started)&&(pcilib_calc_time_to_deadline(&tv) > 0)&&(ctx->reported_id == ctx->event_id)) { #endif /* IPECAMERA_ANNOUNCE_READY */ - usleep(IPECAMERA_NOFRAME_SLEEP); + usleep(IPECAMERA_NOFRAME_SLEEP); } } - } - if (ctx->reported_id == ctx->event_id) return PCILIB_ERROR_TIMEOUT; + if (ctx->reported_id == ctx->event_id) { + return PCILIB_ERROR_TIMEOUT; + } } -- cgit v1.2.3