Hi Gary,

You are the right that the FAQ needs work on this entry.

What it should say is that you should repeatedly call dc1394_capture_dequeue() until the frame pointer (the third argument) gets set to NULL while returning DC1394_SUCCESS. That means the buffer has been drained.

Damien, could you update the FAQ to clarify that?

Thanks,
David


On Sat, Feb 16, 2013 at 5:13 AM, Brack, Gary L (383F) <gary.l.brack@jpl.nasa.gov> wrote:

I think I have found a bug in the linux driver.  I read the FAQ that says:

How do I flush the DMA ring buffer?

Stop the camera ISO transmission (optional); wait (sleep) at least one
frame period (optional, to be sure you have one frame); repeatedly call
dc1394_capture_dequeue(,DC1394_VIDEO1394_POLL) until it returns NULL
Remember also to call dc1394_enqueue_buffer() after every successful call
to a DMA capture function.




So I implemented some code to flush the DMA buffer so I would be sure to
get the most recent frame.


    /*  flush any frames in queue */
    while  (dc1394_capture_dequeue (Camera, DC1394_CAPTURE_POLICY_POLL,
&img) == DC1394_SUCCESS) {
        dc1394_capture_enqueue (Camera, img);
        cnt++;
    }

    return dc1394_capture_dequeue (Camera, DC1392_CAPTURE_POICY_WAIT, img);


It was Seg Faulted on the call to dc1394_capture_enqueue().  The call to
dc1394_capture_dequeue()
was always returning SUCCESS. I traced the code down to the routine:

dc1394error_t dc1394_juju_capture_dequeue (platform_camera_t * craw,
dc1394capture_policy_t policy,
                                           dc1394video_frame_t **frame_return)



Inside of it it does:

            fds[0].fd = craw->iso_fd;
            fds[0].events = POLLIN;

            while (1) {
                err = poll(fds, 1, (policy == DC1394_CAPTURE_POLICY_POLL) ? 0 : -1);
                if (err < 0) {
                    if (errno == EINTR)
                        continue;
                    dc1394_log_error("poll() failed for device %s.", craw->filename);
                    return DC1394_FAILURE;
                } else if (err == 0) {
                        return DC1394_SUCCESS;
                }

                len = read (craw->iso_fd, &iso, sizeof iso);
                if (len < 0) {
                    dc1394_log_error("Juju: dequeue failed to read a response: %m");
                    return DC1394_FAILURE;
                }

                if (iso.i.type == FW_CDEV_EVENT_ISO_INTERRUPT)
                    break;
            }


If I was following the logic correctly when there are no more frames on
the queue the call to poll(fds, 1, 0) should
return immediately with a 0. The (err == 0) case should be executed
returning DC1394_SUCCESS, not NULL like the FAQ suggests.

- Gary Brack











------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
is your hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Mailing list for libdc1394-devel
libdc1394-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdc1394-devel