lavd/sdl: add delay when no events are found in the event queue
authorStefano Sabatini <stefasab@gmail.com>
Tue, 26 Nov 2013 17:37:30 +0000 (18:37 +0100)
committerStefano Sabatini <stefasab@gmail.com>
Tue, 26 Nov 2013 17:38:48 +0000 (18:38 +0100)
Avoid busy loops and decrease CPU usage.

Suggested-By: Roger Pack
libavdevice/sdl.c

index c3ade4a..72d327e 100644 (file)
@@ -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: