Commit 3e5a8ba4 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

vcd: switch to ACCESS_GET_(TITLE|SEEKPOINT)

parent ae721f0a
......@@ -70,6 +70,8 @@ struct access_sys_t
/* Title infos */
int i_titles;
input_title_t *title[99]; /* No more that 99 track in a vcd ? */
int i_current_title;
int i_current_seekpoint;
int i_sector; /* Current Sector */
int *p_sectors; /* Track sectors */
......@@ -196,8 +198,8 @@ static int Open( vlc_object_t *p_this )
p_access->info.b_eof = false;
p_access->info.i_title = i_title;
p_access->info.i_seekpoint = i_chapter;
p_sys->i_current_title = i_title;
p_sys->i_current_seekpoint = i_chapter;
p_access->info.i_pos = (uint64_t)( p_sys->i_sector - p_sys->p_sectors[1+i_title] ) *
VCD_DATA_SIZE;
......@@ -231,7 +233,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
{
access_sys_t *p_sys = p_access->p_sys;
input_title_t ***ppp_title;
int i;
switch( i_query )
{
......@@ -245,7 +246,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) =
p_sys->title[p_access->info.i_title]->i_size;
p_sys->title[p_sys->i_current_title]->i_size;
break;
/* */
......@@ -264,42 +265,49 @@ static int Control( access_t *p_access, int i_query, va_list args )
/* Duplicate title infos */
*ppp_title = malloc( sizeof(input_title_t **) * p_sys->i_titles );
for( i = 0; i < p_sys->i_titles; i++ )
{
for( int i = 0; i < p_sys->i_titles; i++ )
(*ppp_title)[i] = vlc_input_title_Duplicate( p_sys->title[i] );
}
break;
case ACCESS_GET_TITLE:
*va_arg( args, unsigned * ) = p_sys->i_current_title;
break;
case ACCESS_GET_SEEKPOINT:
*va_arg( args, unsigned * ) = p_sys->i_current_seekpoint;
break;
case ACCESS_SET_TITLE:
i = va_arg( args, int );
if( i != p_access->info.i_title )
{
int i = va_arg( args, int );
if( i != p_sys->i_current_title )
{
/* Update info */
p_access->info.i_update |=
INPUT_UPDATE_TITLE|INPUT_UPDATE_SEEKPOINT;
p_access->info.i_title = i;
p_access->info.i_seekpoint = 0;
p_access->info.i_pos = 0;
p_sys->i_current_title = i;
p_sys->i_current_seekpoint = 0;
p_access->info.i_pos = 0;
/* Next sector to read */
p_sys->i_sector = p_sys->p_sectors[1+i];
}
break;
}
case ACCESS_SET_SEEKPOINT:
{
input_title_t *t = p_sys->title[p_access->info.i_title];
i = va_arg( args, int );
int i = va_arg( args, int );
unsigned i_title = p_sys->i_current_title;
input_title_t *t = p_sys->title[i_title];
if( t->i_seekpoint > 0 )
{
p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT;
p_access->info.i_seekpoint = i;
p_sys->i_current_seekpoint = i;
p_sys->i_sector = p_sys->p_sectors[1+p_access->info.i_title] +
p_sys->i_sector = p_sys->p_sectors[1 + i_title] +
t->seekpoint[i]->i_byte_offset / VCD_DATA_SIZE;
p_access->info.i_pos = (uint64_t)(p_sys->i_sector -
p_sys->p_sectors[1+p_access->info.i_title]) *VCD_DATA_SIZE;
p_sys->p_sectors[1 + i_title]) *VCD_DATA_SIZE;
}
break;
}
......@@ -323,26 +331,24 @@ static block_t *Block( access_t *p_access )
if( p_access->info.b_eof ) return NULL;
/* Check end of title */
while( p_sys->i_sector >= p_sys->p_sectors[p_access->info.i_title + 2] )
while( p_sys->i_sector >= p_sys->p_sectors[p_sys->i_current_title + 2] )
{
if( p_access->info.i_title + 2 >= p_sys->i_titles )
if( p_sys->i_current_title + 2 >= p_sys->i_titles )
{
p_access->info.b_eof = true;
return NULL;
}
p_access->info.i_update |=
INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT;
p_access->info.i_title++;
p_access->info.i_seekpoint = 0;
p_sys->i_current_title++;
p_sys->i_current_seekpoint = 0;
p_access->info.i_pos = 0;
}
/* Don't read after the end of a title */
if( p_sys->i_sector + i_blocks >=
p_sys->p_sectors[p_access->info.i_title + 2] )
p_sys->p_sectors[p_sys->i_current_title + 2] )
{
i_blocks = p_sys->p_sectors[p_access->info.i_title + 2 ] - p_sys->i_sector;
i_blocks = p_sys->p_sectors[p_sys->i_current_title + 2 ] - p_sys->i_sector;
}
/* Do the actual reading */
......@@ -368,17 +374,16 @@ static block_t *Block( access_t *p_access )
/* Update seekpoints */
for( int i_read = 0; i_read < i_blocks; i_read++ )
{
input_title_t *t = p_sys->title[p_access->info.i_title];
input_title_t *t = p_sys->title[p_sys->i_current_title];
if( t->i_seekpoint > 0 &&
p_access->info.i_seekpoint + 1 < t->i_seekpoint &&
p_sys->i_current_seekpoint + 1 < t->i_seekpoint &&
(int64_t) /* Unlikely to go over 8192 PetaB */
(p_access->info.i_pos + i_read * VCD_DATA_SIZE) >=
t->seekpoint[p_access->info.i_seekpoint+1]->i_byte_offset )
t->seekpoint[p_sys->i_current_seekpoint + 1]->i_byte_offset )
{
msg_Dbg( p_access, "seekpoint change" );
p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT;
p_access->info.i_seekpoint++;
p_sys->i_current_seekpoint++;
}
}
......@@ -395,13 +400,13 @@ static block_t *Block( access_t *p_access )
static int Seek( access_t *p_access, uint64_t i_pos )
{
access_sys_t *p_sys = p_access->p_sys;
input_title_t *t = p_sys->title[p_access->info.i_title];
input_title_t *t = p_sys->title[p_sys->i_current_title];
int i_seekpoint;
/* Next sector to read */
p_access->info.i_pos = i_pos;
p_sys->i_sector = i_pos / VCD_DATA_SIZE +
p_sys->p_sectors[p_access->info.i_title + 1];
p_sys->p_sectors[p_sys->i_current_title + 1];
/* Update current seekpoint */
for( i_seekpoint = 0; i_seekpoint < t->i_seekpoint; i_seekpoint++ )
......@@ -411,11 +416,10 @@ static int Seek( access_t *p_access, uint64_t i_pos )
i_pos < (uint64_t)t->seekpoint[i_seekpoint + 1]->i_byte_offset ) break;
}
if( i_seekpoint != p_access->info.i_seekpoint )
if( i_seekpoint != p_sys->i_current_seekpoint )
{
msg_Dbg( p_access, "seekpoint change" );
p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT;
p_access->info.i_seekpoint = i_seekpoint;
p_sys->i_current_seekpoint = i_seekpoint;
}
/* Reset eof */
......
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