Logo Search packages:      
Sourcecode: zebra version File versions  Download package

int zebra_process_one ( zebra_processor_t processor,
int  timeout 
)

process from the video stream until a result is available, or the timeout (in milliseconds) expires. specify a timeout of -1 to scan indefinitely (zebra_processor_set_active() may still be used to abort the scan from another thread). if the library window is visible, video display will be enabled.

Note:
that multiple results may still be returned (despite the name).
Returns:
>0 if symbols were successfully decoded, 0 if no symbols were found (ie, the timeout expired) or -1 if an error occurs

Definition at line 697 of file processor.c.

References zebra_image_scanner_enable_cache(), zebra_process_one(), zebra_video_enable(), and zebra_video_get_fd().

Referenced by zebra::Processor::process_one(), and zebra_process_one().

{
    if(proc_lock(proc) < 0)
        return(-1);
    int rc = 0;
    if(proc->video) {
        zebra_image_scanner_enable_cache(proc->scanner, 1);
        rc = zebra_video_enable(proc->video, 1);
        /* FIXME failure recovery? */
        int vid_fd = zebra_video_get_fd(proc->video);
        if(vid_fd >= 0)
            add_poll(proc, vid_fd, proc_video_handler);
        proc->active = 1;
#ifdef HAVE_LIBPTHREAD
        pthread_cond_broadcast(&proc->event);
#endif
        proc_event_wait(proc, EVENT_OUTPUT, timeout);
        rc = zebra_video_enable(proc->video, 0);
        if(vid_fd >= 0)
            remove_poll(proc, vid_fd);
        proc->active = 0;
        proc->events &= ~EVENT_INPUT;
        zebra_image_scanner_enable_cache(proc->scanner, 0);
    }
    else
        rc = -1;
    proc_unlock(proc);
    return(rc);
}


Generated by  Doxygen 1.6.0   Back to index