]> git.sesse.net Git - vlc/blobdiff - modules/demux/avi/avi.c
* ALL: i18n updates and fixes.
[vlc] / modules / demux / avi / avi.c
index a6a12abdffcbdf634085d528779bfc2045323805..5b5c931d7a502f0595e64e9bb687e8078e63b517 100644 (file)
@@ -2,7 +2,7 @@
  * avi.c : AVI file Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: avi.c,v 1.28 2003/01/23 13:44:21 fenrir Exp $
+ * $Id: avi.c,v 1.36 2003/02/27 13:19:43 gbazin Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -52,20 +52,20 @@ static int    AVIDemux_Seekable  ( input_thread_t * );
 static int    AVIDemux_UnSeekable( input_thread_t *p_input );
 
 #define AVIEnd(a) __AVIEnd(VLC_OBJECT(a))
-
+#define FREE( p ) if( p ) { free( p ); (p) = NULL; }
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    add_category_hint( "demuxer", NULL );
+    add_category_hint( N_("avi-demuxer"), NULL, VLC_TRUE );
         add_bool( "avi-interleaved", 0, NULL,
-                  "force interleaved method",
-                  "force interleaved method" );
+                  _("force interleaved method"),
+                  _("force interleaved method"), VLC_TRUE );
         add_bool( "avi-index", 0, NULL,
-                  "force index creation",
-                  "force index creation" );
+                  _("force index creation"),
+                  _("force index creation"), VLC_TRUE );
 
-    set_description( "avi demuxer" );
+    set_description( _("avi demuxer") );
     set_capability( "demux", 212 );
     set_callbacks( AVIInit, __AVIEnd );
 vlc_module_end();
@@ -142,7 +142,11 @@ static int input_ReadInPES( input_thread_t *p_input,
                                           p_pes->i_pes_size, 2048 ) );
         if( i_read <= 0 )
         {
-            return p_pes->i_pes_size;
+            /* should occur only with EOF and max allocation reached 
+             * it safer to  return an error */
+            /* free pes */
+            input_DeletePES( p_input->p_method_data, p_pes );
+            return -1;
         }
 
         if( !p_pes->p_first )
@@ -683,7 +687,7 @@ static void    AVI_StreamStop( input_thread_t *p_input,
 static int AVI_StreamStopFinishedStreams( input_thread_t *p_input,
                                            demux_sys_t *p_avi )
 {
-    int unsigned i_stream;
+    unsigned int i_stream;
     int b_end;
 
     for( i_stream = 0,b_end = VLC_TRUE;
@@ -780,6 +784,8 @@ static void __AVIEnd ( vlc_object_t * p_this )
     }
 #endif
     AVI_ChunkFreeRoot( p_input, &p_avi->ck_root );
+
+    FREE( p_input->p_demux_data );
 }
 
 /*****************************************************************************
@@ -925,7 +931,7 @@ static int AVIInit( vlc_object_t * p_this )
                        p_avih->i_flags&AVIF_ISINTERLEAVED?" IS_INTERLEAVED":"",
                        p_avih->i_flags&AVIF_TRUSTCKTYPE?" TRUST_CKTYPE":"" );
     }
-        
+
     /* now read info on each stream and create ES */
     p_avi->pp_info = calloc( p_avi->i_streams,
                             sizeof( avi_stream_t* ) );
@@ -1696,6 +1702,7 @@ static int AVIDemux_Seekable( input_thread_t *p_input )
 
     demux_sys_t *p_avi = p_input->p_demux_data;
 
+
     /* detect new selected/unselected streams */
     for( i_stream = 0,i_stream_count= 0, b_video = VLC_FALSE;
             i_stream < p_avi->i_streams; i_stream++ )
@@ -1737,7 +1744,7 @@ static int AVIDemux_Seekable( input_thread_t *p_input )
         mtime_t i_date;
         int i_percent;
         /* first wait for empty buffer, arbitrary time FIXME */
-//        msleep( DEFAULT_PTS_DELAY );
+        //msleep( DEFAULT_PTS_DELAY );
 
         i_date = (mtime_t)1000000 *
                  (mtime_t)p_avi->i_length *
@@ -1958,7 +1965,7 @@ static int AVIDemux_Seekable( input_thread_t *p_input )
         /* read thoses data */
         if( p_stream->i_samplesize )
         {
-            int i_toread;
+            unsigned int i_toread;
 
             if( ( i_toread = toread[i_stream].i_toread ) <= 0 )
             {
@@ -1988,6 +1995,7 @@ static int AVIDemux_Seekable( input_thread_t *p_input )
         if( input_ReadInPES( p_input, &p_pes, __EVEN( i_size ) ) < 0 )
         {
             msg_Warn( p_input, "failled reading data" );
+            AVI_StreamStop( p_input, p_avi, i_stream );
             toread[i_stream].b_ok = VLC_FALSE;
             continue;
         }