diff options
| author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-12-13 18:54:51 +0100 | 
|---|---|---|
| committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-12-13 18:54:51 +0100 | 
| commit | 44866dd2d2204128bf37be82a709de92018113a3 (patch) | |
| tree | 86f1ca91be4a8c5c2d4a65f7295a727720d73cd5 /ipecamera | |
| parent | 5af397b0053c32b96b4b83767ddefc22d1fd09f2 (diff) | |
| download | pcitool-44866dd2d2204128bf37be82a709de92018113a3.tar.gz pcitool-44866dd2d2204128bf37be82a709de92018113a3.tar.bz2 pcitool-44866dd2d2204128bf37be82a709de92018113a3.tar.xz pcitool-44866dd2d2204128bf37be82a709de92018113a3.zip | |
Do not call the normall callback in the raw-data-only mode
Diffstat (limited to 'ipecamera')
| -rw-r--r-- | ipecamera/events.c | 43 | ||||
| -rw-r--r-- | ipecamera/ipecamera.c | 4 | 
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 | 
