Search
lxdream.org :: lxdream/src/drivers/cdrom/cd_nrg.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/cdrom/cd_nrg.c
changeset 1178:e55ec927d55d
prev1109:700c5ab26a63
next1298:d0eb2307b847
author Nathan Keynes <nkeynes@lxdream.org>
date Sat Sep 17 22:39:36 2011 +1000 (8 years ago)
permissions -rw-r--r--
last change Fix structure packing on v55 nero images (64-bit)
Add basic support for track mode 16 (CDDA + subchannel data, 2448 bytes)
file annotate diff log raw
1.1 --- a/src/drivers/cdrom/cd_nrg.c Thu Jun 10 22:13:16 2010 +1000
1.2 +++ b/src/drivers/cdrom/cd_nrg.c Sat Sep 17 22:39:36 2011 +1000
1.3 @@ -58,7 +58,7 @@
1.4 struct nrg_footer_v55 {
1.5 uint32_t id;
1.6 uint64_t offset;
1.7 - } v55;
1.8 + } __attribute__((packed)) v55;
1.9 };
1.10
1.11 struct nrg_chunk {
1.12 @@ -132,6 +132,7 @@
1.13 case 2: return SECTOR_MODE2_FORM1;
1.14 case 3: return SECTOR_SEMIRAW_MODE2;
1.15 case 7: return SECTOR_CDDA;
1.16 + case 16: return SECTOR_CDDA_SUBCHANNEL;
1.17 default: return -1;
1.18 }
1.19 }
1.20 @@ -172,14 +173,18 @@
1.21
1.22 fseek( f, -12, SEEK_END );
1.23 fread( &footer, sizeof(footer), 1, f );
1.24 + uint32_t start = 0;
1.25 if( GUINT32_FROM_BE(footer.v50.id) == NERO_V50_ID ) {
1.26 - fseek( f, GUINT32_FROM_BE(footer.v50.offset), SEEK_SET );
1.27 + start = GUINT32_FROM_BE(footer.v50.offset);
1.28 } else if( GUINT32_FROM_BE(footer.v55.id) == NERO_V55_ID ) {
1.29 - fseek( f, (uint32_t)GUINT64_FROM_BE(footer.v55.offset), SEEK_SET );
1.30 + start = (uint32_t)GUINT64_FROM_BE(footer.v55.offset);
1.31 } else {
1.32 /* Not a (recognized) Nero image (should never happen) */
1.33 RETURN_PARSE_ERROR("File is not an NRG image" );
1.34 }
1.35 + if( fseek( f, start, SEEK_SET) != 0 ) {
1.36 + RETURN_PARSE_ERROR("File is not a valid NRG image" );
1.37 + }
1.38
1.39 do {
1.40 fread( &chunk, sizeof(chunk), 1, f );
.