BIG REORGANIZATION.
Reorganize directory structure for inclusion of cd-paranoia. Works for GNU/Linux. Other OS's may be broken. Regression test output needs to be adjusted too. Move: lib/driver (split off of lib) lib/iso9660 (split off of lib) Add from paranoia: lib/cdda_interface lib/paranoia src/paranoia Also made some small changes to capability indentification to show more reading capabilties and show that. cd-info now shows the total disc size.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile.am,v 1.14 2004/10/28 10:08:56 rocky Exp $
|
||||
# $Id: Makefile.am,v 1.15 2004/12/18 17:29:32 rocky Exp $
|
||||
#
|
||||
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
#
|
||||
@@ -25,6 +25,8 @@ libcdioincludedir=$(includedir)/cdio
|
||||
libcdioinclude_HEADERS = \
|
||||
bytesex.h \
|
||||
bytesex_asm.h \
|
||||
paranoia.h \
|
||||
cdda_interface.h \
|
||||
cdio.h \
|
||||
cdtext.h \
|
||||
cdtext.h \
|
||||
|
||||
217
include/cdio/cdda_interface.h
Normal file
217
include/cdio/cdda_interface.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
$Id: cdda_interface.h,v 1.1 2004/12/18 17:29:32 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2001 Xiph.org
|
||||
and Heiko Eissfeldt heiko@escape.colossus.de
|
||||
|
||||
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 cdda_paranoia.h
|
||||
* \brief The top-level interface header; applications include this.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#ifndef _CDDA_INTERFACE_H_
|
||||
#define _CDDA_INTERFACE_H_
|
||||
|
||||
#include <cdio/paranoia.h>
|
||||
|
||||
#define CD_FRAMESAMPLES (CDIO_CD_FRAMESIZE_RAW / 4)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
/** We keep MAXTRK since this header is exposed publicly and other
|
||||
programs may have used this.
|
||||
*/
|
||||
#define MAXTRK (CDIO_CD_MAX_TRACKS+1)
|
||||
|
||||
typedef struct TOC { /* structure of table of contents */
|
||||
unsigned char bFlags;
|
||||
unsigned char bTrack;
|
||||
int32_t dwStartSector;
|
||||
} TOC;
|
||||
|
||||
/** interface types */
|
||||
#define GENERIC_SCSI 0
|
||||
#define COOKED_IOCTL 1
|
||||
#define TEST_INTERFACE 2
|
||||
|
||||
#define CDDA_MESSAGE_FORGETIT 0
|
||||
#define CDDA_MESSAGE_PRINTIT 1
|
||||
#define CDDA_MESSAGE_LOGIT 2
|
||||
|
||||
/** cdrom access function pointer */
|
||||
|
||||
struct cdrom_drive_s {
|
||||
|
||||
int opened; /* This struct may just represent a candidate for opening */
|
||||
|
||||
char *cdda_device_name;
|
||||
char *ioctl_device_name;
|
||||
|
||||
int cdda_fd;
|
||||
int ioctl_fd;
|
||||
|
||||
char *drive_model;
|
||||
int drive_type;
|
||||
int interface;
|
||||
int bigendianp;
|
||||
int nsectors;
|
||||
|
||||
int cd_extra;
|
||||
int tracks;
|
||||
TOC disc_toc[MAXTRK];
|
||||
long audio_first_sector;
|
||||
long audio_last_sector;
|
||||
|
||||
int errordest;
|
||||
int messagedest;
|
||||
char *errorbuf;
|
||||
char *messagebuf;
|
||||
|
||||
/* functions specific to particular drives/interrfaces */
|
||||
|
||||
int (*enable_cdda) (cdrom_drive_t *d, int onoff);
|
||||
int (*read_toc) (cdrom_drive_t *d);
|
||||
long (*read_audio) (cdrom_drive_t *d, void *p, long begin,
|
||||
long sectors);
|
||||
int (*set_speed) (cdrom_drive_t *d, int speed);
|
||||
int error_retry;
|
||||
int report_all;
|
||||
|
||||
int is_atapi;
|
||||
int is_mmc;
|
||||
|
||||
/* SCSI command buffer and offset pointers */
|
||||
unsigned char *sg;
|
||||
unsigned char *sg_buffer;
|
||||
unsigned char inqbytes[4];
|
||||
|
||||
/* Scsi parameters and state */
|
||||
unsigned char density;
|
||||
unsigned char orgdens;
|
||||
unsigned int orgsize;
|
||||
long bigbuff;
|
||||
int adjust_ssize;
|
||||
|
||||
int fua;
|
||||
int lun;
|
||||
|
||||
sigset_t sigset;
|
||||
|
||||
};
|
||||
|
||||
#define IS_AUDIO(d,i) (!(d->disc_toc[i].bFlags & 0x04))
|
||||
|
||||
/** autosense functions */
|
||||
|
||||
extern cdrom_drive_t *cdda_find_a_cdrom(int messagedest, char **message);
|
||||
extern cdrom_drive_t *cdda_identify(const char *device, int messagedest,
|
||||
char **message);
|
||||
extern cdrom_drive_t *cdda_identify_cooked(const char *device,int messagedest,
|
||||
char **message);
|
||||
extern cdrom_drive_t *cdda_identify_scsi(const char *generic_device,
|
||||
const char *ioctl_device,
|
||||
int messagedest, char **message);
|
||||
#ifdef CDDA_TEST
|
||||
extern cdrom_drive_t *cdda_identify_test(const char *filename,
|
||||
int messagedest, char **message);
|
||||
#endif
|
||||
|
||||
/** oriented functions */
|
||||
|
||||
extern int cdda_speed_set(cdrom_drive_t *d, int speed);
|
||||
extern void cdda_verbose_set(cdrom_drive_t *d,int err_action, int mes_action);
|
||||
extern char *cdda_messages(cdrom_drive_t *d);
|
||||
extern char *cdda_errors(cdrom_drive_t *d);
|
||||
|
||||
extern int cdda_close(cdrom_drive_t *d);
|
||||
extern int cdda_open(cdrom_drive_t *d);
|
||||
extern long cdda_read(cdrom_drive_t *d, void *buffer,
|
||||
long int beginsector, long int sectors);
|
||||
|
||||
extern long cdda_track_firstsector(cdrom_drive_t *d,int track);
|
||||
extern long cdda_track_lastsector(cdrom_drive_t *d,int track);
|
||||
extern long cdda_tracks(cdrom_drive_t *d);
|
||||
extern int cdda_sector_gettrack(cdrom_drive_t *d,long sector);
|
||||
extern int cdda_track_channels(cdrom_drive_t *d,int track);
|
||||
extern int cdda_track_audiop(cdrom_drive_t *d,int track);
|
||||
extern int cdda_track_copyp(cdrom_drive_t *d,int track);
|
||||
extern int cdda_track_preemp(cdrom_drive_t *d,int track);
|
||||
extern long cdda_disc_firstsector(cdrom_drive_t *d);
|
||||
extern long cdda_disc_lastsector(cdrom_drive_t *d);
|
||||
|
||||
/** transport errors: */
|
||||
|
||||
#define TR_OK 0
|
||||
#define TR_EWRITE 1 /* Error writing packet command (transport) */
|
||||
#define TR_EREAD 2 /* Error reading packet data (transport) */
|
||||
#define TR_UNDERRUN 3 /* Read underrun */
|
||||
#define TR_OVERRUN 4 /* Read overrun */
|
||||
#define TR_ILLEGAL 5 /* Illegal/rejected request */
|
||||
#define TR_MEDIUM 6 /* Medium error */
|
||||
#define TR_BUSY 7 /* Device busy */
|
||||
#define TR_NOTREADY 8 /* Device not ready */
|
||||
#define TR_FAULT 9 /* Devive failure */
|
||||
#define TR_UNKNOWN 10 /* Unspecified error */
|
||||
#define TR_STREAMING 11 /* loss of streaming */
|
||||
|
||||
#ifdef NEED_STRERROR_TR
|
||||
const char *strerror_tr[]={
|
||||
"Success",
|
||||
"Error writing packet command to device",
|
||||
"Error reading command from device",
|
||||
"SCSI packet data underrun (too little data)",
|
||||
"SCSI packet data overrun (too much data)",
|
||||
"Illegal SCSI request (rejected by target)",
|
||||
"Medium reading data from medium",
|
||||
"Device busy",
|
||||
"Device not ready",
|
||||
"Target hardware fault",
|
||||
"Unspecified error",
|
||||
"Drive lost streaming"
|
||||
};
|
||||
#endif /*NEED_STERROR_TR*/
|
||||
|
||||
/** Errors returned by lib:
|
||||
|
||||
001: Unable to set CDROM to read audio mode
|
||||
002: Unable to read table of contents lead-out
|
||||
003: CDROM reporting illegal number of tracks
|
||||
004: Unable to read table of contents header
|
||||
005: Unable to read table of contents entry
|
||||
006: Could not read any data from drive
|
||||
007: Unknown, unrecoverable error reading data
|
||||
008: Unable to identify CDROM model
|
||||
009: CDROM reporting illegal table of contents
|
||||
010: Unaddressable sector
|
||||
|
||||
100: Interface not supported
|
||||
101: Drive is neither a CDROM nor a WORM device
|
||||
102: Permision denied on cdrom (ioctl) device
|
||||
103: Permision denied on cdrom (data) device
|
||||
|
||||
300: Kernel memory error
|
||||
|
||||
400: Device not open
|
||||
401: Invalid track number
|
||||
402: Track not audio data
|
||||
403: No audio tracks on disc
|
||||
|
||||
*/
|
||||
#endif /*_CDDA_INTERFACE_H_*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- c -*-
|
||||
$Id: cdio.h,v 1.67 2004/12/15 01:45:15 rocky Exp $
|
||||
$Id: cdio.h,v 1.68 2004/12/18 17:29:32 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -469,65 +469,65 @@ extern "C" {
|
||||
unsigned int i_sectors);
|
||||
|
||||
/*!
|
||||
Reads a mode1 sector
|
||||
Reads a mode 1 sector
|
||||
|
||||
@param p_cdio object to read from
|
||||
@param buf place to read data into
|
||||
@param lsn sector to read
|
||||
@param b_form2 true for reading mode1 form2 sectors or false for
|
||||
mode1 form1 sectors.
|
||||
@param b_form2 true for reading mode1 form 2 sectors or false for
|
||||
mode 1 form 1 sectors.
|
||||
|
||||
@return 0 if no error, nonzero otherwise.
|
||||
*/
|
||||
int cdio_read_mode1_sector (const CdIo *p_cdio, void *buf, lsn_t lsn,
|
||||
int cdio_read_mode1_sector (const CdIo *p_cdio, void *p_buf, lsn_t i_lsn,
|
||||
bool b_form2);
|
||||
|
||||
/*!
|
||||
Reads mode1 sectors
|
||||
Reads mode 1 sectors
|
||||
|
||||
@param p_cdio object to read from
|
||||
@param buf place to read data into
|
||||
@param lsn sector to read
|
||||
@param b_form2 true for reading mode1 form2 sectors or false for
|
||||
mode1 form1 sectors.
|
||||
@param b_form2 true for reading mode 1 form 2 sectors or false for
|
||||
mode 1 form 1 sectors.
|
||||
@param i_sectors number of sectors to read
|
||||
|
||||
@return 0 if no error, nonzero otherwise.
|
||||
*/
|
||||
int cdio_read_mode1_sectors (const CdIo *p_cdio, void *buf, lsn_t lsn,
|
||||
int cdio_read_mode1_sectors (const CdIo *p_cdio, void *p_buf, lsn_t i_lsn,
|
||||
bool b_form2, unsigned int i_sectors);
|
||||
|
||||
/*!
|
||||
Reads a mode1 sector
|
||||
Reads a mode 2 sector
|
||||
|
||||
@param p_cdio object to read from
|
||||
@param buf place to read data into
|
||||
@param lsn sector to read
|
||||
@param b_form2 true for reading mode1 form2 sectors or false for
|
||||
mode1 form1 sectors.
|
||||
@param b_form2 true for reading mode 2 form 2 sectors or false for
|
||||
mode 2 form 1 sectors.
|
||||
|
||||
@return 0 if no error, nonzero otherwise.
|
||||
*/
|
||||
int cdio_read_mode2_sector (const CdIo *p_cdio, void *buf, lsn_t lsn,
|
||||
int cdio_read_mode2_sector (const CdIo *p_cdio, void *p_buf, lsn_t i_lsn,
|
||||
bool b_form2);
|
||||
|
||||
/*!
|
||||
Reads mode2 sectors
|
||||
Reads mode 2 sectors
|
||||
|
||||
@param p_cdio object to read from
|
||||
@param buf place to read data into
|
||||
@param lsn sector to read
|
||||
@param b_form2 true for reading mode1 form2 sectors or false for
|
||||
mode1 form1 sectors.
|
||||
@param b_form2 true for reading mode2 form 2 sectors or false for
|
||||
mode 2 form 1 sectors.
|
||||
@param i_sectors number of sectors to read
|
||||
|
||||
@return 0 if no error, nonzero otherwise.
|
||||
*/
|
||||
int cdio_read_mode2_sectors (const CdIo *p_cdio, void *buf, lsn_t lsn,
|
||||
int cdio_read_mode2_sectors (const CdIo *p_cdio, void *p_buf, lsn_t i_lsn,
|
||||
bool b_form2, unsigned int i_sectors);
|
||||
|
||||
/*!
|
||||
Set the arg "key" with "value" in "obj".
|
||||
Set the arg "key" with "value" in "p_cdio".
|
||||
|
||||
@param p_cdio the CD object to set
|
||||
@param key the key to set
|
||||
|
||||
123
include/cdio/paranoia.h
Normal file
123
include/cdio/paranoia.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
$Id: paranoia.h,v 1.1 2004/12/18 17:29:32 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 1998 Monty xiphmont@mit.edu
|
||||
|
||||
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 cdda_paranoia.h
|
||||
* \brief The top-level header for libcdda_paranoia:
|
||||
a library for reading CD-DA with error tolerance and repair.
|
||||
*/
|
||||
|
||||
#ifndef _CDIO_PARANOIA_H_
|
||||
#define _CDIO_PARANOIA_H_
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
|
||||
#define CD_FRAMEWORDS (CDIO_CD_FRAMESIZE_RAW/2)
|
||||
|
||||
/**! Flags used in paranoia_modeset. */
|
||||
|
||||
#define PARANOIA_MODE_FULL 0xff
|
||||
#define PARANOIA_MODE_DISABLE 0
|
||||
|
||||
#define PARANOIA_MODE_VERIFY 1
|
||||
#define PARANOIA_MODE_FRAGMENT 2
|
||||
#define PARANOIA_MODE_OVERLAP 4
|
||||
#define PARANOIA_MODE_SCRATCH 8
|
||||
#define PARANOIA_MODE_REPAIR 16
|
||||
#define PARANOIA_MODE_NEVERSKIP 32
|
||||
|
||||
/** cdrom_paranoia is an opaque structure which is used in all of the
|
||||
library operations.
|
||||
*/
|
||||
typedef struct cdrom_paranoia_s cdrom_paranoia_t;
|
||||
typedef struct cdrom_drive_s cdrom_drive_t;
|
||||
|
||||
typedef enum {
|
||||
PARANOIA_CB_READ,
|
||||
PARANOIA_CB_VERIFY,
|
||||
PARANOIA_CB_FIXUP_EDGE,
|
||||
PARANOIA_CB_FIXUP_ATOM,
|
||||
PARANOIA_CB_SCRATCH,
|
||||
PARANOIA_CB_REPAIR,
|
||||
PARANOIA_CB_SKIP,
|
||||
PARANOIA_CB_DRIFT,
|
||||
PARANOIA_CB_BACKOFF,
|
||||
PARANOIA_CB_OVERLAP,
|
||||
PARANOIA_CB_FIXUP_DROPPED,
|
||||
PARANOIA_CB_FIXUP_DUPED,
|
||||
PARANOIA_CB_READERR
|
||||
} paranoia_cb_mode_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Get and initialize a new cdrom_paranoia object from cdrom_drive.
|
||||
Run this before calling any of the other paranoia routines below.
|
||||
|
||||
@return new cdrom_paranoia object Call paranoia_free() when you are
|
||||
done with it
|
||||
*/
|
||||
extern cdrom_paranoia_t *paranoia_init(cdrom_drive_t *d);
|
||||
|
||||
/*!
|
||||
Free any resources associated with obj.
|
||||
|
||||
@see paranoia_init.
|
||||
*/
|
||||
extern void paranoia_free(cdrom_paranoia_t *p);
|
||||
|
||||
/*!
|
||||
Set the kind of repair you want to on for reading.
|
||||
The modes are listed above
|
||||
*/
|
||||
extern void paranoia_modeset(cdrom_paranoia_t *p, int mode);
|
||||
|
||||
/*!
|
||||
reposition reading offset.
|
||||
|
||||
@param whence like corresponding parameter in libc's lseek, e.g.
|
||||
SEEK_SET or SEEK_END.
|
||||
*/
|
||||
extern lsn_t paranoia_seek(cdrom_paranoia_t *p, off_t seek, int whence);
|
||||
|
||||
/*! The returned buffer is *not* to be freed by the caller. It will
|
||||
persist only until the next call to paranoia_read() for this p
|
||||
*/
|
||||
extern int16_t *paranoia_read(cdrom_paranoia_t *p,
|
||||
void(*callback)(long int, paranoia_cb_mode_t));
|
||||
|
||||
extern int16_t *paranoia_read_limited(cdrom_paranoia_t *p,
|
||||
void(*callback)(long int,
|
||||
paranoia_cb_mode_t),
|
||||
int maxretries);
|
||||
|
||||
|
||||
extern void paranoia_overlapset(cdrom_paranoia_t *p,long overlap);
|
||||
|
||||
extern void paranoia_set_range(cdrom_paranoia_t *p, long int start,
|
||||
long int end);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_CDIO_PARANOIA_H_*/
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: scsi_mmc.h,v 1.35 2004/12/04 12:01:48 rocky Exp $
|
||||
$Id: scsi_mmc.h,v 1.36 2004/12/18 17:29:32 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -415,12 +415,18 @@ char *scsi_mmc_get_mcn ( const CdIo *p_cdio );
|
||||
Can read only up to 25 blocks.
|
||||
*/
|
||||
int scsi_mmc_read_sectors ( const CdIo *p_cdio, void *p_buf, lba_t lba,
|
||||
int sector_type, unsigned int nblocks);
|
||||
int sector_type, unsigned int i_blocks);
|
||||
|
||||
/*!
|
||||
Set the block size for subsequest read requests, via a SCSI MMC
|
||||
MODE_SELECT 6 command.
|
||||
*/
|
||||
int scsi_mmc_set_blocksize ( const CdIo *p_cdio, unsigned int bsize);
|
||||
int scsi_mmc_set_blocksize ( const CdIo *p_cdio, unsigned int i_bsize);
|
||||
|
||||
/*!
|
||||
Set the block size for subsequest read requests, via a SCSI MMC
|
||||
MODE_SENSE 6 command.
|
||||
*/
|
||||
int scsi_mmc_get_blocksize ( const CdIo *p_cdio );
|
||||
|
||||
#endif /* __SCSI_MMC_H__ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: types.h,v 1.23 2004/09/03 23:20:11 rocky Exp $
|
||||
$Id: types.h,v 1.24 2004/12/18 17:29:32 rocky Exp $
|
||||
|
||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -298,8 +298,6 @@ extern "C" {
|
||||
#define CDIO_DRIVE_CAP_MISC_MULTI_SESSION 0x00020 /**< read sessions>1 */
|
||||
#define CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED 0x00080 /**< media changed */
|
||||
#define CDIO_DRIVE_CAP_MISC_RESET 0x00100 /**< hard reset device */
|
||||
#define CDIO_DRIVE_CAP_MCN 0x00200 /**< can read MCN */
|
||||
#define CDIO_DRIVE_CAP_ISRC 0x00200 /**< can read ISRC */
|
||||
#define CDIO_DRIVE_CAP_MISC_FILE 0x20000 /**< drive is really a file,
|
||||
i.e a CD file image */
|
||||
|
||||
@@ -316,6 +314,10 @@ extern "C" {
|
||||
#define CDIO_DRIVE_CAP_READ_DVD_RW 0x00200 /**< drive can read DVD-RW */
|
||||
#define CDIO_DRIVE_CAP_READ_DVD_RPW 0x00400 /**< drive can read DVD+RW */
|
||||
#define CDIO_DRIVE_CAP_READ_C2_ERRS 0x00800 /**< has C2 error correction */
|
||||
#define CDIO_DRIVE_CAP_READ_MODE2_FORM1 0x01000 /**< can read mode 2 form 1 */
|
||||
#define CDIO_DRIVE_CAP_READ_MODE2_FORM2 0x02000 /**< can read mode 2 form 2 */
|
||||
#define CDIO_DRIVE_CAP_READ_MCN 0x04000 /**< can read MCN */
|
||||
#define CDIO_DRIVE_CAP_READ_ISRC 0x08000 /**< can read ISRC */
|
||||
|
||||
/*! Writing masks.. */
|
||||
#define CDIO_DRIVE_CAP_WRITE_CD_R 0x00001 /**< drive can write CD-R */
|
||||
|
||||
Reference in New Issue
Block a user