Break out track and disc routines. (Disc needs more work)

Add more convenience track routines.
Set access-mode for image routines to be the image drivers - for uniformity.
Some name regularization.
And we're in 2005 now.
This commit is contained in:
rocky
2005-01-04 04:33:36 +00:00
parent d72c6b8e40
commit f226947ec6
19 changed files with 581 additions and 348 deletions

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.16 2004/12/31 05:47:36 rocky Exp $ # $Id: Makefile.am,v 1.17 2005/01/04 04:33:36 rocky Exp $
# #
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
# #
@@ -31,6 +31,7 @@ libcdioinclude_HEADERS = \
cdtext.h \ cdtext.h \
cdtext.h \ cdtext.h \
cd_types.h \ cd_types.h \
disc.h \
ds.h \ ds.h \
dvd.h \ dvd.h \
iso9660.h \ iso9660.h \

View File

@@ -1,8 +1,8 @@
/* -*- c -*- /* -*- c -*-
$Id: cdio.h,v 1.71 2005/01/02 22:43:41 rocky Exp $ $Id: cdio.h,v 1.72 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -129,8 +129,6 @@ extern "C" {
#define CDIO_MAX_DRIVER DRIVER_NRG #define CDIO_MAX_DRIVER DRIVER_NRG
#define CDIO_MAX_DEVICE_DRIVER DRIVER_WIN32 #define CDIO_MAX_DEVICE_DRIVER DRIVER_WIN32
extern const char *discmode2str[];
/*! 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];
@@ -254,13 +252,6 @@ extern "C" {
char ** cdio_get_devices_ret (/*in/out*/ driver_id_t *p_driver_id); char ** cdio_get_devices_ret (/*in/out*/ driver_id_t *p_driver_id);
/*!
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
that we've got. The notion of "CD" is extended a little to include
DVD's.
*/
discmode_t cdio_get_discmode (CdIo_t *p_cdio);
/*! /*!
Get the what kind of device we've got. Get the what kind of device we've got.
@@ -309,14 +300,6 @@ extern "C" {
*/ */
driver_id_t cdio_get_driver_id (const CdIo_t *p_cdio); driver_id_t cdio_get_driver_id (const CdIo_t *p_cdio);
/*!
Get the number of the first track.
@return the track number or CDIO_INVALID_TRACK
on error.
*/
track_t cdio_get_first_track_num(const CdIo_t *p_cdio);
/*! /*!
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command. Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
False is returned if we had an error getting the information. False is returned if we had an error getting the information.
@@ -325,41 +308,6 @@ extern "C" {
/* out*/ cdio_hwinfo_t *p_hw_info ); /* out*/ cdio_hwinfo_t *p_hw_info );
/*!
Return the Joliet level recognized for p_cdio.
*/
uint8_t cdio_get_joliet_level(const CdIo_t *p_cdio);
/*!
Get the media catalog number (MCN) from the CD.
@return the media catalog number r NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * cdio_get_mcn (const CdIo_t *p_cdio);
/*!
Get the number of tracks on the CD.
@return the number of tracks, or CDIO_INVALID_TRACK if there is
an error.
*/
track_t cdio_get_num_tracks (const CdIo_t *p_cdio);
/*!
Reposition read offset
Similar to (if not the same as) libc's lseek()
@param p_cdio object to get information from
@param offset amount to seek
@param whence like corresponding parameter in libc's lseek, e.g.
SEEK_SET or SEEK_END.
@return (off_t) -1 on error.
*/
off_t cdio_lseek(const CdIo_t *p_cdio, off_t offset, int whence); off_t cdio_lseek(const CdIo_t *p_cdio, off_t offset, int whence);
/*! /*!
@@ -955,5 +903,7 @@ extern "C" {
/* Track-related functions. */ /* Track-related functions. */
#include <cdio/track.h> #include <cdio/track.h>
/* Disc-related functions. */
#include <cdio/disc.h>
#endif /* __CDIO_H__ */ #endif /* __CDIO_H__ */

95
include/cdio/disc.h Normal file
View File

@@ -0,0 +1,95 @@
/* -*- c -*-
$Id: disc.h,v 1.1 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** \file dic.h
* \brief The top-level header for disc-related libcdio calls
*/
#ifndef __CDIO_DISC_H__
#define __CDIO_DISC_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern const char *discmode2str[];
/*!
Get the lsn of the end of the CD
@return the leadout LSN or CDIO_INVALID_LSN if there is an error.
*/
unsigned int cdio_get_disc_last_lsn(const CdIo *p_cdio);
/*!
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
that we've got. The notion of "CD" is extended a little to include
DVD's.
*/
discmode_t cdio_get_discmode (CdIo_t *p_cdio);
/*!
Get the lsn of the end of the CD
@return the leadout LSN or CDIO_INVALID_LSN if there is an error.
*/
unsigned int cdio_get_disc_last_lsn(const CdIo *p_cdio);
/*!
Return the Joliet level recognized for p_cdio.
*/
uint8_t cdio_get_joliet_level(const CdIo_t *p_cdio);
/*!
Get the media catalog number (MCN) from the CD.
@return the media catalog number r NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * cdio_get_mcn (const CdIo_t *p_cdio);
/*!
Get the number of tracks on the CD.
@return the number of tracks, or CDIO_INVALID_TRACK if there is
an error.
*/
track_t cdio_get_num_tracks (const CdIo_t *p_cdio);
/*!
Reposition read offset
Similar to (if not the same as) libc's lseek()
@param p_cdio object to get information from
@param offset amount to seek
@param whence like corresponding parameter in libc's lseek, e.g.
SEEK_SET or SEEK_END.
@return (off_t) -1 on error.
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CDIO_DISC_H__ */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: sector.h,v 1.30 2005/01/01 14:19:19 rocky Exp $ $Id: sector.h,v 1.31 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -173,23 +173,10 @@ typedef enum {
#define CDIO_CDROM_CDI_TRACK 0x10 #define CDIO_CDROM_CDI_TRACK 0x10
#define CDIO_CDROM_XA_TRACK 0x20 #define CDIO_CDROM_XA_TRACK 0x20
/*! The leadout track is always 0xAA, regardless of # of tracks on
disc, or what value may be used internally. For example although
OS X uses a different value for the lead-out track internally than
given below, programmers should use CDIO_CDROM_LEADOUT_TRACK and
not worry about this.
*/
#define CDIO_CDROM_LEADOUT_TRACK 0xAA
#define M2F2_SECTOR_SIZE 2324 #define M2F2_SECTOR_SIZE 2324
#define M2SUB_SECTOR_SIZE 2332 #define M2SUB_SECTOR_SIZE 2332
#define M2RAW_SECTOR_SIZE 2336 #define M2RAW_SECTOR_SIZE 2336
/*! Largest CD track number */
#define CDIO_CD_MAX_TRACKS 99
/*! Smallest CD track number */
#define CDIO_CD_MIN_TRACK_NO 1
/*! Largest CD session number */ /*! Largest CD session number */
#define CDIO_CD_MAX_SESSIONS 99 #define CDIO_CD_MAX_SESSIONS 99
/*! Smallest CD session number */ /*! Smallest CD session number */

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- c -*-
$Id: track.h,v 1.2 2005/01/02 22:43:41 rocky Exp $ $Id: track.h,v 1.3 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -24,6 +24,24 @@
#ifndef __CDIO_TRACK_H__ #ifndef __CDIO_TRACK_H__
#define __CDIO_TRACK_H__ #define __CDIO_TRACK_H__
/*! The leadout track is always 0xAA, regardless of # of tracks on
disc, or what value may be used internally. For example although
OS X uses a different value for the lead-out track internally than
given below, programmers should use CDIO_CDROM_LEADOUT_TRACK and
not worry about this.
*/
#define CDIO_CDROM_LEADOUT_TRACK 0xAA
/*! Largest CD track number */
#define CDIO_CD_MAX_TRACKS 99
/*! Smallest CD track number */
#define CDIO_CD_MIN_TRACK_NO 1
/*!
Constant for invalid track number
*/
#define CDIO_INVALID_TRACK 0xFF
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
@@ -52,6 +70,30 @@ extern "C" {
int channels; int channels;
} track_flags_t; } track_flags_t;
/*!
Get the number of the first track.
@return the track number or CDIO_INVALID_TRACK
on error.
*/
track_t cdio_get_first_track_num(const CdIo_t *p_cdio);
/*!
Return the last track number.
CDIO_INVALID_TRACK is returned on error.
*/
track_t cdio_get_last_track_num (const CdIo_t *p_cdio);
/*! Find the track which contans lsn.
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
if there was some error.
If the lsn is before the pregap of the first track 0 is returned.
Otherwise we return the track that spans the lsn.
*/
track_t cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn);
/*! Return number of channels in track: 2 or 4; -2 if not /*! Return number of channels in track: 2 or 4; -2 if not
implemented or -1 for error. implemented or -1 for error.
Not meaningful if track is not an audio track. Not meaningful if track is not an audio track.
@@ -76,8 +118,14 @@ extern "C" {
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 *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
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);
/*! /*!
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
@@ -90,7 +138,7 @@ extern "C" {
@param i_track the track number we want the LSN for @param i_track the track number we want the LSN for
@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 *p_cdio, track_t i_track); lba_t cdio_get_track_lba(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
@@ -104,7 +152,7 @@ extern "C" {
@param i_track the track number we want the LSN for @param i_track the track number we want the LSN for
@return the starting LSN or CDIO_INVALID_LSN on error. @return the starting LSN or CDIO_INVALID_LSN on error.
*/ */
lsn_t cdio_get_track_lsn(const CdIo *p_cdio, track_t i_track); lsn_t cdio_get_track_lsn(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
@@ -116,13 +164,14 @@ extern "C" {
@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 *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 *p_cdio, track_t i_track); track_flag_t cdio_get_track_preemphasis(const CdIo_t *p_cdio,
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
@@ -132,11 +181,11 @@ extern "C" {
@return the number of sectors or 0 if there is an error. @return the number of sectors or 0 if there is an error.
*/ */
unsigned int cdio_get_track_sec_count(const CdIo *p_cdio, track_t i_track); unsigned int cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t i_track);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __CDIO_H__ */ #endif /* __CDIO_TRACK_H__ */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: types.h,v 1.24 2004/12/18 17:29:32 rocky Exp $ $Id: types.h,v 1.25 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -221,11 +221,6 @@ extern "C" {
/*! The type of a track number 0..99. */ /*! The type of a track number 0..99. */
typedef uint8_t track_t; typedef uint8_t track_t;
/*!
Constant for invalid track number
*/
#define CDIO_INVALID_TRACK 0xFF
/*! The type of a session number 0..99. */ /*! The type of a session number 0..99. */
typedef uint8_t session_t; typedef uint8_t session_t;

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.2 2004/12/31 07:51:43 rocky Exp $ # $Id: Makefile.am,v 1.3 2005/01/04 04:33:36 rocky Exp $
# #
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
# #
@@ -66,6 +66,7 @@ libcdio_sources = \
cdio.c \ cdio.c \
cdtext.c \ cdtext.c \
cdtext_private.h \ cdtext_private.h \
disc.c \
ds.c \ ds.c \
FreeBSD/freebsd.c \ FreeBSD/freebsd.c \
FreeBSD/freebsd.h \ FreeBSD/freebsd.h \
@@ -88,6 +89,7 @@ libcdio_sources = \
scsi_mmc.c \ scsi_mmc.c \
scsi_mmc_private.h \ scsi_mmc_private.h \
sector.c \ sector.c \
track.c \
util.c util.c
lib_LTLIBRARIES = libcdio.la lib_LTLIBRARIES = libcdio.la

View File

@@ -1,7 +1,7 @@
/* /*
$Id: cdio.c,v 1.4 2005/01/02 22:43:41 rocky Exp $ $Id: cdio.c,v 1.5 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -39,7 +39,7 @@
#include <cdio/logging.h> #include <cdio/logging.h>
#include "cdio_private.h" #include "cdio_private.h"
static const char _rcsid[] = "$Id: cdio.c,v 1.4 2005/01/02 22:43:41 rocky Exp $"; static const char _rcsid[] = "$Id: cdio.c,v 1.5 2005/01/04 04:33:36 rocky Exp $";
const char *track_format2str[6] = const char *track_format2str[6] =
@@ -489,21 +489,6 @@ cdio_get_devices_with_cap_ret (/*out*/ char* search_devices[],
return drives_ret; return drives_ret;
} }
/*!
Get medium associated with cd_obj.
*/
discmode_t
cdio_get_discmode (CdIo *cd_obj)
{
if (cd_obj == NULL) return CDIO_DISC_MODE_ERROR;
if (cd_obj->op.get_discmode) {
return cd_obj->op.get_discmode (cd_obj->env);
} else {
return CDIO_DISC_MODE_NO_INFO;
}
}
/*! /*!
Return the the kind of drive capabilities of device. Return the the kind of drive capabilities of device.
@@ -578,23 +563,6 @@ cdio_get_driver_id (const CdIo *cdio)
return cdio->driver_id; return cdio->driver_id;
} }
/*!
Return the number of the first track.
CDIO_INVALID_TRACK is returned on error.
*/
track_t
cdio_get_first_track_num (const CdIo *p_cdio)
{
if (NULL == p_cdio) return CDIO_INVALID_TRACK;
if (p_cdio->op.get_first_track_num) {
return p_cdio->op.get_first_track_num (p_cdio->env);
} else {
return CDIO_INVALID_TRACK;
}
}
/*! /*!
Return a string containing the name of the driver in use. Return a string containing the name of the driver in use.
if CdIo is NULL (we haven't initialized a specific device driver), if CdIo is NULL (we haven't initialized a specific device driver),
@@ -613,218 +581,12 @@ cdio_get_hwinfo (const CdIo *p_cdio, cdio_hwinfo_t *hw_info)
} }
} }
/*!
Return a string containing the name of the driver in use.
if CdIo is NULL (we haven't initialized a specific device driver),
then return NULL.
*/
char *
cdio_get_mcn (const CdIo *p_cdio)
{
if (p_cdio->op.get_mcn) {
return p_cdio->op.get_mcn (p_cdio->env);
} else {
return NULL;
}
}
/*!
Return the number of tracks in the current medium.
CDIO_INVALID_TRACK is returned on error.
*/
track_t
cdio_get_num_tracks (const CdIo *p_cdio)
{
if (p_cdio == NULL) return CDIO_INVALID_TRACK;
if (p_cdio->op.get_num_tracks) {
return p_cdio->op.get_num_tracks (p_cdio->env);
} else {
return CDIO_INVALID_TRACK;
}
}
/*! Return number of channels in track: 2 or 4; -2 if not
implemented or -1 for error.
Not meaningful if track is not an audio track.
*/
int
cdio_get_track_channels(const CdIo *p_cdio, track_t i_track)
{
if (p_cdio->op.get_track_channels) {
return p_cdio->op.get_track_channels (p_cdio->env, i_track);
} else {
return -2;
}
}
/*! Return copy protection status on a track. Is this meaningful
if not an audio track?
*/
track_flag_t
cdio_get_track_copy_permit(const CdIo *p_cdio, track_t i_track)
{
if (p_cdio->op.get_track_copy_permit) {
return p_cdio->op.get_track_copy_permit (p_cdio->env, i_track);
} else {
return CDIO_TRACK_FLAG_UNKNOWN;
}
}
/*!
Get format of track.
*/
track_format_t
cdio_get_track_format(const CdIo *p_cdio, track_t i_track)
{
if (!p_cdio) return TRACK_FORMAT_ERROR;
if (p_cdio->op.get_track_format) {
return p_cdio->op.get_track_format (p_cdio->env, i_track);
} else {
return TRACK_FORMAT_ERROR;
}
}
/*!
Return true if we have XA data (green, mode2 form1) or
XA data (green, mode2 form2). That is track begins:
sync - header - subheader
12 4 - 8
FIXME: there's gotta be a better design for this and get_track_format?
*/
bool
cdio_get_track_green(const CdIo *cdio, track_t track_num)
{
cdio_assert (cdio != NULL);
if (cdio->op.get_track_green) {
return cdio->op.get_track_green (cdio->env, track_num);
} else {
return false;
}
}
/*!
Return the starting LBA for track number
track_num in cdio. Tracks numbers start at 1.
The "leadout" track is specified either by
using track_num LEADOUT_TRACK or the total tracks+1.
CDIO_INVALID_LBA is returned on error.
*/
lba_t
cdio_get_track_lba(const CdIo *cdio, track_t track_num)
{
if (cdio == NULL) return CDIO_INVALID_LBA;
if (cdio->op.get_track_lba) {
return cdio->op.get_track_lba (cdio->env, track_num);
} else {
msf_t msf;
if (cdio->op.get_track_msf)
if (cdio_get_track_msf(cdio, track_num, &msf))
return cdio_msf_to_lba(&msf);
return CDIO_INVALID_LBA;
}
}
/*!
Return the starting LSN for track number
track_num in cdio. Tracks numbers start at 1.
The "leadout" track is specified either by
using track_num LEADOUT_TRACK or the total tracks+1.
CDIO_INVALID_LBA is returned on error.
*/
lsn_t
cdio_get_track_lsn(const CdIo *cdio, track_t track_num)
{
if (cdio == NULL) return CDIO_INVALID_LBA;
if (cdio->op.get_track_lba) {
return cdio_lba_to_lsn(cdio->op.get_track_lba (cdio->env, track_num));
} else {
msf_t msf;
if (cdio_get_track_msf(cdio, track_num, &msf))
return cdio_msf_to_lsn(&msf);
return CDIO_INVALID_LSN;
}
}
/*!
Return the starting MSF (minutes/secs/frames) for track number
track_num in cdio. Track numbers start at 1.
The "leadout" track is specified either by
using track_num LEADOUT_TRACK or the total tracks+1.
False is returned if there is no track entry.
*/
bool
cdio_get_track_msf(const CdIo *cdio, track_t track_num, /*out*/ msf_t *msf)
{
cdio_assert (cdio != NULL);
if (cdio->op.get_track_msf) {
return cdio->op.get_track_msf (cdio->env, track_num, msf);
} else if (cdio->op.get_track_lba) {
lba_t lba = cdio->op.get_track_lba (cdio->env, track_num);
if (lba == CDIO_INVALID_LBA) return false;
cdio_lba_to_msf(lba, msf);
return true;
} else {
return false;
}
}
/*! Return copy protection status on a track. Is this meaningful
if not an audio track?
*/
track_flag_t
cdio_get_track_preemphasis(const CdIo *p_cdio, track_t i_track)
{
if (p_cdio->op.get_track_preemphasis) {
return p_cdio->op.get_track_preemphasis (p_cdio->env, i_track);
} else {
return CDIO_TRACK_FLAG_UNKNOWN;
}
}
/*!
Return the number of sectors between this track an the next. This
includes any pregap sectors before the start of the next track.
Tracks start at 1.
0 is returned if there is an error.
*/
unsigned int
cdio_get_track_sec_count(const CdIo *cdio, track_t track_num)
{
track_t num_tracks = cdio_get_num_tracks(cdio);
if (track_num >=1 && track_num <= num_tracks)
return ( cdio_get_track_lba(cdio, track_num+1)
- cdio_get_track_lba(cdio, track_num) );
return 0;
}
bool bool
cdio_have_driver(driver_id_t driver_id) cdio_have_driver(driver_id_t driver_id)
{ {
return (*CdIo_all_drivers[driver_id].have_driver)(); return (*CdIo_all_drivers[driver_id].have_driver)();
} }
/*!
Return the Joliet level recognized for p_cdio.
*/
uint8_t
cdio_get_joliet_level(const CdIo *p_cdio)
{
if (!p_cdio) return 0;
{
const generic_img_private_t *p_env
= (generic_img_private_t *) (p_cdio->env);
return p_env->i_joliet_level;
}
}
bool bool
cdio_is_device(const char *psz_source, driver_id_t driver_id) cdio_is_device(const char *psz_source, driver_id_t driver_id)
{ {

View File

@@ -1,7 +1,7 @@
/* /*
$Id: cdio_private.h,v 1.3 2004/12/31 05:47:36 rocky Exp $ $Id: cdio_private.h,v 1.4 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

65
lib/driver/disc.c Normal file
View File

@@ -0,0 +1,65 @@
/*
$Id: disc.c,v 1.1 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/cdio.h>
#include "cdio_private.h"
/*!
Get medium associated with cd_obj.
*/
discmode_t
cdio_get_discmode (CdIo *cd_obj)
{
if (cd_obj == NULL) return CDIO_DISC_MODE_ERROR;
if (cd_obj->op.get_discmode) {
return cd_obj->op.get_discmode (cd_obj->env);
} else {
return CDIO_DISC_MODE_NO_INFO;
}
}
unsigned int
cdio_get_disc_last_lsn(const CdIo *p_cdio)
{
return cdio_get_track_lsn(p_cdio, CDIO_CDROM_LEADOUT_TRACK);
}
/*!
Return a string containing the name of the driver in use.
if CdIo is NULL (we haven't initialized a specific device driver),
then return NULL.
*/
char *
cdio_get_mcn (const CdIo *p_cdio)
{
if (p_cdio->op.get_mcn) {
return p_cdio->op.get_mcn (p_cdio->env);
} else {
return NULL;
}
}

View File

@@ -1,7 +1,7 @@
/* /*
$Id: generic.h,v 1.4 2005/01/01 15:08:48 rocky Exp $ $Id: generic.h,v 1.5 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/* /*
$Id: image.h,v 1.1 2004/12/18 17:29:32 rocky Exp $ $Id: image.h,v 1.2 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/* /*
$Id: bincue.c,v 1.3 2004/12/31 07:51:43 rocky Exp $ $Id: bincue.c,v 1.4 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
cue parsing routine adapted from cuetools cue parsing routine adapted from cuetools
Copyright (C) 2003 Svend Sanjay Sorensen <ssorensen@fastmail.fm> Copyright (C) 2003 Svend Sanjay Sorensen <ssorensen@fastmail.fm>
@@ -26,7 +26,7 @@
(*.cue). (*.cue).
*/ */
static const char _rcsid[] = "$Id: bincue.c,v 1.3 2004/12/31 07:51:43 rocky Exp $"; static const char _rcsid[] = "$Id: bincue.c,v 1.4 2005/01/04 04:33:36 rocky Exp $";
#include "image.h" #include "image.h"
#include "cdio_assert.h" #include "cdio_assert.h"
@@ -1185,6 +1185,7 @@ cdio_open_cue (const char *psz_cue_name)
_set_arg_image (_data, "cue", psz_cue_name); _set_arg_image (_data, "cue", psz_cue_name);
_set_arg_image (_data, "source", psz_bin_name); _set_arg_image (_data, "source", psz_bin_name);
_set_arg_image (_data, "access-mode", "bincue");
free(psz_bin_name); free(psz_bin_name);
if (_init_bincue(_data)) { if (_init_bincue(_data)) {

View File

@@ -1,7 +1,7 @@
/* /*
$Id: cdrdao.c,v 1.3 2004/12/31 07:51:43 rocky Exp $ $Id: cdrdao.c,v 1.4 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
toc reading routine adapted from cuetools toc reading routine adapted from cuetools
Copyright (C) 2003 Svend Sanjay Sorensen <ssorensen@fastmail.fm> Copyright (C) 2003 Svend Sanjay Sorensen <ssorensen@fastmail.fm>
@@ -25,7 +25,7 @@
(*.cue). (*.cue).
*/ */
static const char _rcsid[] = "$Id: cdrdao.c,v 1.3 2004/12/31 07:51:43 rocky Exp $"; static const char _rcsid[] = "$Id: cdrdao.c,v 1.4 2005/01/04 04:33:36 rocky Exp $";
#include "image.h" #include "image.h"
#include "cdio_assert.h" #include "cdio_assert.h"
@@ -1170,6 +1170,7 @@ cdio_open_cdrdao (const char *psz_cue_name)
_set_arg_image (_data, "cue", psz_cue_name); _set_arg_image (_data, "cue", psz_cue_name);
_set_arg_image (_data, "source", psz_cue_name); _set_arg_image (_data, "source", psz_cue_name);
_set_arg_image (_data, "access-mode", "cdrdao");
if (_init_cdrdao(_data)) { if (_init_cdrdao(_data)) {
return ret; return ret;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: nrg.c,v 1.4 2005/01/01 14:55:58 rocky Exp $ $Id: nrg.c,v 1.5 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
@@ -46,7 +46,7 @@
#include "_cdio_stdio.h" #include "_cdio_stdio.h"
#include "nrg.h" #include "nrg.h"
static const char _rcsid[] = "$Id: nrg.c,v 1.4 2005/01/01 14:55:58 rocky Exp $"; static const char _rcsid[] = "$Id: nrg.c,v 1.5 2005/01/04 04:33:36 rocky Exp $";
/* reader */ /* reader */
@@ -1252,6 +1252,7 @@ cdio_open_nrg (const char *psz_source)
_set_arg_image(_data, "source", (NULL == psz_source) _set_arg_image(_data, "source", (NULL == psz_source)
? DEFAULT_CDIO_DEVICE: psz_source); ? DEFAULT_CDIO_DEVICE: psz_source);
_set_arg_image (_data, "access-mode", "Nero");
_data->psz_cue_name = strdup(_get_arg_image(_data, "source")); _data->psz_cue_name = strdup(_get_arg_image(_data, "source"));

View File

@@ -1,5 +1,5 @@
/* /*
$Id: image_common.c,v 1.2 2005/01/01 15:08:48 rocky Exp $ $Id: image_common.c,v 1.3 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -72,6 +72,7 @@ _free_image (void *p_user_data)
free_if_notnull(p_env->psz_mcn); free_if_notnull(p_env->psz_mcn);
free_if_notnull(p_env->psz_cue_name); free_if_notnull(p_env->psz_cue_name);
free_if_notnull(p_env->psz_access_mode);
cdtext_destroy(&(p_env->gen.cdtext)); cdtext_destroy(&(p_env->gen.cdtext));
cdio_generic_stdio_free(p_env); cdio_generic_stdio_free(p_env);
free(p_env); free(p_env);
@@ -239,27 +240,36 @@ get_track_preemphasis_image(const void *p_user_data, track_t i_track)
0 is returned if no error was found, and nonzero if there as an error. 0 is returned if no error was found, and nonzero if there as an error.
*/ */
int int
_set_arg_image (void *user_data, const char key[], const char value[]) _set_arg_image (void *p_user_data, const char key[], const char value[])
{ {
_img_private_t *env = user_data; _img_private_t *p_env = p_user_data;
if (!strcmp (key, "source")) if (!strcmp (key, "source"))
{ {
free_if_notnull (env->gen.source_name); free_if_notnull (p_env->gen.source_name);
if (!value) if (!value)
return -2; return -2;
env->gen.source_name = strdup (value); p_env->gen.source_name = strdup (value);
} }
else if (!strcmp (key, "cue")) else if (!strcmp (key, "cue"))
{ {
free_if_notnull (env->psz_cue_name); free_if_notnull (p_env->psz_cue_name);
if (!value) if (!value)
return -2; return -2;
env->psz_cue_name = strdup (value); p_env->psz_cue_name = strdup (value);
}
else if (!strcmp (key, "access-mode"))
{
free_if_notnull (p_env->psz_access_mode);
if (!value)
return -2;
p_env->psz_access_mode = strdup (value);
} }
else else
return -1; return -1;

View File

@@ -1,7 +1,7 @@
/* /*
$Id: image_common.h,v 1.3 2004/12/31 07:51:43 rocky Exp $ $Id: image_common.h,v 1.4 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -37,6 +37,10 @@ typedef struct {
internal_position_t pos; internal_position_t pos;
char *psz_cue_name; char *psz_cue_name;
char *psz_access_mode; /* Just the name of the driver.
We add this for regularity with other
real CD drivers which has an access mode.
*/
char *psz_mcn; /* Media Catalog Number (5.22.3) char *psz_mcn; /* Media Catalog Number (5.22.3)
exactly 13 bytes */ exactly 13 bytes */
track_info_t tocent[CDIO_CD_MAX_TRACKS+1]; /* entry info for each track track_info_t tocent[CDIO_CD_MAX_TRACKS+1]; /* entry info for each track

View File

@@ -44,6 +44,7 @@ cdio_get_devices_solaris
cdio_get_devices_win32 cdio_get_devices_win32
cdio_get_devices_with_cap cdio_get_devices_with_cap
cdio_get_devices_with_cap_ret cdio_get_devices_with_cap_ret
cdio_get_disc_last_lsn
cdio_get_discmode cdio_get_discmode
cdio_get_drive_cap cdio_get_drive_cap
cdio_get_drive_cap_dev cdio_get_drive_cap_dev
@@ -52,12 +53,15 @@ cdio_get_driver_name
cdio_get_first_track_num cdio_get_first_track_num
cdio_get_hwinfo cdio_get_hwinfo
cdio_get_joliet_level cdio_get_joliet_level
cdio_get_last_track_num
cdio_get_mcn cdio_get_mcn
cdio_get_num_tracks cdio_get_num_tracks
cdio_get_track
cdio_get_track_channels cdio_get_track_channels
cdio_get_track_copy_permit cdio_get_track_copy_permit
cdio_get_track_format cdio_get_track_format
cdio_get_track_green cdio_get_track_green
cdio_get_track_last_lsn
cdio_get_track_lba cdio_get_track_lba
cdio_get_track_lsn cdio_get_track_lsn
cdio_get_track_msf cdio_get_track_msf

306
lib/driver/track.c Normal file
View File

@@ -0,0 +1,306 @@
/*
$Id: track.c,v 1.1 2005/01/04 04:33:36 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/cdio.h>
#include "cdio_private.h"
/*!
Return the number of the first track.
CDIO_INVALID_TRACK is returned on error.
*/
track_t
cdio_get_first_track_num (const CdIo_t *p_cdio)
{
if (NULL == p_cdio) return CDIO_INVALID_TRACK;
if (p_cdio->op.get_first_track_num) {
return p_cdio->op.get_first_track_num (p_cdio->env);
} else {
return CDIO_INVALID_TRACK;
}
}
/*!
Return the last track number.
CDIO_INVALID_TRACK is returned on error.
*/
track_t
cdio_get_last_track_num (const CdIo_t *p_cdio)
{
if (NULL == p_cdio) return CDIO_INVALID_TRACK;
{
const track_t i_first_track = cdio_get_first_track_num(p_cdio);
if ( CDIO_INVALID_TRACK != i_first_track ) {
const track_t i_tracks = cdio_get_num_tracks(p_cdio);
if ( CDIO_INVALID_TRACK != i_tracks )
return i_first_track + i_tracks - 1;
}
return CDIO_INVALID_TRACK;
}
}
/*! Return number of channels in track: 2 or 4; -2 if not
implemented or -1 for error.
Not meaningful if track is not an audio track.
*/
int
cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track)
{
if (p_cdio->op.get_track_channels) {
return p_cdio->op.get_track_channels (p_cdio->env, i_track);
} else {
return -2;
}
}
/*! Return copy protection status on a track. Is this meaningful
if not an audio track?
*/
track_flag_t
cdio_get_track_copy_permit(const CdIo_t *p_cdio, track_t i_track)
{
if (p_cdio->op.get_track_copy_permit) {
return p_cdio->op.get_track_copy_permit (p_cdio->env, i_track);
} else {
return CDIO_TRACK_FLAG_UNKNOWN;
}
}
/*!
Get format of track.
*/
track_format_t
cdio_get_track_format(const CdIo_t *p_cdio, track_t i_track)
{
if (!p_cdio) return TRACK_FORMAT_ERROR;
if (p_cdio->op.get_track_format) {
return p_cdio->op.get_track_format (p_cdio->env, i_track);
} else {
return TRACK_FORMAT_ERROR;
}
}
/*!
Return the Joliet level recognized for p_cdio.
*/
uint8_t
cdio_get_joliet_level(const CdIo_t *p_cdio)
{
if (!p_cdio) return 0;
{
const generic_img_private_t *p_env
= (generic_img_private_t *) (p_cdio->env);
return p_env->i_joliet_level;
}
}
/*!
Return the number of tracks in the current medium.
CDIO_INVALID_TRACK is returned on error.
*/
track_t
cdio_get_num_tracks (const CdIo_t *p_cdio)
{
if (p_cdio == NULL) return CDIO_INVALID_TRACK;
if (p_cdio->op.get_num_tracks) {
return p_cdio->op.get_num_tracks (p_cdio->env);
} else {
return CDIO_INVALID_TRACK;
}
}
/*! Find the track which contans lsn.
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
if there was some error.
If the lsn is before the pregap of the first track 0 is returned.
Otherwise we return the track that spans the lsn.
*/
track_t
cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn)
{
if (!p_cdio) return CDIO_INVALID_TRACK;
{
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 */
if (CDIO_INVALID_TRACK == i_low_track
|| CDIO_INVALID_TRACK == i_high_track ) return CDIO_INVALID_TRACK;
if (lsn < cdio_get_track_lsn(p_cdio, i_low_track))
return 0; /* We're in the pre-gap of first track */
if (lsn > cdio_get_track_lsn(p_cdio, i_high_track))
return CDIO_INVALID_TRACK; /* We're beyond the end. */
do {
const track_t i_mid = (i_low_track + i_high_track) / 2;
if (lsn <= cdio_get_track_lsn(p_cdio, i_mid))
i_high_track = i_mid;
else
i_low_track = i_mid + 1;
} while ( i_low_track < i_high_track );
return i_high_track;
}
}
/*!
Return true if we have XA data (green, mode2 form1) or
XA data (green, mode2 form2). That is track begins:
sync - header - subheader
12 4 - 8
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)
{
if (p_cdio == NULL) {
return false;
}
if (p_cdio->op.get_track_green) {
return p_cdio->op.get_track_green (p_cdio->env, i_track);
} else {
return false;
}
}
/*!
Return the starting LBA for track number
track_num in cdio. Tracks numbers start at 1.
The "leadout" track is specified either by
using track_num LEADOUT_TRACK or the total tracks+1.
CDIO_INVALID_LBA is returned on error.
*/
lba_t
cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track)
{
if (!p_cdio) return CDIO_INVALID_LBA;
if (p_cdio->op.get_track_lba) {
return p_cdio->op.get_track_lba (p_cdio->env, i_track);
} else {
msf_t msf;
if (p_cdio->op.get_track_msf)
if (cdio_get_track_msf(p_cdio, i_track, &msf))
return cdio_msf_to_lba(&msf);
return CDIO_INVALID_LBA;
}
}
/*!
Return the starting LSN for track number
i_track in cdio. Tracks numbers start at 1.
The "leadout" track is specified either by
using i_track LEADOUT_TRACK or the total tracks+1.
CDIO_INVALID_LBA is returned on error.
*/
lsn_t
cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track)
{
if (p_cdio == NULL) return CDIO_INVALID_LSN;
if (p_cdio->op.get_track_lba) {
return cdio_lba_to_lsn(p_cdio->op.get_track_lba (p_cdio->env, i_track));
} else {
msf_t msf;
if (cdio_get_track_msf(p_cdio, i_track, &msf))
return cdio_msf_to_lsn(&msf);
return CDIO_INVALID_LSN;
}
}
/*!
Return the ending LSN for track number
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 lsn = cdio_get_track_lsn(p_cdio, i_track+1);
if (CDIO_INVALID_LSN == lsn) return CDIO_INVALID_LSN;
/* Safe, we've always the leadout. */
return lsn - 1;
}
/*!
Return the starting MSF (minutes/secs/frames) for track number
i_track in cdio. Track numbers start at 1.
The "leadout" track is specified either by
using i_track LEADOUT_TRACK or the total tracks+1.
False is returned if there is no track entry.
*/
bool
cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track, /*out*/ msf_t *msf)
{
if (!p_cdio) return false;
if (p_cdio->op.get_track_msf) {
return p_cdio->op.get_track_msf (p_cdio->env, i_track, msf);
} else if (p_cdio->op.get_track_lba) {
lba_t lba = p_cdio->op.get_track_lba (p_cdio->env, i_track);
if (lba == CDIO_INVALID_LBA) return false;
cdio_lba_to_msf(lba, msf);
return true;
} else {
return false;
}
}
/*! Return copy protection status on a track. Is this meaningful
if not an audio track?
*/
track_flag_t
cdio_get_track_preemphasis(const CdIo *p_cdio, track_t i_track)
{
if (p_cdio->op.get_track_preemphasis) {
return p_cdio->op.get_track_preemphasis (p_cdio->env, i_track);
} else {
return CDIO_TRACK_FLAG_UNKNOWN;
}
}
/*!
Return the number of sectors between this track an the next. This
includes any pregap sectors before the start of the next track.
Tracks start at 1.
0 is returned if there is an error.
*/
unsigned int
cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t i_track)
{
const track_t i_tracks = cdio_get_num_tracks(p_cdio);
if (i_track >=1 && i_track <= i_tracks)
return ( cdio_get_track_lba(p_cdio, i_track+1)
- cdio_get_track_lba(p_cdio, i_track) );
return 0;
}