From 1ce6ec4a3a39f8faad239d8ee1ef8a99bc6e3b8f Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 23 Dec 2006 14:12:55 +0000 Subject: [PATCH] New API function to inquire burn success (and avoid confusing messages) --- cdrskin/cdrskin.c | 22 +++++++++++++++++----- cdrskin/cdrskin_timestamp.h | 2 +- libburn/drive.c | 6 ++++++ libburn/libburn.h | 11 +++++++++++ libburn/write.c | 25 ++++++++++++------------- 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/cdrskin/cdrskin.c b/cdrskin/cdrskin.c index c442740..4edf910 100644 --- a/cdrskin/cdrskin.c +++ b/cdrskin/cdrskin.c @@ -169,6 +169,7 @@ or #define Cdrskin_no_aftergrab_loopS 1 #define Cdrskin_libburn_has_get_profilE 1 #define Cdrskin_libburn_has_set_start_bytE 1 +#define Cdrskin_libburn_has_wrote_welL 1 #endif /* Cdrskin_libburn_0_2_7 */ #ifndef Cdrskin_libburn_versioN @@ -4367,7 +4368,7 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) enum burn_drive_status drive_status; struct burn_progress p; struct burn_drive *drive; - int ret,loop_counter= 0,max_track= -1,i,hflag,nwa,num; + int ret,loop_counter= 0,max_track= -1,i,hflag,nwa,num, wrote_well= 2; int fifo_disabled= 0,fifo_percent,total_min_fill,mb,min_buffer_fill= 101; double put_counter,get_counter,empty_counter,full_counter; double start_time,last_time; @@ -4615,6 +4616,11 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) skin->drive_is_busy= 0; if(skin->verbosity>=Cdrskin_verbose_progresS) printf("\n"); + +#ifdef Cdrskin_libburn_has_wrote_welL + wrote_well = burn_drive_wrote_well(drive); +#endif + if(max_track<0) { printf("Track 01: Total bytes read/written: %.f/%.f (%.f sectors).\n", total_count,total_count,total_count/sector_size); @@ -4630,7 +4636,7 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) #ifndef Cdrskin_extra_leaN - if(skin->fifo!=NULL && skin->fifo_size>0) { + if(skin->fifo!=NULL && skin->fifo_size>0 && wrote_well) { int dummy,final_fill; Cdrfifo_get_buffer_state(skin->fifo,&final_fill,&dummy,0); if(final_fill>0) { @@ -4696,10 +4702,16 @@ fifo_full_at_end:; #endif /* ! Cdrskin_extra_leaN */ - - if(skin->verbosity>=Cdrskin_verbose_progresS) - printf("cdrskin: burning done\n"); ret= 1; + if(wrote_well) { + if(skin->verbosity>=Cdrskin_verbose_progresS) + printf("cdrskin: burning done\n"); + } else { + if(skin->verbosity>=Cdrskin_verbose_progresS) + printf("cdrskin: burning failed\n"); + fprintf(stderr,"cdrskin: FATAL : burning failed.\n"); + ret= 0; + } ex:; skin->drive_is_busy= 0; if(skin->verbosity>=Cdrskin_verbose_debuG) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index b89e7fa..ea5c593 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2006.12.23.102201" +#define Cdrskin_timestamP "2006.12.23.141315" diff --git a/libburn/drive.c b/libburn/drive.c index 2cec1f9..2ce8a99 100644 --- a/libburn/drive.c +++ b/libburn/drive.c @@ -1281,3 +1281,9 @@ int burn_disc_get_profile(struct burn_drive *d, int *pno, char name[80]) } +/* ts A61223 : New API function */ +int burn_drive_wrote_well(struct burn_drive *d) +{ + return !d->cancel; +} + diff --git a/libburn/libburn.h b/libburn/libburn.h index ba9963a..261f38e 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -811,6 +811,17 @@ void burn_disc_write(struct burn_write_opts *o, struct burn_disc *disc); */ void burn_drive_cancel(struct burn_drive *drive); + +/* ts A61223 */ +/** Inquire wether the most recent write run was successful. Reasons for + non-success may be: rejection of burn parameters, abort during fatal errors + during write, a call to burn_drive_cancel() by the application thread. + @param d The drive to inquire. + @return 1=burn seems to have went well, 0=burn failed +*/ +int burn_drive_wrote_well(struct burn_drive *d); + + /** Convert a minute-second-frame (MSF) value to sector count @param m Minute component @param s Second component diff --git a/libburn/write.c b/libburn/write.c index a7a2ff9..3dd66d7 100644 --- a/libburn/write.c +++ b/libburn/write.c @@ -921,7 +921,7 @@ int burn_disc_setup_dvd_plus_rw(struct burn_write_opts *o, if (o->start_byte >= 0) d->nwa = o->start_byte / 2048; - sprintf(msg, "Write start address is %d * 2048\n", d->nwa); + sprintf(msg, "Write start address is %d * 2048", d->nwa); libdax_msgs_submit(libdax_messenger, d->global_index, 0x00020127, LIBDAX_MSGS_SEV_NOTE, LIBDAX_MSGS_PRIO_HIGH, @@ -971,6 +971,15 @@ int burn_dvd_write_sync(struct burn_write_opts *o, msg, 0,0); goto early_failure; } + if (o->start_byte >= 0 && (o->start_byte % 2048)) { + sprintf(msg, + "Write start address not properly aligned to 2048"); + libdax_msgs_submit(libdax_messenger, d->global_index, + 0x00020125, + LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, + msg, 0,0); + goto early_failure; + } ret = burn_disc_setup_dvd_plus_rw(o, disc); if (ret <= 0) { @@ -982,15 +991,6 @@ int burn_dvd_write_sync(struct burn_write_opts *o, msg, 0,0); goto early_failure; } - if (o->start_byte >= 0 && (o->start_byte % 2048)) { - sprintf(msg, - "Write start address not properly aligned to 2048"); - libdax_msgs_submit(libdax_messenger, d->global_index, - 0x00020125, - LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, - msg, 0,0); - goto early_failure; - } } else { sprintf(msg, "Unsuitable media detected. Profile %4.4Xh %s", @@ -1027,9 +1027,6 @@ ex:; return ret; early_failure:; - pthread_mutex_lock(&d->access_lock); - d->cancel = 1; - pthread_mutex_unlock(&d->access_lock); return 0; } @@ -1047,6 +1044,7 @@ void burn_disc_write_sync(struct burn_write_opts *o, struct burn_disc *disc) burn_message_clear_queue(); */ + d->cancel = 0; d->buffer = &buf; memset(d->buffer, 0, sizeof(struct buffer)); d->rlba = -150; @@ -1207,5 +1205,6 @@ fail_wo_sync:; libdax_msgs_submit(libdax_messenger, d->global_index, 0x0002010b, LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH, "Burn run failed", 0, 0); + d->cancel = 1; d->busy = BURN_DRIVE_IDLE; }