]> git.sesse.net Git - vlc/blobdiff - modules/access/udp.c
* modules/gui/wxwindows/interface.cpp: fixed compile issue.
[vlc] / modules / access / udp.c
index b84c69dd27f3a8a608db06e847f414104d15c6f3..88848881a3712d136e2c3589636e8ad579817dd2 100644 (file)
@@ -2,7 +2,7 @@
  * udp.c: raw UDP & RTP access plug-in
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: udp.c,v 1.15 2003/03/03 14:21:08 gbazin Exp $
+ * $Id: udp.c,v 1.19 2003/03/30 18:14:35 gbazin Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Tristan Leteurtre <tooney@via.ecp.fr>
@@ -75,7 +75,7 @@ static ssize_t RTPChoose( input_thread_t *, byte_t *, size_t );
     "value should be set in miliseconds units." )
 
 vlc_module_begin();
-    set_description( _("raw UDP access module") );
+    set_description( _("UDP/RTP input") );
     add_category_hint( N_("udp"), NULL , VLC_TRUE );
     add_integer( "udp-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
     set_capability( "access", 0 );
@@ -235,7 +235,6 @@ static int Open( vlc_object_t *p_this )
     vlc_mutex_lock( &p_input->stream.stream_lock );
     p_input->stream.b_pace_control = 0;
     p_input->stream.b_seekable = 0;
-    p_input->stream.b_connected = 0;
     p_input->stream.p_selected_area->i_tell = 0;
     p_input->stream.i_method = INPUT_METHOD_NETWORK;
     vlc_mutex_unlock( &p_input->stream.stream_lock );
@@ -324,6 +323,7 @@ static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
     input_socket_t * p_access_data = (input_socket_t *)p_input->p_access_data;
     struct timeval  timeout;
     fd_set          fds;
+    ssize_t         i_recv;
     int             i_ret;
 
     /* Initialize file descriptor set */
@@ -335,38 +335,47 @@ static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
     timeout.tv_usec = 500000;
 
     /* Find if some data is available */
-    i_ret = select( p_access_data->i_handle + 1, &fds,
-                    NULL, NULL, &timeout );
+    while( (i_ret = select( p_access_data->i_handle + 1, &fds,
+                            NULL, NULL, &timeout )) == 0
+           || (i_ret < 0 && errno == EINTR) )
+    {
+        FD_ZERO( &fds );
+        FD_SET( p_access_data->i_handle, &fds );
+        timeout.tv_sec = 0;
+        timeout.tv_usec = 500000;
 
-    if( i_ret == -1 && errno != EINTR )
+        if( p_input->b_die || p_input->b_error )
+        {
+            return 0;
+        }
+    }
+
+    if( i_ret < 0 )
     {
         msg_Err( p_input, "network select error (%s)", strerror(errno) );
+        return -1;
     }
-    else if( i_ret > 0 )
-    {
-        ssize_t i_recv = recv( p_access_data->i_handle, p_buffer, i_len, 0 );
 
-        if( i_recv < 0 )
-        {
+    i_recv = recv( p_access_data->i_handle, p_buffer, i_len, 0 );
+
+    if( i_recv < 0 )
+    {
 #ifdef WIN32
-            /* On win32 recv() will fail if the datagram doesn't fit inside
-             * the passed buffer, even though the buffer will be filled with
-             * the first part of the datagram. */
-            if( WSAGetLastError() == WSAEMSGSIZE )
-            {
-                msg_Err( p_input, "recv() failed. "
-                                  "Increase the mtu size (--mtu option)" );
-                i_recv = i_len;
-            }
-            else
+        /* On win32 recv() will fail if the datagram doesn't fit inside
+        * the passed buffer, even though the buffer will be filled with
+        * the first part of the datagram. */
+        if( WSAGetLastError() == WSAEMSGSIZE )
+       {
+           msg_Err( p_input, "recv() failed. "
+                    "Increase the mtu size (--mtu option)" );
+           i_recv = i_len;
+       }
+       else
 #endif
-            msg_Err( p_input, "recv failed (%s)", strerror(errno) );
-        }
-
-        return i_recv;
+           msg_Err( p_input, "recv failed (%s)", strerror(errno) );
     }
 
-    return 0;
+    return i_recv;
 
 #endif
 }