[FFmpeg-devel] [PATCH] fbdev: simplify logic in fbdev_read_packet()
Michael Niedermayer
michaelni at gmx.at
Mon Apr 11 11:59:37 CEST 2011
On Mon, Apr 11, 2011 at 10:56:45AM +0200, Stefano Sabatini wrote:
> On date Monday 2011-04-11 03:02:33 +0200, Michael Niedermayer encoded:
> > Hi
> >
> > ive seen this in libav (and skiped it because its obviosuly
> > buggy) but seem to have missed it here :(
> > sorry, for the (too) late review
> >
> > On Sat, Mar 12, 2011 at 03:28:40PM +0100, Stefano Sabatini wrote:
> > > ---
> > > libavdevice/fbdev.c | 18 ++++++++----------
> > > 1 files changed, 8 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c
> > > index 121f02c..37bba3d 100644
> > > --- a/libavdevice/fbdev.c
> > > +++ b/libavdevice/fbdev.c
> > > @@ -190,22 +190,20 @@ static int fbdev_read_packet(AVFormatContext *avctx, AVPacket *pkt)
> > > fbdev->time_frame = av_gettime();
> > >
> > > /* wait based on the frame rate */
> > > - while (1) {
> > > - curtime = av_gettime();
> > > - delay = fbdev->time_frame - curtime;
> > > - av_dlog(avctx,
> > > - "time_frame:%"PRId64" curtime:%"PRId64" delay:%"PRId64"\n",
> > > - fbdev->time_frame, curtime, delay);
> > > - if (delay <= 0) {
> > > - fbdev->time_frame += INT64_C(1000000) * av_q2d(fbdev->time_base);
> > > - break;
> > > - }
> > > + curtime = av_gettime(); <-------------------------- time read
> > > + delay = fbdev->time_frame - curtime;
> > > + av_dlog(avctx,
> > > + "time_frame:%"PRId64" curtime:%"PRId64" delay:%"PRId64"\n",
> > > + fbdev->time_frame, curtime, delay);
> > > + if (delay > 0) {
> > > if (avctx->flags & AVFMT_FLAG_NONBLOCK)
> > > return AVERROR(EAGAIN);
> > > ts.tv_sec = delay / 1000000;
> > > ts.tv_nsec = (delay % 1000000) * 1000;
> > > while (nanosleep(&ts, &ts) < 0 && errno == EINTR); <--------------------wait
> > > }
> > > + /* compute the time of the next frame */
> > > + fbdev->time_frame += INT64_C(1000000) * av_q2d(fbdev->time_base);
> > >
> > > if ((ret = av_new_packet(pkt, fbdev->frame_size)) < 0)
> > > return ret;
> >
> > some point later <-------------------- read frame
> > even later <------------------- curtime from above used, but its no
> > longer correct due to the wait
>
> Ah I see it now, I suppose we could put a curtime = av_gettime() after
> the nanosleep call, or simply leave the code as it is now.
change it whichever way you prefer
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110411/36c7681e/attachment.asc>
More information about the ffmpeg-devel
mailing list