]> git.sesse.net Git - vlc/commitdiff
*fixed a double malloc/free bug in DVDRead
authorStéphane Borel <stef@videolan.org>
Thu, 31 May 2001 16:10:05 +0000 (16:10 +0000)
committerStéphane Borel <stef@videolan.org>
Thu, 31 May 2001 16:10:05 +0000 (16:10 +0000)
*fixed a lock issue in the interface introduced in my last commit

plugins/dvd/input_dvd.c
plugins/gtk/gtk_callbacks.c
plugins/gtk/gtk_menu.c
src/audio_output/aout_spdif.c

index 8172c0e9dc228d2ac1c01289e30970ab0ec7556b..fc795ebec4fe7e216ad9c3986bfb5dc475418adc 100644 (file)
@@ -10,7 +10,7 @@
  *  -dvd_udf to find files
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_dvd.c,v 1.65 2001/05/31 03:57:54 sam Exp $
+ * $Id: input_dvd.c,v 1.66 2001/05/31 16:10:05 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
 
 #include "modules.h"
 
+/* how many blocks DVDRead will read in each loop */
+#define DVD_BLOCK_READ_ONCE 32
+#define DVD_DATA_READ_ONCE  4*DVD_BLOCK_READ_ONCE
+
+/* Size of netlist */
+#define DVD_NETLIST_SIZE    2048
+
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -223,11 +230,11 @@ static void DVDInit( input_thread_t * p_input )
 
     p_dvd->i_fd = p_input->i_handle;
 
-    /* reading several block once seems to cause lock-up
-     * when using input_ToggleES
-     * who wrote thez damn buggy piece of shit ??? --stef */
-    p_dvd->i_block_once = 32;
-    p_input->i_read_once = 128;
+    /* We read DVD_BLOCK_READ_ONCE in each loop, so the input will receive
+     * DVD_DATA_READ_ONCE at most */
+    p_dvd->i_block_once = DVD_BLOCK_READ_ONCE;
+    /* this value mustn't be modifed */
+    p_input->i_read_once = DVD_DATA_READ_ONCE;
 
     i = CSSTest( p_input->i_handle );
 
@@ -249,7 +256,8 @@ static void DVDInit( input_thread_t * p_input )
 
     /* Reading structures initialisation */
     p_input->p_method_data =
-        DVDNetlistInit( 2048, 4096, 2048, DVD_LB_SIZE, p_dvd->i_block_once );
+        DVDNetlistInit( DVD_NETLIST_SIZE, 2*DVD_NETLIST_SIZE,
+                        DVD_NETLIST_SIZE, DVD_LB_SIZE, p_dvd->i_block_once );
     intf_WarnMsg( 2, "dvd info: netlist initialized" );
 
     /* Ifo allocation & initialisation */
@@ -818,7 +826,7 @@ static int DVDRead( input_thread_t * p_input,
     thread_dvd_data_t *     p_dvd;
     dvd_netlist_t *         p_netlist;
     struct iovec *          p_vec;
-    struct data_packet_s ** pp_data;
+    struct data_packet_s *  pp_data[DVD_DATA_READ_ONCE];
     u8 *                    pi_cur;
     int                     i_block_once;
     int                     i_packet_size;
@@ -831,22 +839,6 @@ static int DVDRead( input_thread_t * p_input,
     boolean_t               b_eof;
     boolean_t               b_eot;
 
-    pp_data = (struct data_packet_s **) malloc( p_input->i_read_once *
-                                        sizeof( struct data_packet_s * ) );
-    if( pp_data == NULL )
-    {
-        intf_ErrMsg( "dvd error: out of memory" );
-        return -1;
-    }
-
-    pp_data = (struct data_packet_s **) malloc( p_input->i_read_once *
-                                        sizeof( struct data_packet_s * ) );
-    if( pp_data == NULL )
-    {
-        intf_ErrMsg( "dvd error: out of memory" );
-        return -1;
-    }
-
     p_dvd = (thread_dvd_data_t *)p_input->p_plugin_data;
     p_netlist = (dvd_netlist_t *)p_input->p_method_data;
 
@@ -854,7 +846,6 @@ static int DVDRead( input_thread_t * p_input,
     if( ( p_vec = DVDGetiovec( p_netlist ) ) == NULL )
     {
         intf_ErrMsg( "dvd error: can't get iovec" );
-        free( pp_data );
         return -1;
     }
 
@@ -873,7 +864,6 @@ static int DVDRead( input_thread_t * p_input,
         {
             pp_packets[0] = NULL;
             intf_ErrMsg( "dvd error: can't find next cell" );
-            free( pp_data );
             return 1;
         }
 
@@ -980,7 +970,6 @@ static int DVDRead( input_thread_t * p_input,
                 else
                 {
                     intf_ErrMsg( "Unable to determine stream type" );
-                    free( pp_data );
                     return( -1 );
                 }
 
@@ -1018,10 +1007,6 @@ static int DVDRead( input_thread_t * p_input,
 
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    free( pp_data );
-
-    free( pp_data );
-
     if( b_eof )
     {
         return 1;
index d39fa611b64bc975035f93d113c5cc7b3d316d17..6f7e40d90da6f2f74a6d79381024c8df5ddd04e3 100644 (file)
@@ -2,7 +2,7 @@
  * gtk_callbacks.c : Callbacks for the Gtk+ plugin.
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: gtk_callbacks.c,v 1.23 2001/05/30 23:02:03 stef Exp $
+ * $Id: gtk_callbacks.c,v 1.24 2001/05/31 16:10:05 stef Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -205,7 +205,9 @@ void GtkTitlePrev( GtkButton * button, gpointer user_data )
         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
 
         p_intf->p_sys->b_title_update = 1;
+        vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
         GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
     }
 }
 
@@ -227,7 +229,9 @@ void GtkTitleNext( GtkButton * button, gpointer user_data )
         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
 
         p_intf->p_sys->b_title_update = 1;
+        vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
         GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
     }
 
 }
@@ -249,7 +253,9 @@ void GtkChapterPrev( GtkButton * button, gpointer user_data )
         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
 
         p_intf->p_sys->b_chapter_update = 1;
+        vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
         GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
     }
 }
 
@@ -270,7 +276,9 @@ void GtkChapterNext( GtkButton * button, gpointer user_data )
         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
 
         p_intf->p_sys->b_chapter_update = 1;
+        vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
         GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
     }
 }
 
index 1ec4c17169baa47b50f11d2740dec7759f345bd2..0ee02d7027eae1074065f6bf0b896a2d31d51e79 100644 (file)
@@ -2,7 +2,7 @@
  * gtk_menu.c : functions to handle menu items.
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: gtk_menu.c,v 1.7 2001/05/30 23:02:04 stef Exp $
+ * $Id: gtk_menu.c,v 1.8 2001/05/31 16:10:05 stef Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -176,7 +176,9 @@ void GtkPopupNavigationToggle( GtkCheckMenuItem * menuitem,
         input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
 
         p_intf->p_sys->b_chapter_update = 1;
+        vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
         GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
 
         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
     }
@@ -197,7 +199,9 @@ void GtkMenubarTitleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
                           p_intf->p_input->stream.pp_areas[i_title] );
 
         p_intf->p_sys->b_title_update = 1;
+        vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
         GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
         p_intf->p_sys->b_title_update = 0;
 
         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
index 6c0575788e95f1b9a60ffa1afe5a9791bf3ab63b..c7bd30643bd9de61da7faadfba84be307ddc8dd4 100644 (file)
@@ -2,7 +2,7 @@
  * aout_spdif: ac3 passthrough output
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: aout_spdif.c,v 1.10 2001/05/31 03:12:49 sam Exp $
+ * $Id: aout_spdif.c,v 1.11 2001/05/31 16:10:05 stef Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -41,7 +41,7 @@
 #include "audio_output.h"
 #include "aout_common.h"
 
-#define BLANK_FRAME_MAX 100
+#define BLANK_FRAME_MAX 1000
 #define SLEEP_TIME      16000
 
 /*****************************************************************************