Allow a status parameter in mmc_get_disc_eraseable to be NULL. Suggested by Frank Endres on libcdio-devel mailing list.
This commit is contained in:
@@ -557,11 +557,15 @@ 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.
|
@param i_status, if not NULL, on return will be set indicate
|
||||||
@return true if the disc is detected as erasable (rewritable), false
|
whether the operation was a success (DRIVER_OP_SUCCESS) or if not
|
||||||
otherwise.
|
to some other value.
|
||||||
|
|
||||||
|
@return true if the disc is detected as erasable (rewritable),
|
||||||
|
false otherwise.
|
||||||
*/
|
*/
|
||||||
bool mmc_get_disc_erasable( const CdIo_t *p_cdio,
|
bool mmc_get_disc_erasable( const CdIo_t *p_cdio,
|
||||||
driver_return_code_t *i_status );
|
driver_return_code_t *i_status );
|
||||||
|
|||||||
@@ -682,29 +682,32 @@ 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.
|
@param i_status, if not NULL, 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, driver_return_code_t *i_status ) {
|
mmc_get_disc_erasable( const CdIo_t *p_cdio,
|
||||||
|
driver_return_code_t *opt_i_status ) {
|
||||||
mmc_cdb_t cdb = {{0, }};
|
mmc_cdb_t cdb = {{0, }};
|
||||||
uint8_t buf[42] = { 0, };
|
uint8_t buf[42] = { 0, };
|
||||||
|
driver_return_code_t 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 (opt_i_status != NULL) *opt_i_status = i_status;
|
||||||
if (buf[2] & 0x10)
|
return (DRIVER_OP_SUCCESS == i_status) ?
|
||||||
return true;
|
((buf[2] & 0x10) ? true : false)
|
||||||
else
|
: false;
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,7 +85,10 @@ tmmc_get_disc_erasable(const CdIo_t *p_cdio, const char *psz_source,
|
|||||||
{
|
{
|
||||||
driver_return_code_t drc;
|
driver_return_code_t drc;
|
||||||
bool b_erasable = mmc_get_disc_erasable(p_cdio, &drc);
|
bool b_erasable = mmc_get_disc_erasable(p_cdio, &drc);
|
||||||
printf("Disc is %serasable.\n", b_erasable ? "" : "not ");
|
if (verbose)
|
||||||
|
printf("Disc is %serasable.\n", b_erasable ? "" : "not ");
|
||||||
|
/* Try also with NULL. */
|
||||||
|
b_erasable = mmc_get_disc_erasable(p_cdio, NULL);
|
||||||
return drc;
|
return drc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user