Commit ded081bc authored by JP Dinger's avatar JP Dinger
Browse files

vcdx: 100% cosmetics; indentation reformatting.

parent f5078293
......@@ -87,52 +87,50 @@ static access_t *p_vcd_access = NULL;
static void
cdio_log_handler (cdio_log_level_t level, const char message[])
{
const vcdplayer_t *p_vcdplayer = (vcdplayer_t *)p_vcd_access->p_sys;
switch (level) {
case CDIO_LOG_DEBUG:
case CDIO_LOG_INFO:
if (p_vcdplayer->i_debug & INPUT_DBG_CDIO)
msg_Dbg( p_vcd_access, "%s", message);
break;
case CDIO_LOG_WARN:
msg_Warn( p_vcd_access, "%s", message);
break;
case CDIO_LOG_ERROR:
case CDIO_LOG_ASSERT:
msg_Err( p_vcd_access, "%s", message);
break;
default:
msg_Warn( p_vcd_access, "%s\n%s %d", message,
"The above message had unknown log level",
level);
}
return;
const vcdplayer_t *p_vcdplayer = (vcdplayer_t *)p_vcd_access->p_sys;
switch (level) {
case CDIO_LOG_DEBUG:
case CDIO_LOG_INFO:
if (p_vcdplayer->i_debug & INPUT_DBG_CDIO)
msg_Dbg( p_vcd_access, "%s", message);
break;
case CDIO_LOG_WARN:
msg_Warn( p_vcd_access, "%s", message);
break;
case CDIO_LOG_ERROR:
case CDIO_LOG_ASSERT:
msg_Err( p_vcd_access, "%s", message);
break;
default:
msg_Warn( p_vcd_access, "%s\n%s %d", message,
"The above message had unknown log level", level);
}
return;
}
/* process messages that originate from vcdinfo. */
static void
vcd_log_handler (vcd_log_level_t level, const char message[])
{
vcdplayer_t *p_vcdplayer = (vcdplayer_t *)p_vcd_access->p_sys;
switch (level) {
case VCD_LOG_DEBUG:
case VCD_LOG_INFO:
if (p_vcdplayer->i_debug & INPUT_DBG_VCDINFO)
msg_Dbg( p_vcd_access, "%s", message);
break;
case VCD_LOG_WARN:
msg_Warn( p_vcd_access, "%s", message);
break;
case VCD_LOG_ERROR:
case VCD_LOG_ASSERT:
msg_Err( p_vcd_access, "%s", message);
break;
default:
msg_Warn( p_vcd_access, "%s\n%s %d", message,
"The above message had unknown vcdimager log level",
level);
}
return;
vcdplayer_t *p_vcdplayer = (vcdplayer_t *)p_vcd_access->p_sys;
switch (level) {
case VCD_LOG_DEBUG:
case VCD_LOG_INFO:
if (p_vcdplayer->i_debug & INPUT_DBG_VCDINFO)
msg_Dbg( p_vcd_access, "%s", message);
break;
case VCD_LOG_WARN:
msg_Warn( p_vcd_access, "%s", message);
break;
case VCD_LOG_ERROR:
case VCD_LOG_ASSERT:
msg_Err( p_vcd_access, "%s", message);
break;
default:
msg_Warn( p_vcd_access, "%s\n%s %d", message,
"The above message had unknown vcdimager log level", level);
}
return;
}
/*****************************************************************************
......@@ -165,77 +163,74 @@ VCDReadBlock( access_t * p_access )
p_buf = (uint8_t *) p_block->p_buffer;
for ( i_read = 0 ; i_read < i_blocks ; i_read++ )
{
vcdplayer_read_status_t read_status = vcdplayer_read(p_access, p_buf);
vcdplayer_read_status_t read_status = vcdplayer_read(p_access, p_buf);
p_access->info.i_pos += M2F2_SECTOR_SIZE;
p_access->info.i_pos += M2F2_SECTOR_SIZE;
switch ( read_status ) {
case READ_END:
/* End reached. Return NULL to indicated this. */
/* We also set the postion to the end so the higher level
(demux?) doesn't try to keep reading. If everything works out
right this shouldn't have to happen.
*/
switch ( read_status ) {
case READ_END:
/* End reached. Return NULL to indicated this. */
/* We also set the postion to the end so the higher level
(demux?) doesn't try to keep reading. If everything works out
right this shouldn't have to happen.
*/
#if 0
if ( p_access->info.i_pos != p_access->info.i_size ) {
msg_Warn( p_access,
if( p_access->info.i_pos != p_access->info.i_size ) {
msg_Warn( p_access,
"At end but pos (%llu) is not size (%llu). Adjusting.",
p_access->info.i_pos, p_access->info.i_size );
p_access->info.i_pos = p_access->info.i_size;
}
p_access->info.i_pos = p_access->info.i_size;
}
#endif
block_Release( p_block );
return NULL;
block_Release( p_block );
return NULL;
case READ_ERROR:
/* Some sort of error. Should we increment lsn? to skip block?
*/
block_Release( p_block );
return NULL;
case READ_STILL_FRAME:
{
case READ_ERROR:
/* Some sort of error. Should we increment lsn? to skip block? */
block_Release( p_block );
return NULL;
case READ_STILL_FRAME:
/* FIXME The below should be done in an event thread.
Until then...
*/
#if 1
msleep( MILLISECONDS_PER_SEC * *p_buf );
VCDSetOrigin(p_access, p_vcdplayer->origin_lsn, p_vcdplayer->i_track,
&(p_vcdplayer->play_item));
// p_vcd->in_still = false;
dbg_print(INPUT_DBG_STILL, "still wait time done");
msleep( MILLISECONDS_PER_SEC * *p_buf );
VCDSetOrigin(p_access, p_vcdplayer->origin_lsn,
p_vcdplayer->i_track, &(p_vcdplayer->play_item));
// p_vcd->in_still = false;
dbg_print(INPUT_DBG_STILL, "still wait time done");
#else
vcdIntfStillTime(p_vcdplayer->p_intf, *p_buf);
vcdIntfStillTime(p_vcdplayer->p_intf, *p_buf);
#endif
block_Release( p_block );
return NULL;
block_Release( p_block );
return NULL;
default:
case READ_BLOCK:
/* Read buffer */
break;
}
default:
case READ_BLOCK:
/* Read buffer */
;
}
p_buf += M2F2_SECTOR_SIZE;
/* Update seekpoint */
if ( VCDINFO_ITEM_TYPE_ENTRY == p_vcdplayer->play_item.type )
{
size_t i_entry = p_vcdplayer->play_item.num+1;
lsn_t i_lsn = vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i_entry);
if ( p_vcdplayer->i_lsn >= i_lsn && i_lsn != VCDINFO_NULL_LSN )
p_buf += M2F2_SECTOR_SIZE;
/* Update seekpoint */
if ( VCDINFO_ITEM_TYPE_ENTRY == p_vcdplayer->play_item.type )
{
dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC),
"entry change to %d, current LSN %u >= end %u",
i_entry, p_vcdplayer->i_lsn, i_lsn);
size_t i_entry = p_vcdplayer->play_item.num+1;
lsn_t i_lsn = vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i_entry);
if ( p_vcdplayer->i_lsn >= i_lsn && i_lsn != VCDINFO_NULL_LSN )
{
dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC),
"entry change to %d, current LSN %u >= end %u",
i_entry, p_vcdplayer->i_lsn, i_lsn);
p_vcdplayer->play_item.num = i_entry;
p_vcdplayer->play_item.num = i_entry;
VCDSetOrigin( p_access, i_lsn, p_vcdplayer->i_track,
&(p_vcdplayer->play_item) );
VCDSetOrigin( p_access, i_lsn, p_vcdplayer->i_track,
&(p_vcdplayer->play_item) );
}
}
}
}
return p_block;
......@@ -249,74 +244,73 @@ int
VCDSeek( access_t * p_access, int64_t i_pos )
{
if (!p_access || !p_access->p_sys) return VLC_EGENERIC;
{
vcdplayer_t *p_vcdplayer = (vcdplayer_t *)p_vcd_access->p_sys;
const input_title_t *t = p_vcdplayer->p_title[p_access->info.i_title];
unsigned int i_entry = VCDINFO_INVALID_ENTRY;
int i_seekpoint;
/* Next sector to read */
p_access->info.i_pos = i_pos;
p_vcdplayer->i_lsn = (i_pos / (int64_t) M2F2_SECTOR_SIZE) +
p_vcdplayer->origin_lsn;
switch (p_vcdplayer->play_item.type) {
case VCDINFO_ITEM_TYPE_TRACK:
case VCDINFO_ITEM_TYPE_ENTRY:
break ;
default:
p_vcdplayer->b_valid_ep = false;
}
/* Find entry */
if( p_vcdplayer->b_valid_ep )
{
for( i_entry = 0 ; i_entry < p_vcdplayer->i_entries ; i_entry ++ )
{
if( p_vcdplayer->i_lsn < p_vcdplayer->p_entries[i_entry] )
{
VCDUpdateVar( p_access, i_entry, VLC_VAR_SETVALUE,
"chapter", _("Entry"), "Setting entry" );
break;
}
}
{
vcdinfo_itemid_t itemid;
itemid.num = i_entry;
itemid.type = VCDINFO_ITEM_TYPE_ENTRY;
VCDSetOrigin(p_access, p_vcdplayer->i_lsn, p_vcdplayer->i_track,
&itemid);
}
vcdplayer_t *p_vcdplayer = (vcdplayer_t *)p_vcd_access->p_sys;
const input_title_t *t = p_vcdplayer->p_title[p_access->info.i_title];
unsigned int i_entry = VCDINFO_INVALID_ENTRY;
int i_seekpoint;
/* Next sector to read */
p_access->info.i_pos = i_pos;
p_vcdplayer->i_lsn = (i_pos / (int64_t) M2F2_SECTOR_SIZE) +
p_vcdplayer->origin_lsn;
switch (p_vcdplayer->play_item.type)
{
case VCDINFO_ITEM_TYPE_TRACK:
case VCDINFO_ITEM_TYPE_ENTRY:
break;
default:
p_vcdplayer->b_valid_ep = false;
break;
}
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_SEEK),
"orig %lu, cur: %lu, offset: %lld, entry %d",
(long unsigned int) p_vcdplayer->origin_lsn,
(long unsigned int) p_vcdplayer->i_lsn, i_pos,
i_entry );
/* Find entry */
if( p_vcdplayer->b_valid_ep )
{
for( i_entry = 0 ; i_entry < p_vcdplayer->i_entries ; i_entry ++ )
{
if( p_vcdplayer->i_lsn < p_vcdplayer->p_entries[i_entry] )
{
VCDUpdateVar( p_access, i_entry, VLC_VAR_SETVALUE,
"chapter", _("Entry"), "Setting entry" );
break;
}
}
{
vcdinfo_itemid_t itemid;
itemid.num = i_entry;
itemid.type = VCDINFO_ITEM_TYPE_ENTRY;
VCDSetOrigin(p_access, p_vcdplayer->i_lsn,
p_vcdplayer->i_track, &itemid);
}
}
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_SEEK),
"orig %lu, cur: %lu, offset: %lld, entry %d",
(long unsigned int) p_vcdplayer->origin_lsn,
(long unsigned int) p_vcdplayer->i_lsn, i_pos,
i_entry );
/* Find seekpoint */
for( i_seekpoint = 0; i_seekpoint < t->i_seekpoint; i_seekpoint++ )
{
if( i_seekpoint + 1 >= t->i_seekpoint ) break;
if( i_pos < t->seekpoint[i_seekpoint + 1]->i_byte_offset ) break;
}
/* Find seekpoint */
for( i_seekpoint = 0; i_seekpoint < t->i_seekpoint; i_seekpoint++ )
{
if( i_seekpoint + 1 >= t->i_seekpoint ) break;
if( i_pos < t->seekpoint[i_seekpoint + 1]->i_byte_offset ) break;
}
/* Update current seekpoint */
if( i_seekpoint != p_access->info.i_seekpoint )
{
dbg_print( (INPUT_DBG_SEEK), "seekpoint change %lu",
(long unsigned int) i_seekpoint );
p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT;
p_access->info.i_seekpoint = i_seekpoint;
}
/* Update current seekpoint */
if( i_seekpoint != p_access->info.i_seekpoint )
{
dbg_print( (INPUT_DBG_SEEK), "seekpoint change %lu",
(long unsigned int) i_seekpoint );
p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT;
p_access->info.i_seekpoint = i_seekpoint;
}
}
p_access->info.b_eof = false;
return VLC_SUCCESS;
}
/*****************************************************************************
......@@ -327,61 +321,59 @@ VCDSeek( access_t * p_access, int64_t i_pos )
static bool
VCDEntryPoints( access_t * p_access )
{
if (!p_access || !p_access->p_sys) return false;
if (!p_access || !p_access->p_sys) return false;
{
vcdplayer_t *p_vcdplayer = (vcdplayer_t *) p_access->p_sys;
const unsigned int i_entries =
vcdinfo_get_num_entries(p_vcdplayer->vcd);
const unsigned int i_entries = vcdinfo_get_num_entries(p_vcdplayer->vcd);
const track_t i_last_track
= cdio_get_num_tracks(vcdinfo_get_cd_image(p_vcdplayer->vcd))
+ cdio_get_first_track_num(vcdinfo_get_cd_image(p_vcdplayer->vcd));
= cdio_get_num_tracks(vcdinfo_get_cd_image(p_vcdplayer->vcd))
+ cdio_get_first_track_num(vcdinfo_get_cd_image(p_vcdplayer->vcd));
unsigned int i;
if (0 == i_entries) {
LOG_ERR ("no entires found -- something is wrong" );
return false;
LOG_ERR ("no entires found -- something is wrong" );
return false;
}
p_vcdplayer->p_entries = malloc( sizeof( lsn_t ) * i_entries );
if( p_vcdplayer->p_entries == NULL )
{
LOG_ERR ("not enough memory for entry points treatment" );
return false;
LOG_ERR ("not enough memory for entry points treatment" );
return false;
}
p_vcdplayer->i_entries = i_entries;
for( i = 0 ; i < i_entries ; i++ )
{
const track_t i_track = vcdinfo_get_track(p_vcdplayer->vcd, i);
if( i_track <= i_last_track ) {
seekpoint_t *s = vlc_seekpoint_New();
char psz_entry[100];
const track_t i_track = vcdinfo_get_track(p_vcdplayer->vcd, i);
if( i_track <= i_last_track )
{
seekpoint_t *s = vlc_seekpoint_New();
char psz_entry[100];
snprintf(psz_entry, sizeof(psz_entry), "%s %02d", _("Entry"), i );
snprintf(psz_entry, sizeof(psz_entry), "%s %02d", _("Entry"), i );
p_vcdplayer->p_entries[i] = vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i);
p_vcdplayer->p_entries[i] =
vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i);
s->psz_name = strdup(psz_entry);
s->i_byte_offset =
(p_vcdplayer->p_entries[i] - vcdinfo_get_track_lsn(p_vcdplayer->vcd, i_track))
* M2F2_SECTOR_SIZE;
s->psz_name = strdup(psz_entry);
s->i_byte_offset = (p_vcdplayer->p_entries[i]
- vcdinfo_get_track_lsn(p_vcdplayer->vcd,i_track))
* M2F2_SECTOR_SIZE;
dbg_print( INPUT_DBG_MRL,
"%s, lsn %d, byte_offset %ld",
s->psz_name, p_vcdplayer->p_entries[i],
(unsigned long int) s->i_byte_offset);
TAB_APPEND( p_vcdplayer->p_title[i_track-1]->i_seekpoint,
p_vcdplayer->p_title[i_track-1]->seekpoint, s );
dbg_print( INPUT_DBG_MRL, "%s, lsn %d, byte_offset %ld",
s->psz_name, p_vcdplayer->p_entries[i],
(unsigned long int) s->i_byte_offset);
TAB_APPEND( p_vcdplayer->p_title[i_track-1]->i_seekpoint,
p_vcdplayer->p_title[i_track-1]->seekpoint, s );
} else
msg_Warn( p_access, "wrong track number found in entry points" );
msg_Warn( p_access, "wrong track number found in entry points" );
}
p_vcdplayer->b_valid_ep = true;
return true;
}
}
/*****************************************************************************
......@@ -410,8 +402,7 @@ VCDSegments( access_t * p_access )
/* We have one additional segment allocated so we can get the size
by subtracting seg[i+1] - seg[i].
*/
p_vcdplayer->p_segments =
malloc( sizeof( lsn_t ) * (p_vcdplayer->i_segments+1) );
p_vcdplayer->p_segments=malloc(sizeof(lsn_t)*(p_vcdplayer->i_segments+1));
if( p_vcdplayer->p_segments == NULL )
{
LOG_ERR ("not enough memory for segment treatment" );
......@@ -594,69 +585,70 @@ VCDParse( access_t * p_access, /*out*/ vcdinfo_itemid_t * p_itemid,
type+entry number. */
unsigned int num;
*psz_parser = '\0';
++psz_parser;
if( *psz_parser )
{
switch(*psz_parser) {
case 'E':
*psz_parser = '\0';
++psz_parser;
if( *psz_parser )
switch(*psz_parser) {
case 'E':
p_itemid->type = VCDINFO_ITEM_TYPE_ENTRY;
++psz_parser;
*play_single_item = true;
break;
case 'P':
case 'P':
p_itemid->type = VCDINFO_ITEM_TYPE_LID;
++psz_parser;
*play_single_item = false;
break;
case 'S':
case 'S':
p_itemid->type = VCDINFO_ITEM_TYPE_SEGMENT;
++psz_parser;
*play_single_item = true;
break;
case 'T':
case 'T':
p_itemid->type = VCDINFO_ITEM_TYPE_TRACK;
++psz_parser;
*play_single_item = true;
break;
default: ;
}
default:
break;
}
num = strtol( psz_parser, &psz_next, 10 );
if ( *psz_parser != '\0' && *psz_next == '\0')
{
p_itemid->num = num;
}
num = strtol( psz_parser, &psz_next, 10 );
if ( *psz_parser != '\0' && *psz_next == '\0')
{
p_itemid->num = num;
}
} else {
*play_single_item = ( VCDINFO_ITEM_TYPE_LID == p_itemid->type );
*play_single_item = ( VCDINFO_ITEM_TYPE_LID == p_itemid->type );
}
if( !*psz_source ) {
if( !*psz_source )
{
/* No source specified, so figure it out. */
if( !p_access->psz_access ) return NULL;
/* No source specified, so figure it out. */
if( !p_access->psz_access ) return NULL;
psz_source = config_GetPsz( p_access, "vcd" );
psz_source = config_GetPsz( p_access, "vcd" );
if( !psz_source || 0==strlen(psz_source) ) {
free( psz_source );
/* Scan for a CD-ROM drive with a VCD in it. */
char **cd_drives = cdio_get_devices_with_cap( NULL,
( CDIO_FS_ANAL_SVCD | CDIO_FS_ANAL_CVD
|CDIO_FS_ANAL_VIDEOCD | CDIO_FS_UNKNOWN ),
true );
if( NULL == cd_drives ) return NULL;
if( cd_drives[0] == NULL )
if( !psz_source || 0==strlen(psz_source) )
{
cdio_free_device_list( cd_drives );
return NULL;
free( psz_source );
/* Scan for a CD-ROM drive with a VCD in it. */
char **cd_drives = cdio_get_devices_with_cap(NULL,
(CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD
|CDIO_FS_ANAL_VIDEOCD|CDIO_FS_UNKNOWN),
true);
if( NULL == cd_drives ) return NULL;
if( cd_drives[0] == NULL )
{
cdio_free_device_list( cd_drives );
return NULL;
}
psz_source = strdup( cd_drives[0] );
cdio_free_device_list( cd_drives );
}
psz_source = strdup( cd_drives[0] );
cdio_free_device_list( cd_drives );
}
}
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_MRL),
......@@ -673,65 +665,65 @@ void
VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
const vcdinfo_itemid_t *p_itemid )
{
vcdplayer_t *p_vcdplayer= (vcdplayer_t *)p_access->p_sys;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_LSN),
"i_lsn: %lu, track: %d", (long unsigned int) i_lsn,
i_track );
vcdplayer_set_origin(p_access, i_lsn, i_track, p_itemid);
switch (p_vcdplayer->play_item.type) {
case VCDINFO_ITEM_TYPE_ENTRY:
VCDUpdateVar( p_access, p_itemid->num, VLC_VAR_SETVALUE,
"chapter", _("Entry"), "Setting entry/segment");
p_access->info.i_title = i_track-1;
if (p_vcdplayer->b_track_length)
{
p_access->info.i_size = p_vcdplayer->p_title[i_track-1]->i_size;
p_access->info.i_pos = (int64_t) M2F2_SECTOR_SIZE *
(vcdinfo_get_track_lsn(p_vcdplayer->vcd, i_track) - i_lsn);
} else {
p_access->info.i_size = M2F2_SECTOR_SIZE * (int64_t)
vcdinfo_get_entry_sect_count(p_vcdplayer->vcd, p_itemid->num);
p_access->info.i_pos = 0;
}
dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), "size: %llu, pos: %llu",
p_access->info.i_size, p_access->info.i_pos );
p_access->info.i_seekpoint = p_itemid->num;
break;
case VCDINFO_ITEM_TYPE_SEGMENT:
VCDUpdateVar( p_access, p_itemid->num, VLC_VAR_SETVALUE,
"chapter", _("Segment"), "Setting entry/segment");
/* The last title entry is the for segments (when segments exist
and they must here. The segment seekpoints are stored after
the entry seekpoints and (zeroed) lid seekpoints.
*/
p_access->info.i_title = p_vcdplayer->i_titles - 1;
p_access->info.i_size = 0; /* No seeking on stills, please. */
p_access->info.i_pos = 0;
p_access->info.i_seekpoint = p_vcdplayer->i_entries
+ p_vcdplayer->i_lids + p_itemid->num;
break;
case VCDINFO_ITEM_TYPE_TRACK:
p_access->info.i_title = i_track-1;
p_access->info.i_size = p_vcdplayer->p_title[i_track-1]->i_size;
p_access->info.i_pos = 0;
p_access->info.i_seekpoint = vcdinfo_track_get_entry(p_vcdplayer->vcd,
i_track);
break;
default:
msg_Warn( p_access, "can't set origin for play type %d",
p_vcdplayer->play_item.type );
}