Search
lxdream.org :: lxdream/src/gdrom/nrg.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/nrg.c
changeset 1023:264e2fd90be8
prev832:40e5bb525c4e
next1030:864417a57662
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/gdrom/nrg.c Wed Aug 27 06:23:19 2008 +0000
1.2 +++ b/src/gdrom/nrg.c Mon Jun 08 04:12:21 2009 +0000
1.3 @@ -186,7 +186,6 @@
1.4 struct nrg_etnf *etnf;
1.5 struct nrg_etn2 *etn2;
1.6 gdrom_disc_t disc;
1.7 - gdrom_image_t image;
1.8 gboolean end = FALSE;
1.9 uint32_t chunk_id;
1.10 int session_id = 0;
1.11 @@ -213,7 +212,6 @@
1.12 ERROR("Unable to allocate memory!");
1.13 return NULL;
1.14 }
1.15 - image = (gdrom_image_t)disc;
1.16
1.17 do {
1.18 fread( &chunk, sizeof(chunk), 1, f );
1.19 @@ -239,34 +237,34 @@
1.20 if( cue->track == 0 )
1.21 continue; /* Track 0. Leadin? always 0? */
1.22 if( cue->track == 0xAA ) { /* end of disc */
1.23 - image->track[track_id-1].sector_count =
1.24 - lba - image->track[track_id-1].lba;
1.25 + disc->track[track_id-1].sector_count =
1.26 + lba - disc->track[track_id-1].lba;
1.27 } else {
1.28 track = bcd_to_uint8(cue->track) - 1;
1.29 if( (cue->control & 0x01) == 0 ) {
1.30 /* Pre-gap address. */
1.31 if( track != 0 ) {
1.32 - image->track[track-1].sector_count =
1.33 - lba - image->track[track-1].lba;
1.34 + disc->track[track-1].sector_count =
1.35 + lba - disc->track[track-1].lba;
1.36 }
1.37 } else { /* Track-start address */
1.38 - image->track[track].lba = lba;
1.39 - image->track[track].flags = cue->type;
1.40 + disc->track[track].lba = lba;
1.41 + disc->track[track].flags = cue->type;
1.42 }
1.43 }
1.44 }
1.45 break;
1.46 case DAOI_ID:
1.47 dao = (struct nrg_daoi *)data;
1.48 - memcpy( image->mcn, dao->mcn, 13 );
1.49 - image->mcn[13] = '\0';
1.50 + memcpy( disc->mcn, dao->mcn, 13 );
1.51 + disc->mcn[13] = '\0';
1.52 assert( (dao->track_count - cue_track_id) * 30 + 22 == chunk.length );
1.53 assert( dao->track_count == track_id );
1.54 for( i=0; i<(dao->track_count-cue_track_id); i++ ) {
1.55 - image->track[cue_track_id].sector_size = GUINT32_FROM_BE(dao->track[i].sector_size);
1.56 - image->track[cue_track_id].offset = GUINT32_FROM_BE(dao->track[i].offset);
1.57 - image->track[cue_track_id].mode = nrg_track_mode( dao->track[i].mode );
1.58 - image->track[cue_track_id].sector_count =
1.59 + disc->track[cue_track_id].sector_size = GUINT32_FROM_BE(dao->track[i].sector_size);
1.60 + disc->track[cue_track_id].offset = GUINT32_FROM_BE(dao->track[i].offset);
1.61 + disc->track[cue_track_id].mode = nrg_track_mode( dao->track[i].mode );
1.62 + disc->track[cue_track_id].sector_count =
1.63 (GUINT32_FROM_BE(dao->track[i].end) - GUINT32_FROM_BE(dao->track[i].offset))/
1.64 GUINT32_FROM_BE(dao->track[i].sector_size);
1.65 cue_track_id++;
1.66 @@ -274,15 +272,15 @@
1.67 break;
1.68 case DAOX_ID:
1.69 daox = (struct nrg_daox *)data;
1.70 - memcpy( image->mcn, daox->mcn, 13 );
1.71 - image->mcn[13] = '\0';
1.72 + memcpy( disc->mcn, daox->mcn, 13 );
1.73 + disc->mcn[13] = '\0';
1.74 assert( (daox->track_count - cue_track_id) * 42 + 22 == chunk.length );
1.75 assert( daox->track_count == track_id );
1.76 for( i=0; i<(daox->track_count-cue_track_id); i++ ) {
1.77 - image->track[cue_track_id].sector_size = GUINT32_FROM_BE(daox->track[i].sector_size);
1.78 - image->track[cue_track_id].offset = GUINT64_FROM_BE(daox->track[i].offset);
1.79 - image->track[cue_track_id].mode = nrg_track_mode( daox->track[i].mode );
1.80 - image->track[cue_track_id].sector_count =
1.81 + disc->track[cue_track_id].sector_size = GUINT32_FROM_BE(daox->track[i].sector_size);
1.82 + disc->track[cue_track_id].offset = GUINT64_FROM_BE(daox->track[i].offset);
1.83 + disc->track[cue_track_id].mode = nrg_track_mode( daox->track[i].mode );
1.84 + disc->track[cue_track_id].sector_count =
1.85 (GUINT64_FROM_BE(daox->track[i].end) - GUINT64_FROM_BE(daox->track[i].offset))/
1.86 GUINT32_FROM_BE(daox->track[i].sector_size);
1.87 cue_track_id++;
1.88 @@ -293,27 +291,27 @@
1.89 /* Data is a single 32-bit number representing number of tracks in session */
1.90 i = GUINT32_FROM_BE( *(uint32_t *)data );
1.91 while( i-- > 0 )
1.92 - image->track[session_track_id++].session = session_id;
1.93 + disc->track[session_track_id++].session = session_id;
1.94 session_id++;
1.95 break;
1.96 case ETNF_ID:
1.97 etnf = (struct nrg_etnf *)data;
1.98 count = chunk.length / sizeof(struct nrg_etnf);
1.99 for( i=0; i < count; i++, etnf++ ) {
1.100 - image->track[track_id].offset = GUINT32_FROM_BE(etnf->offset);
1.101 - image->track[track_id].lba = GUINT32_FROM_BE(etnf->lba) + (i+1)*GDROM_PREGAP;
1.102 - image->track[track_id].mode = nrg_track_mode( GUINT32_FROM_BE(etnf->mode) );
1.103 - if( image->track[track_id].mode == -1 ) {
1.104 - gdrom_image_destroy_no_close(disc);
1.105 + disc->track[track_id].offset = GUINT32_FROM_BE(etnf->offset);
1.106 + disc->track[track_id].lba = GUINT32_FROM_BE(etnf->lba) + (i+1)*GDROM_PREGAP;
1.107 + disc->track[track_id].mode = nrg_track_mode( GUINT32_FROM_BE(etnf->mode) );
1.108 + if( disc->track[track_id].mode == -1 ) {
1.109 + disc->destroy(disc,FALSE);
1.110 return NULL;
1.111 }
1.112 - if( image->track[track_id].mode == GDROM_CDDA )
1.113 - image->track[track_id].flags = 0x01;
1.114 + if( disc->track[track_id].mode == GDROM_CDDA )
1.115 + disc->track[track_id].flags = 0x01;
1.116 else
1.117 - image->track[track_id].flags = 0x01 | TRACK_DATA;
1.118 - image->track[track_id].sector_size = GDROM_SECTOR_SIZE(image->track[track_id].mode);
1.119 - image->track[track_id].sector_count = GUINT32_FROM_BE(etnf->length) /
1.120 - image->track[track_id].sector_size;
1.121 + disc->track[track_id].flags = 0x01 | TRACK_DATA;
1.122 + disc->track[track_id].sector_size = GDROM_SECTOR_SIZE(disc->track[track_id].mode);
1.123 + disc->track[track_id].sector_count = GUINT32_FROM_BE(etnf->length) /
1.124 + disc->track[track_id].sector_size;
1.125 track_id++;
1.126 }
1.127 break;
1.128 @@ -321,20 +319,20 @@
1.129 etn2 = (struct nrg_etn2 *)data;
1.130 count = chunk.length / sizeof(struct nrg_etn2);
1.131 for( i=0; i < count; i++, etn2++ ) {
1.132 - image->track[track_id].offset = (uint32_t)GUINT64_FROM_BE(etn2->offset);
1.133 - image->track[track_id].lba = GUINT32_FROM_BE(etn2->lba) + (i+1)*GDROM_PREGAP;
1.134 - image->track[track_id].mode = nrg_track_mode( GUINT32_FROM_BE(etn2->mode) );
1.135 - if( image->track[track_id].mode == -1 ) {
1.136 - gdrom_image_destroy_no_close(disc);
1.137 + disc->track[track_id].offset = (uint32_t)GUINT64_FROM_BE(etn2->offset);
1.138 + disc->track[track_id].lba = GUINT32_FROM_BE(etn2->lba) + (i+1)*GDROM_PREGAP;
1.139 + disc->track[track_id].mode = nrg_track_mode( GUINT32_FROM_BE(etn2->mode) );
1.140 + if( disc->track[track_id].mode == -1 ) {
1.141 + disc->destroy(disc,FALSE);
1.142 return NULL;
1.143 }
1.144 - if( image->track[track_id].mode == GDROM_CDDA )
1.145 - image->track[track_id].flags = 0x01;
1.146 + if( disc->track[track_id].mode == GDROM_CDDA )
1.147 + disc->track[track_id].flags = 0x01;
1.148 else
1.149 - image->track[track_id].flags = 0x01 | TRACK_DATA;
1.150 - image->track[track_id].sector_size = GDROM_SECTOR_SIZE(image->track[track_id].mode);
1.151 - image->track[track_id].sector_count = (uint32_t)(GUINT64_FROM_BE(etn2->length) /
1.152 - image->track[track_id].sector_size);
1.153 + disc->track[track_id].flags = 0x01 | TRACK_DATA;
1.154 + disc->track[track_id].sector_size = GDROM_SECTOR_SIZE(disc->track[track_id].mode);
1.155 + disc->track[track_id].sector_count = (uint32_t)(GUINT64_FROM_BE(etn2->length) /
1.156 + disc->track[track_id].sector_size);
1.157 track_id++;
1.158 }
1.159 break;
1.160 @@ -344,7 +342,7 @@
1.161 break;
1.162 }
1.163 } while( !end );
1.164 - image->track_count = track_id;
1.165 + disc->track_count = track_id;
1.166 return disc;
1.167 }
1.168
.