diff --git a/include/cdio/mmc.h b/include/cdio/mmc.h index e774da71..c9d2610a 100644 --- a/include/cdio/mmc.h +++ b/include/cdio/mmc.h @@ -1,5 +1,5 @@ /* - $Id: mmc.h,v 1.16 2005/03/02 04:24:00 rocky Exp $ + $Id: mmc.h,v 1.17 2005/03/06 02:59:26 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -425,6 +425,12 @@ typedef struct mmc_subchannel_s driver_return_code_t mmc_audio_read_subchannel (CdIo_t *p_cdio, cdio_subchannel_t *p_subchannel); +/*! + Return a string containing the name of the audio state as returned from + the Q_SUBCHANNEL. + */ +const char *mmc_audio_state2str( uint8_t i_audio_state ); + /*! * Eject using MMC commands. diff --git a/lib/driver/mmc.c b/lib/driver/mmc.c index 019341f9..d89b3164 100644 --- a/lib/driver/mmc.c +++ b/lib/driver/mmc.c @@ -1,6 +1,6 @@ /* Common Multimedia Command (MMC) routines. - $Id: mmc.c,v 1.20 2005/03/06 00:03:53 rocky Exp $ + $Id: mmc.c,v 1.21 2005/03/06 02:59:26 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein @@ -68,6 +68,30 @@ audio_read_subchannel_mmc ( void *p_user_data, cdio_subchannel_t *p_subchannel) return mmc_audio_read_subchannel(p_env->cdio, p_subchannel); } +/*! + Return a string containing the name of the audio state as returned from + the Q_SUBCHANNEL. + */ +const char *mmc_audio_state2str( uint8_t i_audio_state ) +{ + switch(i_audio_state) { + case CDIO_MMC_READ_SUB_ST_INVALID: + return "invalid"; + case CDIO_MMC_READ_SUB_ST_PLAY: + return "playing"; + case CDIO_MMC_READ_SUB_ST_PAUSED: + return "paused"; + case CDIO_MMC_READ_SUB_ST_COMPLETED: + return "completed"; + case CDIO_MMC_READ_SUB_ST_ERROR: + return "error"; + case CDIO_MMC_READ_SUB_ST_NO_STATUS: + return "no status"; + default: + return "unknown"; + } +} + /*! Get the block size for subsequest read requests, via MMC. @return the blocksize if > 0; error if <= 0 diff --git a/src/cd-info.c b/src/cd-info.c index 48743449..a7655013 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.130 2005/03/05 19:27:28 rocky Exp $ + $Id: cd-info.c,v 1.131 2005/03/06 02:59:26 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein Copyright (C) 1996, 1997, 1998 Gerd Knorr @@ -1133,9 +1133,11 @@ main(int argc, const char *argv[]) if (cdio_is_discmode_cdrom(discmode)) { /* get and print MCN */ + + report(stdout, "Media Catalog Number (MCN): "); fflush(stdout); + media_catalog_number = cdio_get_mcn(p_cdio); - report(stdout, "Media Catalog Number (MCN): "); fflush(stdout); if (NULL == media_catalog_number) { if (i_read_cap & CDIO_DRIVE_CAP_READ_MCN) report(stdout, "not available\n"); @@ -1170,35 +1172,29 @@ main(int argc, const char *argv[]) memset(&subchannel, 0, sizeof(subchannel)); subchannel.format = CDIO_CDROM_MSF; - rc = cdio_audio_read_subchannel(p_cdio, &subchannel); - report( stdout, "audio status: "); fflush(stdout); + rc = cdio_audio_read_subchannel(p_cdio, &subchannel); + if (DRIVER_OP_SUCCESS == rc) { bool b_volume = false; bool b_position = false; - + + report ( stdout, "%s\n", + mmc_audio_state2str(subchannel.audio_status) ); + switch (subchannel.audio_status) { - case CDIO_MMC_READ_SUB_ST_INVALID: - report( stdout, "invalid\n" ); break; case CDIO_MMC_READ_SUB_ST_PLAY: b_playing_audio = true; - b_position = true; - b_volume = true; - report( stdout, "playing" ); break; + /* Fall through to next case. */ case CDIO_MMC_READ_SUB_ST_PAUSED: b_position = true; - b_volume = true; - report( stdout, "paused" ); break; - case CDIO_MMC_READ_SUB_ST_COMPLETED: - report( stdout, "completed\n"); break; - case CDIO_MMC_READ_SUB_ST_ERROR: - report( stdout, "error\n" ); break; + /* Fall through to next case. */ case CDIO_MMC_READ_SUB_ST_NO_STATUS: b_volume = true; - report( stdout, "no status\n" ); break; + break; default: - report( stdout, "Oops: unknown\n" ); + ; } if (b_position)