Search
lxdream.org :: lxdream/src/gdrom/cdi.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/cdi.c
changeset 1023:264e2fd90be8
prev999:3d19e3597d9b
next1030:864417a57662
author nkeynes
date Mon Jun 08 04:12:21 2009 +0000 (11 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/gdrom/cdi.c Tue Mar 24 11:35:20 2009 +0000
1.2 +++ b/src/gdrom/cdi.c Mon Jun 08 04:12:21 2009 +0000
1.3 @@ -76,7 +76,6 @@
1.4 gdrom_disc_t cdi_image_open( const gchar *filename, FILE *f )
1.5 {
1.6 gdrom_disc_t disc = NULL;
1.7 - gdrom_image_t image;
1.8 int i,j;
1.9 uint16_t session_count;
1.10 uint16_t track_count;
1.11 @@ -110,13 +109,12 @@
1.12 ERROR("Unable to allocate memory!");
1.13 return NULL;
1.14 }
1.15 - image = (gdrom_image_t)disc;
1.16
1.17 for( i=0; i< session_count; i++ ) {
1.18 fread( &track_count, sizeof(track_count), 1, f );
1.19 if( track_count + total_tracks > 99 ) {
1.20 ERROR( "Invalid number of tracks, bad cdi image\n" );
1.21 - gdrom_image_destroy_no_close(disc);
1.22 + disc->destroy(disc,FALSE);
1.23 return NULL;
1.24 }
1.25 for( j=0; j<track_count; j++ ) {
1.26 @@ -130,7 +128,7 @@
1.27 fread( marker, 20, 1, f );
1.28 if( memcmp( marker, TRACK_START_MARKER, 20) != 0 ) {
1.29 ERROR( "Track start marker not found, error reading cdi image\n" );
1.30 - gdrom_image_destroy_no_close(disc);
1.31 + disc->destroy(disc,FALSE);
1.32 return NULL;
1.33 }
1.34 fseek( f, 4, SEEK_CUR );
1.35 @@ -144,56 +142,56 @@
1.36 fseek( f, 2, SEEK_CUR );
1.37 }
1.38 fread( &trk, sizeof(trk), 1, f );
1.39 - image->track[total_tracks].session = i;
1.40 - image->track[total_tracks].lba = trk.start_lba + 150;
1.41 - image->track[total_tracks].sector_count = trk.length;
1.42 + disc->track[total_tracks].session = i;
1.43 + disc->track[total_tracks].lba = trk.start_lba + 150;
1.44 + disc->track[total_tracks].sector_count = trk.length;
1.45 switch( trk.mode ) {
1.46 case 0:
1.47 - image->track[total_tracks].mode = GDROM_CDDA;
1.48 - image->track[total_tracks].sector_size = 2352;
1.49 - image->track[total_tracks].flags = 0x01;
1.50 + disc->track[total_tracks].mode = GDROM_CDDA;
1.51 + disc->track[total_tracks].sector_size = 2352;
1.52 + disc->track[total_tracks].flags = 0x01;
1.53 if( trk.sector_size != 2 ) {
1.54 ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );
1.55 - gdrom_image_destroy_no_close(disc);
1.56 + disc->destroy(disc,FALSE);
1.57 return NULL;
1.58 }
1.59 break;
1.60 case 1:
1.61 - image->track[total_tracks].mode = GDROM_MODE1;
1.62 - image->track[total_tracks].sector_size = 2048;
1.63 - image->track[total_tracks].flags = 0x41;
1.64 + disc->track[total_tracks].mode = GDROM_MODE1;
1.65 + disc->track[total_tracks].sector_size = 2048;
1.66 + disc->track[total_tracks].flags = 0x41;
1.67 if( trk.sector_size != 0 ) {
1.68 ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );
1.69 - gdrom_image_destroy_no_close(disc);
1.70 + disc->destroy(disc,FALSE);
1.71 return NULL;
1.72 }
1.73 break;
1.74 case 2:
1.75 - image->track[total_tracks].flags = 0x41;
1.76 + disc->track[total_tracks].flags = 0x41;
1.77 switch( trk.sector_size ) {
1.78 case 0:
1.79 - image->track[total_tracks].mode = GDROM_MODE2_FORM1;
1.80 - image->track[total_tracks].sector_size = 2048;
1.81 + disc->track[total_tracks].mode = GDROM_MODE2_FORM1;
1.82 + disc->track[total_tracks].sector_size = 2048;
1.83 break;
1.84 case 1:
1.85 - image->track[total_tracks].mode = GDROM_SEMIRAW_MODE2;
1.86 - image->track[total_tracks].sector_size = 2336;
1.87 + disc->track[total_tracks].mode = GDROM_SEMIRAW_MODE2;
1.88 + disc->track[total_tracks].sector_size = 2336;
1.89 break;
1.90 case 2:
1.91 default:
1.92 ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );
1.93 - gdrom_image_destroy_no_close(disc);
1.94 + disc->destroy(disc,FALSE);
1.95 return NULL;
1.96 }
1.97 break;
1.98 default:
1.99 ERROR( "Unsupported track mode %d", trk.mode );
1.100 - gdrom_image_destroy_no_close(disc);
1.101 + disc->destroy(disc,FALSE);
1.102 return NULL;
1.103 }
1.104 - image->track[total_tracks].offset = posn +
1.105 - trk.pregap_length * image->track[total_tracks].sector_size ;
1.106 - posn += trk.total_length * image->track[total_tracks].sector_size;
1.107 + disc->track[total_tracks].offset = posn +
1.108 + trk.pregap_length * disc->track[total_tracks].sector_size ;
1.109 + posn += trk.total_length * disc->track[total_tracks].sector_size;
1.110 total_tracks++;
1.111 fread( marker, 1, 9, f );
1.112 if( memcmp( marker, EXT_MARKER, 9 ) == 0 ) {
1.113 @@ -204,6 +202,6 @@
1.114 }
1.115 fseek( f, 12, SEEK_CUR );
1.116 }
1.117 - image->track_count = total_tracks;
1.118 + disc->track_count = total_tracks;
1.119 return disc;
1.120 }
.