[FFmpeg-cvslog] lavd/sdl: add delay when no events are found in the event queue

Stefano Sabatini git at videolan.org
Tue Nov 26 18:39:20 CET 2013


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Tue Nov 26 18:37:30 2013 +0100| [70433119691042eaa646adab5903c2302a42fc22] | committer: Stefano Sabatini

lavd/sdl: add delay when no events are found in the event queue

Avoid busy loops and decrease CPU usage.

Suggested-By: Roger Pack

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=70433119691042eaa646adab5903c2302a42fc22
---

 libavdevice/sdl.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavdevice/sdl.c b/libavdevice/sdl.c
index c3ade4a..72d327e 100644
--- a/libavdevice/sdl.c
+++ b/libavdevice/sdl.c
@@ -180,10 +180,14 @@ init_end:
         SDL_Event event;
         SDL_PumpEvents();
         ret = SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_ALLEVENTS);
-        if (ret < 0)
+        if (ret < 0) {
             av_log(s, AV_LOG_ERROR, "Error when getting SDL event: %s\n", SDL_GetError());
-        if (ret <= 0)
             continue;
+        }
+        if (ret == 0) {
+            SDL_Delay(10);
+            continue;
+        }
 
         switch (event.type) {
         case SDL_KEYDOWN:



More information about the ffmpeg-cvslog mailing list