]> git.sesse.net Git - vlc/commitdiff
* src/misc/darwin_specific.m: Partial attempt at fixing a memory leak,
authorChristophe Massiot <massiot@videolan.org>
Tue, 31 Dec 2002 01:54:36 +0000 (01:54 +0000)
committerChristophe Massiot <massiot@videolan.org>
Tue, 31 Dec 2002 01:54:36 +0000 (01:54 +0000)
* input: new b_connected field, allowing to correctly detect the EOF of TCP
  streams (closes #35),
* input: fixed a deadlock when opening a zero-sized file,
* input: fixed a deadlock when opening an unconnected FIFO (closes #54).

16 files changed:
include/input_ext-intf.h
include/vlc_config.h
modules/access/dvd/access.c
modules/access/dvdplay/access.c
modules/access/dvdread/input.c
modules/access/file.c
modules/access/ftp.c
modules/access/http.c
modules/access/mms/mms.c
modules/access/satellite/access.c
modules/access/udp.c
modules/access/v4l/v4l.c
modules/access/vcd/vcd.c
modules/codec/mpeg_video/synchro.c
src/input/input.c
src/misc/darwin_specific.m

index de934aabb33f88c99dd65977851522ea4e0b6800..7e1edd9b855cef91ecbe67c874c5b5df535f41c8 100644 (file)
@@ -4,7 +4,7 @@
  * control the pace of reading.
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-intf.h,v 1.81 2002/12/12 15:10:58 gbazin Exp $
+ * $Id: input_ext-intf.h,v 1.82 2002/12/31 01:54:35 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -219,6 +219,7 @@ 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;
index ad664cab97fd2015235993fb53370d82f7028559..18c22e1f30a3fec02e5236e608faa60d22d552cb 100644 (file)
  * Input thread configuration
  *****************************************************************************/
 
-/* XXX?? */
+/* Used in ErrorThread */
 #define INPUT_IDLE_SLEEP                ((mtime_t)(0.100*CLOCK_FREQ))
 
+/* Time to wait in case of read error */
+#define INPUT_ERROR_SLEEP               ((mtime_t)(0.10*CLOCK_FREQ))
+
 /*
  * General limitations
  */
index 39a8267353bf571bfc69fe0574ff08b821e51b26..da9643a63ade3015ac2af4e60c4cfe3d65106177 100644 (file)
@@ -8,7 +8,7 @@
  *  -udf.* to find files
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: access.c,v 1.7 2002/12/30 23:45:21 massiot Exp $
+ * $Id: access.c,v 1.8 2002/12/31 01:54:35 massiot Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -191,6 +191,7 @@ 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;
 
index 7638e19704994ac3525c40c795a609ff619b2b4f..1d14b33f4adbfa94fcfa2d726827cc81fd252582 100644 (file)
@@ -2,7 +2,7 @@
  * access.c: access capabilities for dvdplay plugin.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: access.c,v 1.8 2002/12/13 01:50:32 gbazin Exp $
+ * $Id: access.c,v 1.9 2002/12/31 01:54:35 massiot Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -133,6 +133,7 @@ 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 ) );
index 4991e99c53e0f06f147d2ff7de86fae69ccd38cf..7af85e1511fc42cf5fab53c7d4da447ab332e09c 100644 (file)
@@ -6,7 +6,7 @@
  * It depends on: libdvdread for ifo files and block reading.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: input.c,v 1.10 2002/12/30 23:45:21 massiot Exp $
+ * $Id: input.c,v 1.11 2002/12/31 01:54:35 massiot Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -362,6 +362,7 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
     /* If we are here we can control the pace... */
     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;
index 8eb05b227558523a1cf01a6166e8d7031b06f7c6..9b3502c7ef5fc1c107ac3a71fc3f2a2cd8a7ad8f 100644 (file)
@@ -2,7 +2,7 @@
  * file.c: file input (file: access plug-in)
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: file.c,v 1.6 2002/12/12 15:10:58 gbazin Exp $
+ * $Id: file.c,v 1.7 2002/12/31 01:54:35 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -113,6 +113,7 @@ 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 */
@@ -198,7 +199,7 @@ static int Open( vlc_object_t *p_this )
                         GetFileSize( (HANDLE)p_access_data->i_handle, NULL );
 #else
         p_access_data->i_handle = open( psz_name,
-                                        /*O_NONBLOCK | O_LARGEFILE*/ 0 );
+                                        O_NONBLOCK /*| O_LARGEFILE*/ );
         if( p_access_data->i_handle == -1 )
         {
 #   ifdef HAVE_ERRNO_H
@@ -213,6 +214,14 @@ static int Open( vlc_object_t *p_this )
 #endif
     }
 
+    if ( p_input->stream.b_seekable
+          && !p_input->stream.p_selected_area->i_size )
+    {
+        msg_Err( p_input, "file %s is empty, aborting", psz_name );
+        free( p_access_data );
+        return VLC_EGENERIC;
+    }
+
     /* Update default_pts to a suitable value for file access */
     p_input->i_pts_delay = config_GetInt( p_input, "file-caching" ) * 1000;
 
@@ -256,14 +265,19 @@ static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
 #else
     i_ret = read( p_access_data->i_handle, p_buffer, i_len );
 #endif
+
     if( i_ret < 0 )
     {
 #   ifdef HAVE_ERRNO_H
-        msg_Err( p_input, "read failed (%s)", strerror(errno) );
+        if ( errno != EINTR && errno != EAGAIN )
+            msg_Err( p_input, "read failed (%s)", strerror(errno) );
 #   else
         msg_Err( p_input, "read failed" );
 #   endif
+
+        /* Delay a bit to avoid consuming all the CPU. This is particularly
+         * useful when reading from an unconnected FIFO. */
+        msleep( INPUT_ERROR_SLEEP );
     }
  
     return i_ret;
index 0bcfe0e23aca8837ed7130f568d2637cd345c2f8..c69e2d2da3ae538e495bc734fb96b6ddf59bca09 100644 (file)
@@ -2,7 +2,7 @@
  * ftp.c:
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: ftp.c,v 1.4 2002/12/25 02:23:36 massiot Exp $
+ * $Id: ftp.c,v 1.5 2002/12/31 01:54:35 massiot Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -371,6 +371,7 @@ 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 );
index 5ff08b0302dc71593407bcb5051e53192ff233b3..19f94ab9dffae004ac71efc520d7f5c0db0d52ba 100644 (file)
@@ -2,7 +2,7 @@
  * http.c: HTTP access plug-in
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: http.c,v 1.19 2002/12/23 15:39:07 massiot Exp $
+ * $Id: http.c,v 1.20 2002/12/31 01:54:35 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -608,6 +608,7 @@ 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;
index fc5e19f9779a5118a2409713fa5b122cc6d527eb..2c6e166e1f37b3c92949d6098508c3b368178d17 100644 (file)
@@ -2,7 +2,7 @@
  * mms.c: MMS access plug-in
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: mms.c,v 1.15 2002/12/30 08:56:19 massiot Exp $
+ * $Id: mms.c,v 1.16 2002/12/31 01:54:35 massiot Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -250,13 +250,14 @@ 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_pace_control = 0;
+        p_input->stream.b_connected = 0;
     }
     else
     {
-        p_input->stream.b_pace_control = 1;
+        p_input->stream.b_connected = 1;
     }
     p_input->stream.p_selected_area->i_tell = 0;
     if( p_access->i_packet_count <= 0 )
index f966f8c9006b157b2c906d3653cdc17cb6f83198..42ea8a4de48dfd64f024ae0eec0affa6d5c47ee4 100644 (file)
@@ -287,6 +287,7 @@ 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 );
index df9cd0da52ef22a0daf4e525fa334faf44b3575e..99b4a06a1623ca0e0fc3945e2d58e2d35090ea2a 100644 (file)
@@ -2,7 +2,7 @@
  * udp.c: raw UDP & RTP access plug-in
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: udp.c,v 1.9 2002/12/30 11:49:32 massiot Exp $
+ * $Id: udp.c,v 1.10 2002/12/31 01:54:35 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Tristan Leteurtre <tooney@via.ecp.fr>
@@ -233,6 +233,7 @@ 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 );
index 0cfe12cd3d1a1f139a10ad933e3e6bdbe9ec90d9..d02bd2b95a7e33e0b148e2186aa524e98e94133d 100644 (file)
@@ -2,7 +2,7 @@
  * v4l.c : Video4Linux input module for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: v4l.c,v 1.1 2002/08/08 00:35:10 sam Exp $
+ * $Id: v4l.c,v 1.2 2002/12/31 01:54:36 massiot Exp $
  *
  * Author: Samuel Hocevar <sam@zoy.org>
  *
@@ -64,6 +64,7 @@ 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;
index bf14c687dc63707db782253bf4dcecec54146773..d738b584e7b5b5d66f2afd215edfa287629021f4 100644 (file)
@@ -2,7 +2,7 @@
  * vcd.c : VCD input module for vlc
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
- * $Id: vcd.c,v 1.12 2002/12/06 16:34:04 sam Exp $
+ * $Id: vcd.c,v 1.13 2002/12/31 01:54:36 massiot Exp $
  *
  * Author: Johan Bilien <jobi@via.ecp.fr>
  *
@@ -170,8 +170,8 @@ static int VCDOpen( vlc_object_t *p_this )
     vlc_mutex_lock( &p_input->stream.stream_lock );
 
     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;
 
index ad52a92b73871fb9b25e412fd7902984aeb7e3e0..c01c965d2740706e1023082a6f9016f3acb0a917 100644 (file)
@@ -2,7 +2,7 @@
  * vpar_synchro.c : frame dropping routines
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: synchro.c,v 1.4 2002/11/08 10:26:53 gbazin Exp $
+ * $Id: synchro.c,v 1.5 2002/12/31 01:54:36 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
@@ -386,6 +386,7 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type,
 
         if( p_vpar->synchro.i_type == VPAR_SYNCHRO_DEFAULT )
         {
+#if 0
             msg_Dbg( p_vpar->p_fifo, "I("I64Fd") P("I64Fd")[%d] B("I64Fd")"
                   "[%d] YUV("I64Fd") : trashed %d:%d/%d",
                   p_vpar->synchro.p_tau[I_CODING_TYPE],
@@ -400,6 +401,18 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type,
                   p_vpar->synchro.i_pic );
             p_vpar->synchro.i_trashed_pic = p_vpar->synchro.i_not_chosen_pic
                 = p_vpar->synchro.i_pic = 0;
+#else
+            if ( p_vpar->synchro.i_pic >= 100 )
+            {
+                msg_Dbg( p_vpar->p_fifo, "decoded %d/%d pictures",
+                         p_vpar->synchro.i_pic
+                           - p_vpar->synchro.i_trashed_pic
+                           - p_vpar->synchro.i_not_chosen_pic,
+                         p_vpar->synchro.i_pic );
+                p_vpar->synchro.i_trashed_pic = p_vpar->synchro.i_not_chosen_pic
+                    = p_vpar->synchro.i_pic = 0;
+            }
+#endif
         }
         break;
 
index 76874031db78b2f19d5d37825fab4f4982eaac15..657b06ed4ad8e8f114301b7ee162f4722dcf505f 100644 (file)
@@ -4,7 +4,7 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id: input.c,v 1.220 2002/12/18 14:17:11 sam Exp $
+ * $Id: input.c,v 1.221 2002/12/31 01:54:36 massiot 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_seekable )
+        if( i_count == 0 && p_input->stream.b_connected )
         {
             /* End of file - we do not set b_die because only the
              * playlist is allowed to do so. */
@@ -488,7 +488,7 @@ static int InitThread( input_thread_t * p_input )
     p_input->p_demux = module_Need( p_input, "demux",
                                     p_input->psz_demux );
 
-    if( p_input->p_demux== NULL )
+    if( p_input->p_demux == NULL )
     {
         msg_Err( p_input, "no suitable demux module for `%s/%s://%s'",
                  p_input->psz_access, p_input->psz_demux, p_input->psz_name );
index c0e76d1ee5d807c72047e703f981367f99d619fe..b9bdaa14693cec3b5e014fac0bf4580d9e3a9b73 100644 (file)
@@ -2,7 +2,7 @@
  * darwin_specific.m: Darwin specific features 
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: darwin_specific.m,v 1.1 2002/12/30 08:56:19 massiot Exp $
+ * $Id: darwin_specific.m,v 1.2 2002/12/31 01:54:36 massiot Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -118,6 +118,7 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
     /* Check if $LANG is set. */
     if ( (p_char = getenv("LANG")) == NULL )
     {
+        NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
         /* Retrieve user's preferences. */
         NSUserDefaults * p_defs =
             [[NSUserDefaults standardUserDefaults] autorelease];
@@ -135,6 +136,8 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
                 break;
             }
         }
+        /* FIXME : why does it segfault ??? */
+        //[o_pool release];
     }
 }