Add cd-paranoia's track flag routines: copy-permitted, pre-emphasis, channels.

Updates to drivers to set this properly is still needed.
This commit is contained in:
rocky
2004-12-30 11:13:49 +00:00
parent 00569141c7
commit c51a6ba67e
6 changed files with 161 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cdda_interface.h,v 1.2 2004/12/19 01:43:38 rocky Exp $ $Id: cdda_interface.h,v 1.3 2004/12/30 11:13:49 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Xiph.org Copyright (C) 2001 Xiph.org
@@ -44,7 +44,10 @@ typedef struct TOC { /* structure of table of contents */
unsigned char bFlags; unsigned char bFlags;
unsigned char bTrack; unsigned char bTrack;
int32_t dwStartSector; int32_t dwStartSector;
} TOC; } TOC_t;
/** For compatibility. TOC is depricated, use TOC_t instead. */
#define TOC TOC_t
/** interface types */ /** interface types */
#define GENERIC_SCSI 0 #define GENERIC_SCSI 0
@@ -75,7 +78,7 @@ struct cdrom_drive_s {
int cd_extra; int cd_extra;
int tracks; int tracks;
TOC disc_toc[MAXTRK]; TOC_t disc_toc[MAXTRK];
long audio_first_sector; long audio_first_sector;
long audio_last_sector; long audio_last_sector;
@@ -159,17 +162,17 @@ extern long cdda_disc_lastsector(cdrom_drive_t *d);
/** transport errors: */ /** transport errors: */
#define TR_OK 0 #define TR_OK 0
#define TR_EWRITE 1 /* Error writing packet command (transport) */ #define TR_EWRITE 1 /**< Error writing packet command (transport) */
#define TR_EREAD 2 /* Error reading packet data (transport) */ #define TR_EREAD 2 /**< Error reading packet data (transport) */
#define TR_UNDERRUN 3 /* Read underrun */ #define TR_UNDERRUN 3 /**< Read underrun */
#define TR_OVERRUN 4 /* Read overrun */ #define TR_OVERRUN 4 /**< Read overrun */
#define TR_ILLEGAL 5 /* Illegal/rejected request */ #define TR_ILLEGAL 5 /**< Illegal/rejected request */
#define TR_MEDIUM 6 /* Medium error */ #define TR_MEDIUM 6 /**< Medium error */
#define TR_BUSY 7 /* Device busy */ #define TR_BUSY 7 /**< Device busy */
#define TR_NOTREADY 8 /* Device not ready */ #define TR_NOTREADY 8 /**< Device not ready */
#define TR_FAULT 9 /* Devive failure */ #define TR_FAULT 9 /**< Device failure */
#define TR_UNKNOWN 10 /* Unspecified error */ #define TR_UNKNOWN 10 /**< Unspecified error */
#define TR_STREAMING 11 /* loss of streaming */ #define TR_STREAMING 11 /**< loss of streaming */
#ifdef NEED_STRERROR_TR #ifdef NEED_STRERROR_TR
const char *strerror_tr[]={ const char *strerror_tr[]={

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- c -*-
$Id: cdio.h,v 1.68 2004/12/18 17:29:32 rocky Exp $ $Id: cdio.h,v 1.69 2004/12/30 11:13:49 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 Rocky Bernstein <rocky@panix.com>
@@ -1023,6 +1023,18 @@ extern "C" {
*/ */
bool cdio_is_device(const char *source_name, driver_id_t driver_id); bool cdio_is_device(const char *source_name, driver_id_t driver_id);
/*! Return number of channels in track: 2 or 4 or -1 for error.
Not meaningful if track is not an audio track.
*/
int cdio_track_channels(const CdIo *p_cdio, track_t i_track);
/*! Return 1 if track is copy protected, 0 if not, or -1 for error.
Is this meaningful if not an audio track?
*/
int cdio_track_copy_permit(const CdIo *p_cdio, track_t i_track);
int cdio_track_preemphasis(const CdIo *p_cdio, track_t i_track);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_generic.c,v 1.1 2004/12/18 17:29:32 rocky Exp $ $Id: _cdio_generic.c,v 1.2 2004/12/30 11:13:49 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -25,7 +25,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.1 2004/12/18 17:29:32 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.2 2004/12/30 11:13:49 rocky Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -369,7 +369,7 @@ get_discmode_cd_generic (void *p_user_data )
track_t track_t
get_first_track_num_generic(void *p_user_data) get_first_track_num_generic(void *p_user_data)
{ {
generic_img_private_t *p_env = p_user_data; const generic_img_private_t *p_env = p_user_data;
if (!p_env->toc_init) if (!p_env->toc_init)
p_env->cdio->op.read_toc (p_user_data); p_env->cdio->op.read_toc (p_user_data);
@@ -424,3 +424,11 @@ init_cdtext_generic (generic_img_private_t *p_env)
); );
} }
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cdio.c,v 1.1 2004/12/18 17:29:32 rocky Exp $ $Id: cdio.c,v 1.2 2004/12/30 11:13:50 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@@ -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.1 2004/12/18 17:29:32 rocky Exp $"; static const char _rcsid[] = "$Id: cdio.c,v 1.2 2004/12/30 11:13:50 rocky Exp $";
const char *track_format2str[6] = const char *track_format2str[6] =
@@ -1131,6 +1131,88 @@ cdio_open_am_cd (const char *psz_source, const char *psz_access_mode)
} }
/* Returns "set" or "clear" value or -1 (for error) if bit "bit" of
the track flag "i_track" is set/clear.
Taken from cdparanoia.
*/
static int
cdio_track_bitmap(const generic_img_private_t *p_env, track_t i_track,
int bit, int set, int clear)
{
return p_env->toc_init ? p_env->i_first_track : -1;
if( i_track < p_env->i_first_track
|| i_track > p_env->i_first_track + p_env->i_tracks ) {
cdio_warn ("invalid track number");
return(-1);
}
if (p_env->flags[i_track] & bit)
return(set);
else
return(clear);
}
/*! Return number of channels in track, 2 or 4 or -1 for error.
Not meaningful if track is not an audio track.
*/
int
cdio_track_channels(const CdIo *p_cdio, track_t i_track)
{
if (!p_cdio) return -1;
{
const generic_img_private_t *p_env
= (generic_img_private_t *) (p_cdio->env);
return(cdio_track_bitmap(p_env, i_track, 8, 4, 2));
}
}
/*! Return 1 if copy is permitted on the track, 0 if not, or -1 for error.
Is this meaningful if not an audio track?
*/
int
cdio_track_copy_permit(const CdIo *p_cdio, track_t i_track)
{
if (!p_cdio) return -1;
{
const generic_img_private_t *p_env
= (generic_img_private_t *) (p_cdio->env);
return(cdio_track_bitmap(p_env, i_track, 2, 1, 0));
}
}
/*! Return 1 if track has pre-emphasis, 0 if not, or -1 for error.
Is this meaningful if not an audio track?
pre-emphasis is a non linear frequency response.
*/
int
cdio_track_preemphasis(const CdIo *p_cdio, track_t i_track)
{
if (!p_cdio) return -1;
{
const generic_img_private_t *p_env
= (generic_img_private_t *) (p_cdio->env);
return(cdio_track_bitmap(p_env, i_track, 1, 1, 0));
}
}
#if 0
/* Use cdio_get_track_format instead of this. */
/*! Return 1 if track is an audio track, 0 if not, or -1 for error. */
int
cdio_track_audiop(const CdIo *p_cdio, track_t i_track)
{
if (!p_cdio) return -1;
{
const generic_img_private_t *p_env
= (generic_img_private_t *) (p_cdio->env);
return(cdio_track_bitmap(p_env, i_track, 4, 0, 1));
}
}
#endif
/* /*
* Local variables: * Local variables:

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cdio_private.h,v 1.1 2004/12/18 17:29:32 rocky Exp $ $Id: cdio_private.h,v 1.2 2004/12/30 11:13:50 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -57,17 +57,17 @@ extern "C" {
Eject media in CD drive. If successful, as a side effect we Eject media in CD drive. If successful, as a side effect we
also free obj. Return 0 if success and 1 for failure. also free obj. Return 0 if success and 1 for failure.
*/ */
int (*eject_media) (void *env); int (*eject_media) (void *p_env);
/*! /*!
Release and free resources associated with cd. Release and free resources associated with cd.
*/ */
void (*free) (void *env); void (*free) (void *p_env);
/*! /*!
Return the value associated with the key "arg". Return the value associated with the key "arg".
*/ */
const char * (*get_arg) (void *env, const char key[]); const char * (*get_arg) (void *p_env, const char key[]);
/*! /*!
Get cdtext information for a CdIo object. Get cdtext information for a CdIo object.
@@ -79,7 +79,7 @@ extern "C" {
If i_track is 0 or CDIO_CDROM_LEADOUT_TRACK the track returned If i_track is 0 or CDIO_CDROM_LEADOUT_TRACK the track returned
is the information assocated with the CD. is the information assocated with the CD.
*/ */
const cdtext_t * (*get_cdtext) (void *env, track_t i_track); const cdtext_t * (*get_cdtext) (void *p_env, track_t i_track);
/*! /*!
Return an array of device names. if CdIo is NULL (we haven't Return an array of device names. if CdIo is NULL (we haven't
@@ -105,7 +105,7 @@ extern "C" {
See cd_types.h for a list of bitmasks for the drive type; See cd_types.h for a list of bitmasks for the drive type;
*/ */
void (*get_drive_cap) (const void *env, void (*get_drive_cap) (const void *p_env,
cdio_drive_read_cap_t *p_read_cap, cdio_drive_read_cap_t *p_read_cap,
cdio_drive_write_cap_t *p_write_cap, cdio_drive_write_cap_t *p_write_cap,
cdio_drive_misc_cap_t *p_misc_cap); cdio_drive_misc_cap_t *p_misc_cap);
@@ -126,27 +126,27 @@ extern "C" {
Return the media catalog number MCN from the CD or NULL if Return the media catalog number MCN from the CD or NULL if
there is none or we don't have the ability to get it. there is none or we don't have the ability to get it.
*/ */
char * (*get_mcn) (const void *env); char * (*get_mcn) (const void *p_env);
/*! /*!
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.
*/ */
track_t (*get_num_tracks) (void *env); track_t (*get_num_tracks) (void *p_env);
/*! /*!
Return the starting LBA for track number Return the starting LBA for track number
track_num in obj. Tracks numbers start at 1. i_track in p_env. Tracks numbers start at 1.
The "leadout" track is specified either by The "leadout" track is specified either by
using track_num LEADOUT_TRACK or the total tracks+1. using track_num LEADOUT_TRACK or the total tracks+1.
CDIO_INVALID_LBA is returned on error. CDIO_INVALID_LBA is returned on error.
*/ */
lba_t (*get_track_lba) (void *env, track_t track_num); lba_t (*get_track_lba) (void *p_env, track_t i_track);
/*! /*!
Get format of track. Get format of track.
*/ */
track_format_t (*get_track_format) (void *env, track_t track_num); track_format_t (*get_track_format) (void *p_env, 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
@@ -156,52 +156,52 @@ 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 (*get_track_green) (void *env, track_t track_num); bool (*get_track_green) (void *p_env, track_t i_track);
/*! /*!
Return the starting MSF (minutes/secs/frames) for track number Return the starting MSF (minutes/secs/frames) for track number
track_num in obj. Tracks numbers start at 1. i_track in p_env. Tracks numbers start at 1.
The "leadout" track is specified either by The "leadout" track is specified either by
using track_num LEADOUT_TRACK or the total tracks+1. using i_track LEADOUT_TRACK or the total tracks+1.
False is returned on error. False is returned on error.
*/ */
bool (*get_track_msf) (void *env, track_t track_num, msf_t *msf); bool (*get_track_msf) (void *p_env, track_t i_track, msf_t *p_msf);
/*! /*!
lseek - reposition read/write file offset lseek - reposition read/write file offset
Returns (off_t) -1 on error. Returns (off_t) -1 on error.
Similar to libc's lseek() Similar to libc's lseek()
*/ */
off_t (*lseek) (void *env, off_t offset, int whence); off_t (*lseek) (void *p_env, off_t offset, int whence);
/*! /*!
Reads into buf the next size bytes. Reads into buf the next size bytes.
Returns -1 on error. Returns -1 on error.
Similar to libc's read() Similar to libc's read()
*/ */
ssize_t (*read) (void *env, void *buf, size_t size); ssize_t (*read) (void *p_env, void *p_buf, size_t size);
/*! /*!
Reads a single mode2 sector from cd device into buf starting Reads a single mode2 sector from cd device into buf starting
from lsn. Returns 0 if no error. from lsn. Returns 0 if no error.
*/ */
int (*read_audio_sectors) (void *env, void *buf, lsn_t lsn, int (*read_audio_sectors) (void *p_env, void *p_buf, lsn_t lsn,
unsigned int nblocks); unsigned int i_blocks);
/*! /*!
Reads a single mode2 sector from cd device into buf starting Reads a single mode2 sector from cd device into buf starting
from lsn. Returns 0 if no error. from lsn. Returns 0 if no error.
*/ */
int (*read_mode2_sector) (void *env, void *buf, lsn_t lsn, int (*read_mode2_sector) (void *p_env, void *p_buf, lsn_t lsn,
bool mode2_form2); bool b_mode2_form2);
/*! /*!
Reads nblocks of mode2 sectors from cd device into data starting Reads i_blocks of mode2 sectors from cd device into data starting
from lsn. from lsn.
Returns 0 if no error. Returns 0 if no error.
*/ */
int (*read_mode2_sectors) (void *p_env, void *p_buf, lsn_t lsn, int (*read_mode2_sectors) (void *p_env, void *p_buf, lsn_t lsn,
bool mode2_form2, unsigned int nblocks); bool b_mode2_form2, unsigned int i_blocks);
/*! /*!
Reads a single mode1 sector from cd device into buf starting Reads a single mode1 sector from cd device into buf starting
@@ -211,12 +211,12 @@ extern "C" {
bool mode1_form2); bool mode1_form2);
/*! /*!
Reads nblocks of mode1 sectors from cd device into data starting Reads i_blocks of mode1 sectors from cd device into data starting
from lsn. from lsn.
Returns 0 if no error. Returns 0 if no error.
*/ */
int (*read_mode1_sectors) (void *p_env, void *p_buf, lsn_t lsn, int (*read_mode1_sectors) (void *p_env, void *p_buf, lsn_t lsn,
bool mode1_form2, unsigned int nblocks); bool mode1_form2, unsigned int i_blocks);
bool (*read_toc) ( void *p_env ) ; bool (*read_toc) ( void *p_env ) ;
@@ -241,12 +241,12 @@ extern "C" {
/*! /*!
Set the arg "key" with "value" in the source device. Set the arg "key" with "value" in the source device.
*/ */
int (*set_arg) (void *env, const char key[], const char value[]); int (*set_arg) (void *p_env, const char key[], const char value[]);
/*! /*!
Return the size of the CD in logical block address (LBA) units. Return the size of the CD in logical block address (LBA) units.
*/ */
uint32_t (*stat_size) (void *env); uint32_t (*stat_size) (void *p_env);
} cdio_funcs; } cdio_funcs;
@@ -255,7 +255,7 @@ extern "C" {
struct _CdIo { struct _CdIo {
driver_id_t driver_id; /**< Particular driver opened. */ driver_id_t driver_id; /**< Particular driver opened. */
cdio_funcs op; /**< driver-specific routines handling cdio_funcs op; /**< driver-specific routines handling
implementation*/ implementation*/
void *env; /**< environment. Passed to routine above. */ void *env; /**< environment. Passed to routine above. */
}; };

View File

@@ -1,5 +1,5 @@
/* /*
$Id: generic.h,v 1.1 2004/12/18 17:29:32 rocky Exp $ $Id: generic.h,v 1.2 2004/12/30 11:13:50 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -66,8 +66,13 @@ extern "C" {
iso9660_svd_t svd; iso9660_svd_t svd;
CdIo *cdio; /**< a way to call general cdio routines. */ CdIo *cdio; /**< a way to call general cdio routines. */
cdtext_t cdtext; /**< CD-Text for disc. */ cdtext_t cdtext; /**< CD-Text for disc. */
cdtext_t cdtext_track[CDIO_CD_MAX_TRACKS+1]; /*CD-TEXT for each track*/ cdtext_t cdtext_track[CDIO_CD_MAX_TRACKS+1]; /**< CD-TEXT for each track*/
uint8_t flags[CDIO_CD_MAX_TRACKS+1]; /**< track flags:
bit 4: # channels 2 or 4
bit 3: audio?
bit 2: copy protection
bit 1: premphasis
*/
} generic_img_private_t; } generic_img_private_t;
/*! /*!