summaryrefslogtreecommitdiff
path: root/libavformat/sapdec.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2011-01-28 03:12:21 +0100
committerLuca Barbato <lu_zero@gentoo.org>2011-01-28 15:45:19 +0100
commita8475bbdb64e638bd8161df9647876fd23f8a29a (patch)
tree06d3c3a4999b0085f3fa0dbc8fa49cccb27350b7 /libavformat/sapdec.c
parent5ce5dbc5f3d0bce1f8d76fea1907c91469ebdd01 (diff)
os: replace select with poll
Select has limitations on the fd values it could accept and silently breaks when it is reached.
Diffstat (limited to 'libavformat/sapdec.c')
-rw-r--r--libavformat/sapdec.c14
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) {