libcdio-devel
[Top][All Lists]
Advanced

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

[Libcdio-devel] Needing help.


From: Frank Endres
Subject: [Libcdio-devel] Needing help.
Date: Mon, 8 Feb 2010 17:27:01 -0100

Hi !

Does someone know how I can get a CD-R or CD-RW capacity (the available
space for burning) ? Read format capacities works with DVD, but for writable
CDs, I get no media present or unknown capacity.

/**
    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 (no media present, unknown
    capacity or operation failure); 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,
                    uint8_t **mmc_format_capacities_data) {
    driver_return_code_t i_status;
    uint32_t capacity;
    uint8_t descriptor_type;
    uint8_t *p;

    if (*mmc_format_capacities_data == NULL)
            mmc_get_format_capacities_data (p_cdio, &i_status,
mmc_format_capacities_data);
        else
            i_status = DRIVER_OP_SUCCESS;
    if (opt_i_status != NULL) *opt_i_status = i_status;

    if (i_status == DRIVER_OP_SUCCESS) {
        descriptor_type = (*mmc_format_capacities_data)[8] & 0x03;

        if (descriptor_type == 0x03) { //no media present or unknown
capacity
            capacity = 0;
        } else {
            p = (*mmc_format_capacities_data) + 4;
            capacity = CDIO_MMC_GET_LEN32 (p);
            capacity = capacity * 2;
        }
    } else {
        capacity =  0;
    }

        return capacity;
}


Thanks !

Frank Endres


reply via email to

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