New API function to obtain media type: burn_disc_get_profile()

This commit is contained in:
Thomas Schmitt 2006-12-02 11:17:12 +00:00
bovenliggende ad2c080145
commit 229328e869
5 gewijzigde bestanden met toevoegingen van 100 en 35 verwijderingen

Bestand weergeven

@ -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");

Bestand weergeven

@ -1 +1 @@
#define Cdrskin_timestamP "2006.12.01.213845"
#define Cdrskin_timestamP "2006.12.02.111701"

Bestand weergeven

@ -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;
}

Bestand weergeven

@ -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

Bestand weergeven

@ -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; i++)
texts[i] = "";
/* mmc5r03c.pdf , Table 89 */
/* mmc5r03c.pdf , Table 89, Spelling: guessed cdrecord style */
texts[0x01] = "Non-removable disk";
texts[0x02] = "Removable disk";
texts[0x03] = "MO erasable";
texts[0x04] = "Optical write once";
texts[0x05] = "AS-MO";
texts[0x08] = "CD-ROM";
texts[0x09] = "CD-R";
texts[0x0a] = "CD-RW";
texts[0x10] = "DVD-ROM";
texts[0x11] = "DVD-R Sequential";
texts[0x11] = "DVD-R sequential recording";
texts[0x12] = "DVD-RAM";
texts[0x13] = "DVD-RW Restricted Overwrite";
texts[0x14] = "DVD-RW Sequential";
texts[0x15] = "DVD-R DL Sequential";
texts[0x16] = "DVD-R DL Jump";
texts[0x13] = "DVD-RW restricted overwrite";
texts[0x14] = "DVD-RW sequential overwrite";
texts[0x15] = "DVD-R/DL sequential recording";
texts[0x16] = "DVD-R/DL layer jump recording";
texts[0x1a] = "DVD+RW";
texts[0x1b] = "DVD+R";
texts[0x2a] = "DVD+RW DL";
texts[0x2b] = "DVD+R DL";
texts[0x2a] = "DVD+RW/DL";
texts[0x2b] = "DVD+R/DL";
texts[0x40] = "BD-ROM";
texts[0x41] = "BD-R SRM Sequential";
texts[0x42] = "BD-R RRM Random";
texts[0x41] = "BD-R sequential recording";
texts[0x42] = "BD-R random recording";
texts[0x43] = "BD-RE";
texts[0x50] = "HD DVD-ROM";
texts[0x51] = "HD DVD-R";
texts[0x52] = "HD DVD-RAM";
texts[0x50] = "HD-DVD-ROM";
texts[0x51] = "HD-DVD-R";
texts[0x52] = "HD-DVD-RAM";
}
if (profile_number<0 || profile_number>=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;