[FFmpeg-devel] [PATCH] fbdev: simplify logic in fbdev_read_packet()

Stefano Sabatini stefano.sabatini-lala
Sat Mar 12 15:28:40 CET 2011


---
 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();
+    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);
     }
+    /* 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;
-- 
1.7.2.3




More information about the ffmpeg-devel mailing list