Handle SDL_PushEvent() errors

Pushing an event to the main thread may fail. If this happens, log an
error, and try to recover when possible.
This commit is contained in:
Romain Vimont
2021-10-30 20:21:00 +02:00
parent 4c4381de4c
commit dae091e3ab
3 changed files with 30 additions and 4 deletions

View File

@@ -62,7 +62,10 @@ BOOL WINAPI windows_ctrl_handler(DWORD ctrl_type) {
if (ctrl_type == CTRL_C_EVENT) {
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
int ret = SDL_PushEvent(&event);
if (ret < 0) {
LOGW("Could not post SDL_QUIT event: %s", SDL_GetError());
}
return TRUE;
}
return FALSE;
@@ -250,7 +253,11 @@ stream_on_eos(struct stream *stream, void *userdata) {
SDL_Event stop_event;
stop_event.type = EVENT_STREAM_STOPPED;
SDL_PushEvent(&stop_event);
int ret = SDL_PushEvent(&stop_event);
if (ret < 0) {
LOGE("Could not post stream stopped event: %s", SDL_GetError());
// XXX What could we do?
}
}
bool