/alps/ipecamera

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/ipecamera

« back to all changes in this revision

Viewing changes to data.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-08-14 00:59:59 UTC
  • Revision ID: csa@suren.me-20150814005959-v94qfz8cyspjbjje
Fix a bug causing image_broken flag to be checked before it set when preprocessing was enabled

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
 
59
59
    res = ufo_decoder_decode_frame(ctx->ipedec, ctx->buffer + buf_ptr * ctx->padded_size, ctx->frame[buf_ptr].event.raw_size, pixels, &ctx->frame[buf_ptr].event.meta);
60
60
    if (!res) {
61
 
        ipecamera_debug(HARDWARE, "Decoding of frame %u has failed, ufodecode returns error %i", ctx->event_id, res);
62
61
        ipecamera_debug_buffer(BROKEN_FRAMES, ctx->frame[buf_ptr].event.raw_size, ctx->buffer + buf_ptr * ctx->padded_size, PCILIB_DEBUG_BUFFER_MKDIR, "broken_frame.%4lu", ctx->event_id);
63
62
        err = PCILIB_ERROR_INVALID_DATA;
64
63
        ctx->frame[buf_ptr].event.image_broken = err;
65
64
        goto ready;
66
 
    }
67
 
            
 
65
    } 
 
66
 
68
67
    ctx->frame[buf_ptr].event.image_broken = 0;
69
68
 
70
69
ready:
157
156
static int ipecamera_get_frame(ipecamera_t *ctx, pcilib_event_id_t event_id) {
158
157
    int err;
159
158
    int buf_ptr = (event_id - 1) % ctx->buffer_size;
160
 
    
161
 
    if (ctx->preproc) { 
162
 
        if (ctx->frame[buf_ptr].event.image_broken)
163
 
            return ctx->frame[buf_ptr].event.image_broken;
164
 
    } else {
 
159
 
 
160
    if (!ctx->preproc) {
165
161
        pthread_rwlock_rdlock(&ctx->frame[buf_ptr].mutex);
166
162
 
167
163
        err = ipecamera_decode_frame(ctx, event_id);
175
171
    }
176
172
 
177
173
 
178
 
    while (!ctx->frame[buf_ptr].event.image_ready) {
 
174
    while (!((volatile ipecamera_t*)ctx)->frame[buf_ptr].event.image_ready) {
179
175
        usleep(IPECAMERA_NOFRAME_PREPROC_SLEEP);
180
176
 
181
177
        buf_ptr = ipecamera_resolve_event_id(ctx, event_id);
182
178
        if (buf_ptr < 0) return PCILIB_ERROR_OVERWRITTEN;
183
179
    }
184
180
 
 
181
    if (((volatile ipecamera_t*)ctx)->frame[buf_ptr].event.image_broken)
 
182
        return ctx->frame[buf_ptr].event.image_broken;
 
183
 
185
184
    pthread_rwlock_rdlock(&ctx->frame[buf_ptr].mutex);
186
185
 
187
186
    buf_ptr = ipecamera_resolve_event_id(ctx, event_id);