* cdrom_tools.c: cdrom tools
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: cdrom_tools.c,v 1.2 2002/04/04 05:08:05 sam Exp $
+ * $Id: cdrom_tools.c,v 1.4 2002/04/27 02:20:32 jobi Exp $
*
* Author: Johan Bilien <jobi@via.ecp.fr>
* Jon Lech Johansen <jon-vl@nanocrew.net>
#include <sys/ioctl.h>
-#if defined(SYS_BSDI)
+#if defined( SYS_BSDI )
# include <dvd.h>
#elif defined ( SYS_DARWIN )
# include <CoreFoundation/CFBase.h>
# include <IOKit/storage/IOCDTypes.h>
# include <IOKit/storage/IOCDMedia.h>
# include <IOKit/storage/IOCDMediaBSDClient.h>
+#elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H )
+# include <sys/cdio.h>
+# include <sys/cdrio.h>
#else
# include <linux/cdrom.h>
#endif
freeTOC( pTOC );
+#elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H )
+ struct ioc_toc_header tochdr;
+
+ if( ioctl( i_fd, CDIOREADTOCHEADER, &tochdr ) == -1 )
+ {
+ intf_ErrMsg( "vcd error: could not read TOCHDR" );
+ return -1;
+ }
+
+ i_count = tochdr.ending_track - tochdr.starting_track + 1;
+
#else
struct cdrom_tochdr tochdr;
freeTOC( pTOC );
+#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 );
+ p_sectors = malloc( (i_tracks + 1) * sizeof(int) );
+ if( p_sectors == NULL )
+ {
+ intf_ErrMsg( "vcd error: could not allocate p_sectors" );
+ return NULL;
+ }
+
+ toc_entries.address_format = CD_LBA_FORMAT;
+ toc_entries.starting_track = 0;
+ toc_entries.data_len = ( i_tracks + 1 ) * sizeof( struct cd_toc_entry );
+ toc_entries.data = (struct cd_toc_entry *) malloc( toc_entries.data_len );
+ if( toc_entries.data == NULL )
+ {
+ intf_ErrMsg( "vcd error: not enoug memory" );
+ free( p_sectors );
+ return NULL;
+ }
+
+ /* Read the TOC */
+ if( ioctl( i_fd, CDIOREADTOCENTRYS, &toc_entries ) == -1 )
+ {
+ intf_ErrMsg( "vcd error: could not read the TOC" );
+ free( p_sectors );
+ free( toc_entries.data );
+ return NULL;
+ }
+
+ /* Fill the p_sectors structure with the track/sector matches */
+ for( i = 0 ; i <= i_tracks ; i++ )
+ {
+ p_sectors[ i ] = ntohl( toc_entries.data[i].addr.lba );
+ }
#else
struct cdrom_tochdr tochdr;
struct cdrom_tocentry tocent;
return( -1 );
}
+#elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H )
+
+ int i_size = VCD_SECTOR_SIZE;
+
+ if( ioctl( i_fd, CDRIOCSETBLOCKSIZE, &i_size ) == -1 )
+ {
+ intf_ErrMsg( "vcd error: Could not set block size" );
+ return( -1 );
+ }
+
+ if( lseek( i_fd, i_sector * VCD_SECTOR_SIZE, SEEK_SET ) == -1 )
+ {
+ intf_ErrMsg( "vcd error: Could not lseek to sector %d", i_sector );
+ return( -1 );
+ }
+
+ if( read( i_fd, p_block, VCD_SECTOR_SIZE ) == -1 )
+ {
+ intf_ErrMsg( "vcd error: Could not read sector %d", i_sector );
+ return( -1 );
+ }
+
#else
int i_dummy = i_sector + 2 * CD_FRAMES;