mirror of
https://github.com/encounter/SDL.git
synced 2025-05-22 15:21:27 +00:00
core: Convert SDL_IOReady()'s 2nd parameter to flags
This commit is contained in:
parent
81fe2ccb9c
commit
c97c46877f
@ -156,7 +156,7 @@ PAUDIO_WaitDevice(_THIS)
|
|||||||
#ifdef DEBUG_AUDIO
|
#ifdef DEBUG_AUDIO
|
||||||
fprintf(stderr, "Waiting for audio to get ready\n");
|
fprintf(stderr, "Waiting for audio to get ready\n");
|
||||||
#endif
|
#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,
|
* In general we should never print to the screen,
|
||||||
* but in this case we have no other way of letting
|
* but in this case we have no other way of letting
|
||||||
|
@ -120,7 +120,9 @@ QSA_WaitDevice(_THIS)
|
|||||||
/* If timeout occured than something wrong with hardware or driver */
|
/* If timeout occured than something wrong with hardware or driver */
|
||||||
/* For example, Vortex 8820 audio driver stucks on second DAC because */
|
/* For example, Vortex 8820 audio driver stucks on second DAC because */
|
||||||
/* it doesn't exist ! */
|
/* 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) {
|
switch (result) {
|
||||||
case -1:
|
case -1:
|
||||||
SDL_SetError("QSA: SDL_IOReady() failed: %s", strerror(errno));
|
SDL_SetError("QSA: SDL_IOReady() failed: %s", strerror(errno));
|
||||||
|
@ -98,7 +98,7 @@ SUNAUDIO_WaitDevice(_THIS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SDL_IOReady(this->hidden->audio_fd, SDL_TRUE, -1);
|
SDL_IOReady(this->hidden->audio_fd, SDL_IOR_WRITE, -1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +34,12 @@
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
SDL_IOReady(int fd, int flags, int timeoutMS)
|
||||||
{
|
{
|
||||||
int result;
|
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 */
|
/* Note: We don't bother to account for elapsed time if we get EINTR */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -45,10 +47,12 @@ SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
|||||||
struct pollfd info;
|
struct pollfd info;
|
||||||
|
|
||||||
info.fd = fd;
|
info.fd = fd;
|
||||||
if (forWrite) {
|
info.events = 0;
|
||||||
info.events = POLLOUT;
|
if (flags & SDL_IOR_READ) {
|
||||||
} else {
|
info.events |= POLLIN | POLLPRI;
|
||||||
info.events = POLLIN | POLLPRI;
|
}
|
||||||
|
if (flags & SDL_IOR_WRITE) {
|
||||||
|
info.events |= POLLOUT;
|
||||||
}
|
}
|
||||||
result = poll(&info, 1, timeoutMS);
|
result = poll(&info, 1, timeoutMS);
|
||||||
#else
|
#else
|
||||||
@ -59,15 +63,16 @@ SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
|||||||
/* If this assert triggers we'll corrupt memory here */
|
/* If this assert triggers we'll corrupt memory here */
|
||||||
SDL_assert(fd >= 0 && fd < FD_SETSIZE);
|
SDL_assert(fd >= 0 && fd < FD_SETSIZE);
|
||||||
|
|
||||||
if (forWrite) {
|
if (flags & SDL_IOR_READ) {
|
||||||
FD_ZERO(&wfdset);
|
|
||||||
FD_SET(fd, &wfdset);
|
|
||||||
wfdp = &wfdset;
|
|
||||||
} else {
|
|
||||||
FD_ZERO(&rfdset);
|
FD_ZERO(&rfdset);
|
||||||
FD_SET(fd, &rfdset);
|
FD_SET(fd, &rfdset);
|
||||||
rfdp = &rfdset;
|
rfdp = &rfdset;
|
||||||
}
|
}
|
||||||
|
if (flags & SDL_IOR_WRITE) {
|
||||||
|
FD_ZERO(&wfdset);
|
||||||
|
FD_SET(fd, &wfdset);
|
||||||
|
wfdp = &wfdset;
|
||||||
|
}
|
||||||
|
|
||||||
if (timeoutMS >= 0) {
|
if (timeoutMS >= 0) {
|
||||||
tv.tv_sec = timeoutMS / 1000;
|
tv.tv_sec = timeoutMS / 1000;
|
||||||
|
@ -26,8 +26,10 @@
|
|||||||
|
|
||||||
#include "SDL_stdinc.h"
|
#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_ */
|
#endif /* SDL_poll_h_ */
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos)
|
|||||||
sigset_t old_sig_set;
|
sigset_t old_sig_set;
|
||||||
struct timespec zerotime = {0};
|
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);
|
sigemptyset(&sig_set);
|
||||||
sigaddset(&sig_set, SIGPIPE);
|
sigaddset(&sig_set, SIGPIPE);
|
||||||
@ -96,7 +96,7 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate)
|
|||||||
ssize_t bytes_read = 0;
|
ssize_t bytes_read = 0;
|
||||||
size_t pos = 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) {
|
if (ready == 0) {
|
||||||
bytes_read = SDL_SetError("Pipe timeout");
|
bytes_read = SDL_SetError("Pipe timeout");
|
||||||
|
@ -259,7 +259,7 @@ Wayland_WaitEventTimeout(_THIS, int timeout)
|
|||||||
/* wl_display_prepare_read() will return -1 if the default queue is not empty.
|
/* 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 the default queue is empty, it will prepare us for our SDL_IOReady() call. */
|
||||||
if (WAYLAND_wl_display_prepare_read(d->display) == 0) {
|
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 */
|
/* There are new events available to read */
|
||||||
WAYLAND_wl_display_read_events(d->display);
|
WAYLAND_wl_display_read_events(d->display);
|
||||||
WAYLAND_wl_display_dispatch_pending(d->display);
|
WAYLAND_wl_display_dispatch_pending(d->display);
|
||||||
@ -308,7 +308,7 @@ Wayland_PumpEvents(_THIS)
|
|||||||
/* wl_display_prepare_read() will return -1 if the default queue is not empty.
|
/* 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 the default queue is empty, it will prepare us for our SDL_IOReady() call. */
|
||||||
if (WAYLAND_wl_display_prepare_read(d->display) == 0) {
|
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);
|
WAYLAND_wl_display_read_events(d->display);
|
||||||
} else {
|
} else {
|
||||||
WAYLAND_wl_display_cancel_read(d->display);
|
WAYLAND_wl_display_cancel_read(d->display);
|
||||||
|
@ -155,7 +155,7 @@ Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
|
|||||||
break;
|
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. */
|
/* Error or timeout expired without any events for us. Cancel the read. */
|
||||||
WAYLAND_wl_display_cancel_read(display);
|
WAYLAND_wl_display_cancel_read(display);
|
||||||
break;
|
break;
|
||||||
|
@ -1536,7 +1536,7 @@ X11_Pending(Display * display)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* More drastic measures are required -- see if X is ready to talk */
|
/* 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));
|
return (X11_XPending(display));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1586,7 +1586,7 @@ X11_WaitEventTimeout(_THIS, int timeout)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if (timeout > 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);
|
X11_XNextEvent(display, &xevent);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user