Commit c2aac10e authored by Stéphane Borel's avatar Stéphane Borel

*Fixed EOF segfault at end of DVD

*Buffer manager is renintialised at area change.
parent d865ef30
......@@ -2,7 +2,7 @@
* dvd.h: thread structure of the DVD plugin
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd.h,v 1.2 2002/03/08 22:58:12 stef Exp $
* $Id: dvd.h,v 1.3 2002/03/09 16:48:33 stef Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
......@@ -58,8 +58,6 @@ typedef struct thread_dvd_data_s
int i_vts_lb; /* sector in vts */
int i_end_lb; /* last sector of current cell */
int i_size;
/* Structure that contains all information of the DVD */
struct ifo_s * p_ifo;
......
......@@ -8,7 +8,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: dvd_access.c,v 1.4 2002/03/09 13:42:46 sam Exp $
* $Id: dvd_access.c,v 1.5 2002/03/09 16:48:33 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -416,7 +416,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
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;
......@@ -424,11 +423,12 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
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
......@@ -551,7 +551,7 @@ static int DVDRead( input_thread_t * p_input,
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 )
{
......
/* dvd_demux.c: DVD demux functions.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: dvd_demux.c,v 1.2 2002/03/06 12:26:35 stef Exp $
* $Id: dvd_demux.c,v 1.3 2002/03/09 16:48:33 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -109,13 +109,17 @@ static void DVDEnd( input_thread_t * p_input )
*****************************************************************************/
static int DVDDemux( input_thread_t * p_input )
{
int i;
data_packet_t * p_data;
ssize_t i_result;
int i;
/* Read headers to compute payload length */
for( i = 0 ; i < DVD_READ_ONCE ; i++ )
{
input_ReadPS( p_input, &p_data );
if( ( i_result = input_ReadPS( p_input, &p_data ) ) <= 0)
{
return i_result;
}
input_DemuxPS( p_input, p_data );
}
......
/* dvd_seek.c: functions to navigate through DVD.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: dvd_seek.c,v 1.2 2002/03/08 22:58:12 stef Exp $
* $Id: dvd_seek.c,v 1.3 2002/03/09 16:48:33 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -69,9 +69,9 @@ int CellIsInterleaved( thread_dvd_data_t * p_dvd )
return title.p_cell_play[p_dvd->i_prg_cell].i_category & 0xf000;
}
u32 CellPrg2Map( thread_dvd_data_t * p_dvd )
int CellPrg2Map( thread_dvd_data_t * p_dvd )
{
u32 i_cell;
int i_cell;
i_cell = p_dvd->i_map_cell;
......@@ -97,9 +97,14 @@ u32 CellPrg2Map( thread_dvd_data_t * p_dvd )
return i_cell;
}
u32 CellAngleOffset( thread_dvd_data_t * p_dvd, u32 i_prg_cell )
int CellAngleOffset( thread_dvd_data_t * p_dvd, int i_prg_cell )
{
u32 i_cell_off;
int i_cell_off;
if( i_prg_cell >= title.i_cell_nb )
{
return 0;
}
/* basic handling of angles */
switch( ( ( title.p_cell_play[i_prg_cell].i_category & 0xf000 )
......@@ -122,21 +127,21 @@ u32 CellAngleOffset( thread_dvd_data_t * p_dvd, u32 i_prg_cell )
return i_cell_off;
}
u32 CellStartSector( thread_dvd_data_t * p_dvd )
int CellStartSector( thread_dvd_data_t * p_dvd )
{
return __MAX( cell.p_cell_map[p_dvd->i_map_cell].i_start_sector,
title.p_cell_play[p_dvd->i_prg_cell].i_start_sector );
}
u32 CellEndSector( thread_dvd_data_t * p_dvd )
int CellEndSector( thread_dvd_data_t * p_dvd )
{
return __MIN( cell.p_cell_map[p_dvd->i_map_cell].i_end_sector,
title.p_cell_play[p_dvd->i_prg_cell].i_end_sector );
}
u32 NextCellPrg( thread_dvd_data_t * p_dvd )
int NextCellPrg( thread_dvd_data_t * p_dvd )
{
u32 i_cell = p_dvd->i_prg_cell;
int i_cell = p_dvd->i_prg_cell;
if( p_dvd->i_vts_lb > title.p_cell_play[i_cell].i_end_sector )
{
......@@ -152,9 +157,9 @@ u32 NextCellPrg( thread_dvd_data_t * p_dvd )
return i_cell;
}
u32 Lb2CellPrg( thread_dvd_data_t * p_dvd )
int Lb2CellPrg( thread_dvd_data_t * p_dvd )
{
u32 i_cell = 0;
int i_cell = 0;
while( p_dvd->i_vts_lb > title.p_cell_play[i_cell].i_end_sector )
{
......@@ -170,9 +175,9 @@ u32 Lb2CellPrg( thread_dvd_data_t * p_dvd )
return i_cell;
}
u32 Lb2CellMap( thread_dvd_data_t * p_dvd )
int Lb2CellMap( thread_dvd_data_t * p_dvd )
{
u32 i_cell = 0;
int i_cell = 0;
while( p_dvd->i_vts_lb > cell.p_cell_map[i_cell].i_end_sector )
{
......@@ -187,9 +192,9 @@ u32 Lb2CellMap( thread_dvd_data_t * p_dvd )
return i_cell;
}
u32 LbMaxOnce( thread_dvd_data_t * p_dvd )
int LbMaxOnce( thread_dvd_data_t * p_dvd )
{
u32 i_block_once = p_dvd->i_end_lb - p_dvd->i_vts_lb + 1;
int i_block_once = p_dvd->i_end_lb - p_dvd->i_vts_lb + 1;
/* Get the position of the next cell if we're at cell end */
if( i_block_once <= 0 )
......@@ -210,6 +215,11 @@ u32 LbMaxOnce( thread_dvd_data_t * p_dvd )
p_dvd->i_vts_lb = CellStartSector( p_dvd );
p_dvd->i_end_lb = CellEndSector( p_dvd );
if( ( p_dvd->i_chapter = NextChapter( p_dvd ) ) < 0)
{
return 0;
}
/* Position the fd pointer on the right address */
if( ( dvdcss_seek( p_dvd->dvdhandle,
......@@ -221,8 +231,6 @@ u32 LbMaxOnce( thread_dvd_data_t * p_dvd )
return 0;
}
p_dvd->i_chapter = NextChapter( p_dvd );
i_block_once = p_dvd->i_end_lb - p_dvd->i_vts_lb + 1;
}
......@@ -264,9 +272,9 @@ int NextChapter( thread_dvd_data_t * p_dvd )
if( title.chapter_map.pi_start_cell[p_dvd->i_chapter] <= i_cell+1 )
{
p_dvd->i_chapter++;
if( p_dvd->i_chapter >= p_dvd->i_chapter_nb )
if( p_dvd->i_chapter > p_dvd->i_chapter_nb )
{
return 0;
return -1;
}
p_dvd->b_new_chapter = 1;
return p_dvd->i_chapter;
......
/* dvd_seek.h: DVD access plugin.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: dvd_seek.h,v 1.2 2002/03/08 22:58:12 stef Exp $
* $Id: dvd_seek.h,v 1.3 2002/03/09 16:48:33 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -21,15 +21,15 @@
*****************************************************************************/
int CellIsInterleaved( thread_dvd_data_t * );
u32 CellAngleOffset ( thread_dvd_data_t *, u32 );
u32 CellPrg2Map ( thread_dvd_data_t * );
u32 CellStartSector ( thread_dvd_data_t * );
u32 CellEndSector ( thread_dvd_data_t * );
int CellAngleOffset ( thread_dvd_data_t *, int );
int CellPrg2Map ( thread_dvd_data_t * );
int CellStartSector ( thread_dvd_data_t * );
int CellEndSector ( thread_dvd_data_t * );
u32 NextCellPrg ( thread_dvd_data_t * );
u32 Lb2CellPrg ( thread_dvd_data_t * );
u32 Lb2CellMap ( thread_dvd_data_t * );
u32 LbMaxOnce ( thread_dvd_data_t * );
int NextCellPrg ( thread_dvd_data_t * );
int Lb2CellPrg ( thread_dvd_data_t * );
int Lb2CellMap ( thread_dvd_data_t * );
int LbMaxOnce ( thread_dvd_data_t * );
int CellPrg2Chapter ( thread_dvd_data_t * );
int NextChapter ( thread_dvd_data_t * );
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input.c,v 1.187 2002/03/06 01:20:56 stef Exp $
* $Id: input.c,v 1.188 2002/03/09 16:48:33 stef Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Alexis Guillard <alexis.guillard@bt.com>
......@@ -339,6 +339,8 @@ static int RunThread( input_thread_t *p_input )
/* Reinitialize synchro. */
p_pgrm->i_synchro_state = SYNCHRO_REINIT;
}
input_AccessReinit( p_input );
}
p_input->stream.p_new_area = NULL;
}
......
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