core: Convert SDL_IOReady()'s 2nd parameter to flags
diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index c139182..d518aa6 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c
@@ -156,7 +156,7 @@ #ifdef DEBUG_AUDIO fprintf(stderr, "Waiting for audio to get ready\n"); #endif - if (SDL_IOReady(this->hidden->audio_fd, SDL_TRUE, timeoutMS) <= 0) { + if (SDL_IOReady(this->hidden->audio_fd, SDL_IOR_WRITE, timeoutMS) <= 0) { /* * In general we should never print to the screen, * but in this case we have no other way of letting
diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c index cb95551..f951bc3 100644 --- a/src/audio/qsa/SDL_qsa_audio.c +++ b/src/audio/qsa/SDL_qsa_audio.c
@@ -120,7 +120,9 @@ /* If timeout occured than something wrong with hardware or driver */ /* For example, Vortex 8820 audio driver stucks on second DAC because */ /* it doesn't exist ! */ - result = SDL_IOReady(this->hidden->audio_fd, !this->hidden->iscapture, 2 * 1000); + result = SDL_IOReady(this->hidden->audio_fd, + this->hidden->iscapture ? SDL_IOR_READ : SDL_IOR_WRITE, + 2 * 1000); switch (result) { case -1: SDL_SetError("QSA: SDL_IOReady() failed: %s", strerror(errno));
diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index c9147e4..cae17ed 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c
@@ -98,7 +98,7 @@ } } #else - SDL_IOReady(this->hidden->audio_fd, SDL_TRUE, -1); + SDL_IOReady(this->hidden->audio_fd, SDL_IOR_WRITE, -1); #endif }
diff --git a/src/core/unix/SDL_poll.c b/src/core/unix/SDL_poll.c index 2670b04..ec0a533 100644 --- a/src/core/unix/SDL_poll.c +++ b/src/core/unix/SDL_poll.c
@@ -34,10 +34,12 @@ int -SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS) +SDL_IOReady(int fd, int flags, int timeoutMS) { int result; + SDL_assert(flags & (SDL_IOR_READ | SDL_IOR_WRITE)); + /* Note: We don't bother to account for elapsed time if we get EINTR */ do { @@ -45,10 +47,12 @@ struct pollfd info; info.fd = fd; - if (forWrite) { - info.events = POLLOUT; - } else { - info.events = POLLIN | POLLPRI; + info.events = 0; + if (flags & SDL_IOR_READ) { + info.events |= POLLIN | POLLPRI; + } + if (flags & SDL_IOR_WRITE) { + info.events |= POLLOUT; } result = poll(&info, 1, timeoutMS); #else @@ -59,15 +63,16 @@ /* If this assert triggers we'll corrupt memory here */ SDL_assert(fd >= 0 && fd < FD_SETSIZE); - if (forWrite) { - FD_ZERO(&wfdset); - FD_SET(fd, &wfdset); - wfdp = &wfdset; - } else { + if (flags & SDL_IOR_READ) { FD_ZERO(&rfdset); FD_SET(fd, &rfdset); rfdp = &rfdset; } + if (flags & SDL_IOR_WRITE) { + FD_ZERO(&wfdset); + FD_SET(fd, &wfdset); + wfdp = &wfdset; + } if (timeoutMS >= 0) { tv.tv_sec = timeoutMS / 1000;
diff --git a/src/core/unix/SDL_poll.h b/src/core/unix/SDL_poll.h index f8abc24..10497d1 100644 --- a/src/core/unix/SDL_poll.h +++ b/src/core/unix/SDL_poll.h
@@ -26,8 +26,10 @@ #include "SDL_stdinc.h" +#define SDL_IOR_READ 0x1 +#define SDL_IOR_WRITE 0x2 -extern int SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS); +extern int SDL_IOReady(int fd, int flags, int timeoutMS); #endif /* SDL_poll_h_ */
diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index 8dca704..8de4cdd 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c
@@ -50,7 +50,7 @@ sigset_t old_sig_set; struct timespec zerotime = {0}; - ready = SDL_IOReady(fd, SDL_TRUE, PIPE_MS_TIMEOUT); + ready = SDL_IOReady(fd, SDL_IOR_WRITE, PIPE_MS_TIMEOUT); sigemptyset(&sig_set); sigaddset(&sig_set, SIGPIPE); @@ -96,7 +96,7 @@ ssize_t bytes_read = 0; size_t pos = 0; - ready = SDL_IOReady(fd, SDL_FALSE, PIPE_MS_TIMEOUT); + ready = SDL_IOReady(fd, SDL_IOR_READ, PIPE_MS_TIMEOUT); if (ready == 0) { bytes_read = SDL_SetError("Pipe timeout");
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 9a17b0a..607c6a2 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c
@@ -259,7 +259,7 @@ /* wl_display_prepare_read() will return -1 if the default queue is not empty. * If the default queue is empty, it will prepare us for our SDL_IOReady() call. */ if (WAYLAND_wl_display_prepare_read(d->display) == 0) { - if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_FALSE, timeout) > 0) { + if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_IOR_READ, timeout) > 0) { /* There are new events available to read */ WAYLAND_wl_display_read_events(d->display); WAYLAND_wl_display_dispatch_pending(d->display); @@ -308,7 +308,7 @@ /* wl_display_prepare_read() will return -1 if the default queue is not empty. * If the default queue is empty, it will prepare us for our SDL_IOReady() call. */ if (WAYLAND_wl_display_prepare_read(d->display) == 0) { - if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_FALSE, 0) > 0) { + if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_IOR_READ, 0) > 0) { WAYLAND_wl_display_read_events(d->display); } else { WAYLAND_wl_display_cancel_read(d->display);
diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c index 934406f..ff11d16 100644 --- a/src/video/wayland/SDL_waylandopengles.c +++ b/src/video/wayland/SDL_waylandopengles.c
@@ -155,7 +155,7 @@ break; } - if (SDL_IOReady(WAYLAND_wl_display_get_fd(display), SDL_FALSE, max_wait - now) <= 0) { + if (SDL_IOReady(WAYLAND_wl_display_get_fd(display), SDL_IOR_READ, max_wait - now) <= 0) { /* Error or timeout expired without any events for us. Cancel the read. */ WAYLAND_wl_display_cancel_read(display); break;
diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index fd52092..ccab1fb 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c
@@ -1536,7 +1536,7 @@ } /* More drastic measures are required -- see if X is ready to talk */ - if (SDL_IOReady(ConnectionNumber(display), SDL_FALSE, 0)) { + if (SDL_IOReady(ConnectionNumber(display), SDL_IOR_READ, 0)) { return (X11_XPending(display)); } @@ -1586,7 +1586,7 @@ return 0; } } else if (timeout > 0) { - if (SDL_IOReady(ConnectionNumber(display), SDL_FALSE, timeout) > 0) { + if (SDL_IOReady(ConnectionNumber(display), SDL_IOR_READ, timeout) > 0) { X11_XNextEvent(display, &xevent); } else { return 0;