Add a driver return code parameter to mmc_get_get_disc_erasable.

This commit is contained in:
R. Bernstein
2010-01-29 03:51:21 -05:00
parent edf69959c1
commit aef85b1bc7
3 changed files with 32 additions and 18 deletions

View File

@@ -540,11 +540,13 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
/** /**
Detects if a disc (CD or DVD) is erasable or not. Detects if a disc (CD or DVD) is erasable or not.
@param p_user_data the CD object to be acted upon. @param p_user_data the CD object to be acted upon.
@param i_status on return will be set indicate whether the operation
was a success (DRIVER_OP_SUCCESS) or if not to some other value.
@return true if the disc is detected as erasable (rewritable), false @return true if the disc is detected as erasable (rewritable), false
otherwise. otherwise.
*/ */
bool bool mmc_get_disc_erasable( const CdIo_t *p_cdio,
mmc_get_disc_erasable( const CdIo_t *p_cdio ); driver_return_code_t *i_status );
/** /**
Get the lsn of the end of the CD Get the lsn of the end of the CD
@@ -620,7 +622,8 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
@return DRIVER_OP_SUCCESS (0) if we got the status. @return DRIVER_OP_SUCCESS (0) if we got the status.
return codes are the same as driver_return_code_t return codes are the same as driver_return_code_t
*/ */
int mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2]); driver_return_code_t mmc_get_event_status(const CdIo_t *p_cdio,
uint8_t out_buf[2]);
/** /**
Find out if media tray is open or closed. Find out if media tray is open or closed.

View File

@@ -683,21 +683,22 @@ mmc_get_cmd_len(uint8_t scsi_cmd)
/** /**
Detects if a disc (CD or DVD) is erasable or not. Detects if a disc (CD or DVD) is erasable or not.
@param p_user_data the CD object to be acted upon. @param p_user_data the CD object to be acted upon.
@param i_status on return will be set indicate whether the operation
was a success (DRIVER_OP_SUCCESS) or if not to some other value.
@return true if the disc is detected as erasable (rewritable), false @return true if the disc is detected as erasable (rewritable), false
otherwise. otherwise.
*/ */
bool bool
mmc_get_disc_erasable( const CdIo_t *p_cdio ) { mmc_get_disc_erasable( const CdIo_t *p_cdio, driver_return_code_t *i_status ) {
mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
uint8_t buf[42] = { 0, }; uint8_t buf[42] = { 0, };
int i_status;
CDIO_MMC_SET_COMMAND (cdb.field, CDIO_MMC_GPCMD_READ_DISC_INFO); CDIO_MMC_SET_COMMAND (cdb.field, CDIO_MMC_GPCMD_READ_DISC_INFO);
CDIO_MMC_SET_READ_LENGTH8 (cdb.field, sizeof(buf)); CDIO_MMC_SET_READ_LENGTH8 (cdb.field, sizeof(buf));
i_status = mmc_run_cmd (p_cdio, 0, &cdb, SCSI_MMC_DATA_READ, *i_status = mmc_run_cmd (p_cdio, 0, &cdb, SCSI_MMC_DATA_READ,
sizeof(buf), &buf); sizeof(buf), &buf);
if (i_status == 0) { if (*i_status == 0) {
if (buf[2] & 0x10) if (buf[2] & 0x10)
return true; return true;
else else
@@ -960,7 +961,8 @@ mmc_get_hwinfo ( const CdIo_t *p_cdio,
@return DRIVER_OP_SUCCESS (0) if we got the status. @return DRIVER_OP_SUCCESS (0) if we got the status.
return codes are the same as driver_return_code_t return codes are the same as driver_return_code_t
*/ */
int mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2]) driver_return_code_t
mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2])
{ {
mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
uint8_t buf[8] = { 0, }; uint8_t buf[8] = { 0, };
@@ -981,12 +983,11 @@ int mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2])
mmc_get_cmd_len(cdb.field[0]), mmc_get_cmd_len(cdb.field[0]),
&cdb, SCSI_MMC_DATA_READ, &cdb, SCSI_MMC_DATA_READ,
sizeof(buf), buf); sizeof(buf), buf);
if(i_status == 0) { if(i_status == DRIVER_OP_SUCCESS) {
out_buf[0] = buf[4]; out_buf[0] = buf[4];
out_buf[1] = buf[5]; out_buf[1] = buf[5];
return DRIVER_OP_SUCCESS;
} }
return DRIVER_OP_ERROR; return i_status;
} }
/** /**

View File

@@ -45,8 +45,9 @@ static int tmmc_eject_load_cycle(CdIo_t *p_cdio, int flag);
static int tmmc_eject_test_load(CdIo_t *p_cdio, int flag); static int tmmc_eject_test_load(CdIo_t *p_cdio, int flag);
static void tmmc_get_disc_erasable(const CdIo_t *p_cdio, const char *psz_source, static driver_return_code_t tmmc_get_disc_erasable(const CdIo_t *p_cdio,
int verbose); const char *psz_source,
int verbose);
static int tmmc_handle_outcome(CdIo_t *p_cdio, int i_status, static int tmmc_handle_outcome(CdIo_t *p_cdio, int i_status,
int *sense_avail, int *sense_avail,
@@ -78,12 +79,14 @@ static int tmmc_test(char *drive_path, int flag);
/* ------------------------- Helper functions ---------------------------- */ /* ------------------------- Helper functions ---------------------------- */
static void static driver_return_code_t
tmmc_get_disc_erasable(const CdIo_t *p_cdio, const char *psz_source, tmmc_get_disc_erasable(const CdIo_t *p_cdio, const char *psz_source,
int verbose) int verbose)
{ {
bool b_erasable = mmc_get_disc_erasable(p_cdio); driver_return_code_t drc;
bool b_erasable = mmc_get_disc_erasable(p_cdio, &drc);
printf("disk is %serasable.\n", b_erasable ? "" : "not "); printf("disk is %serasable.\n", b_erasable ? "" : "not ");
return drc;
} }
@@ -743,7 +746,10 @@ main(int argc, const char *argv[])
char **ppsz_drives=NULL; char **ppsz_drives=NULL;
const char *psz_source = NULL; const char *psz_source = NULL;
int ret; int ret;
int exitrc = 0;
bool b_verbose = (argc > 1); bool b_verbose = (argc > 1);
driver_return_code_t drc;
cdio_loglevel_default = b_verbose ? CDIO_LOG_DEBUG : CDIO_LOG_INFO; cdio_loglevel_default = b_verbose ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
@@ -769,8 +775,12 @@ main(int argc, const char *argv[])
exit(1); exit(1);
} }
tmmc_get_disc_erasable(p_cdio, psz_source, b_verbose); drc = tmmc_get_disc_erasable(p_cdio, psz_source, b_verbose);
if (DRIVER_OP_SUCCESS != drc) {
printf("Got status %d back from get_disc_erasable(%s)\n",
drc, psz_source);
}
if ( psz_have_mmc if ( psz_have_mmc
&& 0 == strncmp("true", psz_have_mmc, sizeof("true")) && 0 == strncmp("true", psz_have_mmc, sizeof("true"))
&& (DRIVER_WIN32 != cdio_get_driver_id(p_cdio)) ) { && (DRIVER_WIN32 != cdio_get_driver_id(p_cdio)) ) {
@@ -797,7 +807,7 @@ main(int argc, const char *argv[])
cdio_free_device_list(ppsz_drives); cdio_free_device_list(ppsz_drives);
return 0; return exitrc;
} }