diff --git a/example/sample8.c b/example/sample8.c index dec60891..87985c94 100644 --- a/example/sample8.c +++ b/example/sample8.c @@ -1,5 +1,5 @@ /* - $Id: sample8.c,v 1.4 2004/07/17 02:18:26 rocky Exp $ + $Id: sample8.c,v 1.5 2004/07/21 10:19:20 rocky Exp $ Copyright (C) 2003 Rocky Bernstein @@ -30,8 +30,7 @@ static void print_cdtext_track_info(CdIo *cdio, track_t i_track, const char *message) { - const cdtext_t *cdtext = cdio_get_cdtext(cdio, 0); - + const cdtext_t *cdtext = cdio_get_cdtext(cdio, 0); if (NULL != cdtext) { cdtext_field_t i; @@ -43,11 +42,31 @@ print_cdtext_track_info(CdIo *cdio, track_t i_track, const char *message) { } } } + } static void print_cdtext_info(CdIo *cdio, track_t i_tracks, track_t i_first_track) { track_t i_last_track = i_first_track+i_tracks; + cd_disctype_t cd_disctype = cdio_get_disctype(cdio); + + switch (cd_disctype) { + case CDIO_DISC_TYPE_CD: + printf("Disc is CD-DA or CD-ROM.\n"); + break; + case CDIO_DISC_TYPE_CD_I: + printf("Disc is CD-i.\n"); + break; + case CDIO_DISC_TYPE_XA: + printf("Disc is CD-XA or DDCD.\n"); + break; + case CDIO_DISC_TYPE_UNDEF: + printf("Not a CD - perhaps a DVD.\n"); + break; + case CDIO_DISC_TYPE_ERROR: + printf("Error getting CD info or request not supported by drive.\n"); + break; + } print_cdtext_track_info(cdio, 0, "\nCD-TEXT for Disc:"); for ( ; i_first_track < i_last_track; i_first_track++ ) { @@ -60,20 +79,20 @@ print_cdtext_info(CdIo *cdio, track_t i_tracks, track_t i_first_track) { int main(int argc, const char *argv[]) { + track_t i_first_track; + track_t i_tracks; CdIo *cdio = cdio_open ("../test/cdda.cue", DRIVER_BINCUE); - track_t i_first_track = cdio_get_first_track_num(cdio); - track_t i_tracks = cdio_get_num_tracks(cdio); if (NULL == cdio) { - printf("Couldn't open ../test/cdda.cue with BIN/CUE driver \n"); - return 1; + printf("Couldn't open ../test/cdda.cue with BIN/CUE driver.\n"); } else { + i_first_track = cdio_get_first_track_num(cdio); + i_tracks = cdio_get_num_tracks(cdio); print_cdtext_info(cdio, i_tracks, i_first_track); + cdio_destroy(cdio); } - cdio_destroy(cdio); - cdio = cdio_open (NULL, DRIVER_UNKNOWN); i_first_track = cdio_get_first_track_num(cdio); i_tracks = cdio_get_num_tracks(cdio); diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h index 618d32b0..081458e9 100644 --- a/include/cdio/cdio.h +++ b/include/cdio/cdio.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: cdio.h,v 1.58 2004/07/17 22:16:46 rocky Exp $ + $Id: cdio.h,v 1.59 2004/07/21 10:19:20 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -118,19 +118,19 @@ extern "C" { /*! Eject media in CD drive if there is a routine to do so. - @param obj the CD object to be acted upon. + @param cd_obj the CD object to be acted upon. @return 0 if success and 1 for failure, and 2 if no routine. - If the CD is ejected *obj is freed and obj set to NULL. + If the CD is ejected *cd_obj is freed and cd_obj set to NULL. */ - int cdio_eject_media (CdIo **obj); + int cdio_eject_media (CdIo **cd_obj); /*! - Free any resources associated with obj. Call this when done using obj + Free any resources associated with cd_obj. Call this when done using cd_obj and using CD reading/control operations. - @param obj the CD object to eliminated. + @param cd_obj the CD object to eliminated. */ - void cdio_destroy (CdIo *obj); + void cdio_destroy (CdIo *cd_obj); /*! Free device list returned by cdio_get_devices or @@ -147,24 +147,24 @@ extern "C" { /*! Get the value associatied with key. - @param obj the CD object queried + @param cd_obj the CD object queried @param key the key to retrieve - @return the value associatd with "key" or NULL if obj is NULL + @return the value associatd with "key" or NULL if cd_obj is NULL or "key" does not exist. */ - const char * cdio_get_arg (const CdIo *obj, const char key[]); + const char * cdio_get_arg (const CdIo *cd_obj, const char key[]); /*! Get cdtext information for a CdIo object. - @param obj the CD object that may contain CD-TEXT information. + @param cd_obj the CD object that may contain CD-TEXT information. @return the CD-TEXT object or NULL if obj is NULL or CD-TEXT information does not exist. If i_track is 0 or CDIO_CDROM_LEADOUT_TRACK the track returned is the information assocated with the CD. */ - const cdtext_t *cdio_get_cdtext (CdIo *obj, track_t i_track); + const cdtext_t *cdio_get_cdtext (CdIo *cd_obj, track_t i_track); /*! Get an array of device names in search_devices that have at @@ -201,10 +201,10 @@ extern "C" { /*! Get the default CD device. - if obj is NULL (we haven't initialized a specific device driver), + if cd_obj is NULL (we haven't initialized a specific device driver), then find a suitable one and return the default device for that. - @param obj the CD object queried + @param cd_obj the CD object queried @return a string containing the default CD device or NULL is if we couldn't get a default device. @@ -212,19 +212,19 @@ extern "C" { there is no media in it and it is possible for this routine to return NULL even though there may be a hardware CD-ROM. */ - char * cdio_get_default_device (const CdIo *obj); + char * cdio_get_default_device (const CdIo *cd_obj); /*! Get the what kind of device we've got. - @param obj the CD object queried + @param cd_obj the CD object queried @return a list of device capabilities. In some situations of drivers or OS's we can't find a CD device if there is no media in it and it is possible for this routine to return NULL even though there may be a hardware CD-ROM. */ - void cdio_get_drive_cap (const CdIo *obj, + void cdio_get_drive_cap (const CdIo *cd_obj, cdio_drive_read_cap_t *p_read_cap, cdio_drive_write_cap_t *p_write_cap, cdio_drive_misc_cap_t *p_misc_cap); @@ -253,7 +253,7 @@ extern "C" { string when done with it. */ - char * cdio_get_mcn (const CdIo *obj); + char * cdio_get_mcn (const CdIo *cd_obj); /*! Get a string containing the name of the driver in use. @@ -261,7 +261,7 @@ extern "C" { @return a string with driver name or NULL if CdIo is NULL (we haven't initialized a specific device. */ - const char * cdio_get_driver_name (const CdIo *obj); + const char * cdio_get_driver_name (const CdIo *cd_obj); /*! Get the driver id. @@ -270,7 +270,7 @@ extern "C" { @return the driver id.. */ - driver_id_t cdio_get_driver_id (const CdIo *obj); + driver_id_t cdio_get_driver_id (const CdIo *cd_obj); /*! Get the number of the first track. @@ -278,20 +278,27 @@ extern "C" { @return the track number or CDIO_INVALID_TRACK on error. */ - track_t cdio_get_first_track_num(const CdIo *obj); + track_t cdio_get_first_track_num(const CdIo *cd_obj); + /*! + 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 *cd_obj); + /*! 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 *obj); + track_t cdio_get_num_tracks (const CdIo *cd_obj); /*! Get the format (audio, mode2, mode1) of track. */ - track_format_t cdio_get_track_format(const CdIo *obj, track_t i_track); + track_format_t cdio_get_track_format(const CdIo *cd_obj, track_t i_track); /*! Return true if we have XA data (green, mode2 form1) or @@ -301,25 +308,25 @@ extern "C" { FIXME: there's gotta be a better design for this and get_track_format? */ - bool cdio_get_track_green(const CdIo *obj, track_t i_track); + bool cdio_get_track_green(const CdIo *cd_obj, track_t i_track); /*! Get the starting LBA for track number - i_track in obj. Track numbers usually start at something + i_track in cd_obj. Track numbers usually start at something greater than 0, usually 1. The "leadout" track is specified either by using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1. - @param obj object to get information from + @param cd_obj object to get information from @param i_track the track number we want the LSN for @return the starting LBA or CDIO_INVALID_LBA on error. */ - lba_t cdio_get_track_lba(const CdIo *obj, track_t i_track); + lba_t cdio_get_track_lba(const CdIo *cd_obj, track_t i_track); /*! Return the starting MSF (minutes/secs/frames) for track number - i_track in obj. Track numbers usually start at something + i_track in cd_obj. Track numbers usually start at something greater than 0, usually 1. The "leadout" track is specified either by @@ -329,11 +336,11 @@ extern "C" { @param i_track the track number we want the LSN for @return the starting LSN or CDIO_INVALID_LSN on error. */ - lsn_t cdio_get_track_lsn(const CdIo *obj, track_t i_track); + lsn_t cdio_get_track_lsn(const CdIo *cd_obj, track_t i_track); /*! Return the starting MSF (minutes/secs/frames) for track number - i_track in obj. Track numbers usually start at something + i_track in cd_obj. Track numbers usually start at something greater than 0, usually 1. The "leadout" track is specified either by @@ -341,7 +348,7 @@ extern "C" { @return true if things worked or false if there is no track entry. */ - bool cdio_get_track_msf(const CdIo *obj, track_t i_track, + bool cdio_get_track_msf(const CdIo *cd_obj, track_t i_track, /*out*/ msf_t *msf); /*! @@ -352,19 +359,19 @@ extern "C" { @return the number of sectors or 0 if there is an error. */ - unsigned int cdio_get_track_sec_count(const CdIo *obj, track_t i_track); + unsigned int cdio_get_track_sec_count(const CdIo *cd_obj, track_t i_track); /*! Reposition read offset Similar to (if not the same as) libc's lseek() - @param obj object to get information from + @param cd_obj 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 *obj, off_t offset, int whence); + off_t cdio_lseek(const CdIo *cd_obj, off_t offset, int whence); /*! Reads into buf the next size bytes. @@ -372,36 +379,36 @@ extern "C" { @return (ssize_t) -1 on error. */ - ssize_t cdio_read(const CdIo *obj, void *buf, size_t size); + ssize_t cdio_read(const CdIo *cd_obj, void *buf, size_t size); /*! Read an audio sector - @param obj object to read from + @param cd_obj object to read from @param buf place to read data into @param lsn sector to read @return 0 if no error, nonzero otherwise. */ - int cdio_read_audio_sector (const CdIo *obj, void *buf, lsn_t lsn); + int cdio_read_audio_sector (const CdIo *cd_obj, void *buf, lsn_t lsn); /*! Reads audio sectors - @param obj object to read from + @param cd_obj object to read from @param buf place to read data into @param lsn sector to read @param i_sectors number of sectors to read @return 0 if no error, nonzero otherwise. */ - int cdio_read_audio_sectors (const CdIo *obj, void *buf, lsn_t lsn, + int cdio_read_audio_sectors (const CdIo *cd_obj, void *buf, lsn_t lsn, unsigned int i_sectors); /*! Reads a mode1 sector - @param obj object to read from + @param cd_obj 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 @@ -409,13 +416,13 @@ extern "C" { @return 0 if no error, nonzero otherwise. */ - int cdio_read_mode1_sector (const CdIo *obj, void *buf, lsn_t lsn, + int cdio_read_mode1_sector (const CdIo *cd_obj, void *buf, lsn_t lsn, bool b_form2); /*! Reads mode1 sectors - @param obj object to read from + @param cd_obj 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 @@ -424,13 +431,13 @@ extern "C" { @return 0 if no error, nonzero otherwise. */ - int cdio_read_mode1_sectors (const CdIo *obj, void *buf, lsn_t lsn, + int cdio_read_mode1_sectors (const CdIo *cd_obj, void *buf, lsn_t lsn, bool b_form2, unsigned int i_sectors); /*! Reads a mode1 sector - @param obj object to read from + @param cd_obj 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 @@ -438,13 +445,13 @@ extern "C" { @return 0 if no error, nonzero otherwise. */ - int cdio_read_mode2_sector (const CdIo *obj, void *buf, lsn_t lsn, + int cdio_read_mode2_sector (const CdIo *cd_obj, void *buf, lsn_t lsn, bool b_form2); /*! Reads mode2 sectors - @param obj object to read from + @param cd_obj 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 @@ -453,26 +460,26 @@ extern "C" { @return 0 if no error, nonzero otherwise. */ - int cdio_read_mode2_sectors (const CdIo *obj, void *buf, lsn_t lsn, + int cdio_read_mode2_sectors (const CdIo *cd_obj, void *buf, lsn_t lsn, bool b_form2, unsigned int i_sectors); /*! Set the arg "key" with "value" in "obj". - @param obj the CD object to set + @param cd_obj the CD object to set @param key the key to set @param value the value to assocaiate with key @return 0 if no error was found, and nonzero otherwise. */ - int cdio_set_arg (CdIo *obj, const char key[], const char value[]); + int cdio_set_arg (CdIo *cd_obj, const char key[], const char value[]); /*! Get the size of the CD in logical block address (LBA) units. - @param obj the CD object queried + @param cd_obj the CD object queried @return the size */ - uint32_t cdio_stat_size (const CdIo *obj); + uint32_t cdio_stat_size (const CdIo *cd_obj); /*! Initialize CD Reading and control routines. Should be called first. @@ -604,7 +611,7 @@ extern "C" { CdIo * cdio_open_am_cd (const char *psz_device, const char *psz_access_mode); - /*! CDRWIN BIN/CUE CD disk-image routines. Source is the .cue file + /*! CDRWIN BIN/CUE CD disc-image routines. Source is the .cue file @return the cdio object for subsequent operations. NULL on error. diff --git a/include/cdio/scsi_mmc.h b/include/cdio/scsi_mmc.h index 07fcb7bc..82df634d 100644 --- a/include/cdio/scsi_mmc.h +++ b/include/cdio/scsi_mmc.h @@ -1,5 +1,5 @@ /* - $Id: scsi_mmc.h,v 1.9 2004/07/19 01:13:31 rocky Exp $ + $Id: scsi_mmc.h,v 1.10 2004/07/21 10:19:20 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -26,6 +26,23 @@ #ifndef __SCSI_MMC_H__ #define __SCSI_MMC_H__ +/*! The generic packet command opcodes for CD/DVD Logical Units. */ + +#define CDIO_MMC_GPCMD_MODE_SENSE 0x1a +#define CDIO_MMC_GPCMD_START_STOP 0x1b +#define CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL 0x1e +#define CDIO_MMC_GPCMD_READ_10 0x28 +#define CDIO_MMC_GPCMD_READ_SUBCHANNEL 0x42 +#define CDIO_MMC_GPCMD_READ_TOC 0x43 +#define CDIO_MMC_GPCMD_READ_DISC_INFO 0x51 +#define CDIO_MMC_GPCMD_MODE_SELECT 0x55 +#define CDIO_MMC_GPCMD_MODE_SELECT_6 0x15 +#define CDIO_MMC_GPCMD_MODE_SENSE_10 0x5a +#define CDIO_MMC_GPCMD_READ_12 0xa8 +#define CDIO_MMC_GPCMD_READ_CD 0xbe +#define CDIO_MMC_GPCMD_READ_MSF 0xb9 + + /*! Level values that can go into READ_CD */ #define CDIO_MMC_READ_TYPE_ANY 0 /**< All types */ #define CDIO_MMC_READ_TYPE_CDDA 1 /**< Only CD-DA sectors */ @@ -42,22 +59,6 @@ #define CDIO_MMC_READTOC_FMT_ATIP 4 /**< includes media type */ #define CDIO_MMC_READTOC_FMT_CDTEXT 5 /**< CD-TEXT info */ -/*! The generic packet command opcodes for CD/DVD Logical Units. */ - -#define CDIO_MMC_GPCMD_MODE_SENSE 0x1a -#define CDIO_MMC_GPCMD_START_STOP 0x1b -#define CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL 0x1e -#define CDIO_MMC_GPCMD_READ_10 0x28 -#define CDIO_MMC_GPCMD_READ_SUBCHANNEL 0x42 -#define CDIO_MMC_GPCMD_READ_TOC 0x43 -#define CDIO_MMC_GPCMD_MODE_SELECT 0x55 -#define CDIO_MMC_GPCMD_MODE_SELECT_6 0x15 -#define CDIO_MMC_GPCMD_MODE_SENSE_10 0x5a -#define CDIO_MMC_GPCMD_READ_12 0xa8 -#define CDIO_MMC_GPCMD_READ_CD 0xbe -#define CDIO_MMC_GPCMD_READ_MSF 0xb9 - - /*! Page codes for MODE SENSE and MODE SET. */ #define CDIO_MMC_R_W_ERROR_PAGE 0x01 #define CDIO_MMC_WRITE_PARMS_PAGE 0x05 diff --git a/include/cdio/sector.h b/include/cdio/sector.h index 4f29eb3a..d8f792f3 100644 --- a/include/cdio/sector.h +++ b/include/cdio/sector.h @@ -1,5 +1,5 @@ /* - $Id: sector.h,v 1.18 2004/07/17 15:31:00 rocky Exp $ + $Id: sector.h,v 1.19 2004/07/21 10:19:21 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -81,11 +81,19 @@ typedef enum { MODE2_RAW /**< 2352 byte block length */ } trackmode_t; -/*! disc modes (5.29.2.8) */ +/*! disc modes. The first combined from MMC-3 5.29.2.8 and + GNU/Linux /usr/include/linux/cdrom.h and we've added DVD. + */ typedef enum { - CDIO_DISC_MODE_CD_DA, /* CD-DA */ - CDIO_DISC_MODE_CD_ROM, /* CD-ROM mode 1 */ - CDIO_DISC_MODE_CD_ROM_XA /* CD-ROM XA and CD-I */ + CDIO_DISC_MODE_CD_DA, /**< CD-DA */ + CDIO_DISC_MODE_CD_DATA_1, /**< CD-ROM mode 1 */ + CDIO_DISC_MODE_CD_DATA_2, /**< CD-ROM mode 2 */ + CDIO_DISC_MODE_CD_XA_2_1, /**< CD-ROM mode 1 */ + CDIO_DISC_MODE_CD_XA_2_2, /**< CD-ROM mode 2 */ + CDIO_DISC_MODE_CD_MIXED, /**< CD-ROM XA and CD-I */ + CDIO_DISC_MODE_DVD, /**< some sort of DVD */ + CDIO_DISC_MODE_NO_INFO, + CDIO_DISC_MODE_ERROR } discmode_t; /*! Information that can be obtained through a Read Subchannel diff --git a/lib/_cdio_linux.c b/lib/_cdio_linux.c index c1ff5bd9..2286f528 100644 --- a/lib/_cdio_linux.c +++ b/lib/_cdio_linux.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_linux.c,v 1.70 2004/07/19 01:13:31 rocky Exp $ + $Id: _cdio_linux.c,v 1.71 2004/07/21 10:19:21 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.70 2004/07/19 01:13:31 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.71 2004/07/21 10:19:21 rocky Exp $"; #include @@ -155,6 +155,40 @@ cdio_is_cdrom(char *drive, char *mnttype) return(is_cd); } +/*! + Get disc tyhpe associated with cd_obj. +*/ +static discmode_t +_get_discmode_linux (void *user_data) +{ + _img_private_t *env = user_data; + + int32_t i_discmode; + i_discmode = ioctl (env->gen.fd, CDROM_DISC_STATUS); + + if (i_discmode < 0) return CDIO_DISC_MODE_ERROR; + + /* FIXME Need to add getting DVD types. */ + switch(i_discmode) { + case CDS_AUDIO: + return CDIO_DISC_MODE_CD_DA; + case CDS_DATA_1: + return CDIO_DISC_MODE_CD_DATA_1; + case CDS_DATA_2: + return CDIO_DISC_MODE_CD_DATA_2; + case CDS_MIXED: + return CDIO_DISC_MODE_CD_MIXED; + case CDS_XA_2_1: + return CDIO_DISC_MODE_CD_XA_2_1; + case CDS_XA_2_2: + return CDIO_DISC_MODE_CD_XA_2_2; + case CDS_NO_INFO: + return CDIO_DISC_MODE_NO_INFO; + default: + return CDIO_DISC_MODE_ERROR; + } +} + static char * cdio_check_mounts(const char *mtab) { @@ -708,35 +742,32 @@ static bool _init_cdtext_linux (_img_private_t *env) { + struct cdrom_generic_command cdc; + struct request_sense sense; + unsigned char wdata[2000]= {0, }; /* Data read from device starts here */ int status; - struct scsi_cmd { - unsigned int inlen; /* Length of data written to device */ - unsigned int outlen; /* Length of data read from device */ - unsigned char cdb[10]; /* SCSI command bytes (6 <= x <= 16) */ - unsigned char wdata[5000]; /* Data read from device starts here - On error, sense buffer starts here */ - } scsi_cmd; - memset( scsi_cmd.cdb, 0, sizeof(scsi_cmd.cdb) ); + memset(&cdc, 0, sizeof(struct cdrom_generic_command)); + memset(&sense, 0, sizeof(struct request_sense)); /* Operation code */ - CDIO_MMC_SET_COMMAND(scsi_cmd.cdb, CDIO_MMC_GPCMD_READ_TOC); - - scsi_cmd.cdb[1] = 0x02; /* MSF mode */ + CDIO_MMC_SET_COMMAND(cdc.cmd, CDIO_MMC_GPCMD_READ_TOC); /* Format */ - scsi_cmd.cdb[2] = CDIO_MMC_READTOC_FMT_CDTEXT; + cdc.cmd[2] = CDIO_MMC_READTOC_FMT_CDTEXT; - CDIO_MMC_SET_READ_LENGTH(scsi_cmd.cdb, sizeof(scsi_cmd.wdata)); + cdc.buffer = wdata; + cdc.buflen = sizeof(wdata); + cdc.stat = 0; + cdc.sense = &sense; + cdc.data_direction = CGC_DATA_READ; - scsi_cmd.inlen = sizeof(scsi_cmd.cdb); - scsi_cmd.outlen = sizeof(scsi_cmd.wdata); - status = ioctl(env->gen.fd, SCSI_IOCTL_SEND_COMMAND, (void *)&scsi_cmd); - if (status != 0) { - cdio_warn ("CDTEXT reading failed: %s\n", strerror(errno)); + status = ioctl(env->gen.fd, CDROM_SEND_PACKET, (void *)&cdc); + if (status < 0) { + cdio_info ("CDTEXT reading failed\n"); return false; } else { - return cdtext_data_init(env, FIRST_TRACK_NUM, scsi_cmd.wdata, + return cdtext_data_init(env, FIRST_TRACK_NUM, wdata, set_cdtext_field_linux); } } @@ -1250,6 +1281,7 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode) .get_cdtext = _get_cdtext_linux, .get_devices = cdio_get_devices_linux, .get_default_device = cdio_get_default_device_linux, + .get_discmode = _get_discmode_linux, .get_drive_cap = _get_drive_cap_linux, .get_first_track_num= _get_first_track_num_linux, .get_mcn = _get_mcn_linux, @@ -1286,9 +1318,7 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode) _set_arg_linux(_data, "source", psz_orig_source); else { /* The below would be okay if all device drivers worked this way. */ -#if 0 cdio_info ("source %s is a not a device", psz_orig_source); -#endif return NULL; } } diff --git a/lib/cdio.c b/lib/cdio.c index b2ea2b83..42bd964e 100644 --- a/lib/cdio.c +++ b/lib/cdio.c @@ -1,5 +1,5 @@ /* - $Id: cdio.c,v 1.63 2004/07/18 05:12:03 rocky Exp $ + $Id: cdio.c,v 1.64 2004/07/21 10:19:21 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 2001 Herbert Valerio Riedel @@ -39,7 +39,7 @@ #include #include "cdio_private.h" -static const char _rcsid[] = "$Id: cdio.c,v 1.63 2004/07/18 05:12:03 rocky Exp $"; +static const char _rcsid[] = "$Id: cdio.c,v 1.64 2004/07/21 10:19:21 rocky Exp $"; const char *track_format2str[6] = @@ -511,6 +511,21 @@ cdio_get_first_track_num (const CdIo *cdio) } } +/*! + 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 a string containing the name of the driver in use. if CdIo is NULL (we haven't initialized a specific device driver), diff --git a/lib/cdio_private.h b/lib/cdio_private.h index 70122b37..b9cf1296 100644 --- a/lib/cdio_private.h +++ b/lib/cdio_private.h @@ -1,5 +1,5 @@ /* - $Id: cdio_private.h,v 1.30 2004/07/17 22:16:47 rocky Exp $ + $Id: cdio_private.h,v 1.31 2004/07/21 10:19:21 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -82,6 +82,11 @@ extern "C" { */ char * (*get_default_device)(void); + /*! + Get disc mode associated with cd_obj. + */ + discmode_t (*get_discmode) (void *env); + /*! Return the what kind of device we've got.