From e9cc5c05f7423734b0a8a4c8e105e8bb65e50dcd Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Borel?= Date: Thu, 31 May 2001 16:10:05 +0000 Subject: [PATCH] *fixed a double malloc/free bug in DVDRead *fixed a lock issue in the interface introduced in my last commit --- plugins/dvd/input_dvd.c | 47 ++++++++++++----------------------- plugins/gtk/gtk_callbacks.c | 10 +++++++- plugins/gtk/gtk_menu.c | 6 ++++- src/audio_output/aout_spdif.c | 4 +-- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/plugins/dvd/input_dvd.c b/plugins/dvd/input_dvd.c index 8172c0e9dc..fc795ebec4 100644 --- a/plugins/dvd/input_dvd.c +++ b/plugins/dvd/input_dvd.c @@ -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 * @@ -96,6 +96,13 @@ #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; diff --git a/plugins/gtk/gtk_callbacks.c b/plugins/gtk/gtk_callbacks.c index d39fa611b6..6f7e40d90d 100644 --- a/plugins/gtk/gtk_callbacks.c +++ b/plugins/gtk/gtk_callbacks.c @@ -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 * Stéphane Borel @@ -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 ); } } diff --git a/plugins/gtk/gtk_menu.c b/plugins/gtk/gtk_menu.c index 1ec4c17169..0ee02d7027 100644 --- a/plugins/gtk/gtk_menu.c +++ b/plugins/gtk/gtk_menu.c @@ -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 * Stéphane Borel @@ -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 ); diff --git a/src/audio_output/aout_spdif.c b/src/audio_output/aout_spdif.c index 6c0575788e..c7bd30643b 100644 --- a/src/audio_output/aout_spdif.c +++ b/src/audio_output/aout_spdif.c @@ -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 * Stéphane Borel @@ -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 /***************************************************************************** -- 2.39.2