int zbar_processor_user_wait (zbar_processor_t *proc, int timeout) { int rc; proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); rc = -1; if(proc->visible || proc->streaming || timeout >= 0) { zbar_timer_t timer; rc = _zbar_processor_wait(proc, EVENT_INPUT, _zbar_timer_init(&timer, timeout)); } if(!proc->visible) rc = err_capture(proc, SEV_WARNING, ZBAR_ERR_CLOSED, __func__, "display window not available for input"); if(rc > 0) rc = proc->input; _zbar_mutex_lock(&proc->mutex); proc_leave(proc); return(rc); }
int zbar_process_one (zbar_processor_t *proc, int timeout) { proc_enter(proc); int streaming = proc->streaming; _zbar_mutex_unlock(&proc->mutex); int rc = 0; if(!proc->video) { rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video input not initialized"); goto done; } if(!streaming) { rc = zbar_processor_set_active(proc, 1); if(rc) goto done; } zbar_timer_t timer; rc = _zbar_processor_wait(proc, EVENT_OUTPUT, _zbar_timer_init(&timer, timeout)); if(!streaming && zbar_processor_set_active(proc, 0)) rc = -1; done: _zbar_mutex_lock(&proc->mutex); proc_leave(proc); return(rc); }