Commit d865ef30 authored by Sam Hocevar's avatar Sam Hocevar

  * ./plugins/dvd/dvd_access.c ./plugins/vcd/input_vcd.c: we now exit more
    cleanly on initialization error.
parent 83b13fcb
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* -dvd_udf to find files * -dvd_udf to find files
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: dvd_access.c,v 1.3 2002/03/08 22:58:12 stef Exp $ * $Id: dvd_access.c,v 1.4 2002/03/09 13:42:46 sam Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -114,7 +114,6 @@ void _M( access_getfunctions)( function_list_t * p_function_list ) ...@@ -114,7 +114,6 @@ void _M( access_getfunctions)( function_list_t * p_function_list )
static int DVDOpen( struct input_thread_s *p_input ) static int DVDOpen( struct input_thread_s *p_input )
{ {
char * psz_device; char * psz_device;
dvdcss_handle dvdhandle;
thread_dvd_data_t * p_dvd; thread_dvd_data_t * p_dvd;
input_area_t * p_area; input_area_t * p_area;
int i; int i;
...@@ -142,23 +141,23 @@ static int DVDOpen( struct input_thread_s *p_input ) ...@@ -142,23 +141,23 @@ static int DVDOpen( struct input_thread_s *p_input )
/* /*
* get plugin ready * get plugin ready
*/ */
dvdhandle = dvdcss_open( psz_device ); p_dvd->dvdhandle = dvdcss_open( psz_device );
/* free allocated string */ /* free allocated string */
free( psz_device ); free( psz_device );
if( p_dvd->dvdhandle == NULL )
if( dvdhandle == NULL )
{ {
intf_ErrMsg( "dvd error: dvdcss can't open device" ); intf_ErrMsg( "dvd error: dvdcss can't open device" );
free( p_dvd );
return -1; return -1;
} }
p_dvd->dvdhandle = (dvdcss_handle) dvdhandle;
if( dvdcss_seek( p_dvd->dvdhandle, 0, DVDCSS_NOFLAGS ) < 0 ) if( dvdcss_seek( p_dvd->dvdhandle, 0, DVDCSS_NOFLAGS ) < 0 )
{ {
intf_ErrMsg( "dvd error: %s", dvdcss_error( p_dvd->dvdhandle ) ); intf_ErrMsg( "dvd error: %s", dvdcss_error( p_dvd->dvdhandle ) );
dvdcss_close( p_dvd->dvdhandle );
free( p_dvd );
return -1; return -1;
} }
...@@ -166,6 +165,7 @@ static int DVDOpen( struct input_thread_s *p_input ) ...@@ -166,6 +165,7 @@ static int DVDOpen( struct input_thread_s *p_input )
if( IfoCreate( p_dvd ) < 0 ) if( IfoCreate( p_dvd ) < 0 )
{ {
intf_ErrMsg( "dvd error: allcation error in ifo" ); intf_ErrMsg( "dvd error: allcation error in ifo" );
dvdcss_close( p_dvd->dvdhandle );
free( p_dvd ); free( p_dvd );
return -1; return -1;
} }
...@@ -174,6 +174,7 @@ static int DVDOpen( struct input_thread_s *p_input ) ...@@ -174,6 +174,7 @@ static int DVDOpen( struct input_thread_s *p_input )
{ {
intf_ErrMsg( "dvd error: fatal failure in ifo" ); intf_ErrMsg( "dvd error: fatal failure in ifo" );
IfoDestroy( p_dvd->p_ifo ); IfoDestroy( p_dvd->p_ifo );
dvdcss_close( p_dvd->dvdhandle );
free( p_dvd ); free( p_dvd );
return -1; return -1;
} }
...@@ -237,6 +238,9 @@ static int DVDOpen( struct input_thread_s *p_input ) ...@@ -237,6 +238,9 @@ static int DVDOpen( struct input_thread_s *p_input )
if( DVDSetArea( p_input, p_area ) < 0 ) if( DVDSetArea( p_input, p_area ) < 0 )
{ {
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
IfoDestroy( p_dvd->p_ifo );
dvdcss_close( p_dvd->dvdhandle );
free( p_dvd );
return -1; return -1;
} }
...@@ -252,17 +256,11 @@ static int DVDOpen( struct input_thread_s *p_input ) ...@@ -252,17 +256,11 @@ static int DVDOpen( struct input_thread_s *p_input )
*****************************************************************************/ *****************************************************************************/
static void DVDClose( struct input_thread_s *p_input ) static void DVDClose( struct input_thread_s *p_input )
{ {
thread_dvd_data_t * p_dvd; thread_dvd_data_t *p_dvd = (thread_dvd_data_t*)p_input->p_access_data;
p_dvd = (thread_dvd_data_t*)p_input->p_access_data;
IfoDestroy( p_dvd->p_ifo ); IfoDestroy( p_dvd->p_ifo );
dvdcss_close( p_dvd->dvdhandle );
p_input->p_access_data = (void *)(p_dvd->dvdhandle);
free( p_dvd ); free( p_dvd );
/* Clean up libdvdcss */
dvdcss_close( (dvdcss_handle) p_input->p_access_data );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -238,8 +238,9 @@ static int VCDOpen( struct input_thread_s *p_input ) ...@@ -238,8 +238,9 @@ static int VCDOpen( struct input_thread_s *p_input )
p_vcd->p_sectors = ioctl_GetSectors( p_vcd->i_handle, p_vcd->p_sectors = ioctl_GetSectors( p_vcd->i_handle,
psz_source ); psz_source );
if ( p_vcd->p_sectors == NULL ) if( p_vcd->p_sectors == NULL )
{ {
input_BuffersEnd( p_input->p_method_data );
close( p_vcd->i_handle ); close( p_vcd->i_handle );
free( p_vcd ); free( p_vcd );
return -1; return -1;
...@@ -286,15 +287,14 @@ static int VCDOpen( struct input_thread_s *p_input ) ...@@ -286,15 +287,14 @@ static int VCDOpen( struct input_thread_s *p_input )
return 0; return 0;
} }
/***************************************************************************** /*****************************************************************************
* VCDClose: closes vcd * VCDClose: closes vcd
*****************************************************************************/ *****************************************************************************/
static void VCDClose( struct input_thread_s *p_input ) static void VCDClose( struct input_thread_s *p_input )
{ {
thread_vcd_data_t * p_vcd thread_vcd_data_t *p_vcd = (thread_vcd_data_t *)p_input->p_access_data;
= (thread_vcd_data_t *)p_input->p_access_data;
input_BuffersEnd( p_input->p_method_data );
close( p_vcd->i_handle ); close( p_vcd->i_handle );
free( p_vcd ); free( p_vcd );
} }
...@@ -498,13 +498,7 @@ static int VCDInit( input_thread_t * p_input ) ...@@ -498,13 +498,7 @@ static int VCDInit( input_thread_t * p_input )
*****************************************************************************/ *****************************************************************************/
static void VCDEnd( input_thread_t * p_input ) static void VCDEnd( input_thread_t * p_input )
{ {
thread_vcd_data_t * p_vcd; ;
input_BuffersEnd( p_input->p_method_data );
p_vcd = (thread_vcd_data_t*)p_input->p_access_data;
free( p_vcd );
} }
......
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