diff options
-rw-r--r-- | ipecamera/events.c | 18 | ||||
-rw-r--r-- | ipecamera/private.h | 4 |
2 files changed, 19 insertions, 3 deletions
diff --git a/ipecamera/events.c b/ipecamera/events.c index a6cf57e..032e8ed 100644 --- a/ipecamera/events.c +++ b/ipecamera/events.c @@ -48,7 +48,11 @@ int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, v // This loop iterates while the generation while ((run_flag)&&((ctx->run_streamer)||(ctx->reported_id != ctx->event_id))) { +#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 */ if ((ctx->event_id - ctx->reported_id) > (ctx->buffer_size - IPECAMERA_RESERVE_BUFFERS)) ctx->reported_id = ctx->event_id - (ctx->buffer_size - 1) - IPECAMERA_RESERVE_BUFFERS; else ++ctx->reported_id; @@ -90,12 +94,22 @@ int ipecamera_next_event(pcilib_context_t *vctx, pcilib_timeout_t timeout, pcili return PCILIB_ERROR_INVALID_REQUEST; } +#ifdef IPECAMERA_ANNOUNCE_READY + if (((!ctx->preproc)&&(ctx->reported_id == ctx->event_id))||((ctx->preproc)&&(ctx->reported_id == ctx->preproc_id))) { +#else /* IPECAMERA_ANNOUNCE_READY */ if (ctx->reported_id == ctx->event_id) { +#endif /* IPECAMERA_ANNOUNCE_READY */ + if (timeout) { pcilib_calc_deadline(&tv, timeout); - - while ((pcilib_calc_time_to_deadline(&tv) > 0)&&(ctx->reported_id == ctx->event_id)) + +#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)))) { +#else /* IPECAMERA_ANNOUNCE_READY */ + 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; diff --git a/ipecamera/private.h b/ipecamera/private.h index e15d6ba..0645715 100644 --- a/ipecamera/private.h +++ b/ipecamera/private.h @@ -7,6 +7,8 @@ #define IPECAMERA_BUG_MULTIFRAME_PACKETS #define IPECAMERA_BUG_INCOMPLETE_PACKETS +#define IPECAMERA_ANNOUNCE_READY //**< announce new event only after the reconstruction is done */ + #define IPECAMERA_DEFAULT_BUFFER_SIZE 16//64 //**< should be power of 2 */ #define IPECAMERA_RESERVE_BUFFERS 2 //**< Return Frame is Lost error, if requested frame will be overwritten after specified number of frames #define IPECAMERA_SLEEP_TIME 250000 //**< Michele thinks 250 should be enough, but reset failing in this case */ @@ -63,7 +65,7 @@ struct ipecamera_s { void *cb_user; volatile pcilib_event_id_t event_id; - pcilib_event_id_t preproc_id; + volatile pcilib_event_id_t preproc_id; pcilib_event_id_t reported_id; pcilib_dma_engine_t rdma, wdma; |