Search
lxdream.org :: lxdream/src/drivers/cd_osx.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/cd_osx.c
changeset 1023:264e2fd90be8
prev786:8f6ece92500e
author nkeynes
date Mon Jun 08 04:12:21 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change General cleanup of the GD-rom subsystem
- merge gdrom_image_t and gdrom_disc_t
- Abstract MMC devices using a lower-level scsi transport
- OSX: only look at the whole disc device, and ignore partitions
file annotate diff log raw
1.1 --- a/src/drivers/cd_osx.c Tue Jul 29 08:51:10 2008 +0000
1.2 +++ b/src/drivers/cd_osx.c Mon Jun 08 04:12:21 2009 +0000
1.3 @@ -35,30 +35,32 @@
1.4
1.5 static gboolean cdrom_osx_image_is_valid( FILE *f );
1.6 static gdrom_disc_t cdrom_osx_open_device( const gchar *filename, FILE *f );
1.7 -static gdrom_error_t cdrom_osx_read_toc( gdrom_image_t disc );
1.8 +static gdrom_error_t cdrom_osx_read_toc( gdrom_disc_t disc );
1.9 static gdrom_error_t cdrom_osx_read_sector( gdrom_disc_t disc, uint32_t sector,
1.10 int mode, unsigned char *buf, uint32_t *length );
1.11
1.12 struct gdrom_image_class cdrom_device_class = { "osx", NULL,
1.13 cdrom_osx_image_is_valid, cdrom_osx_open_device };
1.14
1.15 -#define OSX_DRIVE(disc) ( (osx_cdrom_drive_t)(((gdrom_image_t)disc)->private) )
1.16 +#define OSX_DRIVE(disc) ( (osx_cdrom_drive_t)(((gdrom_disc_t)disc)->impl_data) )
1.17
1.18 -static void cdrom_osx_destroy( gdrom_disc_t disc )
1.19 +static void cdrom_osx_destroy( gdrom_disc_t disc, gboolean close_fh )
1.20 {
1.21 - osx_cdrom_close_drive( OSX_DRIVE(disc) );
1.22 - gdrom_image_destroy_no_close( disc );
1.23 + if( close_fh ) {
1.24 + osx_cdrom_close_drive( OSX_DRIVE(disc) );
1.25 + }
1.26 + gdrom_disc_destroy( disc, FALSE ); /* chain to the main destroy */
1.27 }
1.28
1.29 static void cdrom_osx_media_changed( osx_cdrom_drive_t drive, gboolean present,
1.30 void *user_data )
1.31 {
1.32 - gdrom_image_t image = (gdrom_image_t)user_data;
1.33 + gdrom_disc_t disc = (gdrom_disc_t)user_data;
1.34 if( present ) {
1.35 - cdrom_osx_read_toc( image );
1.36 + cdrom_osx_read_toc( disc );
1.37 } else {
1.38 - image->disc_type = IDE_DISC_NONE;
1.39 - image->track_count = 0;
1.40 + disc->disc_type = IDE_DISC_NONE;
1.41 + disc->track_count = 0;
1.42 }
1.43 }
1.44
1.45 @@ -67,14 +69,14 @@
1.46 {
1.47 char tmp[strlen(name)+7];
1.48 sprintf( tmp, "dvd://%s", name );
1.49 - gdrom_image_t image = (gdrom_image_t)gdrom_image_new(tmp, NULL);
1.50 - image->private = drive;
1.51 + gdrom_disc_t disc = gdrom_disc_new(tmp, NULL);
1.52 + disc->impl_data = drive;
1.53
1.54 - image->disc.read_sector = cdrom_osx_read_sector;
1.55 - image->disc.close = cdrom_osx_destroy;
1.56 - cdrom_osx_read_toc(image);
1.57 - osx_cdrom_set_media_changed_callback( drive, cdrom_osx_media_changed, image );
1.58 - return (gdrom_disc_t)image;
1.59 + disc->read_sector = cdrom_osx_read_sector;
1.60 + disc->destroy = cdrom_osx_destroy;
1.61 + cdrom_osx_read_toc(disc);
1.62 + osx_cdrom_set_media_changed_callback( drive, cdrom_osx_media_changed, disc );
1.63 + return (gdrom_disc_t)disc;
1.64 }
1.65
1.66 gdrom_disc_t cdrom_open_device( const gchar *method, const gchar *path )
1.67 @@ -123,14 +125,14 @@
1.68 return NULL;
1.69 }
1.70
1.71 -static gdrom_error_t cdrom_osx_read_toc( gdrom_image_t image )
1.72 +static gdrom_error_t cdrom_osx_read_toc( gdrom_disc_t disc )
1.73 {
1.74 - osx_cdrom_drive_t drive = OSX_DRIVE(image);
1.75 + osx_cdrom_drive_t drive = OSX_DRIVE(disc);
1.76
1.77 int fh = osx_cdrom_get_media_handle(drive);
1.78 if( fh == -1 ) {
1.79 - image->disc_type = IDE_DISC_NONE;
1.80 - image->track_count = 0;
1.81 + disc->disc_type = IDE_DISC_NONE;
1.82 + disc->track_count = 0;
1.83 return -1;
1.84 } else {
1.85 unsigned char buf[MAXTOCSIZE];
1.86 @@ -143,11 +145,12 @@
1.87 readtoc.buffer = buf;
1.88
1.89 if( ioctl(fh, DKIOCCDREADTOC, &readtoc ) == -1 ) {
1.90 - image->disc_type = IDE_DISC_NONE;
1.91 - image->track_count = 0;
1.92 + WARN( "Failed to read TOC (%s)", strerror(errno) );
1.93 + disc->disc_type = IDE_DISC_NONE;
1.94 + disc->track_count = 0;
1.95 return -1;
1.96 } else {
1.97 - mmc_parse_toc2( image, buf );
1.98 + mmc_parse_toc2( disc, buf );
1.99 }
1.100 }
1.101 return 0;
1.102 @@ -156,7 +159,6 @@
1.103 static gdrom_error_t cdrom_osx_read_sector( gdrom_disc_t disc, uint32_t lba,
1.104 int mode, unsigned char *buf, uint32_t *length )
1.105 {
1.106 - gdrom_image_t image = (gdrom_image_t)disc;
1.107 int real_lba = lba - 150;
1.108 int sector_size = 2352;
1.109 int direct_read = 1;
1.110 @@ -179,8 +181,8 @@
1.111 /* Sector could be anything - need to do a raw read and then parse
1.112 * the requested data out ourselves
1.113 */
1.114 - int track_no = gdrom_image_get_track_by_lba( image, lba );
1.115 - struct gdrom_track *track = &image->track[track_no-1];
1.116 + int track_no = gdrom_disc_get_track_by_lba( disc, lba );
1.117 + struct gdrom_track *track = &disc->track[track_no-1];
1.118
1.119 sector_size = 2352;
1.120 if( track->mode == GDROM_CDDA ) {
.