From d10938c43c7dcd30fd2bffb5d06c45eef39594ec Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 17 May 2011 22:59:36 -0400 Subject: [PATCH] Add mmc routine to get the ISRC information on a CD that is in the q subchannel but not showing up in the CDTEXT. Contributed by Scot C. Bontrager. --- THANKS | 5 +++++ include/cdio/mmc.h | 29 +++++++++++++++++++++-------- lib/driver/mmc/mmc.c | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 61 insertions(+), 11 deletions(-) diff --git a/THANKS b/THANKS index afcc8802..687fa8e4 100644 --- a/THANKS +++ b/THANKS @@ -75,3 +75,8 @@ Daniel Schwarz Robert William Fuller get_track_pregap_lba, get_track_pregap_lsn. Section on "CD-DA pregap" in libcdio manual. + +Scot C. Bontrager + mmc routine to get the ISRC information on a CD that is in the q subchannel + but not showing up in the CDTEXT. + diff --git a/include/cdio/mmc.h b/include/cdio/mmc.h index e21a9d70..b742ccf2 100644 --- a/include/cdio/mmc.h +++ b/include/cdio/mmc.h @@ -528,16 +528,29 @@ typedef struct mmc_cdb_s { driver_return_code_t mmc_audio_get_volume (CdIo_t *p_cdio, /*out*/ mmc_audio_volume_t *p_volume); -/** - Read Audio Subchannel information - - @param p_cdio the CD object to be acted upon. - @param p_subchannel place for returned subchannel information -*/ -driver_return_code_t -mmc_audio_read_subchannel (CdIo_t *p_cdio, + /** + Read Audio Subchannel information + + @param p_cdio the CD object to be acted upon. + @param p_subchannel place for returned subchannel information + */ + driver_return_code_t + mmc_audio_read_subchannel (CdIo_t *p_cdio, /*out*/ cdio_subchannel_t *p_subchannel); + /** + Read ISRC Subchannel information. Contributed by + Scot C. Bontrager (scot@indievisible.org) + May 15, 2011 - + + @param p_cdio the CD object to be acted upon. + @param track the track you to get ISRC info + @param buf place to put ISRC info + */ + driver_return_code_t + mmc_isrc_track_read_subchannel (CdIo_t *p_cdio, /*in*/ const track_t track, + /*out*/ char *p_isrc); + /** Return a string containing the name of the audio state as returned from the Q_SUBCHANNEL. diff --git a/lib/driver/mmc/mmc.c b/lib/driver/mmc/mmc.c index f8cf454f..9140a5a8 100644 --- a/lib/driver/mmc/mmc.c +++ b/lib/driver/mmc/mmc.c @@ -475,6 +475,41 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio, cdio_subchannel_t *p_subchannel) return i_rc; } +/** + Read ISRC Subchannel information. Contributed by + Scot C. Bontrager (scot@indievisible.org) + May 15, 2011 - + + @param p_cdio the CD object to be acted upon. + @param track the track you to get ISRC info + @param buf place to put ISRC info +*/ +driver_return_code_t +mmc_isrc_track_read_subchannel (CdIo_t *p_cdio, /*in*/ const track_t track, + /*out*/ char *p_isrc) +{ + mmc_cdb_t cdb = {{0, }}; + driver_return_code_t i_rc; + char buf[28] = { 0, }; + + if (!p_cdio) return DRIVER_OP_UNINIT; + + CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_SUBCHANNEL); + CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf)); + + cdb.field[1] = 0x0; + cdb.field[2] = 1 << 6; + cdb.field[3] = CDIO_SUBCHANNEL_TRACK_ISRC; /* 0x03 */ + cdb.field[6] = track; + + i_rc = mmc_run_cmd(p_cdio, mmc_timeout_ms, &cdb, SCSI_MMC_DATA_READ, + sizeof(buf), buf); + if (DRIVER_OP_SUCCESS == i_rc) { + strncpy(p_isrc, &buf[9], sizeof(buf)-9); + } + return i_rc; +} + /** Get the block size used in read requests, via MMC (e.g. READ_10, READ_MSF, ...) @@ -1015,9 +1050,6 @@ mmc_set_blocksize ( const CdIo_t *p_cdio, uint16_t i_blocksize) i_blocksize); } - - - /* * Local variables: