Released drive in case welcome_media fails

This commit is contained in:
Thomas Schmitt 2007-09-30 12:11:10 +00:00
parent 782067545b
commit 23b2720cc0

View File

@ -53,11 +53,11 @@ int isoburn_initialize(void)
static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
int flag)
{
int ret;
int ret, lba, nwa;
struct burn_multi_caps *caps= NULL;
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;
ret= isoburn_new(o, 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 */
caps->start_adr= 0;
(*o)->fabricated_disc_status= BURN_DISC_APPENDABLE;
/* is not set with MMC multi-session: (*o)->nwa= Hardcoded_cd_rw_nwA; */
#endif
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 {
/* >>> 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;
@ -97,7 +104,7 @@ ex:
int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
char *adr, int load)
{
int ret, conv_ret;
int ret, conv_ret, drive_grabbed= 0;
char libburn_drive_adr[BURN_DRIVE_ADR_LEN];
struct isoburn *o= NULL;
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);
if(ret<=0)
goto ex;
drive_grabbed= 1;
ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, 0);
if(ret<=0)
goto ex;
ret= 1;
ex:
if(ret<=0)
isoburn_destroy(&o,0);
if(ret<=0) {
if(drive_grabbed)
burn_drive_release((*drive_infos)[0].drive, 0);
isoburn_destroy(&o, 0);
}
return(ret);
}