From f14b66a09b3add68b025d2cf6f07e31de6110f78 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 24 Sep 2010 09:07:05 +0000 Subject: [PATCH] New API call burn_disc_get_bd_spare_info() --- ChangeLog | 6 ++++++ cdrskin/cdrskin_timestamp.h | 2 +- libburn/drive.c | 15 +++++++++++++++ libburn/libburn.h | 23 +++++++++++++++++++++-- libburn/mmc.c | 30 +++++++++++++++++++++++++++++- libburn/mmc.h | 3 +++ 6 files changed, 75 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a394dbd..9e7b24b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +SVN trunk (to become libburn-0.8.8.pl00.tar.gz) +=============================================================================== +* New API call burn_offst_source_new() +* New API call burn_disc_get_bd_spare_info() + + libburn-0.8.6.pl00.tar.gz Fri Sep 17 2010 =============================================================================== * Lifted test reservation on DVD-R DL media. diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 33dc038..59909da 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2010.09.22.180921" +#define Cdrskin_timestamP "2010.09.24.090631" diff --git a/libburn/drive.c b/libburn/drive.c index ce03573..5e5d592 100644 --- a/libburn/drive.c +++ b/libburn/drive.c @@ -2836,3 +2836,18 @@ int burn_disc_get_cd_info(struct burn_drive *d, char disc_type[80], *valid = d->disc_info_valid; return 1; } + + +/* ts B00924 : API */ +int burn_disc_get_bd_spare_info(struct burn_drive *d, + int *alloc_blocks, int *free_blocks, int flag) +{ + int ret; + + if (burn_drive_get_drive_role(d) != 1) + return 0; + *alloc_blocks = *free_blocks = 0; + ret = mmc_get_bd_spare_info(d, alloc_blocks, free_blocks, 0); + return ret; +} + diff --git a/libburn/libburn.h b/libburn/libburn.h index 974a3ea..4e32ad3 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -1237,12 +1237,29 @@ char *burn_guess_cd_manufacturer(int m_li, int s_li, int f_li, bit5= Disc is nominally erasable (Erasable bit) This will be set with overwriteable media which libburn normally considers to be unerasable blank. + @return 1 success, <= 0 an error occured @since 0.7.2 */ int burn_disc_get_cd_info(struct burn_drive *d, char disc_type[80], unsigned int *disc_id, char bar_code[9], int *app_code, int *valid); +/* ts B00924 */ +/** Read the current usage of the eventual BD Spare Area. This area gets + reserved on BD media during formatting. During writing it is used to + host replacements of blocks which failed the checkread immediately after + writing. + This call applies only to recordable BD media. I.e. profiles 0x41 to 0x43. + @param d The drive to query. + @param alloc_blocks Returns the number of blocks reserved as Spare Area + @param free_blocks Returns the number of yet unused blocks in that area + @param flag Bitfield for control purposes (unused yet, submit 0) + @return 1 = reply prarameters are valid, + <=0 = reply is invalid (e.g. because no BD profile) + @since 0.8.8 +*/ +int burn_disc_get_bd_spare_info(struct burn_drive *d, + int *alloc_blocks, int *free_blocks, int flag); /* ts A61110 */ /** Read start lba and Next Writeable Address of a track from media. @@ -1907,7 +1924,8 @@ struct burn_source *burn_fd_source_new(int datafd, int subfd, off_t size); has ended its work. Best is to keep them all until all tracks are done. - @param inp The burn_source object from which to read stream data + @param inp The burn_source object from which to read stream data. + E.g. created by burn_file_source_new(). @param prev The eventual offset source object which shall read data from inp before the new offset source will begin its own work. This must either be a result of burn_offst_source_new() or @@ -1916,7 +1934,8 @@ struct burn_source *burn_fd_source_new(int datafd, int subfd, off_t size); consumer. inp bytes may get skipped to reach this address. @param size The number of bytes to be delivered to the consumer. @param flag Bitfield for control purposes (unused yet, submit 0). - @return Pointer to a burn_source object, NULL indicates failure + @return Pointer to a burn_source object, later to be freed by + burn_source_free(). NULL indicates failure. @since 0.8.8 */ struct burn_source *burn_offst_source_new( diff --git a/libburn/mmc.c b/libburn/mmc.c index 5b5321e..82b9440 100644 --- a/libburn/mmc.c +++ b/libburn/mmc.c @@ -3876,6 +3876,11 @@ int mmc_compose_mode_page_5(struct burn_drive *d, pd[4] = spc_block_type(o->block_type); +/* +fprintf(stderr, "libburn_EXPERIMENTAL: block_type = %d, pd[4]= %u\n", + o->block_type, (unsigned int) pd[4]); +*/ + /* ts A61104 */ if(!(o->control&4)) /* audio (MMC-1 table 61) */ if(o->write_type == BURN_WRITE_TAO) @@ -4127,7 +4132,7 @@ static int mmc_set_product_id(char *reply, /* ts A90903 */ -/* MMC backend of API call burn_get_media_product_id() +/* MMC backend of API call burn_disc_get_media_id() See also doc/mediainfo.txt @param flag Bitfield for control purposes bit0= do not escape " _/" (not suitable for @@ -4314,6 +4319,29 @@ ex:; } +/* ts B00924 + MMC-5, 6.23.3.3.4 Format Code 0Ah: Spare Area Information +*/ +int mmc_get_bd_spare_info(struct burn_drive *d, + int *alloc_blocks, int *free_blocks, int flag) +{ + int ret, reply_len; + char *reply = NULL; + + ret = mmc_read_disc_structure(d, 1, 0, 0x0a, 12, &reply, + &reply_len, 0); + if (ret <= 0) + goto ex; + *alloc_blocks = mmc_four_char_to_int((unsigned char *) reply + 8); + *free_blocks = mmc_four_char_to_int((unsigned char *) reply + 4); + ret = 1; +ex:; + if (reply != NULL) + free(reply); + return ret; +} + + /* ts A61021 : the mmc specific part of sg.c:enumerate_common() */ int mmc_setup_drive(struct burn_drive *d) diff --git a/libburn/mmc.h b/libburn/mmc.h index 5c0a5cc..0e47c75 100644 --- a/libburn/mmc.h +++ b/libburn/mmc.h @@ -106,5 +106,8 @@ int mmc_function_spy(struct burn_drive *d, char * text); /* ts A91118 */ int mmc_start_if_needed(struct burn_drive *d, int flag); +/* ts B00924 */ +int mmc_get_bd_spare_info(struct burn_drive *d, + int *alloc_blocks, int *free_blocks, int flag); #endif /*__MMC*/