Commit edcfc7d3 authored by Sam Hocevar's avatar Sam Hocevar

  * Added a wrapper for readv() on platforms which don't support it. The
    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 ?
parent 7f62d904
......@@ -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>
*
......@@ -43,8 +43,14 @@
#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 )
{
......
......@@ -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
......@@ -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
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment