From 3ee180e93e32c46f3949d1177266a47849b3af70 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Mon, 12 Dec 2011 10:01:53 +0100 Subject: Fix handling of return values from frame decoder and event callback --- ipecamera/data.c | 5 +++-- ipecamera/events.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ipecamera/data.c b/ipecamera/data.c index 5de6617..efde7a1 100644 --- a/ipecamera/data.c +++ b/ipecamera/data.c @@ -37,6 +37,7 @@ static int ipecamera_resolve_event_id(ipecamera_t *ctx, pcilib_event_id_t evid) inline static int ipecamera_decode_frame(ipecamera_t *ctx, pcilib_event_id_t event_id) { int err = 0; + size_t res; uint32_t tmp; uint16_t *pixels; @@ -54,8 +55,8 @@ inline static int ipecamera_decode_frame(ipecamera_t *ctx, pcilib_event_id_t eve pixels = ctx->image + buf_ptr * ctx->image_size; memset(ctx->cmask + ctx->buffer_pos * ctx->dim.height, 0, ctx->dim.height * sizeof(ipecamera_change_mask_t)); - err = ufo_decoder_decode_frame(ctx->ipedec, ctx->buffer + buf_ptr * ctx->padded_size, ctx->raw_size, pixels, &tmp, &tmp, ctx->cmask + ctx->buffer_pos * ctx->dim.height); - if (err) { + res = ufo_decoder_decode_frame(ctx->ipedec, ctx->buffer + buf_ptr * ctx->padded_size, ctx->raw_size, pixels, &tmp, &tmp, ctx->cmask + ctx->buffer_pos * ctx->dim.height); + if (!res) { ctx->frame[buf_ptr].event.image_broken = 1; err = PCILIB_ERROR_FAILED; goto ready; diff --git a/ipecamera/events.c b/ipecamera/events.c index 58d2971..173423b 100644 --- a/ipecamera/events.c +++ b/ipecamera/events.c @@ -21,7 +21,7 @@ #include "events.h" int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, void *user) { - int err = 0; + int res, err = 0; int do_stop = 0; ipecamera_event_info_t info; @@ -54,9 +54,9 @@ int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, v 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) { - err = callback(ctx->reported_id, (pcilib_event_info_t*)&info, user); - if (err <= 0) { - if (err < 0) err = -err; + res = callback(ctx->reported_id, (pcilib_event_info_t*)&info, user); + if (res <= 0) { + if (res < 0) err = -res; break; } } -- cgit v1.2.3