Browse Source

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

Avoid busy loops and decrease CPU usage.

Suggested-By: Roger Pack
tags/n2.2-rc1
Stefano Sabatini 12 years ago
parent
commit
7043311969
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      libavdevice/sdl.c

+ 6
- 2
libavdevice/sdl.c View 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:


Loading…
Cancel
Save