diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2012-02-02 18:06:36 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2012-02-02 18:06:36 +0100 |
commit | a1163a63376d86af317c3fd83aad2333e1fa5c54 (patch) | |
tree | 6fe8eddcda1808b5b964af5ca944a1f19095a8f8 | |
parent | 77c529f2c7eca27e7500ba02f916f0f443447d65 (diff) | |
download | ipecamera-a1163a63376d86af317c3fd83aad2333e1fa5c54.tar.gz ipecamera-a1163a63376d86af317c3fd83aad2333e1fa5c54.tar.bz2 ipecamera-a1163a63376d86af317c3fd83aad2333e1fa5c54.tar.xz ipecamera-a1163a63376d86af317c3fd83aad2333e1fa5c54.zip |
Support infinite timeouts in the get_next_frame
-rw-r--r-- | ipecamera/events.c | 18 |
1 files 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: |