fprintf(stderr, "DV1394: Frame drop detected (%d). Reseting ..\n",
av_log(context, AV_LOG_ERROR, "DV1394: Frame drop detected (%d). Reseting ..\n",
static int dv1394_read_packet(AVFormatContext *context, AVPacket *pkt){    struct dv1394_data *dv = context->priv_data;    int size;    size = dv_get_packet(dv->dv_demux, pkt);    if (size > 0)        goto out;    if (!dv->avail) {        struct dv1394_status s;        struct pollfd p;        if (dv->done) {            /* Request more frames */            if (ioctl(dv->fd, DV1394_RECEIVE_FRAMES, dv->done) < 0) {                /* This usually means that ring buffer overflowed.                 * We have to reset :(.                 */                  fprintf(stderr, "DV1394: Ring buffer overflow. Reseting ..\n");                 dv1394_reset(dv);                dv1394_start(dv);            }            dv->done = 0;        }        /* Wait until more frames are available */restart_poll:        p.fd = dv->fd;        p.events = POLLIN | POLLERR | POLLHUP;        if (poll(&p, 1, -1) < 0) {            if (errno == EAGAIN || errno == EINTR)                goto restart_poll;            perror("Poll failed");            return -EIO;        }        if (ioctl(dv->fd, DV1394_GET_STATUS, &s) < 0) {            perror("Failed to get status");            return -EIO;        }#ifdef DV1394_DEBUG        fprintf(stderr, "DV1394: status\n"                "\tactive_frame\t%d\n"                "\tfirst_clear_frame\t%d\n"                "\tn_clear_frames\t%d\n"                "\tdropped_frames\t%d\n",                s.active_frame, s.first_clear_frame,                s.n_clear_frames, s.dropped_frames);#endif        dv->avail = s.n_clear_frames;        dv->index = s.first_clear_frame;        dv->done  = 0;        if (s.dropped_frames) {            fprintf(stderr, "DV1394: Frame drop detected (%d). Reseting ..\n",                    s.dropped_frames);            dv1394_reset(dv);            dv1394_start(dv);        }    }#ifdef DV1394_DEBUG    fprintf(stderr, "index %d, avail %d, done %d\n", dv->index, dv->avail,            dv->done);#endif    size = dv_produce_packet(dv->dv_demux, pkt,                              dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE), 			     DV1394_PAL_FRAME_SIZE);    dv->index = (dv->index + 1) % DV1394_RING_FRAMES;    dv->done++; dv->avail--;    dv->pts = av_gettime() & ((1LL << 48) - 1);    out:    pkt->pts = dv->pts;    return size;}