Search
lxdream.org :: lxdream :: r468:3a49695e081a
lxdream 0.9.1
released Jun 29
Download Now
changeset468:3a49695e081a
parent467:0120dc87e05d
child469:3e2a0fde5cd8
authornkeynes
dateSun Oct 28 07:23:46 2007 +0000 (13 years ago)
Fix CDI with multiple tracks/session
Fix file being closed too early
src/gdrom/cdi.c
src/gdrom/gdimage.c
src/gdrom/gdrom.h
src/gdrom/linux.c
src/gdrom/nrg.c
1.1 --- a/src/gdrom/cdi.c Sat Oct 27 05:48:22 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;
2.1 --- a/src/gdrom/gdimage.c Sat Oct 27 05:48:22 2007 +0000
2.2 +++ b/src/gdrom/gdimage.c Sun Oct 28 07:23:46 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: gdimage.c,v 1.3 2007-10-27 05:44:54 nkeynes Exp $
2.6 + * $Id: gdimage.c,v 1.4 2007-10-28 07:23:46 nkeynes Exp $
2.7 *
2.8 * GD-Rom image-file common functions.
2.9 *
2.10 @@ -80,6 +80,19 @@
2.11 free( disc );
2.12 }
2.13
2.14 +void gdrom_image_destroy_no_close( gdrom_disc_t disc )
2.15 +{
2.16 + gdrom_image_t img = (gdrom_image_t)disc;
2.17 + if( img->file != NULL ) {
2.18 + img->file = NULL;
2.19 + }
2.20 + if( disc->name != NULL ) {
2.21 + g_free( disc->name );
2.22 + disc->name = NULL;
2.23 + }
2.24 + free( disc );
2.25 +}
2.26 +
2.27 static int gdrom_image_get_track_by_lba( gdrom_image_t image, uint32_t lba )
2.28 {
2.29 int i;
3.1 --- a/src/gdrom/gdrom.h Sat Oct 27 05:48:22 2007 +0000
3.2 +++ b/src/gdrom/gdrom.h Sun Oct 28 07:23:46 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: gdrom.h,v 1.13 2007-10-27 05:44:54 nkeynes Exp $
3.6 + * $Id: gdrom.h,v 1.14 2007-10-28 07:23:46 nkeynes Exp $
3.7 *
3.8 * This file defines the structures and functions used by the GD-Rom
3.9 * disc driver. (ie, the modules that supply a CD image to be used by the
3.10 @@ -181,6 +181,12 @@
3.11 void gdrom_image_dump_info( gdrom_disc_t d );
3.12
3.13 /**
3.14 + * Destroy an image data structure without closing the file
3.15 + * (Intended for use from image loaders only)
3.16 + */
3.17 +void gdrom_image_destroy_no_close( gdrom_disc_t d );
3.18 +
3.19 +/**
3.20 * Retrieve the disc table of contents, and write it into the buffer in the
3.21 * format expected by the DC.
3.22 * @return 0 on success, error code on failure (eg no disc mounted)
4.1 --- a/src/gdrom/linux.c Sat Oct 27 05:48:22 2007 +0000
4.2 +++ b/src/gdrom/linux.c Sun Oct 28 07:23:46 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: linux.c,v 1.6 2007-10-27 05:44:54 nkeynes Exp $
4.6 + * $Id: linux.c,v 1.7 2007-10-28 07:23:46 nkeynes Exp $
4.7 *
4.8 * Linux cd-rom device driver.
4.9 *
4.10 @@ -115,7 +115,7 @@
4.11
4.12 gdrom_error_t status = linux_read_disc_toc( (gdrom_image_t)disc );
4.13 if( status != 0 ) {
4.14 - disc->close(disc);
4.15 + gdrom_image_destroy_no_close(disc);
4.16 if( status == 0xFFFF ) {
4.17 ERROR("Unable to load disc table of contents (%s)", strerror(errno));
4.18 } else {
5.1 --- a/src/gdrom/nrg.c Sat Oct 27 05:48:22 2007 +0000
5.2 +++ b/src/gdrom/nrg.c Sun Oct 28 07:23:46 2007 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: nrg.c,v 1.6 2007-10-27 05:44:54 nkeynes Exp $
5.6 + * $Id: nrg.c,v 1.7 2007-10-28 07:23:46 nkeynes Exp $
5.7 *
5.8 * Nero (NRG) CD file format. File information stolen shamelessly from
5.9 * libcdio.
5.10 @@ -180,7 +180,6 @@
5.11
5.12 disc = gdrom_image_new(filename, f);
5.13 if( disc == NULL ) {
5.14 - fclose(f);
5.15 ERROR("Unable to allocate memory!");
5.16 return NULL;
5.17 }
5.18 @@ -249,7 +248,7 @@
5.19 image->track[track_id].lba = ntohl(etnf->lba) + (i+1)*GDROM_PREGAP;
5.20 image->track[track_id].mode = nrg_track_mode( ntohl(etnf->mode) );
5.21 if( image->track[track_id].mode == -1 ) {
5.22 - disc->close(disc);
5.23 + gdrom_image_destroy_no_close(disc);
5.24 return NULL;
5.25 }
5.26 if( image->track[track_id].mode == GDROM_CDDA )
.