[FFmpeg-cvslog] udp: use non-blocking read instead of select.

Nicolas George git at videolan.org
Thu Mar 22 18:40:46 CET 2012


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Thu Mar 15 13:07:10 2012 +0100| [63afc4f6384c4e3b37173e52782cc110406f573f] | committer: Nicolas George

udp: use non-blocking read instead of select.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63afc4f6384c4e3b37173e52782cc110406f573f
---

 libavformat/udp.c |   21 +--------------------
 1 files changed, 1 insertions(+), 20 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 0a831e8..dad79ff 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -327,33 +327,14 @@ static void *circular_buffer_task( void *_URLContext)
 {
     URLContext *h = _URLContext;
     UDPContext *s = h->priv_data;
-    fd_set rfds;
-    struct timeval tv;
     int old_cancelstate;
 
     pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate);
+    ff_socket_nonblock(s->udp_fd, 0);
     while(1) {
         int left;
-        int ret;
         int len;
 
-        FD_ZERO(&rfds);
-        FD_SET(s->udp_fd, &rfds);
-        tv.tv_sec = 1;
-        tv.tv_usec = 0;
-        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancelstate);
-        ret = select(s->udp_fd + 1, &rfds, NULL, NULL, &tv);
-        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate);
-        if (ret < 0) {
-            if (ff_neterrno() == AVERROR(EINTR))
-                continue;
-            s->circular_buffer_error = AVERROR(EIO);
-            goto end;
-        }
-
-        if (!(ret > 0 && FD_ISSET(s->udp_fd, &rfds)))
-            continue;
-
         /* How much do we have left to the end of the buffer */
         /* Whats the minimum we can read so that we dont comletely fill the buffer */
         left = av_fifo_space(s->fifo);



More information about the ffmpeg-cvslog mailing list