Released drive in case welcome_media fails

This commit is contained in:
Thomas Schmitt 2007-09-30 12:11:10 +00:00
parent 0c6ab93875
commit 52abdb1bf4

View File

@ -53,11 +53,11 @@ int isoburn_initialize(void)
static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d, static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
int flag) int flag)
{ {
int ret; int ret, lba, nwa;
struct burn_multi_caps *caps= NULL; struct burn_multi_caps *caps= NULL;
ret= burn_disc_get_multi_caps(d, BURN_WRITE_NONE, &caps, 0); ret= burn_disc_get_multi_caps(d, BURN_WRITE_NONE, &caps, 0);
if(ret<=0) if(ret<0) /* == 0 is read-only media, but it is too early to reject it here */
goto ex; goto ex;
ret= isoburn_new(o, 0); ret= isoburn_new(o, 0);
if(ret<=0) if(ret<=0)
@ -71,7 +71,6 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
caps->start_adr= 0; caps->start_adr= 0;
(*o)->fabricated_disc_status= BURN_DISC_APPENDABLE; (*o)->fabricated_disc_status= BURN_DISC_APPENDABLE;
/* is not set with MMC multi-session: (*o)->nwa= Hardcoded_cd_rw_nwA; */
#endif #endif
if(caps->start_adr) { /* set emulation to overwriteable */ if(caps->start_adr) { /* set emulation to overwriteable */
@ -83,7 +82,15 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
} }
} else { } else {
/* >>> recognize unsuitable media */; /* >>> recognize unsuitable media (but allow read-only media) */;
#ifdef Hardcoded_cd_rW
(*o)->nwa= Hardcoded_cd_rw_nwA;
#else
ret= burn_disc_track_lba_nwa(d, NULL, 0, &lba, &nwa);
if(ret>0)
(*o)->nwa= nwa;
#endif
} }
ret= 1; ret= 1;
@ -97,7 +104,7 @@ ex:
int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
char *adr, int load) char *adr, int load)
{ {
int ret, conv_ret; int ret, conv_ret, drive_grabbed= 0;
char libburn_drive_adr[BURN_DRIVE_ADR_LEN]; char libburn_drive_adr[BURN_DRIVE_ADR_LEN];
struct isoburn *o= NULL; struct isoburn *o= NULL;
char msg[BURN_MSGS_MESSAGE_LEN+4096]; char msg[BURN_MSGS_MESSAGE_LEN+4096];
@ -113,14 +120,18 @@ int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
ret= burn_drive_scan_and_grab(drive_infos, libburn_drive_adr, load); ret= burn_drive_scan_and_grab(drive_infos, libburn_drive_adr, load);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
drive_grabbed= 1;
ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, 0); ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, 0);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
ret= 1; ret= 1;
ex: ex:
if(ret<=0) if(ret<=0) {
isoburn_destroy(&o,0); if(drive_grabbed)
burn_drive_release((*drive_infos)[0].drive, 0);
isoburn_destroy(&o, 0);
}
return(ret); return(ret);
} }