1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[iso] upgrade libcdio track and sector handling

* From latest git version of libcdio
This commit is contained in:
Pete Batard 2013-06-04 01:03:56 +01:00
parent d3238d7210
commit b0e131e5e4
5 changed files with 179 additions and 165 deletions

View file

@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** \file track.h /** \file track.h
* \brief The top-level header for track-related libcdio calls. * \brief The top-level header for track-related libcdio calls.
*/ */
#ifndef CDIO_TRACK_H_ #ifndef CDIO_TRACK_H_
@ -27,7 +27,7 @@ extern "C" {
/*! Printable tags for track_format_t enumeration. */ /*! Printable tags for track_format_t enumeration. */
extern const char *track_format2str[6]; extern const char *track_format2str[6];
typedef enum { typedef enum {
TRACK_FORMAT_AUDIO, /**< Audio track, e.g. CD-DA */ TRACK_FORMAT_AUDIO, /**< Audio track, e.g. CD-DA */
TRACK_FORMAT_CDI, /**< CD-i. How this is different from DATA below? */ TRACK_FORMAT_CDI, /**< CD-i. How this is different from DATA below? */
@ -40,9 +40,9 @@ extern "C" {
} track_format_t; } track_format_t;
typedef enum { typedef enum {
CDIO_TRACK_FLAG_FALSE, CDIO_TRACK_FLAG_FALSE,
CDIO_TRACK_FLAG_TRUE, CDIO_TRACK_FLAG_TRUE,
CDIO_TRACK_FLAG_ERROR, CDIO_TRACK_FLAG_ERROR,
CDIO_TRACK_FLAG_UNKNOWN CDIO_TRACK_FLAG_UNKNOWN
} track_flag_t; } track_flag_t;
@ -54,7 +54,7 @@ extern "C" {
implemented or -1 for error. implemented or -1 for error.
*/ */
} track_flags_t; } track_flags_t;
/*! The leadout track is always 0xAA, regardless of # of tracks on /*! The leadout track is always 0xAA, regardless of # of tracks on
disc, or what value may be used internally. For example although disc, or what value may be used internally. For example although
OS X uses a different value for the lead-out track internally than OS X uses a different value for the lead-out track internally than
@ -71,7 +71,7 @@ extern "C" {
CDIO_CDROM_LBA = 0x01, /**< "logical block": first frame is #0 */ CDIO_CDROM_LBA = 0x01, /**< "logical block": first frame is #0 */
CDIO_CDROM_MSF = 0x02, /**< "minute-second-frame": binary, not CDIO_CDROM_MSF = 0x02, /**< "minute-second-frame": binary, not
BCD here! */ BCD here! */
CDIO_CDROM_DATA_TRACK = 0x04, CDIO_CDROM_DATA_TRACK = 0x04,
CDIO_CDROM_CDI_TRACK = 0x10, CDIO_CDROM_CDI_TRACK = 0x10,
CDIO_CDROM_XA_TRACK = 0x20, CDIO_CDROM_XA_TRACK = 0x20,
CDIO_CD_MAX_TRACKS = 99, /**< Largest CD track number */ CDIO_CD_MAX_TRACKS = 99, /**< Largest CD track number */
@ -79,10 +79,10 @@ extern "C" {
CDIO_INVALID_TRACK = 0xFF, /**< Constant for invalid track number */ CDIO_INVALID_TRACK = 0xFF, /**< Constant for invalid track number */
} cdio_track_enums; } cdio_track_enums;
#define CDIO_CD_MIN_TRACK_NO 1 /**< Smallest CD track number */ #define CDIO_CD_MIN_TRACK_NO 1 /**< Smallest CD track number */
/*! track modes (Table 350) /*! track modes (Table 350)
reference: MMC-3 draft revsion - 10g reference: MMC-3 draft revsion - 10g
*/ */
typedef enum { typedef enum {
@ -95,26 +95,26 @@ extern "C" {
MODE2_FORM_MIX, /**< 2336 byte block length */ MODE2_FORM_MIX, /**< 2336 byte block length */
MODE2_RAW /**< 2352 byte block length */ MODE2_RAW /**< 2352 byte block length */
} trackmode_t; } trackmode_t;
/*!
Get the number of the first track.
@return the track number or CDIO_INVALID_TRACK /*!
Get the number of the first track.
@return the track number or CDIO_INVALID_TRACK
on error. on error.
*/ */
track_t cdio_get_first_track_num(const CdIo_t *p_cdio); track_t cdio_get_first_track_num(const CdIo_t *p_cdio);
/*! /*!
Return the last track number. Return the last track number.
CDIO_INVALID_TRACK is returned on error. CDIO_INVALID_TRACK is returned on error.
*/ */
track_t cdio_get_last_track_num (const CdIo_t *p_cdio); track_t cdio_get_last_track_num (const CdIo_t *p_cdio);
/*! Find the track which contains lsn. /*! Find the track which contains lsn.
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
if there was some error. if there was some error.
If the lsn is before the pregap of the first track 0 is returned. If the lsn is before the pregap of the first track 0 is returned.
Otherwise we return the track that spans the lsn. Otherwise we return the track that spans the lsn.
*/ */
@ -125,37 +125,37 @@ extern "C" {
Not meaningful if track is not an audio track. Not meaningful if track is not an audio track.
*/ */
int cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track); int cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track);
/*! Return copy protection status on a track. Is this meaningful /*! Return copy protection status on a track. Is this meaningful
if not an audio track? if not an audio track?
*/ */
track_flag_t cdio_get_track_copy_permit(const CdIo_t *p_cdio, track_flag_t cdio_get_track_copy_permit(const CdIo_t *p_cdio,
track_t i_track); track_t i_track);
/*! /*!
Get the format (audio, mode2, mode1) of track. Get the format (audio, mode2, mode1) of track.
*/ */
track_format_t cdio_get_track_format(const CdIo_t *p_cdio, track_t i_track); track_format_t cdio_get_track_format(const CdIo_t *p_cdio, track_t i_track);
/*! /*!
Return true if we have XA data (green, mode2 form1) or Return true if we have XA data (green, mode2 form1) or
XA data (green, mode2 form2). That is track begins: XA data (green, mode2 form2). That is track begins:
sync - header - subheader sync - header - subheader
12 4 - 8 12 4 - 8
FIXME: there's gotta be a better design for this and get_track_format? FIXME: there's gotta be a better design for this and get_track_format?
*/ */
bool cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track); bool cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track);
/*! /*!
Return the ending LSN for track number Return the ending LSN for track number
i_track in cdio. CDIO_INVALID_LSN is returned on error. i_track in cdio. CDIO_INVALID_LSN is returned on error.
*/ */
lsn_t cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t i_track); lsn_t cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t i_track);
/*! /*!
Get the starting LBA for track number Get the starting LBA for track number
i_track in p_cdio. Track numbers usually start at something i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1. greater than 0, usually 1.
The "leadout" track is specified either by The "leadout" track is specified either by
@ -166,10 +166,10 @@ extern "C" {
@return the starting LBA or CDIO_INVALID_LBA on error. @return the starting LBA or CDIO_INVALID_LBA on error.
*/ */
lba_t cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track); lba_t cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track);
/*! /*!
Return the starting LSN for track number Return the starting LSN for track number
i_track in p_cdio. Track numbers usually start at something i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1. greater than 0, usually 1.
The "leadout" track is specified either by The "leadout" track is specified either by
@ -181,9 +181,9 @@ extern "C" {
*/ */
lsn_t cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track); lsn_t cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track);
/*! /*!
Return the starting LBA for the pregap for track number Return the starting LBA for the pregap for track number
i_track in p_cdio. Track numbers usually start at something i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1. greater than 0, usually 1.
@param p_cdio object to get information from @param p_cdio object to get information from
@ -192,9 +192,9 @@ extern "C" {
*/ */
lba_t cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track); lba_t cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track);
/*! /*!
Return the starting LSN for the pregap for track number Return the starting LSN for the pregap for track number
i_track in p_cdio. Track numbers usually start at something i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1. greater than 0, usually 1.
@param p_cdio object to get information from @param p_cdio object to get information from
@ -216,30 +216,30 @@ extern "C" {
*/ */
char * cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track); char * cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track);
/*! /*!
Return the starting MSF (minutes/secs/frames) for track number Return the starting MSF (minutes/secs/frames) for track number
i_track in p_cdio. Track numbers usually start at something i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1. greater than 0, usually 1.
The "leadout" track is specified either by The "leadout" track is specified either by
using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1. using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
@return true if things worked or false if there is no track entry. @return true if things worked or false if there is no track entry.
*/ */
bool cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track, bool cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track,
/*out*/ msf_t *msf); /*out*/ msf_t *msf);
/*! Get linear preemphasis status on an audio track /*! Get linear preemphasis status on an audio track
This is not meaningful if not an audio track? This is not meaningful if not an audio track?
*/ */
track_flag_t cdio_get_track_preemphasis(const CdIo_t *p_cdio, track_flag_t cdio_get_track_preemphasis(const CdIo_t *p_cdio,
track_t i_track); track_t i_track);
/*! /*!
Get the number of sectors between this track an the next. This Get the number of sectors between this track an the next. This
includes any pregap sectors before the start of the next track. includes any pregap sectors before the start of the next track.
Track numbers usually start at something Track numbers usually start at something
greater than 0, usually 1. greater than 0, usually 1.
@return the number of sectors or 0 if there is an error. @return the number of sectors or 0 if there is an error.

View file

@ -27,7 +27,7 @@
#include <time.h> #include <time.h>
#if defined(__MINGW32__) && !defined(__MINGW64__) #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
struct timespec { struct timespec {
time_t tv_sec; /* Seconds */ time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */ long tv_nsec; /* Nanoseconds */

View file

@ -41,21 +41,21 @@ static const char _rcsid[] = "$Id: sector.c,v 1.5 2005/02/06 04:20:25 rocky Exp
/*! String of bytes used to identify the beginning of a Mode 1 or /*! String of bytes used to identify the beginning of a Mode 1 or
Mode 2 sector. */ Mode 2 sector. */
const uint8_t CDIO_SECTOR_SYNC_HEADER[CDIO_CD_SYNC_SIZE] = const uint8_t CDIO_SECTOR_SYNC_HEADER[CDIO_CD_SYNC_SIZE] =
{0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}; {0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0};
/* Variables to hold debugger-helping enumerations */ /* Variables to hold debugger-helping enumerations */
enum cdio_cd_enums; enum cdio_cd_enums;
enum m2_sector_enums; enum m2_sector_enums;
lba_t lba_t
cdio_lba_to_lsn (lba_t lba) cdio_lba_to_lsn (lba_t lba)
{ {
if (CDIO_INVALID_LBA == lba) return CDIO_INVALID_LSN; if (CDIO_INVALID_LBA == lba) return CDIO_INVALID_LSN;
return lba - CDIO_PREGAP_SECTORS; return lba - CDIO_PREGAP_SECTORS;
} }
/* /*
The below is adapted from cdparanoia code which claims it is The below is adapted from cdparanoia code which claims it is
straight from the MMC3 spec. straight from the MMC3 spec.
*/ */
@ -64,7 +64,7 @@ void
cdio_lsn_to_msf (lsn_t lsn, msf_t *msf) cdio_lsn_to_msf (lsn_t lsn, msf_t *msf)
{ {
int m, s, f; int m, s, f;
cdio_assert (msf != 0); cdio_assert (msf != 0);
if ( lsn >= -CDIO_PREGAP_SECTORS ){ if ( lsn >= -CDIO_PREGAP_SECTORS ){
@ -81,17 +81,17 @@ cdio_lsn_to_msf (lsn_t lsn, msf_t *msf)
f = lsn + CDIO_CD_MAX_LSN; f = lsn + CDIO_CD_MAX_LSN;
} }
if (m > 99) { if (m > 6) {
cdio_warn ("number of minutes (%d) truncated to 99.", m); cdio_warn ("number of minutes (%d) truncated to 99.", m);
m = 99; m = 6;
} }
msf->m = cdio_to_bcd8 (m); msf->m = cdio_to_bcd8 (m);
msf->s = cdio_to_bcd8 (s); msf->s = cdio_to_bcd8 (s);
msf->f = cdio_to_bcd8 (f); msf->f = cdio_to_bcd8 (f);
} }
/*! /*!
Convert an LBA into a string representation of the MSF. Convert an LBA into a string representation of the MSF.
\warning cdio_lba_to_msf_str returns new allocated string */ \warning cdio_lba_to_msf_str returns new allocated string */
char * char *
@ -108,7 +108,7 @@ cdio_lba_to_msf_str (lba_t lba)
} }
} }
/*! /*!
Convert an LSN into the corresponding LBA. Convert an LSN into the corresponding LBA.
CDIO_INVALID_LBA is returned if there is an error. CDIO_INVALID_LBA is returned if there is an error.
*/ */
@ -116,10 +116,10 @@ lba_t
cdio_lsn_to_lba (lsn_t lsn) cdio_lsn_to_lba (lsn_t lsn)
{ {
if (CDIO_INVALID_LSN == lsn) return CDIO_INVALID_LBA; if (CDIO_INVALID_LSN == lsn) return CDIO_INVALID_LBA;
return lsn + CDIO_PREGAP_SECTORS; return lsn + CDIO_PREGAP_SECTORS;
} }
/*! /*!
Convert an LBA into the corresponding MSF. Convert an LBA into the corresponding MSF.
*/ */
void void
@ -129,7 +129,7 @@ cdio_lba_to_msf (lba_t lba, msf_t *msf)
cdio_lsn_to_msf(cdio_lba_to_lsn(lba), msf); cdio_lsn_to_msf(cdio_lba_to_lsn(lba), msf);
} }
/*! /*!
Convert a MSF into the corresponding LBA. Convert a MSF into the corresponding LBA.
CDIO_INVALID_LBA is returned if there is an error. CDIO_INVALID_LBA is returned if there is an error.
*/ */
@ -145,13 +145,13 @@ cdio_msf_to_lba (const msf_t *msf)
lba += cdio_from_bcd8 (msf->s); lba += cdio_from_bcd8 (msf->s);
lba *= CDIO_CD_FRAMES_PER_SEC; lba *= CDIO_CD_FRAMES_PER_SEC;
lba += cdio_from_bcd8 (msf->f); lba += cdio_from_bcd8 (msf->f);
return lba; return lba;
} }
/*! /*!
Convert a MSF into the corresponding LSN. Convert a MSF into the corresponding LSN.
CDIO_INVALID_LSN is returned if there is an error. CDIO_INVALID_LSN is returned if there is an error.
*/ */
@ -161,32 +161,32 @@ cdio_msf_to_lsn (const msf_t *msf)
return cdio_lba_to_lsn(cdio_msf_to_lba (msf)); return cdio_lba_to_lsn(cdio_msf_to_lba (msf));
} }
/*! /*!
Convert an LBA into a string representation of the MSF. Convert an LBA into a string representation of the MSF.
\warning cdio_lba_to_msf_str returns new allocated string */ \warning cdio_lba_to_msf_str returns new allocated string */
char * char *
cdio_msf_to_str (const msf_t *msf) cdio_msf_to_str (const msf_t *msf)
{ {
char buf[16]; char buf[16];
snprintf (buf, sizeof (buf), "%2.2x:%2.2x:%2.2x", msf->m, msf->s, msf->f); snprintf (buf, sizeof (buf), "%2.2x:%2.2x:%2.2x", msf->m, msf->s, msf->f);
return strdup (buf); return strdup (buf);
} }
/*! /*!
Convert a MSF - broken out as 3 integer components into the Convert a MSF - broken out as 3 integer components into the
corresponding LBA. corresponding LBA.
CDIO_INVALID_LBA is returned if there is an error. CDIO_INVALID_LBA is returned if there is an error.
*/ */
lba_t lba_t
cdio_msf3_to_lba (unsigned int minutes, unsigned int seconds, cdio_msf3_to_lba (unsigned int minutes, unsigned int seconds,
unsigned int frames) unsigned int frames)
{ {
return ((minutes * CDIO_CD_SECS_PER_MIN + seconds) * CDIO_CD_FRAMES_PER_SEC return ((minutes * CDIO_CD_SECS_PER_MIN + seconds) * CDIO_CD_FRAMES_PER_SEC
+ frames); + frames);
} }
/*! /*!
Convert a string of the form MM:SS:FF into the corresponding LBA. Convert a string of the form MM:SS:FF into the corresponding LBA.
CDIO_INVALID_LBA is returned if there is an error. CDIO_INVALID_LBA is returned if there is an error.
*/ */
@ -196,10 +196,10 @@ cdio_mmssff_to_lba (const char *psz_mmssff)
int psz_field; int psz_field;
lba_t ret; lba_t ret;
unsigned char c; unsigned char c;
if (0 == strcmp (psz_mmssff, "0")) if (0 == strcmp (psz_mmssff, "0"))
return 0; return 0;
c = *psz_mmssff++; c = *psz_mmssff++;
if(c >= '0' && c <= '9') if(c >= '0' && c <= '9')
psz_field = (c - '0'); psz_field = (c - '0');
@ -211,9 +211,9 @@ cdio_mmssff_to_lba (const char *psz_mmssff)
else else
return CDIO_INVALID_LBA; return CDIO_INVALID_LBA;
} }
ret = cdio_msf3_to_lba (psz_field, 0, 0); ret = cdio_msf3_to_lba (psz_field, 0, 0);
c = *psz_mmssff++; c = *psz_mmssff++;
if(c >= '0' && c <= '9') if(c >= '0' && c <= '9')
psz_field = (c - '0'); psz_field = (c - '0');
@ -229,12 +229,12 @@ cdio_mmssff_to_lba (const char *psz_mmssff)
else else
return CDIO_INVALID_LBA; return CDIO_INVALID_LBA;
} }
if(psz_field >= CDIO_CD_SECS_PER_MIN) if(psz_field >= CDIO_CD_SECS_PER_MIN)
return CDIO_INVALID_LBA; return CDIO_INVALID_LBA;
ret += cdio_msf3_to_lba (0, psz_field, 0); ret += cdio_msf3_to_lba (0, psz_field, 0);
c = *psz_mmssff++; c = *psz_mmssff++;
if (isdigit(c)) if (isdigit(c))
psz_field = (c - '0'); psz_field = (c - '0');
@ -248,20 +248,20 @@ cdio_mmssff_to_lba (const char *psz_mmssff)
else else
return CDIO_INVALID_LBA; return CDIO_INVALID_LBA;
} }
if('\0' != c) if('\0' != c)
return CDIO_INVALID_LBA; return CDIO_INVALID_LBA;
if(psz_field >= CDIO_CD_FRAMES_PER_SEC) if(psz_field >= CDIO_CD_FRAMES_PER_SEC)
return CDIO_INVALID_LBA; return CDIO_INVALID_LBA;
ret += psz_field; ret += psz_field;
return ret; return ret;
} }
/* /*
* Local variables: * Local variables:
* c-file-style: "gnu" * c-file-style: "gnu"
* tab-width: 8 * tab-width: 8

View file

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2003, 2004, 2005, 2008, 2011, 2012 Copyright (C) 2003-2005, 2008, 2011-2013
Rocky Bernstein <rocky@gnu.org> Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@ -25,13 +25,13 @@
#ifdef HAVE_STDBOOL_H #ifdef HAVE_STDBOOL_H
# include <stdbool.h> # include <stdbool.h>
#endif #endif
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/logging.h> #include <cdio/logging.h>
#include "cdio_private.h" #include "cdio_private.h"
const char *track_format2str[6] = const char *track_format2str[6] =
{ {
"audio", "CD-i", "XA", "data", "PSX", "error" "audio", "CD-i", "XA", "data", "PSX", "error"
}; };
@ -40,7 +40,7 @@ const char *track_format2str[6] =
enum cdio_track_enums; enum cdio_track_enums;
/*! /*!
Return the number of the first track. Return the number of the first track.
CDIO_INVALID_TRACK is returned on error. CDIO_INVALID_TRACK is returned on error.
*/ */
track_t track_t
@ -50,7 +50,7 @@ cdio_get_first_track_num(const CdIo_t *p_cdio)
cdio_info("Null CdIo object passed\n"); cdio_info("Null CdIo object passed\n");
return CDIO_INVALID_TRACK; return CDIO_INVALID_TRACK;
} }
if (p_cdio->op.get_first_track_num) { if (p_cdio->op.get_first_track_num) {
return p_cdio->op.get_first_track_num (p_cdio->env); return p_cdio->op.get_first_track_num (p_cdio->env);
@ -74,9 +74,9 @@ cdio_get_last_track_num (const CdIo_t *p_cdio)
{ {
const track_t i_first_track = cdio_get_first_track_num(p_cdio); const track_t i_first_track = cdio_get_first_track_num(p_cdio);
if ( CDIO_INVALID_TRACK != i_first_track ) { if ( CDIO_INVALID_TRACK != i_first_track ) {
const track_t i_tracks = cdio_get_num_tracks(p_cdio); const track_t u_tracks = cdio_get_num_tracks(p_cdio);
if ( CDIO_INVALID_TRACK != i_tracks ) if ( CDIO_INVALID_TRACK != u_tracks )
return i_first_track + i_tracks - 1; return i_first_track + u_tracks - 1;
} }
return CDIO_INVALID_TRACK; return CDIO_INVALID_TRACK;
} }
@ -87,19 +87,21 @@ cdio_get_last_track_num (const CdIo_t *p_cdio)
Not meaningful if track is not an audio track. Not meaningful if track is not an audio track.
*/ */
int int
cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_channels(const CdIo_t *p_cdio, track_t u_track)
{ {
track_t u_last_track;
if (NULL == p_cdio) { if (NULL == p_cdio) {
cdio_info("Null CdIo object passed\n"); cdio_info("Null CdIo object passed\n");
return -1; return -1;
} }
if (i_track > CDIO_CD_MAX_TRACKS) { u_last_track = cdio_get_last_track_num(p_cdio);
if (u_track > u_last_track) {
cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n", cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n",
i_track, CDIO_CD_MAX_TRACKS); u_track, u_last_track);
return -1; return -1;
} }
if (p_cdio->op.get_track_channels) { if (p_cdio->op.get_track_channels) {
return p_cdio->op.get_track_channels (p_cdio->env, i_track); return p_cdio->op.get_track_channels (p_cdio->env, u_track);
} else { } else {
return -2; return -2;
} }
@ -109,44 +111,44 @@ cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track)
if not an audio track? if not an audio track?
*/ */
track_flag_t track_flag_t
cdio_get_track_copy_permit(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_copy_permit(const CdIo_t *p_cdio, track_t u_track)
{ {
if (p_cdio->op.get_track_copy_permit) { if (p_cdio->op.get_track_copy_permit) {
return p_cdio->op.get_track_copy_permit (p_cdio->env, i_track); return p_cdio->op.get_track_copy_permit (p_cdio->env, u_track);
} else { } else {
return CDIO_TRACK_FLAG_UNKNOWN; return CDIO_TRACK_FLAG_UNKNOWN;
} }
} }
/*! /*!
Get format of track. Get format of track.
*/ */
track_format_t track_format_t
cdio_get_track_format(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_format(const CdIo_t *p_cdio, track_t u_track)
{ {
if (!p_cdio) return TRACK_FORMAT_ERROR; if (!p_cdio) return TRACK_FORMAT_ERROR;
if (p_cdio->op.get_track_format) { if (p_cdio->op.get_track_format) {
return p_cdio->op.get_track_format (p_cdio->env, i_track); return p_cdio->op.get_track_format (p_cdio->env, u_track);
} else { } else {
return TRACK_FORMAT_ERROR; return TRACK_FORMAT_ERROR;
} }
} }
/*! /*!
Return the Joliet level recognized for p_cdio. Return the Joliet level recognized for p_cdio.
*/ */
uint8_t uint8_t
cdio_get_joliet_level(const CdIo_t *p_cdio) cdio_get_joliet_level(const CdIo_t *p_cdio)
{ {
if (!p_cdio) return 0; if (!p_cdio) return 0;
{ {
const generic_img_private_t *p_env const generic_img_private_t *p_env
= (generic_img_private_t *) (p_cdio->env); = (generic_img_private_t *) (p_cdio->env);
return p_env->i_joliet_level; return p_env->i_joliet_level;
} }
} }
/*! /*!
Return the number of tracks in the current medium. Return the number of tracks in the current medium.
CDIO_INVALID_TRACK is returned on error. CDIO_INVALID_TRACK is returned on error.
*/ */
@ -164,8 +166,8 @@ cdio_get_num_tracks (const CdIo_t *p_cdio)
/*! Find the track which contans lsn. /*! Find the track which contans lsn.
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
if there was some error. if there was some error.
If the lsn is before the pregap of the first track 0 is returned. If the lsn is before the pregap of the first track 0 is returned.
Otherwise we return the track that spans the lsn. Otherwise we return the track that spans the lsn.
*/ */
@ -173,18 +175,19 @@ track_t
cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn) cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn)
{ {
if (!p_cdio) return CDIO_INVALID_TRACK; if (!p_cdio) return CDIO_INVALID_TRACK;
{ {
track_t i_low_track = cdio_get_first_track_num(p_cdio); track_t i_low_track = cdio_get_first_track_num(p_cdio);
track_t i_high_track = cdio_get_last_track_num(p_cdio)+1; /* LEADOUT */ track_t i_high_track = cdio_get_last_track_num(p_cdio)+1;
track_t i_lead_track = i_high_track;
if (CDIO_INVALID_TRACK == i_low_track if (CDIO_INVALID_TRACK == i_low_track
|| CDIO_INVALID_TRACK == i_high_track ) return CDIO_INVALID_TRACK; || CDIO_INVALID_TRACK == i_high_track ) return CDIO_INVALID_TRACK;
if (lsn < cdio_get_track_lsn(p_cdio, i_low_track)) if (lsn < cdio_get_track_lsn(p_cdio, i_low_track))
return 0; /* We're in the pre-gap of first track */ return 0; /* We're in the pre-gap of first track */
if (lsn > cdio_get_track_lsn(p_cdio, i_high_track)) if (lsn > cdio_get_track_lsn(p_cdio, CDIO_CDROM_LEADOUT_TRACK))
return CDIO_INVALID_TRACK; /* We're beyond the end. */ return CDIO_INVALID_TRACK; /* We're beyond the end. */
do { do {
@ -194,8 +197,14 @@ cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn)
if (lsn >= i_mid_lsn) i_low_track = i_mid + 1; if (lsn >= i_mid_lsn) i_low_track = i_mid + 1;
} while ( i_low_track <= i_high_track ); } while ( i_low_track <= i_high_track );
return (i_low_track > i_high_track + 1) if (i_low_track > i_high_track + 1) {
? i_high_track + 1 : i_high_track; i_high_track++;
}
if (i_high_track == i_lead_track ) {
return CDIO_CDROM_LEADOUT_TRACK;
} else {
return i_high_track;
}
} }
} }
@ -204,24 +213,24 @@ cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn)
XA data (green, mode2 form2). That is track begins: XA data (green, mode2 form2). That is track begins:
sync - header - subheader sync - header - subheader
12 4 - 8 12 4 - 8
FIXME: there's gotta be a better design for this and get_track_format? FIXME: there's gotta be a better design for this and get_track_format?
*/ */
bool bool
cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_green(const CdIo_t *p_cdio, track_t u_track)
{ {
if (p_cdio == NULL) { if (p_cdio == NULL) {
return false; return false;
} }
if (p_cdio->op.get_track_green) { if (p_cdio->op.get_track_green) {
return p_cdio->op.get_track_green (p_cdio->env, i_track); return p_cdio->op.get_track_green (p_cdio->env, u_track);
} else { } else {
return false; return false;
} }
} }
/*! /*!
Return the starting LBA for track number Return the starting LBA for track number
track_num in cdio. Tracks numbers start at 1. track_num in cdio. Tracks numbers start at 1.
The "leadout" track is specified either by The "leadout" track is specified either by
@ -229,7 +238,7 @@ cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track)
CDIO_INVALID_LBA is returned on error. CDIO_INVALID_LBA is returned on error.
*/ */
lba_t lba_t
cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_lba(const CdIo_t *p_cdio, track_t u_track)
{ {
if (NULL == p_cdio) { if (NULL == p_cdio) {
cdio_info("Null CdIo object passed\n"); cdio_info("Null CdIo object passed\n");
@ -237,42 +246,45 @@ cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track)
} }
if (p_cdio->op.get_track_lba) { if (p_cdio->op.get_track_lba) {
return p_cdio->op.get_track_lba (p_cdio->env, i_track); return p_cdio->op.get_track_lba (p_cdio->env, u_track);
} else { } else {
msf_t msf; msf_t msf;
if (p_cdio->op.get_track_msf) if (p_cdio->op.get_track_msf)
if (cdio_get_track_msf(p_cdio, i_track, &msf)) if (cdio_get_track_msf(p_cdio, u_track, &msf))
return cdio_msf_to_lba(&msf); return cdio_msf_to_lba(&msf);
return CDIO_INVALID_LBA; return CDIO_INVALID_LBA;
} }
} }
/*! /*!
Return the starting LSN for track number Return the starting LSN for track number
i_track in cdio. Tracks numbers start at 1. u_track in cdio. Tracks numbers start at 1.
The "leadout" track is specified either by The "leadout" track is specified either by
using i_track LEADOUT_TRACK or the total tracks+1. using u_track LEADOUT_TRACK or the total tracks+1.
CDIO_INVALID_LSN is returned on error. CDIO_INVALID_LSN is returned on error.
*/ */
lsn_t lsn_t
cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_lsn(const CdIo_t *p_cdio, track_t u_track)
{ {
/*track_t u_last_track; */
if (NULL == p_cdio) { if (NULL == p_cdio) {
cdio_info("Null CdIo object passed\n"); cdio_info("Null CdIo object passed\n");
return CDIO_INVALID_LSN; return CDIO_INVALID_LSN;
} }
if (i_track > CDIO_CD_MAX_TRACKS && i_track != CDIO_CDROM_LEADOUT_TRACK) { /*
u_last_track = cdio_get_last_track_num(p_cdio);
if (u_track > u_last_track && u_track != CDIO_CDROM_LEADOUT_TRACK) {
cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n", cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n",
i_track, CDIO_CD_MAX_TRACKS); u_track, u_last_track);
return CDIO_INVALID_LSN; return CDIO_INVALID_LSN;
} }
*/
if (p_cdio->op.get_track_lba) { if (p_cdio->op.get_track_lba) {
return cdio_lba_to_lsn(p_cdio->op.get_track_lba (p_cdio->env, i_track)); return cdio_lba_to_lsn(p_cdio->op.get_track_lba (p_cdio->env, u_track));
} else { } else {
msf_t msf; msf_t msf;
if (cdio_get_track_msf(p_cdio, i_track, &msf)) if (cdio_get_track_msf(p_cdio, u_track, &msf))
return cdio_msf_to_lsn(&msf); return cdio_msf_to_lsn(&msf);
return CDIO_INVALID_LSN; return CDIO_INVALID_LSN;
} }
@ -280,39 +292,41 @@ cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track)
/*! /*!
Return the International Standard Recording Code (ISRC) for track number Return the International Standard Recording Code (ISRC) for track number
i_track in p_cdio. Track numbers start at 1. u_track in p_cdio. Track numbers start at 1.
Note: string is malloc'd so caller has to free() the returned Note: string is malloc'd so caller has to free() the returned
string when done with it. string when done with it.
*/ */
char * char *
cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track) cdio_get_track_isrc (const CdIo_t *p_cdio, track_t u_track)
{ {
track_t u_last_track;
if (NULL == p_cdio) { if (NULL == p_cdio) {
cdio_info("Null CdIo object passed\n"); cdio_info("Null CdIo object passed\n");
return NULL; return NULL;
} }
if (i_track > CDIO_CD_MAX_TRACKS) { u_last_track = cdio_get_last_track_num(p_cdio);
if (u_track > u_last_track) {
cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n", cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n",
i_track, CDIO_CD_MAX_TRACKS); u_track, u_last_track);
return NULL; return NULL;
} }
if (p_cdio->op.get_track_isrc) { if (p_cdio->op.get_track_isrc) {
return p_cdio->op.get_track_isrc (p_cdio->env, i_track); return p_cdio->op.get_track_isrc (p_cdio->env, u_track);
} else { } else {
return NULL; return NULL;
} }
} }
/*! /*!
Return the starting LBA for the pregap for track number Return the starting LBA for the pregap for track number
i_track in cdio. Track numbers start at 1. u_track in cdio. Track numbers start at 1.
CDIO_INVALID_LBA is returned on error. CDIO_INVALID_LBA is returned on error.
*/ */
lba_t lba_t
cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t u_track)
{ {
if (NULL == p_cdio) { if (NULL == p_cdio) {
cdio_info("Null CdIo object passed\n"); cdio_info("Null CdIo object passed\n");
@ -320,53 +334,53 @@ cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track)
} }
if (p_cdio->op.get_track_pregap_lba) { if (p_cdio->op.get_track_pregap_lba) {
return p_cdio->op.get_track_pregap_lba (p_cdio->env, i_track); return p_cdio->op.get_track_pregap_lba (p_cdio->env, u_track);
} else { } else {
return CDIO_INVALID_LBA; return CDIO_INVALID_LBA;
} }
} }
/*! /*!
Return the starting LSN for the pregap for track number Return the starting LSN for the pregap for track number
i_track in cdio. Track numbers start at 1. u_track in cdio. Track numbers start at 1.
CDIO_INVALID_LSN is returned on error. CDIO_INVALID_LSN is returned on error.
*/ */
lsn_t lsn_t
cdio_get_track_pregap_lsn(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_pregap_lsn(const CdIo_t *p_cdio, track_t u_track)
{ {
return cdio_lba_to_lsn(cdio_get_track_pregap_lba(p_cdio, i_track)); return cdio_lba_to_lsn(cdio_get_track_pregap_lba(p_cdio, u_track));
} }
/*! /*!
Return the ending LSN for track number Return the ending LSN for track number
i_track in cdio. CDIO_INVALID_LSN is returned on error. u_track in cdio. CDIO_INVALID_LSN is returned on error.
*/ */
lsn_t lsn_t
cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t u_track)
{ {
lsn_t lsn = cdio_get_track_lsn(p_cdio, i_track+1); lsn_t lsn = cdio_get_track_lsn(p_cdio, u_track+1);
if (CDIO_INVALID_LSN == lsn) return CDIO_INVALID_LSN; if (CDIO_INVALID_LSN == lsn) return CDIO_INVALID_LSN;
/* Safe, we've always the leadout. */ /* Safe, we've always the leadout. */
return lsn - 1; return lsn - 1;
} }
/*! /*!
Return the starting MSF (minutes/secs/frames) for track number Return the starting MSF (minutes/secs/frames) for track number
i_track in cdio. Track numbers start at 1. u_track in cdio. Track numbers start at 1.
The "leadout" track is specified either by The "leadout" track is specified either by
using i_track LEADOUT_TRACK or the total tracks+1. using u_track LEADOUT_TRACK or the total tracks+1.
False is returned if there is no track entry. False is returned if there is no track entry.
*/ */
bool bool
cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track, /*out*/ msf_t *msf) cdio_get_track_msf(const CdIo_t *p_cdio, track_t u_track, /*out*/ msf_t *msf)
{ {
if (!p_cdio) return false; if (!p_cdio) return false;
if (p_cdio->op.get_track_msf) { if (p_cdio->op.get_track_msf) {
return p_cdio->op.get_track_msf (p_cdio->env, i_track, msf); return p_cdio->op.get_track_msf (p_cdio->env, u_track, msf);
} else if (p_cdio->op.get_track_lba) { } else if (p_cdio->op.get_track_lba) {
lba_t lba = p_cdio->op.get_track_lba (p_cdio->env, i_track); lba_t lba = p_cdio->op.get_track_lba (p_cdio->env, u_track);
if (lba == CDIO_INVALID_LBA) return false; if (lba == CDIO_INVALID_LBA) return false;
cdio_lba_to_msf(lba, msf); cdio_lba_to_msf(lba, msf);
return true; return true;
@ -379,28 +393,28 @@ cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track, /*out*/ msf_t *msf)
if not an audio track? if not an audio track?
*/ */
track_flag_t track_flag_t
cdio_get_track_preemphasis(const CdIo *p_cdio, track_t i_track) cdio_get_track_preemphasis(const CdIo *p_cdio, track_t u_track)
{ {
if (p_cdio->op.get_track_preemphasis) { if (p_cdio->op.get_track_preemphasis) {
return p_cdio->op.get_track_preemphasis (p_cdio->env, i_track); return p_cdio->op.get_track_preemphasis (p_cdio->env, u_track);
} else { } else {
return CDIO_TRACK_FLAG_UNKNOWN; return CDIO_TRACK_FLAG_UNKNOWN;
} }
} }
/*! /*!
Return the number of sectors between this track an the next. This Return the number of sectors between this track an the next. This
includes any pregap sectors before the start of the next track. includes any pregap sectors before the start of the next track.
Tracks start at 1. Tracks start at 1.
0 is returned if there is an error. 0 is returned if there is an error.
*/ */
unsigned int unsigned int
cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t i_track) cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t u_track)
{ {
const track_t i_tracks = cdio_get_num_tracks(p_cdio); const track_t u_tracks = cdio_get_num_tracks(p_cdio);
if (i_track >=1 && i_track <= i_tracks) if (u_track >=1 && u_track <= u_tracks)
return ( cdio_get_track_lba(p_cdio, i_track+1) return ( cdio_get_track_lba(p_cdio, u_track+1)
- cdio_get_track_lba(p_cdio, i_track) ); - cdio_get_track_lba(p_cdio, u_track) );
return 0; return 0;
} }

View file

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329 IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.3.3.246" CAPTION "Rufus v1.3.3.247"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -276,8 +276,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,3,246 FILEVERSION 1,3,3,247
PRODUCTVERSION 1,3,3,246 PRODUCTVERSION 1,3,3,247
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -294,13 +294,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.3.3.246" VALUE "FileVersion", "1.3.3.247"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "(c) 2011-2013 Pete Batard (GPL v3)" VALUE "LegalCopyright", "(c) 2011-2013 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.3.3.246" VALUE "ProductVersion", "1.3.3.247"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"