* cdrom.c: cdrom tools
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: cdrom.c,v 1.1 2002/08/04 17:23:42 sam Exp $
+ * $Id: cdrom.c,v 1.2 2002/08/08 22:28:22 sam Exp $
*
* Author: Johan Bilien <jobi@via.ecp.fr>
* Jon Lech Johansen <jon-vl@nanocrew.net>
/*****************************************************************************
* ioctl_ReadTocHeader: Read the TOC header and return the track number.
*****************************************************************************/
-int ioctl_GetTrackCount( int i_fd, const char *psz_dev )
+int ioctl_GetTrackCount( vlc_object_t * p_this, int i_fd, const char *psz_dev )
{
int i_count = -1;
if( ( pTOC = getTOC( psz_dev ) ) == NULL )
{
-//X intf_ErrMsg( "vcd error: failed to get the TOC" );
+ msg_Err( p_this, "failed to get the TOC" );
return( -1 );
}
if( ioctl( i_fd, CDIOREADTOCHEADER, &tochdr ) == -1 )
{
-//X intf_ErrMsg( "vcd error: could not read TOCHDR" );
+ msg_Err( p_this, "could not read TOCHDR" );
return -1;
}
/* First we read the TOC header */
if( ioctl( i_fd, CDROMREADTOCHDR, &tochdr ) == -1 )
{
-//X intf_ErrMsg( "vcd error: could not read TOCHDR" );
+ msg_Err( p_this, "could not read TOCHDR" );
return -1;
}
/*****************************************************************************
* ioctl_GetSectors: Read the Table of Contents and fill p_vcd.
*****************************************************************************/
-int * ioctl_GetSectors( int i_fd, const char *psz_dev )
+int * ioctl_GetSectors( vlc_object_t *p_this, int i_fd, const char *psz_dev )
{
int i, i_tracks;
int *p_sectors = NULL;
if( ( pTOC = getTOC( psz_dev ) ) == NULL )
{
-//X intf_ErrMsg( "vcd error: failed to get the TOC" );
+ msg_Err( p_this, "failed to get the TOC" );
return( NULL );
}
p_sectors = malloc( (i_tracks + 1) * sizeof(int) );
if( p_sectors == NULL )
{
-//X intf_ErrMsg( "vcd error: could not allocate p_sectors" );
+ msg_Err( p_this, "out of memory" );
freeTOC( pTOC );
return NULL;
}
if( i_leadout == -1 )
{
-//X intf_ErrMsg( "vcd error: leadout not found" );
+ msg_Err( p_this, "leadout not found" );
free( p_sectors );
freeTOC( pTOC );
return( NULL );
#elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H )
struct ioc_read_toc_entry toc_entries;
- i_tracks = ioctl_GetTrackCount( i_fd, psz_dev );
+ i_tracks = ioctl_GetTrackCount( p_this, i_fd, psz_dev );
p_sectors = malloc( (i_tracks + 1) * sizeof(int) );
if( p_sectors == NULL )
{
-//X intf_ErrMsg( "vcd error: could not allocate p_sectors" );
+ msg_Err( p_this, "out of memory" );
return NULL;
}
toc_entries.data = (struct cd_toc_entry *) malloc( toc_entries.data_len );
if( toc_entries.data == NULL )
{
-//X intf_ErrMsg( "vcd error: not enoug memory" );
+ msg_Err( p_this, "out of memory" );
free( p_sectors );
return NULL;
}
/* Read the TOC */
if( ioctl( i_fd, CDIOREADTOCENTRYS, &toc_entries ) == -1 )
{
-//X intf_ErrMsg( "vcd error: could not read the TOC" );
+ msg_Err( p_this, "could not read the TOC" );
free( p_sectors );
free( toc_entries.data );
return NULL;
/* First we read the TOC header */
if( ioctl( i_fd, CDROMREADTOCHDR, &tochdr ) == -1 )
{
-//X intf_ErrMsg( "vcd error: could not read TOCHDR" );
+ msg_Err( p_this, "could not read TOCHDR" );
return NULL;
}
p_sectors = malloc( (i_tracks + 1) * sizeof(int) );
if( p_sectors == NULL )
{
-//X intf_ErrMsg( "vcd error: could not allocate p_sectors" );
+ msg_Err( p_this, "out of memory" );
return NULL;
}
if( ioctl( i_fd, CDROMREADTOCENTRY, &tocent ) == -1 )
{
-//X intf_ErrMsg( "vcd error: could not read TOCENTRY" );
+ msg_Err( p_this, "could not read TOCENTRY" );
free( p_sectors );
return NULL;
}
/****************************************************************************
* ioctl_ReadSector: Read a sector (2324 bytes)
****************************************************************************/
-int ioctl_ReadSector( int i_fd, int i_sector, byte_t * p_buffer )
+int ioctl_ReadSector( vlc_object_t *p_this,
+ int i_fd, int i_sector, byte_t * p_buffer )
{
byte_t p_block[ VCD_SECTOR_SIZE ];
if( ioctl( i_fd, DKIOCCDREAD, &cd_read ) == -1 )
{
-//X intf_ErrMsg( "vcd error: could not read block %d", i_sector );
+ msg_Err( p_this, "could not read block %d", i_sector );
return( -1 );
}
if( ioctl( i_fd, CDRIOCSETBLOCKSIZE, &i_size ) == -1 )
{
-//X intf_ErrMsg( "vcd error: Could not set block size" );
+ msg_Err( p_this, "Could not set block size" );
return( -1 );
}
if( lseek( i_fd, i_sector * VCD_SECTOR_SIZE, SEEK_SET ) == -1 )
{
-//X intf_ErrMsg( "vcd error: Could not lseek to sector %d", i_sector );
+ msg_Err( p_this, "Could not lseek to sector %d", i_sector );
return( -1 );
}
if( read( i_fd, p_block, VCD_SECTOR_SIZE ) == -1 )
{
-//X intf_ErrMsg( "vcd error: Could not read sector %d", i_sector );
+ msg_Err( p_this, "Could not read sector %d", i_sector );
return( -1 );
}
if( ioctl(i_fd, CDROMREADRAW, p_block) == -1 )
{
-//X intf_ErrMsg( "vcd error: could not read block %i from disc",
-//X i_sector );
+ msg_Err( p_this, "could not read block %i from disc", i_sector );
return( -1 );
}
#endif
if( psz_dev == NULL )
{
-//X intf_ErrMsg( "vcd error: invalid device path" );
+ msg_Err( p_this, "invalid device path" );
return( NULL );
}
/* get port for IOKit communication */
if( ( ret = IOMasterPort( MACH_PORT_NULL, &port ) ) != KERN_SUCCESS )
{
-//X intf_ErrMsg( "vcd error: IOMasterPort: 0x%08x", ret );
+ msg_Err( p_this, "IOMasterPort: 0x%08x", ret );
return( NULL );
}
port, IOBSDNameMatching( port, 0, psz_devname ),
&iterator ) ) != KERN_SUCCESS )
{
-//X intf_ErrMsg( "vcd error: IOServiceGetMatchingServices: 0x%08x", ret );
+ msg_Err( p_this, "IOServiceGetMatchingServices: 0x%08x", ret );
return( NULL );
}
if( ( ret = IORegistryEntryGetParentIterator( service,
kIOServicePlane, &iterator ) ) != KERN_SUCCESS )
{
-//X intf_ErrMsg( "vcd error: "
-//X "IORegistryEntryGetParentIterator: 0x%08x", ret );
+ msg_Err( p_this, "IORegistryEntryGetParentIterator: 0x%08x", ret );
IOObjectRelease( service );
return( NULL );
}
if( service == NULL )
{
-//X intf_ErrMsg( "vcd error: search for kIOCDMediaClass came up empty" );
+ msg_Err( p_this, "search for kIOCDMediaClass came up empty" );
return( NULL );
}
if( ( ret = IORegistryEntryCreateCFProperties( service, &properties,
kCFAllocatorDefault, kNilOptions ) ) != KERN_SUCCESS )
{
-//X intf_ErrMsg( "vcd error: "
-//X " IORegistryEntryCreateCFProperties: 0x%08x", ret );
+ msg_Err( p_this, "IORegistryEntryCreateCFProperties: 0x%08x", ret );
IOObjectRelease( service );
return( NULL );
}
}
else
{
-//X intf_ErrMsg( "vcd error: CFDictionaryGetValue failed" );
+ msg_Err( p_this, "CFDictionaryGetValue failed" );
}
CFRelease( properties );