Commit 607b74b2 authored by Gildas Bazin's avatar Gildas Bazin

* modules/access/*: pf_read() in access modules is now blocking. We still
   check regularly for p_input->b_die though. Now the demuxers can safely
   assume that pf_read() == 0 means EOF.
* ALL: got rid of the p_input->b_connected flag.
* src/input/input_ext-plugins.c, src/input/input.c: fixed the infinite loop
   of "decoder stuck" messages that sometimes happened.
* src/interface/intf_eject.c, modules/misc/network/ipv4.c: fixed compilation
   warnings.
parent c4969929
......@@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.86 2003/03/09 23:39:05 jlj Exp $
* $Id: input_ext-intf.h,v 1.87 2003/03/24 17:15:29 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -222,7 +222,6 @@ struct stream_descriptor_t
disc or network */
vlc_bool_t b_pace_control; /* can we read when we want ? */
vlc_bool_t b_seekable; /* can we do lseek() ? */
vlc_bool_t b_connected; /* does read() == 0 imply EOF ? */
/* if (b_seekable) : */
unsigned int i_area_nb;
......
......@@ -2,7 +2,7 @@
* directory.c: expands a directory (directory: access plug-in)
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: directory.c,v 1.2 2003/03/24 01:39:58 gbazin Exp $
* $Id: directory.c,v 1.3 2003/03/24 17:15:29 gbazin Exp $
*
* Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
*
......@@ -238,7 +238,6 @@ static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
p_access_data->i_buf_pos += i_ret;
return (ssize_t) i_ret;
}
p_input->stream.b_connected = VLC_TRUE;
return 0;
}
......@@ -8,7 +8,7 @@
* -udf.* to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: access.c,v 1.11 2003/03/11 23:56:53 gbazin Exp $
* $Id: access.c,v 1.12 2003/03/24 17:15:29 gbazin Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -191,7 +191,6 @@ int E_(DVDOpen) ( vlc_object_t *p_this )
p_input->stream.i_method = INPUT_METHOD_DVD;
p_input->stream.b_pace_control = 1;
p_input->stream.b_seekable = 1;
p_input->stream.b_connected = 1;
p_input->stream.p_selected_area->i_size = 0;
p_input->stream.p_selected_area->i_tell = 0;
......
......@@ -2,7 +2,7 @@
* access.c: access capabilities for dvdplay plugin.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: access.c,v 1.14 2003/03/24 14:18:28 hartman Exp $
* $Id: access.c,v 1.15 2003/03/24 17:15:29 gbazin Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -130,7 +130,6 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
p_input->stream.b_pace_control = 1;
/* seek is only allowed when we have size info */
p_input->stream.b_seekable = 0;
p_input->stream.b_connected = 1;
/* Initialize ES structures */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
......
......@@ -6,7 +6,7 @@
* It depends on: libdvdread for ifo files and block reading.
*****************************************************************************
* Copyright (C) 2001, 2003 VideoLAN
* $Id: input.c,v 1.18 2003/03/24 14:18:28 hartman Exp $
* $Id: input.c,v 1.19 2003/03/24 17:15:29 gbazin Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -364,7 +364,6 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
/* If we are here we can control the pace... */
p_input->stream.b_pace_control = VLC_TRUE;
p_input->stream.b_seekable = VLC_TRUE;
p_input->stream.b_connected = VLC_TRUE;
p_input->stream.p_selected_area->i_size = 0;
p_input->stream.p_selected_area->i_tell = 0;
......
......@@ -2,7 +2,7 @@
* file.c: file input (file: access plug-in)
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: file.c,v 1.13 2003/03/04 21:12:04 gbazin Exp $
* $Id: file.c,v 1.14 2003/03/24 17:15:29 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -130,7 +130,6 @@ static int Open( vlc_object_t *p_this )
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_connected = 1;
if( *p_input->psz_access && !strncmp( p_input->psz_access, "stream", 7 ) )
{
/* stream:%s */
......
......@@ -2,7 +2,7 @@
* ftp.c:
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: ftp.c,v 1.9 2003/03/03 14:21:08 gbazin Exp $
* $Id: ftp.c,v 1.10 2003/03/24 17:15:29 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -374,7 +374,6 @@ static int Open( vlc_object_t *p_this )
p_input->stream.b_pace_control = 1;
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.b_seekable = 1;
p_input->stream.b_connected = 1;
p_input->stream.p_selected_area->i_size = p_access->i_filesize;
p_input->stream.i_method = INPUT_METHOD_NETWORK;
vlc_mutex_unlock( &p_input->stream.stream_lock );
......@@ -817,6 +816,7 @@ static ssize_t NetRead( input_thread_t *p_input,
#else
struct timeval timeout;
fd_set fds;
ssize_t i_recv;
int i_ret;
/* Initialize file descriptor set */
......@@ -828,26 +828,30 @@ static ssize_t NetRead( input_thread_t *p_input,
timeout.tv_usec = 1000000;
/* Find if some data is available */
i_ret = select( p_socket->i_handle + 1, &fds,
NULL, NULL, &timeout );
while( (i_ret = select( p_socket->i_handle + 1, &fds,
NULL, NULL, &timeout )) == 0
|| (i_ret < 0 && errno == EINTR) )
{
if( p_input->b_die || p_input->b_error )
{
return 0;
}
}
if( i_ret == -1 && errno != EINTR )
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_socket->i_handle, p_buffer, i_len, 0 );
if( i_recv < 0 )
{
msg_Err( p_input, "recv failed (%s)", strerror(errno) );
}
i_recv = recv( p_socket->i_handle, p_buffer, i_len, 0 );
return i_recv;
if( i_recv < 0 )
{
msg_Err( p_input, "recv failed (%s)", strerror(errno) );
}
return 0;
return i_recv;
#endif
}
......
......@@ -2,7 +2,7 @@
* http.c: HTTP access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: http.c,v 1.27 2003/03/22 23:03:02 sigmunau Exp $
* $Id: http.c,v 1.28 2003/03/24 17:15:29 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -611,7 +611,6 @@ static int Open( vlc_object_t *p_this )
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_pace_control = VLC_TRUE;
p_input->stream.b_seekable = VLC_TRUE;
p_input->stream.b_connected = VLC_TRUE;
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.p_selected_area->i_size = 0;
p_input->stream.i_method = INPUT_METHOD_NETWORK;
......@@ -700,6 +699,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 */
......@@ -711,35 +711,35 @@ 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
#ifdef HAVE_ERRNO_H
if( i_ret == -1 && errno != EINTR )
|| (i_ret < 0 && errno == EINTR)
#endif
)
{
msg_Err( p_input, "network select error (%s)", strerror(errno) );
if( p_input->b_die || p_input->b_error )
{
return 0;
}
}
#else
if( i_ret == -1 )
if( i_ret < 0 )
{
msg_Err( p_input, "network select error" );
return -1;
}
#endif
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 HAVE_ERRNO_H
msg_Err( p_input, "recv failed (%s)", strerror(errno) );
msg_Err( p_input, "recv failed (%s)", strerror(errno) );
#else
msg_Err( p_input, "recv failed" );
msg_Err( p_input, "recv failed" );
#endif
}
return i_recv;
}
return 0;
return i_recv;
}
......@@ -2,7 +2,7 @@
* mms.c: MMS access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: mms.c,v 1.27 2003/03/16 01:49:28 fenrir Exp $
* $Id: mms.c,v 1.28 2003/03/24 17:15:29 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -252,14 +252,6 @@ static int Open( vlc_object_t *p_this )
/* *** finished to set some variable *** */
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_pace_control = 0;
if( p_access->i_proto == MMS_PROTO_UDP )
{
p_input->stream.b_connected = 0;
}
else
{
p_input->stream.b_connected = 1;
}
p_input->stream.p_selected_area->i_tell = 0;
/*
* i_flags_broadcast
......@@ -1477,11 +1469,17 @@ static int NetFillBuffer( input_thread_t *p_input )
timeout.tv_usec = 500000;
/* Find if some data is available */
i_ret = select( i_handle_max + 1,
&fds,
NULL, NULL, &timeout );
while( (i_ret = select( i_handle_max + 1, &fds,
NULL, NULL, &timeout )) == 0
|| (i_ret < 0 && errno == EINTR) )
{
if( p_input->b_die || p_input->b_error )
{
return 0;
}
}
if( i_ret == -1 && errno != EINTR )
if( i_ret < 0 )
{
msg_Err( p_input, "network select error (%s)", strerror(errno) );
return -1;
......
......@@ -287,7 +287,6 @@ int E_(Open) ( vlc_object_t *p_this )
p_input->stream.b_pace_control = 1;
p_input->stream.b_seekable = 0;
p_input->stream.b_connected = 0;
p_input->stream.p_selected_area->i_tell = 0;
vlc_mutex_unlock( &p_input->stream.stream_lock );
......
......@@ -2,7 +2,7 @@
* slp.c: SLP access plugin
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: slp.c,v 1.8 2003/02/20 01:52:45 sigmunau Exp $
* $Id: slp.c,v 1.9 2003/03/24 17:15:29 gbazin Exp $
*
* Authors: Loc Minier <lool@videolan.org>
*
......@@ -340,7 +340,6 @@ static int Open( vlc_object_t * p_this )
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_pace_control = VLC_FALSE;
p_input->stream.b_seekable = VLC_FALSE;
p_input->stream.b_connected = VLC_TRUE;
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.p_selected_area->i_size = 0;
p_input->stream.i_method = INPUT_METHOD_SLP;
......
......@@ -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.16 2003/03/24 17:15:29 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Tristan Leteurtre <tooney@via.ecp.fr>
......@@ -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,42 @@ 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) )
{
if( p_input->b_die || p_input->b_error )
{
return 0;
}
}
if( i_ret == -1 && errno != EINTR )
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
}
......
......@@ -2,7 +2,7 @@
* v4l.c : Video4Linux input module for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: v4l.c,v 1.2 2002/12/31 01:54:36 massiot Exp $
* $Id: v4l.c,v 1.3 2003/03/24 17:15:30 gbazin Exp $
*
* Author: Samuel Hocevar <sam@zoy.org>
*
......@@ -64,7 +64,6 @@ static int V4lOpen( 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_size = 0;
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.i_method = INPUT_METHOD_FILE;
......
......@@ -2,7 +2,7 @@
* vcd.c : VCD input module for vlc
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: vcd.c,v 1.16 2003/03/11 23:56:54 gbazin Exp $
* $Id: vcd.c,v 1.17 2003/03/24 17:15:30 gbazin Exp $
*
* Author: Johan Bilien <jobi@via.ecp.fr>
*
......@@ -171,7 +171,6 @@ static int VCDOpen( vlc_object_t *p_this )
p_input->stream.b_pace_control = 1;
p_input->stream.b_seekable = 1;
p_input->stream.b_connected = 1;
p_input->stream.p_selected_area->i_size = 0;
p_input->stream.p_selected_area->i_tell = 0;
......
......@@ -2,7 +2,7 @@
* ipv4.c: IPv4 network abstraction layer
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: ipv4.c,v 1.16 2003/03/11 13:52:25 titer Exp $
* $Id: ipv4.c,v 1.17 2003/03/24 17:15:30 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Mathias Kretschmer <mathias@research.att.com>
......@@ -384,7 +384,7 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
ttl = 1;
if( setsockopt( i_handle, IPPROTO_IP, IP_MULTICAST_TTL,
&ttl, sizeof( ttl ) ) < 0 )
(void *) &ttl, sizeof( ttl ) ) < 0 )
{
#ifdef HAVE_ERRNO_H
msg_Warn( p_this, "failed to set ttl (%s)",
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.225 2003/03/14 00:24:08 sigmunau Exp $
* $Id: input.c,v 1.226 2003/03/24 17:15:30 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -341,7 +341,7 @@ static int RunThread( input_thread_t *p_input )
/* Read and demultiplex some data. */
i_count = p_input->pf_demux( p_input );
if( i_count == 0 && p_input->stream.b_connected )
if( i_count == 0 )
{
/* End of file - we do not set b_die because only the
* playlist is allowed to do so. */
......
......@@ -2,7 +2,7 @@
* input_ext-plugins.c: useful functions for access and demux plug-ins
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: input_ext-plugins.c,v 1.30 2003/03/05 17:55:13 gbazin Exp $
* $Id: input_ext-plugins.c,v 1.31 2003/03/24 17:15:30 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -517,6 +517,12 @@ ssize_t input_FillBuffer( input_thread_t * p_input )
(byte_t *)p_buf + sizeof(data_buffer_t)
+ i_remains,
p_input->i_bufsize );
if( i_ret < 0 && i_remains == 0 )
{
/* Our internal buffers are empty, we can signal the error */
return -1;
}
if( i_ret < 0 ) i_ret = 0;
p_input->p_data_buffer = p_buf;
......@@ -538,7 +544,7 @@ ssize_t input_Peek( input_thread_t * p_input, byte_t ** pp_byte, size_t i_size )
/* Go to the next buffer */
ssize_t i_ret = input_FillBuffer( p_input );
if( i_ret == -1 )
if( i_ret < 0 )
{
return -1;
}
......@@ -564,7 +570,7 @@ ssize_t input_SplitBuffer( input_thread_t * p_input,
/* Go to the next buffer */
ssize_t i_ret = input_FillBuffer( p_input );
if( i_ret == -1 )
if( i_ret < 0 )
{
return -1;
}
......
......@@ -2,7 +2,7 @@
* intf_eject.c: CD/DVD-ROM ejection handling functions
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: intf_eject.c,v 1.19 2003/03/21 17:14:56 gbazin Exp $
* $Id: intf_eject.c,v 1.20 2003/03/24 17:15:30 gbazin Exp $
*
* Author: Julien Blache <jb@technologeek.org> for the Linux part
* with code taken from the Linux "eject" command
......@@ -157,11 +157,13 @@ int __intf_Eject( vlc_object_t *p_this, const char *psz_device )
{
st.dwItem = MCI_STATUS_READY;
/* Eject disc */
mciSendCommand( op.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0 );
i_ret = mciSendCommand( op.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0 );
/* Release access to the device */
mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 );
}
else i_ret = VLC_EGENERIC;
return i_ret;
#else /* WIN32 */
int i_fd;
......
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