]> git.sesse.net Git - vlc/commitdiff
* Added a wrapper for readv() on platforms which don't support it. The
authorSam Hocevar <sam@videolan.org>
Mon, 28 May 2001 04:23:52 +0000 (04:23 +0000)
committerSam Hocevar <sam@videolan.org>
Mon, 28 May 2001 04:23:52 +0000 (04:23 +0000)
    network support now compiles under Win32, but still doesn't work, the
    select in plugins/mpeg/input_ts.c never returns any data.

    Is there anything like strace(1) under Win32 to debug this ?

plugins/mpeg/input_ts.c
plugins/mpeg/input_ts.h
src/input/input.c
src/input/input_netlist.c

index 45b1e635cea1263c8a4c8adedc445e65a616ec29..35dba2fd5c8574ec14b0ffaa6794a5cdb13005e6 100644 (file)
@@ -2,7 +2,7 @@
  * input_ts.c: TS demux and netlist management
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ts.c,v 1.19 2001/05/08 12:53:30 bozo Exp $
+ * $Id: input_ts.c,v 1.20 2001/05/28 04:23:52 sam Exp $
  *
  * Authors: Henri Fallon <henri@videolan.org>
  *
 #include <sys/select.h>
 #endif
 
-#ifndef WIN32
-#include <sys/uio.h>
+#ifndef WIN32 
+#   include <sys/uio.h>                                      /* struct iovec */
+#else
+    struct iovec
+    {
+        void *iov_base; /* Pointer to data.  */
+        size_t iov_len; /* Length of data.  */
+    };
 #endif
 
 #include <sys/stat.h>
@@ -211,7 +217,7 @@ static void TSInit( input_thread_t * p_input )
  *****************************************************************************/
 void TSFakeOpen( input_thread_t * p_input )
 {
-#if !defined( SYS_BEOS ) && !defined( SYS_NTO ) && !defined( WIN32 )
+#if !defined( SYS_BEOS ) && !defined( SYS_NTO )
     char *psz_name = p_input->p_source;
 
     if( ( strlen(psz_name) > 3 ) && !strncasecmp( psz_name, "ts:", 3 ) )
@@ -284,8 +290,8 @@ static int TSRead( input_thread_t * p_input,
     memset( pp_packets, 0, INPUT_READ_ONCE * sizeof(data_packet_t *) );
     
     /* Fill if some data is available */
-    i_data = select(p_input->i_handle + 1, &(p_method->s_fdset), NULL, NULL, 
-                    &s_wait);
+    i_data = select( p_input->i_handle + 1, &(p_method->s_fdset), NULL, NULL, 
+                     &s_wait);
     
     if( i_data == -1 )
     {
@@ -295,11 +301,7 @@ static int TSRead( input_thread_t * p_input,
     
     if( i_data )
     {
-#ifndef WIN32
         i_read = readv( p_input->i_handle, p_iovec, INPUT_READ_ONCE );
-#else
-        i_read = -1;
-#endif
         
         if( i_read == -1 )
         {
index e1a23706e709558af6f11b25a199e1159b904d33..088d7899859b0166266c0e9a778e87a3e33b709c 100644 (file)
@@ -2,7 +2,7 @@
  * input_ts.h: structures of the input not exported to other modules
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ts.h,v 1.4 2001/03/21 13:42:34 sam Exp $
+ * $Id: input_ts.h,v 1.5 2001/05/28 04:23:52 sam Exp $
  *
  * Authors: Henri Fallon <henri@via.ecp.fr>
  *
@@ -32,3 +32,46 @@ typedef struct thread_ts_data_s {
     fd_set s_fdset;
     
 } thread_ts_data_t;
+
+#ifdef WIN32
+static __inline__ int readv( int i_fd, struct iovec *p_iovec, int i_count )
+{
+    int i_index, i_len, i_total = 0;
+    char *p_base;
+
+    for( i_index = i_count; i_index; i_index-- )
+    {
+        i_len  = p_iovec->iov_len;
+        p_base = p_iovec->iov_base;
+
+        while( i_len > 0 )
+        {
+            register signed int i_bytes;
+            i_bytes = read( i_fd, p_base, i_len );
+
+            if( i_total == 0 )
+            {
+                if( i_bytes < 0 )
+                {
+                    intf_ErrMsg( "input error: read failed on socket" );
+                    return -1;
+                }
+            }
+
+            if( i_bytes <= 0 )
+            {
+                return i_total;
+            }
+
+            i_len   -= i_bytes;
+            i_total += i_bytes;
+            p_base  += i_bytes;
+        }
+
+        p_iovec++;
+    }
+
+    return i_total;
+}
+#endif
+
index abefe3e80741bd77b975772e4555e4328bcf30e2..13bb1aea9dd812e8f94dc9773977091c5476023a 100644 (file)
@@ -4,7 +4,7 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.110 2001/05/28 03:17:01 xav Exp $
+ * $Id: input.c,v 1.111 2001/05/28 04:23:52 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -570,18 +570,17 @@ void input_NetworkOpen( input_thread_t * p_input )
     int                 i_opt;
     struct sockaddr_in  sock;
 
-       /* WinSock Library Init. */
-
-       #ifdef WIN32
-               WSADATA                         Data;
-               int Result = WSAStartup( MAKEWORD( 1,1 ),&Data );
-               
-               if( Result != 0 )
-               {
-               intf_ErrMsg( "Can't initiate WinSocks : error %i", Result) ;
-               return ;
-               }
-       #endif
+#ifdef WIN32
+    /* WinSock Library Init. */
+    WSADATA Data;
+    int i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
+
+    if( i_err )
+    {
+        intf_ErrMsg( "input: can't initiate WinSocks, error %i", i_err );
+        return ;
+    }
+#endif
     
     /* Get the remote server */
     if( p_input->p_source != NULL )
@@ -688,8 +687,8 @@ void input_NetworkOpen( input_thread_t * p_input )
     if( setsockopt( p_input->i_handle, SOL_SOCKET, SO_REUSEADDR,
                     &i_opt, sizeof( i_opt ) ) == -1 )
     {
-        intf_ErrMsg("input error: can't configure socket (SO_REUSEADDR: %s)",
-                    strerror(errno));
+        intf_ErrMsg( "input error: can't configure socket (SO_REUSEADDR: %s)",
+                     strerror(errno));
         close( p_input->i_handle );
         p_input->b_error = 1;
         return;
@@ -701,17 +700,17 @@ void input_NetworkOpen( input_thread_t * p_input )
     if( setsockopt( p_input->i_handle, SOL_SOCKET, SO_RCVBUF,
                     &i_opt, sizeof( i_opt ) ) == -1 )
     {
-        intf_ErrMsg("input error: can't configure socket (SO_RCVBUF: %s)", 
-                    strerror(errno));
+        intf_ErrMsg( "input error: can't configure socket (SO_RCVBUF: %s)", 
+                     strerror(errno));
         close( p_input->i_handle );
         p_input->b_error = 1;
         return;
     }
 
     /* Build the local socket */
-    if ( network_BuildLocalAddr( &sock, i_port, psz_broadcast ) 
-         == -1 )
+    if ( network_BuildLocalAddr( &sock, i_port, psz_broadcast ) == -1 )
     {
+        intf_ErrMsg( "input error: can't build local address" );
         close( p_input->i_handle );
         p_input->b_error = 1;
         return;
@@ -730,6 +729,7 @@ void input_NetworkOpen( input_thread_t * p_input )
     /* Build socket for remote connection */
     if ( network_BuildRemoteAddr( &sock, psz_server ) == -1 )
     {
+        intf_ErrMsg( "input error: can't build remote address" );
         close( p_input->i_handle );
         p_input->b_error = 1;
         return;
@@ -739,7 +739,7 @@ void input_NetworkOpen( input_thread_t * p_input )
     if( connect( p_input->i_handle, (struct sockaddr *) &sock,
                  sizeof( sock ) ) == (-1) )
     {
-        intf_ErrMsg( "NetworkOpen: can't connect socket : %s", 
+        intf_ErrMsg( "input error: can't connect socket, %s", 
                      strerror(errno) );
         close( p_input->i_handle );
         p_input->b_error = 1;
@@ -750,6 +750,8 @@ void input_NetworkOpen( input_thread_t * p_input )
      * with the server. */
     p_input->stream.b_pace_control = 0;
     p_input->stream.b_seekable = 0;
+
+    intf_WarnMsg( 3, "input: successfully opened network mode" );
     
     return;
 }
@@ -761,9 +763,10 @@ void input_NetworkClose( input_thread_t * p_input )
 {
     close( p_input->i_handle );
 
-       #ifdef WIN32 
-               WSACleanup();
-       #endif
+#ifdef WIN32 
+    WSACleanup();
+#endif
 
 }
 #endif
+
index 930e121927c532dbe387c9027091acdebd4775b8..31203ef74285fded6cce8d86f3785df9a0bb5645 100644 (file)
@@ -2,7 +2,7 @@
  * input_netlist.c: netlist management
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_netlist.c,v 1.36 2001/05/06 04:32:02 sam Exp $
+ * $Id: input_netlist.c,v 1.37 2001/05/28 04:23:52 sam Exp $
  *
  * Authors: Henri Fallon <henri@videolan.org>
  *
@@ -81,14 +81,20 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
      * the netlist_t struct */
     /* As i_loop is unsigned int, and i_ns_data int, this shouldn't be a 
      * problem */
-    for( i_loop=1; i_loop < i_nb_data; i_loop*=2 )
+    for( i_loop = 1; i_loop < i_nb_data; i_loop *= 2 )
+    {
         ;
+    }
+
     intf_DbgMsg( "Netlist : Required %i byte, got %u",i_nb_data,i_loop );
     i_nb_data = i_loop;
 
     /* Same thing for i_nb_pes */
-    for( i_loop=1; i_loop < i_nb_data; i_loop*=2 )
+    for( i_loop = 1; i_loop < i_nb_data; i_loop *= 2 )
+    {
         ;
+    }
+
     intf_DbgMsg( "Netlist : Required %i byte, got %u",i_nb_data,i_loop );
     i_nb_data = i_loop;