lavd/sdl: add delay when no events are found in the event queue
Avoid busy loops and decrease CPU usage. Suggested-By: Roger Pack
This commit is contained in:
parent
35349bbb97
commit
7043311969
@ -180,10 +180,14 @@ init_end:
|
|||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
ret = SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_ALLEVENTS);
|
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());
|
av_log(s, AV_LOG_ERROR, "Error when getting SDL event: %s\n", SDL_GetError());
|
||||||
if (ret <= 0)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
|
SDL_Delay(10);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user