libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libcdio-devel] Re: New MMC functions to detect media type


From: Frank Endres
Subject: Re: [Libcdio-devel] Re: New MMC functions to detect media type
Date: Tue, 9 Feb 2010 15:09:10 -0100

Hi Thomas !

I have finally written a disc capacity detection routine. It works with
empty/blank CDs and DVDs and although simplistic (I am not proud at all of
this solution), it is sufficient for my needs.

#define MMC_TRACK_INFORMATION_DATA_SIZE 48
#define CDIO_MMC_GPCMD_READ_TRACK_INFORMATION 0x52
/**
    Retrieves MMC TRACK_INFORMATION DATA.

    @param p_cdio 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 mmc_track_information_data, in return. Free when no longer
needed.
 */
void
mmc_get_track_information_data( const CdIo_t *p_cdio,
                                                     driver_return_code_t
*i_status,
                 uint8_t **mmc_track_information_data,
                 track_t trackno) {
    mmc_cdb_t cdb = {{0, }};

    *mmc_track_information_data = (uint8_t*) malloc
(MMC_TRACK_INFORMATION_DATA_SIZE * sizeof (uint8_t));
    memset (*mmc_track_information_data, 0,
MMC_TRACK_INFORMATION_DATA_SIZE);
    CDIO_MMC_SET_COMMAND (cdb.field, CDIO_MMC_GPCMD_READ_TRACK_INFORMATION);
    CDIO_MMC_SET_READ_LENGTH16 (cdb.field, MMC_TRACK_INFORMATION_DATA_SIZE);
    cdb.field[1] = 0x01; //to specify track number
    cdb.field[5] = trackno;

    *i_status = mmc_run_cmd (p_cdio, 0, &cdb, SCSI_MMC_DATA_READ,
                            MMC_TRACK_INFORMATION_DATA_SIZE,
*mmc_track_information_data);
}


/**
    Detects a disc (CD or DVD) capacity.
    @param p_user_data the CD object to be acted upon.

  @param opt_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 the detected disc capacity, or 0 on error;
    for non writable CDs, capacity is equal to size.
 */
uint32_t mmc_get_disc_capacity ( const CdIo_t *p_cdio,
                    driver_return_code_t *opt_i_status) {
    driver_return_code_t i_status;
    uint8_t *mmc_track_information_data;
    uint32_t capacity;
    uint8_t *p;

    mmc_get_track_information_data (p_cdio, &i_status,
&mmc_track_information_data, 0x01); //will "not work" with multi track CDs,
but they have to be blanked before use
    if (opt_i_status != NULL) *opt_i_status = i_status;

    if (i_status == DRIVER_OP_SUCCESS) {
        p = mmc_track_information_data + 24;
        capacity = CDIO_MMC_GET_LEN32 (p);
    } else {
        capacity = 0;
    }

    free (mmc_track_information_data);

    capacity = capacity * 2;
    return capacity;
}

After reading what You said, I think libburnia is very interesting. So
libburnia support as SimpleBurn burning suite has been added to the TODO
list. It will - I hope - just need adding some bash scripts (and maybe a
wrapper for displaying progress). If You are interested, I will tell You
when git repository is up to date.


Frank


reply via email to

[Prev in Thread] Current Thread [Next in Thread]