summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipecamera/events.c43
-rw-r--r--ipecamera/ipecamera.c4
2 files changed, 29 insertions, 18 deletions
diff --git a/ipecamera/events.c b/ipecamera/events.c
index 032e8ed..24e588a 100644
--- a/ipecamera/events.c
+++ b/ipecamera/events.c
@@ -46,28 +46,34 @@ int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, v
do_stop = 1;
}
- // This loop iterates while the generation
- while ((run_flag)&&((ctx->run_streamer)||(ctx->reported_id != ctx->event_id))) {
+ if (ctx->parse_data) {
+ // 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))) {
+ 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) {
+ 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;
-
- memcpy(&info, ctx->frame + ((ctx->reported_id-1)%ctx->buffer_size), sizeof(ipecamera_event_info_t));
-
- if ((ctx->event_id - ctx->reported_id) < ctx->buffer_size) {
- res = callback(ctx->reported_id, (pcilib_event_info_t*)&info, user);
- if (res <= 0) {
- if (res < 0) err = -res;
- run_flag = 0;
- break;
+ 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;
+
+ memcpy(&info, ctx->frame + ((ctx->reported_id-1)%ctx->buffer_size), sizeof(ipecamera_event_info_t));
+
+ if ((ctx->event_id - ctx->reported_id) < ctx->buffer_size) {
+ res = callback(ctx->reported_id, (pcilib_event_info_t*)&info, user);
+ if (res <= 0) {
+ if (res < 0) err = -res;
+ run_flag = 0;
+ break;
+ }
}
}
+ usleep(IPECAMERA_NOFRAME_SLEEP);
+ }
+ } else {
+ while ((run_flag)&&(ctx->run_streamer)) {
+ usleep(IPECAMERA_NOFRAME_SLEEP);
}
- usleep(IPECAMERA_NOFRAME_SLEEP);
}
ctx->streaming = 0;
@@ -93,6 +99,11 @@ int ipecamera_next_event(pcilib_context_t *vctx, pcilib_timeout_t timeout, pcili
pcilib_error("IPECamera is not in grabbing mode");
return PCILIB_ERROR_INVALID_REQUEST;
}
+
+ if (!ctx->parse_data) {
+ pcilib_error("RAWData only mode is requested");
+ 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))) {
diff --git a/ipecamera/ipecamera.c b/ipecamera/ipecamera.c
index d963494..b76cf19 100644
--- a/ipecamera/ipecamera.c
+++ b/ipecamera/ipecamera.c
@@ -275,7 +275,7 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev
ctx->buffer_pos = 0;
ctx->parse_data = (flags&PCILIB_EVENT_FLAG_RAW_DATA_ONLY)?0:1;
ctx->cur_size = 0;
-
+
ctx->dim.width = IPECAMERA_WIDTH;
GET_REG(n_lines_reg, ctx->dim.height);
@@ -405,7 +405,7 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev
ctx->autostop.evid = vctx->params.autostop.max_events;
}
- if (flags&PCILIB_EVENT_FLAG_PREPROCESS) {
+ if ((ctx->parse_data)&&(flags&PCILIB_EVENT_FLAG_PREPROCESS)) {
ctx->n_preproc = pcilib_get_cpu_count();
// it would be greate to detect hyperthreading cores and ban them