aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2013-11-26 18:37:30 +0100
committerStefano Sabatini <stefasab@gmail.com>2013-11-26 18:38:48 +0100
commit70433119691042eaa646adab5903c2302a42fc22 (patch)
tree98f78cbda9189b47e78e86c7c089f7b6777480b7
parent35349bbb97eb29e98f63bf48efc15b6bbda6157a (diff)
downloadffmpeg-70433119691042eaa646adab5903c2302a42fc22.tar.gz
lavd/sdl: add delay when no events are found in the event queue
Avoid busy loops and decrease CPU usage. Suggested-By: Roger Pack
-rw-r--r--libavdevice/sdl.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavdevice/sdl.c b/libavdevice/sdl.c
index c3ade4a38d..72d327e8e8 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: