libcdio-paranoia 10.2+2.0.2
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
cdda.h File Reference

The top-level interface header for libcdio_cdda. Applications include this for paranoia access. More...

#include <cdio/cdio.h>
#include <signal.h>

Go to the source code of this file.

Data Structures

struct  TOC_s
 Structure for cdparanoia's CD Table of Contents. More...
 
struct  cdrom_drive_s
 Structure for cdparanoia's CD-ROM access. More...
 

Macros

#define MAXTRK   (CDIO_CD_MAX_TRACKS+1)
 
#define TOC   TOC_t
 
#define CDDA_TEST_ALWAYS_JITTER   4
 
#define CDDA_TEST_FRAG_SMALL   (1<<3)
 
#define CDDA_TEST_FRAG_LARGE   (2<<3)
 
#define CDDA_TEST_FRAG_MASSIVE   (3<<3)
 
#define CDDA_TEST_UNDERRUN   64
 
#define cdda_find_a_cdrom   cdio_cddap_find_a_cdrom
 
#define cdda_identify   cdio_cddap_identify
 
#define cdda_version   cdio_cddap_version
 
#define cdda_speed_set   cdio_cddap_speed_set
 
#define cdda_verbose_set   cdio_cddap_verbose_set
 
#define cdda_messages   cdio_cddap_messages
 
#define cdda_errors   cdio_cddap_errors
 
#define cdda_close   cdio_cddap_close
 
#define cdda_open   cdio_cddap_open
 
#define cdda_read   cdio_cddap_read
 
#define cdda_read_timed   cdio_cddap_read_timed
 
#define cdda_track_firstsector   cdio_cddap_track_firstsector
 
#define cdda_track_lastsector   cdio_cddap_track_lastsector
 
#define cdda_tracks   cdio_cddap_tracks
 
#define cdda_sector_gettrack   cdio_cddap_sector_gettrack
 
#define cdda_track_channels   cdio_cddap_track_channels
 
#define cdda_track_audiop   cdio_cddap_track_audiop
 
#define cdda_track_copyp   cdio_cddap_track_copyp
 
#define cdda_track_preemp   cdio_cddap_track_preemp
 
#define cdda_disc_firstsector   cdio_cddap_disc_firstsector
 
#define cdda_disc_lastsector   cdio_cddap_disc_lastsector
 
#define cdrom_drive   cdrom_drive_t
 

Typedefs

typedef struct cdrom_paranoia_s cdrom_paranoia_t
 
typedef struct cdrom_drive_s cdrom_drive_t
 
typedef struct TOC_s TOC_t
 Structure for cdparanoia's CD Table of Contents. More...
 

Enumerations

enum  paranoia_cdda_enums_t {
  CDDA_MESSAGE_FORGETIT = 0 , CDDA_MESSAGE_PRINTIT = 1 , CDDA_MESSAGE_LOGIT = 2 , CD_FRAMESAMPLES = CDIO_CD_FRAMESIZE_RAW / 4 ,
  MAXTRK = (CDIO_CD_MAX_TRACKS+1)
}
 
enum  paranoia_jitter_t {
  CDDA_TEST_JITTER_SMALL = 1 , CDDA_TEST_JITTER_LARGE = 2 , CDDA_TEST_JITTER_MASSIVE = 3 , CDDA_TEST_FRAG_SMALL = (1<<3) ,
  CDDA_TEST_FRAG_LARGE = (2<<3) , CDDA_TEST_FRAG_MASSIVE = (3<<3) , CDDA_TEST_UNDERRUN = 64
}
 
enum  transport_error_t {
  TR_OK = 0 , TR_EWRITE = 1 , TR_EREAD = 2 , TR_UNDERRUN = 3 ,
  TR_OVERRUN = 4 , TR_ILLEGAL = 5 , TR_MEDIUM = 6 , TR_BUSY = 7 ,
  TR_NOTREADY = 8 , TR_FAULT = 9 , TR_UNKNOWN = 10 , TR_STREAMING = 11
}
 

Functions

cdrom_drive_tcdio_cddap_find_a_cdrom (int messagedest, char **ppsz_message)
 
cdrom_drive_tcdio_cddap_identify (const char *psz_device, int messagedest, char **ppsz_message)
 
cdrom_drive_tcdio_cddap_identify_cdio (CdIo_t *p_cdio, int messagedest, char **ppsz_messages)
 
const char * cdio_cddap_version (void)
 
char * cdio_cddap_messages (cdrom_drive_t *d)
 
char * cdio_cddap_errors (cdrom_drive_t *d)
 
void cdio_cddap_free_messages (char *psz_messages)
 
int cdio_cddap_speed_set (cdrom_drive_t *d, int speed)
 
void cdio_cddap_verbose_set (cdrom_drive_t *d, int err_action, int mes_action)
 
bool cdio_cddap_close_no_free_cdio (cdrom_drive_t *d)
 
int cdio_cddap_close (cdrom_drive_t *d)
 
int cdio_cddap_open (cdrom_drive_t *d)
 
long cdio_cddap_read (cdrom_drive_t *d, void *p_buffer, lsn_t beginsector, long sectors)
 
long cdio_cddap_read_timed (cdrom_drive_t *d, void *p_buffer, lsn_t beginsector, long sectors, int *milliseconds)
 
lsn_t cdio_cddap_track_firstsector (cdrom_drive_t *d, track_t i_track)
 
lsn_t cdio_cddap_track_lastsector (cdrom_drive_t *d, track_t i_track)
 
track_t cdio_cddap_tracks (cdrom_drive_t *d)
 
int cdio_cddap_sector_gettrack (cdrom_drive_t *d, lsn_t lsn)
 
int cdio_cddap_track_channels (cdrom_drive_t *d, track_t i_track)
 
int cdio_cddap_track_audiop (cdrom_drive_t *d, track_t i_track)
 
int cdio_cddap_track_copyp (cdrom_drive_t *d, track_t i_track)
 
int cdio_cddap_track_preemp (cdrom_drive_t *d, track_t i_track)
 
lsn_t cdio_cddap_disc_firstsector (cdrom_drive_t *d)
 
lsn_t cdio_cddap_disc_lastsector (cdrom_drive_t *d)
 
int data_bigendianp (cdrom_drive_t *d)
 

Variables

paranoia_jitter_t debug_paranoia_jitter
 
paranoia_cdda_enums_t debug_paranoia_cdda_enums
 

Detailed Description

The top-level interface header for libcdio_cdda. Applications include this for paranoia access.

Macro Definition Documentation

◆ cdda_close

#define cdda_close   cdio_cddap_close

◆ cdda_disc_firstsector

#define cdda_disc_firstsector   cdio_cddap_disc_firstsector

◆ cdda_disc_lastsector

#define cdda_disc_lastsector   cdio_cddap_disc_lastsector

◆ cdda_errors

#define cdda_errors   cdio_cddap_errors

◆ cdda_find_a_cdrom

#define cdda_find_a_cdrom   cdio_cddap_find_a_cdrom

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
404: No medium present
405: Option not supported by drive

For compatibility with good ol' paranoia

◆ cdda_identify

#define cdda_identify   cdio_cddap_identify

◆ cdda_messages

#define cdda_messages   cdio_cddap_messages

◆ cdda_open

#define cdda_open   cdio_cddap_open

◆ cdda_read

#define cdda_read   cdio_cddap_read

◆ cdda_read_timed

#define cdda_read_timed   cdio_cddap_read_timed

◆ cdda_sector_gettrack

#define cdda_sector_gettrack   cdio_cddap_sector_gettrack

◆ cdda_speed_set

#define cdda_speed_set   cdio_cddap_speed_set

◆ CDDA_TEST_ALWAYS_JITTER

#define CDDA_TEST_ALWAYS_JITTER   4

jitter testing. The first two bits are set to determine the byte-distance we will jitter the data; 0 is no shifting. < jitter testing. Set the below bit to always cause jittering on reads. The below bit only has any effect if the first two (above) bits are nonzero. If the above bits are set, but the below bit isn't we'll jitter 90% of the time.

◆ CDDA_TEST_FRAG_LARGE

#define CDDA_TEST_FRAG_LARGE   (2<<3)

◆ CDDA_TEST_FRAG_MASSIVE

#define CDDA_TEST_FRAG_MASSIVE   (3<<3)

under-run testing. The below bit is set for testing.

◆ CDDA_TEST_FRAG_SMALL

#define CDDA_TEST_FRAG_SMALL   (1<<3)

fragment testing

◆ CDDA_TEST_UNDERRUN

#define CDDA_TEST_UNDERRUN   64

◆ cdda_track_audiop

#define cdda_track_audiop   cdio_cddap_track_audiop

◆ cdda_track_channels

#define cdda_track_channels   cdio_cddap_track_channels

◆ cdda_track_copyp

#define cdda_track_copyp   cdio_cddap_track_copyp

◆ cdda_track_firstsector

#define cdda_track_firstsector   cdio_cddap_track_firstsector

◆ cdda_track_lastsector

#define cdda_track_lastsector   cdio_cddap_track_lastsector

◆ cdda_track_preemp

#define cdda_track_preemp   cdio_cddap_track_preemp

◆ cdda_tracks

#define cdda_tracks   cdio_cddap_tracks

◆ cdda_verbose_set

#define cdda_verbose_set   cdio_cddap_verbose_set

◆ cdda_version

#define cdda_version   cdio_cddap_version

◆ cdrom_drive

#define cdrom_drive   cdrom_drive_t

◆ MAXTRK

#define MAXTRK   (CDIO_CD_MAX_TRACKS+1)

We keep MAXTRK since this header is exposed publicly and other programs may have used this.

◆ TOC

#define TOC   TOC_t

For compatibility. TOC is deprecated, use TOC_t instead.

Typedef Documentation

◆ cdrom_drive_t

typedef struct cdrom_drive_s cdrom_drive_t

◆ cdrom_paranoia_t

cdrom_paranoia is an opaque structure which is used in all of the library operations.

◆ TOC_t

typedef struct TOC_s TOC_t

Structure for cdparanoia's CD Table of Contents.

Enumeration Type Documentation

◆ paranoia_cdda_enums_t

For compatibility. cdrom_drive_t is deprecated, use cdrom_drive_t instead. Flags for simulating jitter used in testing.

The enumeration type one probably wouldn't really use in a program. It is here instead of defines to give symbolic names that can be helpful in debuggers where wants just to say refer to CDDA_TEST_JITTER_SMALL and get the correct value.

Enumerator
CDDA_MESSAGE_FORGETIT 
CDDA_MESSAGE_PRINTIT 
CDDA_MESSAGE_LOGIT 
CD_FRAMESAMPLES 
MAXTRK 

◆ paranoia_jitter_t

Flags for simulating jitter used in testing.

The enumeration type one probably wouldn't really use in a program. It is here instead of defines to give symbolic names that can be helpful in debuggers where wants just to say refer to CDDA_TEST_JITTER_SMALL and get the correct value.

Enumerator
CDDA_TEST_JITTER_SMALL 
CDDA_TEST_JITTER_LARGE 
CDDA_TEST_JITTER_MASSIVE 
CDDA_TEST_FRAG_SMALL 
CDDA_TEST_FRAG_LARGE 
CDDA_TEST_FRAG_MASSIVE 
CDDA_TEST_UNDERRUN 

◆ transport_error_t

transport errors:

Enumerator
TR_OK 
TR_EWRITE 

Error writing packet command (transport)

TR_EREAD 

Error reading packet data (transport)

TR_UNDERRUN 

Read underrun

TR_OVERRUN 

Read overrun

TR_ILLEGAL 

Illegal/rejected request

TR_MEDIUM 

Medium error

TR_BUSY 

Device busy

TR_NOTREADY 

Device not ready

TR_FAULT 

Device failure

TR_UNKNOWN 

Unspecified error

TR_STREAMING 

loss of streaming

Function Documentation

◆ cdio_cddap_close()

int cdio_cddap_close ( cdrom_drive_t d)

Closes d and releases all storage associated with it. Doubles as "cdrom_drive_free()".

Parameters
dcdrom_drive_t object to be closed.
Returns
0 if passed a null pointer and 1 if not in which case some work was probably done.
See also
cdio_cddap_close_no_free_cdio

◆ cdio_cddap_close_no_free_cdio()

bool cdio_cddap_close_no_free_cdio ( cdrom_drive_t d)

Closes d and releases all storage associated with it except the internal p_cdio pointer.

Parameters
dcdrom_drive_t object to be closed.
Returns
0 if passed a null pointer and 1 if not in which case some work was probably done.
See also
cdio_cddap_close

◆ cdio_cddap_disc_firstsector()

lsn_t cdio_cddap_disc_firstsector ( cdrom_drive_t d)

Get first lsn of the first audio track. -1 is returned on error.

◆ cdio_cddap_disc_lastsector()

lsn_t cdio_cddap_disc_lastsector ( cdrom_drive_t d)

Get last lsn of the last audio track. The last lsn is generally one less than the start of the next track after the audio track. -1 is returned on error.

◆ cdio_cddap_errors()

char * cdio_cddap_errors ( cdrom_drive_t d)

Returns the current error buffer. Free the returned string using cdio_cddap_free_messages() if not NULL.

◆ cdio_cddap_find_a_cdrom()

cdrom_drive_t * cdio_cddap_find_a_cdrom ( int  messagedest,
char **  ppsz_message 
)

autosense functions Get a CD-ROM drive with a CD-DA in it. If mesagedest is CDDA_MESSAGE_LOGIT, then any messages in the process will be stored in message.

When using CDDA_MESSAGE_LOGIT, free the message buffer with cdio_cddap_free_messages() after use.

◆ cdio_cddap_free_messages()

void cdio_cddap_free_messages ( char *  psz_messages)

Frees the message string passed in psz_messages.

References NULL.

◆ cdio_cddap_identify()

cdrom_drive_t * cdio_cddap_identify ( const char *  psz_dev,
int  messagedest,
char **  ppsz_messages 
)

Returns a paranoia CD-ROM drive object with a CD-DA in it or NULL if there was an error.

See also
cdio_cddap_identify_cdio

When using CDDA_MESSAGE_LOGIT, free the message buffer with cdio_cddap_free_messages() after use.

Returns a paranoia CD-ROM drive object with a CD-DA in it or NULL if there was an error.

See also
cdio_cddap_identify_cdio

References idmessage(), and NULL.

◆ cdio_cddap_identify_cdio()

cdrom_drive_t * cdio_cddap_identify_cdio ( CdIo_t *  p_cdio,
int  messagedest,
char **  ppsz_messages 
)

Returns a paranoia CD-ROM drive object with a CD-DA in it or NULL if there was an error. In contrast to cdio_cddap_identify, we start out with an initialized p_cdio object. For example you may have used that for other purposes such as to get CDDB/CD-Text information.

See also
cdio_cddap_identify

When using CDDA_MESSAGE_LOGIT, free the message buffer with cdio_cddap_free_messages() after use.

Returns a paranoia CD-ROM drive object with a CD-DA in it or NULL if there was an error. In contrast to cdio_cddap_identify, we start out with an initialized p_cdio object. For example you may have used that for other purposes such as to get CDDB/CD-Text information.

See also
cdio_cddap_identify

References idmessage(), and NULL.

◆ cdio_cddap_messages()

char * cdio_cddap_messages ( cdrom_drive_t d)

Returns the current message buffer. Free the returned string using cdio_cddap_free_messages() if not NULL.

◆ cdio_cddap_open()

int cdio_cddap_open ( cdrom_drive_t d)

◆ cdio_cddap_read()

long cdio_cddap_read ( cdrom_drive_t d,
void *  p_buffer,
lsn_t  beginsector,
long  sectors 
)

◆ cdio_cddap_read_timed()

long cdio_cddap_read_timed ( cdrom_drive_t d,
void *  p_buffer,
lsn_t  beginsector,
long  sectors,
int *  milliseconds 
)

◆ cdio_cddap_sector_gettrack()

int cdio_cddap_sector_gettrack ( cdrom_drive_t d,
lsn_t  lsn 
)

Return the track containing the given LSN. If the LSN is before the first track (in the pregap), 0 is returned. If there was an error or the LSN after the LEADOUT (beyond the end of the CD), then CDIO_INVALID_TRACK is returned.

◆ cdio_cddap_speed_set()

int cdio_cddap_speed_set ( cdrom_drive_t d,
int  speed 
)

drive-oriented functions

◆ cdio_cddap_track_audiop()

int cdio_cddap_track_audiop ( cdrom_drive_t d,
track_t  i_track 
)

Return 1 is track is an audio track, 0 otherwise.

◆ cdio_cddap_track_channels()

int cdio_cddap_track_channels ( cdrom_drive_t d,
track_t  i_track 
)

Return the 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.

◆ cdio_cddap_track_copyp()

int cdio_cddap_track_copyp ( cdrom_drive_t d,
track_t  i_track 
)

Return 1 is track has copy permit set, 0 otherwise.

Return 1 is track is an audio track, 0 otherwise.

◆ cdio_cddap_track_firstsector()

lsn_t cdio_cddap_track_firstsector ( cdrom_drive_t d,
track_t  i_track 
)

Return the lsn for the start of track i_track

◆ cdio_cddap_track_lastsector()

lsn_t cdio_cddap_track_lastsector ( cdrom_drive_t d,
track_t  i_track 
)

Get last lsn of the track. This generally one less than the start of the next track. -1 is returned on error.

◆ cdio_cddap_track_preemp()

int cdio_cddap_track_preemp ( cdrom_drive_t d,
track_t  i_track 
)

Return 1 is audio track has linear preemphasis set, 0 otherwise. Only makes sense for audio tracks.

◆ cdio_cddap_tracks()

track_t cdio_cddap_tracks ( cdrom_drive_t d)

Return the number of tracks on the CD.

◆ cdio_cddap_verbose_set()

void cdio_cddap_verbose_set ( cdrom_drive_t d,
int  err_action,
int  mes_action 
)

◆ cdio_cddap_version()

const char * cdio_cddap_version ( void  )

informational functions

References LIBCDIO_PARANOIA_VERSION.

◆ data_bigendianp()

int data_bigendianp ( cdrom_drive_t d)

Determine Endian-ness of the CD-drive based on reading data from it. Some drives return audio data Big Endian while some (most) return data Little Endian. Drives known to return data bigendian are SCSI drives from Kodak, Ricoh, HP, Philips, Plasmon, Grundig CDR100IPW, and Mitsumi CD-R. ATAPI and MMC drives are little endian.

rocky: As someone who didn't write the code, I have to say this is nothing less than brilliant. An FFT is done both ways and the the transform is looked at to see which has data in the FFT (or audible) portion. (Or so that's how I understand it.)

Returns
1 if big-endian, 0 if little-endian, -1 if we couldn't figure things out or some error.

Variable Documentation

◆ debug_paranoia_cdda_enums

paranoia_cdda_enums_t debug_paranoia_cdda_enums
extern

◆ debug_paranoia_jitter

paranoia_jitter_t debug_paranoia_jitter
extern

The below variables are trickery to force the above enum symbol values to be recorded in debug symbol tables. They are used to allow one to refer to the enumeration value names in the typedefs above in a debugger and debugger expressions

CD-ROM code which interfaces between user-level visible CD paranoia routines and libddio routines. (There is some GNU/Linux-specific code here too that should probably be removed. The below variables are trickery to force the above enum symbol values to be recorded in debug symbol tables. They are used to allow one to refer to the enumeration value names in the typedefs above in a debugger and debugger expressions