Search
lxdream.org :: lxdream/src/gdrom/cdi.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/cdi.c
changeset 468:3a49695e081a
prev464:8e099fad42a6
next513:ae1dea71613d
author nkeynes
date Sun Oct 28 07:23:46 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Fix CDI with multiple tracks/session
Fix file being closed too early
file annotate diff log raw
1.1 --- a/src/gdrom/cdi.c Sat Oct 27 05:44:54 2007 +0000
1.2 +++ b/src/gdrom/cdi.c Sun Oct 28 07:23:46 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: cdi.c,v 1.9 2007-10-27 05:44:54 nkeynes Exp $
1.6 + * $Id: cdi.c,v 1.10 2007-10-28 07:23:46 nkeynes Exp $
1.7 *
1.8 * CDI CD-image file support
1.9 *
1.10 @@ -107,7 +107,6 @@
1.11
1.12 disc = gdrom_image_new(filename, f);
1.13 if( disc == NULL ) {
1.14 - fclose(f);
1.15 ERROR("Unable to allocate memory!");
1.16 return NULL;
1.17 }
1.18 @@ -117,7 +116,7 @@
1.19 fread( &track_count, sizeof(track_count), 1, f );
1.20 if( track_count + total_tracks > 99 ) {
1.21 ERROR( "Invalid number of tracks, bad cdi image\n" );
1.22 - disc->close(disc);
1.23 + gdrom_image_destroy_no_close(disc);
1.24 return NULL;
1.25 }
1.26 for( j=0; j<track_count; j++ ) {
1.27 @@ -131,7 +130,7 @@
1.28 fread( marker, 20, 1, f );
1.29 if( memcmp( marker, TRACK_START_MARKER, 20) != 0 ) {
1.30 ERROR( "Track start marker not found, error reading cdi image\n" );
1.31 - disc->close(disc);
1.32 + gdrom_image_destroy_no_close(disc);
1.33 return NULL;
1.34 }
1.35 fseek( f, 4, SEEK_CUR );
1.36 @@ -148,7 +147,7 @@
1.37 image->track[total_tracks].flags = 0x01;
1.38 if( trk.sector_size != 2 ) {
1.39 ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );
1.40 - disc->close(disc);
1.41 + gdrom_image_destroy_no_close(disc);
1.42 return NULL;
1.43 }
1.44 break;
1.45 @@ -158,7 +157,7 @@
1.46 image->track[total_tracks].flags = 0x41;
1.47 if( trk.sector_size != 0 ) {
1.48 ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );
1.49 - disc->close(disc);
1.50 + gdrom_image_destroy_no_close(disc);
1.51 return NULL;
1.52 }
1.53 break;
1.54 @@ -176,13 +175,13 @@
1.55 case 2:
1.56 default:
1.57 ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );
1.58 - disc->close(disc);
1.59 + gdrom_image_destroy_no_close(disc);
1.60 return NULL;
1.61 }
1.62 break;
1.63 default:
1.64 ERROR( "Unsupported track mode %d", trk.mode );
1.65 - disc->close(disc);
1.66 + gdrom_image_destroy_no_close(disc);
1.67 return NULL;
1.68 }
1.69 image->track[total_tracks].offset = posn +
1.70 @@ -191,11 +190,12 @@
1.71 total_tracks++;
1.72 fread( marker, 1, 9, f );
1.73 if( memcmp( marker, EXT_MARKER, 9 ) == 0 ) {
1.74 - fseek( f, 91, SEEK_CUR );
1.75 + fseek( f, 79, SEEK_CUR );
1.76 } else {
1.77 - fseek( f, 3, SEEK_CUR );
1.78 + fseek( f, -9, SEEK_CUR );
1.79 }
1.80 }
1.81 + fseek( f, 12, SEEK_CUR );
1.82 }
1.83 image->track_count = total_tracks;
1.84 return disc;
.