diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2011-01-28 03:12:21 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-01-30 03:40:59 +0100 |
commit | d0eb91ad0451cdb6c062b2d4760bfa7f8bb4db6b (patch) | |
tree | aad8df0b1a480fbcdcae278fe393f287106d76d3 /libavformat/sapdec.c | |
parent | b5f83debf5384195c8700d024fb760ab8d7250aa (diff) | |
download | ffmpeg-d0eb91ad0451cdb6c062b2d4760bfa7f8bb4db6b.tar.gz |
os: replace select with poll
Select has limitations on the fd values it could accept and silently
breaks when it is reached.
(cherry picked from commit a8475bbdb64e638bd8161df9647876fd23f8a29a)
Diffstat (limited to 'libavformat/sapdec.c')
-rw-r--r-- | libavformat/sapdec.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 208591cd0c..73525f5df8 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -25,8 +25,8 @@ #include "network.h" #include "os_support.h" #include "internal.h" -#if HAVE_SYS_SELECT_H -#include <sys/select.h> +#if HAVE_POLL_H +#include <poll.h> #endif #include <sys/time.h> @@ -183,19 +183,15 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt) struct SAPState *sap = s->priv_data; int fd = url_get_file_handle(sap->ann_fd); int n, ret; - fd_set rfds; - struct timeval tv; + struct pollfd p = {fd, POLLIN, 0}; uint8_t recvbuf[1500]; if (sap->eof) return AVERROR_EOF; while (1) { - FD_ZERO(&rfds); - FD_SET(fd, &rfds); - tv.tv_sec = tv.tv_usec = 0; - n = select(fd + 1, &rfds, NULL, NULL, &tv); - if (n <= 0 || !FD_ISSET(fd, &rfds)) + n = poll(&p, 1, 0); + if (n <= 0 || !(p.revents & POLLIN)) break; ret = url_read(sap->ann_fd, recvbuf, sizeof(recvbuf)); if (ret >= 8) { |