diff --git a/cdrskin/cdrskin.c b/cdrskin/cdrskin.c index c9d7ade..4684f07 100644 --- a/cdrskin/cdrskin.c +++ b/cdrskin/cdrskin.c @@ -206,14 +206,6 @@ or #endif /* Cdrskin_libburn_from_pykix_svN */ -#ifndef _LARGEFILE_SOURCE -#define _LARGEFILE_SOURCE 1 -#endif -#ifndef _FILE_OFFSET_BITS -#define _FILE_OFFSET_BITS 64 -#endif - - /* These macros activate cdrskin workarounds for deficiencies resp. problematic features of libburn which hopefully will change in future. */ @@ -279,7 +271,6 @@ or #include #include -/* #include */ #include "../libburn/libburn.h" #ifdef Cdrskin_libburn_has_audioxtR @@ -899,11 +890,33 @@ int Cdrtrack_set_track_type(struct CdrtracK *o, int track_type, int flag) } +/** + @param flag Bitfield for control purposes: + bit0= size returns number of actually processed source bytes + rather than the predicted fixed_size (if available). + padding returns the difference from number of written + bytes. +*/ int Cdrtrack_get_size(struct CdrtracK *track, double *size, double *padding, double *sector_size, int flag) { + *size= track->fixed_size; *padding= track->padding; +#ifdef Cdrskin_allow_libburn_taO + if((flag&1) && track->libburn_track!=NULL) { + off_t readcounter,writecounter; + + burn_track_get_counters(track->libburn_track,&readcounter,&writecounter); + *size= readcounter; + *padding= writecounter-readcounter; +/* + fprintf(stderr,"cdrskin_debug: sizeof(off_t)=%d\n", + sizeof(off_t)); +*/ + } + +#endif *sector_size= track->sector_size; return(1); } @@ -3769,12 +3782,12 @@ int Cdrskin_burn_pacifier(struct CdrskiN *skin, if(old_track_idx>=0 && old_track_idxsupposed_track_idx) { Cdrtrack_get_size(skin->tracklist[old_track_idx],&fixed_size,&padding, - §or_size,0); + §or_size,1); if(skin->verbosity>=Cdrskin_verbose_progresS) printf("\n"); printf("%sTrack %-2.2d: Total bytes read/written: %.f/%.f (%.f sectors).\n", - debug_mark,old_track_idx+1,fixed_size,fixed_size, - fixed_size/sector_size); + debug_mark,old_track_idx+1,fixed_size,fixed_size+padding, + (fixed_size+padding)/sector_size); } sector_size= 2048.0; @@ -3975,6 +3988,7 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) double put_counter,get_counter,empty_counter,full_counter; double start_time,last_time; double total_count= 0.0,last_count= 0.0,size,padding,sector_size= 2048.0; + double sectors; printf("cdrskin: beginning to burn disk\n"); @@ -3997,7 +4011,8 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) return(0); } Cdrtrack_get_size(skin->tracklist[i],&size,&padding,§or_size,0); - skin->fixed_size+= size+padding; + if(size>0) + skin->fixed_size+= size+padding; } ret= Cdrskin_grab_drive(skin,0); @@ -4053,8 +4068,11 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) frac= (seconds-min*60-sec)*100; if(frac>99) frac= 99; + sectors= (int) (skin->fixed_size/sector_size); + if(sectors*sector_size != skin->fixed_size) + sectors++; printf("Total size: %5d MB (%-2.2d:%-2.2d.%-2.2d) = %d sectors\n", - mb,min,sec,frac,(int) (skin->fixed_size/sector_size)); + mb,min,sec,frac,(int) sectors); seconds+= 2; min= seconds/60.0; sec= seconds-min*60; @@ -4062,7 +4080,7 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) if(frac>99) frac= 99; printf("Lout start: %5d MB (%-2.2d:%-2.2d/%-2.2d) = %d sectors\n", - mb,min,sec,frac,(int) (skin->fixed_size/sector_size)); + mb,min,sec,frac,(int) sectors); } } @@ -4173,14 +4191,14 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) skin->drive_is_busy= 0; if(skin->verbosity>=Cdrskin_verbose_progresS) printf("\n"); - if(max_track<=0) { + if(max_track<0) { printf("Track 01: Total bytes read/written: %.f/%.f (%.f sectors).\n", total_count,total_count,total_count/sector_size); } else { - Cdrtrack_get_size(skin->tracklist[max_track],&size,&padding,§or_size,0); + Cdrtrack_get_size(skin->tracklist[max_track],&size,&padding,§or_size,1); printf( "Track %-2.2d: Total bytes read/written: %.f/%.f (%.f sectors).\n", - max_track+1,size,size,size/sector_size); + max_track+1,size,size+padding,(size+padding)/sector_size); } if(skin->verbosity>=Cdrskin_verbose_progresS) printf("Writing time: %.3fs\n",Sfile_microtime(0)-start_time); @@ -4622,7 +4640,12 @@ set_driveropts:; } strcpy(skin->eject_device,argv[i]+13); if(skin->verbosity>=Cdrskin_verbose_cmD) +#ifdef Cdrskin_burn_drive_eject_brokeN printf("cdrskin: eject_device : %s\n",skin->eject_device); +#else + printf("cdrskin: ignoring obsolete eject_device=%s\n", + skin->eject_device); +#endif #ifndef Cdrskin_extra_leaN diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index cceb4b0..3998fba 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2006.10.31.184736" +#define Cdrskin_timestamP "2006.11.01.163934" diff --git a/cdrskin/compile_cdrskin.sh b/cdrskin/compile_cdrskin.sh index adae1fb..e82e807 100755 --- a/cdrskin/compile_cdrskin.sh +++ b/cdrskin/compile_cdrskin.sh @@ -6,6 +6,7 @@ debug_opts= def_opts= +largefile_opts="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1" libvers="-DCdrskin_libburn_0_2_3" cleanup_src_or_obj="libburn/cleanup.o" libdax_msgs_o="libburn/libdax_msgs.o" @@ -50,6 +51,9 @@ do elif test "$i" = "-oldfashioned" then def_opts="$def_opts -DCdrskin_oldfashioned_api_usE" + elif test "$i" = "-no_largefile" + then + largefile_opts= elif test "$i" = "-do_not_compile_cdrskin" then compile_cdrskin=0 @@ -76,6 +80,7 @@ do echo " -cvs_A60220 set macro to match libburn-CVS of 20 Feb 2006." echo " -libburn_0_2_2 set macro to match libburn-0.2.2." echo " -libburn_0_2_3 set macro to match current libburn-SVN." + echo " -no_largefile do not use 64 bit off_t (must match libburn)." echo " -do_not_compile_cdrskin omit compilation of cdrskin/cdrskin." echo " -experimental use newly introduced libburn features." echo " -oldfashioned use pre-0.2.2 libburn features only." @@ -99,7 +104,14 @@ echo "Build timestamp : $timestamp" if test "$compile_cdrskin" then echo "compiling program cdrskin/cdrskin.c $static_opts $debug_opts $libvers $def_opts $cleanup_src_or_obj" - cc $warn_opts -I. $static_opts $debug_opts $libvers $def_opts \ + cc -I. \ + $warn_opts \ + $static_opts \ + $debug_opts \ + $libvers \ + $largefile_opts \ + $def_opts \ + \ -DCdrskin_build_timestamP='"'"$timestamp"'"' \ \ -o cdrskin/cdrskin \ diff --git a/libburn/libburn.h b/libburn/libburn.h index 981a8ee..3186a79 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -7,6 +7,7 @@ expressing a file or stream size. XXX we should enforce 64-bitness for off_t + ts A61101 : this is usually done by the build system (if it is not broken) */ #include @@ -917,10 +918,19 @@ struct burn_source *burn_file_source_new(const char *path, */ struct burn_source *burn_fd_source_new(int datafd, int subfd, off_t size); -/** Tells how long a track will be on disc */ +/** Tells how long a track will be on disc + >>> NOTE: Not reliable with tracks of undefined length +*/ int burn_track_get_sectors(struct burn_track *); +/* ts A61101 */ +/** Tells how many source bytes have been read and how many data bytes have + been written by the track during burn */ +int burn_track_get_counters(struct burn_track *t, + off_t *read_bytes, off_t *written_bytes); + + /** Sets drive read and write speed @param d The drive to set speed for @param read Read speed in k/s (0 is max) diff --git a/libburn/sector.c b/libburn/sector.c index 08ce5d8..1a45aa3 100644 --- a/libburn/sector.c +++ b/libburn/sector.c @@ -129,6 +129,7 @@ static void get_bytes(struct burn_track *track, int count, unsigned char *data) track->eos = 1; valid = 0; } + track->sourcecount += valid; #ifdef Libburn_log_in_and_out_streaM /* <<< ts A61031 */ @@ -183,15 +184,6 @@ ex:; if(shortage) memset(data + curr, 0, shortage); /* this is old icculus.org */ if (track->swap_source_bytes == 1) { - -/* -{ static int swapping_count= 0; - fprintf(stderr,"\rlibburn_debug: swapping #%d \r", - swapping_count); - swapping_count++; -} -*/ - for (i = 1; i < count; i += 2) { tr = data[i]; data[i] = data[i-1]; @@ -202,7 +194,9 @@ ex:; /* ts A61009 : seems to hand out sector start pointer in opts->drive->buffer and to count hand outs as well as reserved bytes */ -static unsigned char *get_sector(struct burn_write_opts *opts, int inmode) +/* ts A61101 : added parameter track for counting written bytes */ +static unsigned char *get_sector(struct burn_write_opts *opts, + struct burn_track *track, int inmode) { struct burn_drive *d = opts->drive; struct buffer *out = d->buffer; @@ -227,6 +221,11 @@ static unsigned char *get_sector(struct burn_write_opts *opts, int inmode) err = d->write(d, d->nwa, out); if (err == BE_CANCELLED) return NULL; + + /* ts A61101 */ + if(track != NULL) + track->writecount += out->bytes; + d->nwa += out->sectors; out->bytes = 0; out->sectors = 0; @@ -257,7 +256,7 @@ static void unget_sector(struct burn_write_opts *opts, int inmode) Ensures out->bytes >= out->sectors */ seclen = burn_sector_length(outmode); if (seclen <= 0) - return NULL; + return; seclen += burn_subcode_length(outmode); out->bytes -= seclen; @@ -392,7 +391,7 @@ int sector_toc(struct burn_write_opts *o, int mode) unsigned char *data; unsigned char subs[96]; - data = get_sector(o, mode); + data = get_sector(o, NULL, mode); if (data == NULL) return 0; /* ts A61010 */ @@ -412,7 +411,7 @@ int sector_pregap(struct burn_write_opts *o, unsigned char *data; unsigned char subs[96]; - data = get_sector(o, mode); + data = get_sector(o, NULL, mode); if (data == NULL) return 0; /* ts A61010 */ @@ -432,7 +431,7 @@ int sector_postgap(struct burn_write_opts *o, unsigned char subs[96]; unsigned char *data; - data = get_sector(o, mode); + data = get_sector(o, NULL, mode); if (data == NULL) return 0; /* ts A61010 */ @@ -604,7 +603,7 @@ int sector_lout(struct burn_write_opts *o, unsigned char control, int mode) unsigned char subs[96]; unsigned char *data; - data = get_sector(o, mode); + data = get_sector(o, NULL, mode); if (!data) return 0; /* ts A61010 */ @@ -623,7 +622,7 @@ int sector_data(struct burn_write_opts *o, struct burn_track *t, int psub) unsigned char subs[96]; unsigned char *data; - data = get_sector(o, t->mode); + data = get_sector(o, t, t->mode); if (!data) return 0; /* ts A61010 */ diff --git a/libburn/source.c b/libburn/source.c index 7dd475e..a5ec152 100644 --- a/libburn/source.c +++ b/libburn/source.c @@ -24,7 +24,7 @@ enum burn_source_status burn_track_set_source(struct burn_track *t, t->source = s; /* ts A61031 */ - t->open_ended= (s->get_size(s) <= 0); + t->open_ended = (s->get_size(s) <= 0); return BURN_SOURCE_OK; } diff --git a/libburn/structure.c b/libburn/structure.c index 5e51f7e..9344abe 100644 --- a/libburn/structure.c +++ b/libburn/structure.c @@ -115,9 +115,13 @@ struct burn_track *burn_track_create(void) t->pad = 1; t->entry = NULL; t->source = NULL; + t->eos = 0; + + /* ts A61101 */ + t->sourcecount = 0; + t->writecount = 0; /* ts A61031 */ - t->eos = 0; t->open_ended = 0; t->track_data_done = 0; @@ -330,6 +334,19 @@ int burn_track_is_open_ended(struct burn_track *t) return !!t->open_ended; } +/* ts A61101 : API function */ +int burn_track_get_counters(struct burn_track *t, + off_t *read_bytes, off_t *written_bytes) +{ +/* + fprintf(stderr, "libburn_experimental: sizeof(off_t)=%d\n", + sizeof(off_t)); +*/ + *read_bytes = t->sourcecount; + *written_bytes = t->writecount; + return 1; +} + /* ts A61031 */ int burn_track_is_data_done(struct burn_track *t) { diff --git a/libburn/structure.h b/libburn/structure.h index f09b3cb..ab871ce 100644 --- a/libburn/structure.h +++ b/libburn/structure.h @@ -32,6 +32,10 @@ struct burn_track /** End of Source flag */ int eos; + /* ts A61101 */ + off_t sourcecount; + off_t writecount; + /* ts A61031 */ /** Source is of undefined length */ int open_ended; diff --git a/libburn/write.c b/libburn/write.c index d3b5d5e..c3e220a 100644 --- a/libburn/write.c +++ b/libburn/write.c @@ -99,7 +99,7 @@ void type_to_form(int mode, unsigned char *ctladr, int *form) *form |= 0x40; } -int burn_write_flush(struct burn_write_opts *o) +int burn_write_flush(struct burn_write_opts *o, struct burn_track *track) { struct burn_drive *d = o->drive; @@ -108,7 +108,13 @@ int burn_write_flush(struct burn_write_opts *o) err = d->write(d, d->nwa, d->buffer); if (err == BE_CANCELLED) return 0; + /* A61101 */ + if(track != NULL) + track->writecount += d->buffer->bytes; + d->nwa += d->buffer->sectors; + d->buffer->bytes = 0; + d->buffer->sectors = 0; } d->sync_cache(d); return 1; @@ -331,8 +337,17 @@ XXX this is untested :) */ if (!tar[i]->pad) { rem += burn_track_get_shortage(tar[i]); - if (i +1 != ntr) - tar[i]->source->next = tar[i+1]->source; + + /* ts A61101 : I doubt that linking would yield a + desireable effect. With TAO it is + counterproductive in any way. + */ + if (o->write_type == BURN_WRITE_TAO) + tar[i]->source->next = NULL; + else + + if (i +1 != ntr) + tar[i]->source->next = tar[i+1]->source; } else if (rem) { rem = 0; runtime++; @@ -507,10 +522,6 @@ int burn_write_track(struct burn_write_opts *o, struct burn_session *s, sectors = burn_track_get_sectors(t); open_ended = burn_track_is_open_ended(t); - /* <<< ts A61031 */ - fprintf(stderr, "libburn_experimental: sectors= %d , open_ended= %d\n", - sectors,open_ended); - /* Update progress */ d->progress.start_sector = d->nwa; d->progress.sectors = sectors; @@ -577,13 +588,17 @@ int burn_write_track(struct burn_write_opts *o, struct burn_session *s, err = d->write(d, d->nwa, d->buffer); if (err == BE_CANCELLED) return 0; + + /* A61101 : probably this is not payload data */ + /* t->writecount += d->buffer->bytes; */ + d->nwa += d->buffer->sectors; d->buffer->bytes = 0; d->buffer->sectors = 0; } } if (o->write_type == BURN_WRITE_TAO) { - if (!burn_write_flush(o)) + if (!burn_write_flush(o, t)) return 0; /* ts A61030 */ @@ -729,7 +744,7 @@ return crap. so we send the command, then ignore the result. goto fail; } else - if (!burn_write_flush(o)) + if (!burn_write_flush(o, NULL)) goto fail; d->nwa += first ? 6750 : 2250; @@ -746,7 +761,7 @@ return crap. so we send the command, then ignore the result. /* ts A61030: extended skipping of flush to TAO: session is closed */ if (o->write_type != BURN_WRITE_SAO && o->write_type != BURN_WRITE_TAO) - if (!burn_write_flush(o)) + if (!burn_write_flush(o, NULL)) goto fail; sleep(1); diff --git a/libburn/write.h b/libburn/write.h index 27ba00f..7ec17ba 100644 --- a/libburn/write.h +++ b/libburn/write.h @@ -24,7 +24,7 @@ int burn_write_leadout(struct burn_write_opts *o, int burn_write_session(struct burn_write_opts *o, struct burn_session *s); int burn_write_track(struct burn_write_opts *o, struct burn_session *s, int tnum); -int burn_write_flush(struct burn_write_opts *o); +int burn_write_flush(struct burn_write_opts *o, struct burn_track *track); /* ts A61030 : necessary for TAO */ int burn_write_close_track(struct burn_write_opts *o, int tnum);