diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2013-11-26 21:37:30 +0400 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2013-11-26 21:38:48 +0400 |
commit | 70433119691042eaa646adab5903c2302a42fc22 (patch) | |
tree | 98f78cbda9189b47e78e86c7c089f7b6777480b7 /libavdevice/sdl.c | |
parent | 35349bbb97eb29e98f63bf48efc15b6bbda6157a (diff) |
lavd/sdl: add delay when no events are found in the event queue
Avoid busy loops and decrease CPU usage.
Suggested-By: Roger Pack
Diffstat (limited to 'libavdevice/sdl.c')
-rw-r--r-- | libavdevice/sdl.c | 8 |
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: |