From d30f687b974d38549a5ffd4e1ca53dbc78456130 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 2 Dec 2006 11:17:12 +0000 Subject: [PATCH] New API function to obtain media type: burn_disc_get_profile() --- libburn/trunk/cdrskin/cdrskin.c | 39 ++++++++++--- libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- libburn/trunk/libburn/drive.c | 16 +++++- libburn/trunk/libburn/libburn.h | 10 ++++ libburn/trunk/libburn/mmc.c | 68 ++++++++++++++--------- 5 files changed, 100 insertions(+), 35 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin.c b/libburn/trunk/cdrskin/cdrskin.c index 8764803a..5c751eab 100644 --- a/libburn/trunk/cdrskin/cdrskin.c +++ b/libburn/trunk/cdrskin/cdrskin.c @@ -165,6 +165,7 @@ or #define Cdrskin_libburn_versioN "0.2.7" #define Cdrskin_libburn_from_pykix_svN 1 #define Cdrskin_atip_speed_is_oK 1 +#define Cdrskin_libburn_has_get_profilE 1 #endif /* Cdrskin_libburn_0_2_7 */ #ifndef Cdrskin_libburn_versioN @@ -3634,6 +3635,8 @@ int Cdrskin_atip(struct CdrskiN *skin, int flag) double x_speed_max, x_speed_min= -1.0; enum burn_disc_status s; struct burn_drive *drive; + int profile_number= 0; + char profile_name[80]; printf("cdrskin: pseudo-atip on drive %d\n",skin->driveno); ret= Cdrskin_checkdrive(skin,1); @@ -3705,20 +3708,40 @@ int Cdrskin_atip(struct CdrskiN *skin, int flag) #endif /* Cdrskin_atip_speed_brokeN */ + profile_name[0]= 0; +#ifdef Cdrskin_libburn_has_get_profilE + ret= burn_disc_get_profile(drive,&profile_number,profile_name); + if(ret<=0) { + profile_number= 0; + strcpy(profile_name, "-unidentified-"); + } +#endif /* Cdrskin_libburn_has_get_profilE */ + #ifdef Cdrskin_libburn_has_read_atiP - ret= burn_disc_read_atip(drive); - if(ret>0) { - ret= burn_drive_get_min_write_speed(drive); - x_speed_min= ((double) ret)/Cdrskin_libburn_cd_speed_factoR; + if(burn_disc_get_status(drive) != BURN_DISC_UNSUITABLE) { + ret= burn_disc_read_atip(drive); + if(ret>0) { + ret= burn_drive_get_min_write_speed(drive); + x_speed_min= ((double) ret)/Cdrskin_libburn_cd_speed_factoR; + } } #endif #ifdef Cdrskin_libburn_has_burn_disc_unsuitablE if(burn_disc_get_status(drive) == BURN_DISC_UNSUITABLE) { - printf("Current: UNSUITABLE MEDIA\n"); + if(skin->verbosity>=Cdrskin_verbose_progresS) { +#ifdef Cdrskin_libburn_has_get_profilE + if(profile_name[0]) + printf("Current: %s\n",profile_name); + else + printf("Current: UNSUITABLE MEDIA (Profile %4.4Xh)\n",profile_number); +#else + printf("Current: UNSUITABLE MEDIA\n"); +#endif + } {ret= 0; goto ex;} } -#endif +#endif /* Cdrskin_libburn_has_burn_disc_unsuitablE */ ret= burn_drive_get_write_speed(drive); x_speed_max= ((double) ret)/Cdrskin_libburn_cd_speed_factoR; @@ -3726,7 +3749,9 @@ int Cdrskin_atip(struct CdrskiN *skin, int flag) x_speed_min= x_speed_max; printf("cdrskin: burn_drive_get_write_speed = %d (%.1fx)\n",ret,x_speed_max); if(skin->verbosity>=Cdrskin_verbose_progresS) { - if(burn_disc_erasable(drive)) + if(profile_name[0]) + printf("Current: %s\n",profile_name); + else if(burn_disc_erasable(drive)) printf("Current: CD-RW\n"); else printf("Current: CD-R\n"); diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index bcb3ef80..b1d34728 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2006.12.01.213845" +#define Cdrskin_timestamP "2006.12.02.111701" diff --git a/libburn/trunk/libburn/drive.c b/libburn/trunk/libburn/drive.c index 3f93549b..bab5e565 100644 --- a/libburn/trunk/libburn/drive.c +++ b/libburn/trunk/libburn/drive.c @@ -144,8 +144,7 @@ int burn_drive_inquire_media(struct burn_drive *d) int loop_count, old_speed = -1234567890, new_speed = -987654321; int old_erasable = -1234567890, new_erasable = -987654321; - /* ts A61020 : this was BURN_DISC_BLANK as pure guess */ - d->status = BURN_DISC_UNREADY; + /* ts A61020 : d->status was set to BURN_DISC_BLANK as pure guess */ if (d->mdata->cdr_write || d->mdata->cdrw_write || d->mdata->dvdr_write || d->mdata->dvdram_write) { @@ -209,6 +208,7 @@ int burn_drive_grab(struct burn_drive *d, int le) burn_print(1, "can't grab - already grabbed\n"); return 0; } + d->status = BURN_DISC_UNREADY; errcode = d->grab(d); if (errcode == 0) { @@ -332,6 +332,8 @@ int burn_drive_mark_unready(struct burn_drive *d) d->start_lba= -2000000000; d->end_lba= -2000000000; + /* ts A61202 */ + d->current_profile = -1; d->status = BURN_DISC_UNREADY; if (d->toc_entry != NULL) free(d->toc_entry); @@ -1258,3 +1260,13 @@ int burn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o, return ret; } + +/* ts A61202 : New API function */ +int burn_disc_get_profile(struct burn_drive *d, int *pno, char name[80]) +{ + *pno = d->current_profile; + strcpy(name,d->current_profile_text); + return *pno >= 0; +} + + diff --git a/libburn/trunk/libburn/libburn.h b/libburn/trunk/libburn/libburn.h index 779d9f04..9156e483 100644 --- a/libburn/trunk/libburn/libburn.h +++ b/libburn/trunk/libburn/libburn.h @@ -720,6 +720,16 @@ int burn_drive_get_start_end_lba(struct burn_drive *drive, int burn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o, int trackno, int *lba, int *nwa); +/* ts A61202 */ +/** Tells the MMC Profile identifier of the loaded media. The drive must be + grabbed in order to get a non-zero result. + @param d The drive where the media is inserted. + @param pno Profile Number as of mmc5r03c.pdf, table 89 + @param name Profile Name (e.g "CD-RW", unknown profiles have empty name) + @return 1 profile is valid, 0 no profile info available + Note: libburn currently writes only to profiles 0x09 "CD-R", 0x0a "CD-RW". +*/ +int burn_disc_get_profile(struct burn_drive *d, int *pno, char name[80]); /** Tells whether a disc can be erased or not @return Non-zero means erasable diff --git a/libburn/trunk/libburn/mmc.c b/libburn/trunk/libburn/mmc.c index 749103d6..22cf9f7f 100644 --- a/libburn/trunk/libburn/mmc.c +++ b/libburn/trunk/libburn/mmc.c @@ -470,9 +470,14 @@ void mmc_read_disc_info(struct burn_drive *d) d->start_lba = d->end_lba = -2000000000; d->erasable = 0; + /* ts A61202 */ + d->toc_entries = 0; + if (d->status == BURN_DISC_EMPTY) + return; + mmc_get_configuration(d); if (! d->current_is_cd_profile) { - sprintf(msg, "Unsuitable media detected. Profile 0x%2.2X %s", + sprintf(msg, "Unsuitable media detected. Profile %4.4Xh %s", d->current_profile, d->current_profile_text); libdax_msgs_submit(libdax_messenger, d->global_index, 0x0002011e, @@ -822,41 +827,55 @@ void mmc_set_speed(struct burn_drive *d, int r, int w) } -/* A61201 : found in unfunctional state */ -void mmc_get_configuration(struct burn_drive *d) +/* ts A61201 */ +static char *mmc_obtain_profile_name(int profile_number) { - struct buffer buf; - int len, i, cp; - struct command c; - char msg[160]; - static char *texts[256] = {NULL}; + static char *texts[0x53] = {NULL}; + int i, max_pno = 0x53; if (texts[0] == NULL) { - for (i = 0; i<256; i++) + for (i = 0; i=max_pno) + return ""; + return texts[profile_number]; +} + + +/* ts A61201 : found in unfunctional state */ +void mmc_get_configuration(struct burn_drive *d) +{ + struct buffer buf; + int len, cp; + struct command c; d->current_profile = 0; d->current_profile_text[0] = 0; @@ -883,8 +902,7 @@ void mmc_get_configuration(struct burn_drive *d) return; cp = (c.page->data[6]<<8) | c.page->data[7]; d->current_profile = cp; - if (cp < 256) - strcpy(d->current_profile_text, texts[cp]); + strcpy(d->current_profile_text, mmc_obtain_profile_name(cp)); if (cp == 0x08 || cp == 0x09 || cp == 0x0a) d->current_is_cd_profile = 1; } @@ -969,7 +987,7 @@ int mmc_setup_drive(struct burn_drive *d) /* ts A61201 */ d->erasable = 0; - d->current_profile = 0; + d->current_profile = -1; d->current_profile_text[0] = 0; d->current_is_cd_profile = 0;