* -dvd_udf to find files
*****************************************************************************
* 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.9 2002/03/18 19:14:52 sam Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
static int DVDOpen( struct input_thread_s *p_input )
{
char * psz_device;
- dvdcss_handle dvdhandle;
thread_dvd_data_t * p_dvd;
input_area_t * p_area;
int i;
/*
* get plugin ready
*/
- dvdhandle = dvdcss_open( psz_device );
+ p_dvd->dvdhandle = dvdcss_open( psz_device );
/* free allocated string */
free( psz_device );
-
- if( dvdhandle == NULL )
+ if( p_dvd->dvdhandle == NULL )
{
intf_ErrMsg( "dvd error: dvdcss can't open device" );
+ free( p_dvd );
return -1;
}
- p_dvd->dvdhandle = (dvdcss_handle) dvdhandle;
-
if( dvdcss_seek( p_dvd->dvdhandle, 0, DVDCSS_NOFLAGS ) < 0 )
{
intf_ErrMsg( "dvd error: %s", dvdcss_error( p_dvd->dvdhandle ) );
+ dvdcss_close( p_dvd->dvdhandle );
+ free( p_dvd );
return -1;
}
if( IfoCreate( p_dvd ) < 0 )
{
intf_ErrMsg( "dvd error: allcation error in ifo" );
+ dvdcss_close( p_dvd->dvdhandle );
free( p_dvd );
return -1;
}
{
intf_ErrMsg( "dvd error: fatal failure in ifo" );
IfoDestroy( p_dvd->p_ifo );
+ dvdcss_close( p_dvd->dvdhandle );
free( p_dvd );
return -1;
}
p_area = p_input->stream.pp_areas[p_dvd->i_title];
- p_dvd->i_chapter = p_dvd->i_chapter <= p_area->i_part_nb ?
- p_dvd->i_chapter : 1;
- p_area->i_part = p_dvd->i_chapter;
+ p_area->i_part = p_dvd->i_chapter <= p_area->i_part_nb ?
+ p_dvd->i_chapter : 1;
+ p_dvd->i_chapter = 1;
p_dvd->b_new_chapter = 0;
p_dvd->i_audio_nb = 0;
if( DVDSetArea( p_input, p_area ) < 0 )
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
+ IfoDestroy( p_dvd->p_ifo );
+ dvdcss_close( p_dvd->dvdhandle );
+ free( p_dvd );
return -1;
}
*****************************************************************************/
static void DVDClose( struct input_thread_s *p_input )
{
- thread_dvd_data_t * p_dvd;
-
- p_dvd = (thread_dvd_data_t*)p_input->p_access_data;
+ thread_dvd_data_t *p_dvd = (thread_dvd_data_t*)p_input->p_access_data;
IfoDestroy( p_dvd->p_ifo );
-
- p_input->p_access_data = (void *)(p_dvd->dvdhandle);
+ dvdcss_close( p_dvd->dvdhandle );
free( p_dvd );
-
- /* Clean up libdvdcss */
- dvdcss_close( (dvdcss_handle) p_input->p_access_data );
}
/*****************************************************************************
vts.i_pos + vts.manager_inf.i_title_vob_start_sector;
/* last cell */
- intf_WarnMsg( 4, "prg_cell nb %d", vts.title_unit.p_title[p_dvd->i_title_id-1].title.i_cell_nb );
p_dvd->i_prg_cell = -1 +
vts.title_unit.p_title[p_dvd->i_title_id-1].title.i_cell_nb;
p_dvd->i_map_cell = 0;
i_size = CellEndSector( p_dvd );
/* first cell */
- p_dvd->i_prg_cell = 0;
- p_dvd->i_map_cell = 0;
- p_dvd->i_map_cell = CellPrg2Map ( p_dvd );
- p_dvd->i_vts_lb = CellStartSector( p_dvd );
- p_dvd->i_end_lb = CellEndSector ( p_dvd );
+ p_dvd->i_prg_cell = 0;
+ p_dvd->i_map_cell = 0;
+ p_dvd->i_angle_cell = 0;
+ p_dvd->i_map_cell = CellPrg2Map ( p_dvd );
+ p_dvd->i_vts_lb = CellStartSector( p_dvd );
+ p_dvd->i_end_lb = CellEndSector ( p_dvd );
/* Force libdvdcss to check its title key.
* It is only useful for title cracking method. Methods using the
if( ( p_input->stream.p_selected_area->i_tell
>= p_input->stream.p_selected_area->i_size )
- || ( i_block_once < 0 ) )
+ || ( i_block_once <= 0 ) )
{
if( ( p_dvd->i_title + 1 ) >= p_input->stream.i_area_nb )
{
}
else
{
- psz_raw = NULL;
+ psz_raw = "";
}
if( *psz_parser && !strtol( psz_parser, NULL, 10 ) )
{
/* we have only a partial list of options, no device */
psz_parser = psz_raw;
- psz_raw = NULL;
+ psz_raw = "";
b_options = 1;
break;
}
else
{
/* found beginning of options ; no raw device specified */
- psz_raw = NULL;
+ psz_raw = "";
b_options = 1;
}
p_dvd->i_angle = i_angle ? i_angle : 1;
}
- if( psz_raw )
+ if( *psz_raw )
{
if( *psz_raw )
{
psz_raw, strerror(errno));
/* put back '@' */
*(psz_raw - 1) = '@';
- psz_raw = NULL;
+ psz_raw = "";
}
else
{
" not a valid char device", psz_raw );
/* put back '@' */
*(psz_raw - 1) = '@';
- psz_raw = NULL;
+ psz_raw = "";
}
else
#endif
}
else
{
- psz_raw = NULL;
+ psz_raw = "";
}
}
/* no device and no access specified: we probably don't want DVD */
return NULL;
}
- psz_device = config_GetPszVariable( INPUT_DVD_DEVICE_VAR );
+ psz_device = config_GetPszVariable( "dvd_device" );
}
/* check block device */
if( stat( psz_device, &stat_info ) == -1 )
{
- intf_ErrMsg( "input error: cannot stat() device `%s' (%s)",
+ intf_ErrMsg( "dvd error: cannot stat() device `%s' (%s)",
psz_device, strerror(errno));
return NULL;
}