dapted cdrskin pacifier to possibly unknown track size

This commit is contained in:
Thomas Schmitt 2006-11-01 16:39:07 +00:00
parent 5af92d13fe
commit d337722920
10 changed files with 130 additions and 50 deletions

View File

@ -206,14 +206,6 @@ or
#endif /* Cdrskin_libburn_from_pykix_svN */ #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. /* These macros activate cdrskin workarounds for deficiencies resp.
problematic features of libburn which hopefully will change in problematic features of libburn which hopefully will change in
future. */ future. */
@ -279,7 +271,6 @@ or
#include <errno.h> #include <errno.h>
#include <sys/time.h> #include <sys/time.h>
/* #include <libburn/libburn.h> */
#include "../libburn/libburn.h" #include "../libburn/libburn.h"
#ifdef Cdrskin_libburn_has_audioxtR #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, int Cdrtrack_get_size(struct CdrtracK *track, double *size, double *padding,
double *sector_size, int flag) double *sector_size, int flag)
{ {
*size= track->fixed_size; *size= track->fixed_size;
*padding= track->padding; *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; *sector_size= track->sector_size;
return(1); return(1);
} }
@ -3769,12 +3782,12 @@ int Cdrskin_burn_pacifier(struct CdrskiN *skin,
if(old_track_idx>=0 && old_track_idx<skin->supposed_track_idx) { if(old_track_idx>=0 && old_track_idx<skin->supposed_track_idx) {
Cdrtrack_get_size(skin->tracklist[old_track_idx],&fixed_size,&padding, Cdrtrack_get_size(skin->tracklist[old_track_idx],&fixed_size,&padding,
&sector_size,0); &sector_size,1);
if(skin->verbosity>=Cdrskin_verbose_progresS) if(skin->verbosity>=Cdrskin_verbose_progresS)
printf("\n"); printf("\n");
printf("%sTrack %-2.2d: Total bytes read/written: %.f/%.f (%.f sectors).\n", printf("%sTrack %-2.2d: Total bytes read/written: %.f/%.f (%.f sectors).\n",
debug_mark,old_track_idx+1,fixed_size,fixed_size, debug_mark,old_track_idx+1,fixed_size,fixed_size+padding,
fixed_size/sector_size); (fixed_size+padding)/sector_size);
} }
sector_size= 2048.0; 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 put_counter,get_counter,empty_counter,full_counter;
double start_time,last_time; double start_time,last_time;
double total_count= 0.0,last_count= 0.0,size,padding,sector_size= 2048.0; double total_count= 0.0,last_count= 0.0,size,padding,sector_size= 2048.0;
double sectors;
printf("cdrskin: beginning to burn disk\n"); printf("cdrskin: beginning to burn disk\n");
@ -3997,6 +4011,7 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag)
return(0); return(0);
} }
Cdrtrack_get_size(skin->tracklist[i],&size,&padding,&sector_size,0); Cdrtrack_get_size(skin->tracklist[i],&size,&padding,&sector_size,0);
if(size>0)
skin->fixed_size+= size+padding; skin->fixed_size+= size+padding;
} }
@ -4053,8 +4068,11 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag)
frac= (seconds-min*60-sec)*100; frac= (seconds-min*60-sec)*100;
if(frac>99) if(frac>99)
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", 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; seconds+= 2;
min= seconds/60.0; min= seconds/60.0;
sec= seconds-min*60; sec= seconds-min*60;
@ -4062,7 +4080,7 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag)
if(frac>99) if(frac>99)
frac= 99; frac= 99;
printf("Lout start: %5d MB (%-2.2d:%-2.2d/%-2.2d) = %d sectors\n", 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; skin->drive_is_busy= 0;
if(skin->verbosity>=Cdrskin_verbose_progresS) if(skin->verbosity>=Cdrskin_verbose_progresS)
printf("\n"); printf("\n");
if(max_track<=0) { if(max_track<0) {
printf("Track 01: Total bytes read/written: %.f/%.f (%.f sectors).\n", printf("Track 01: Total bytes read/written: %.f/%.f (%.f sectors).\n",
total_count,total_count,total_count/sector_size); total_count,total_count,total_count/sector_size);
} else { } else {
Cdrtrack_get_size(skin->tracklist[max_track],&size,&padding,&sector_size,0); Cdrtrack_get_size(skin->tracklist[max_track],&size,&padding,&sector_size,1);
printf( printf(
"Track %-2.2d: Total bytes read/written: %.f/%.f (%.f sectors).\n", "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) if(skin->verbosity>=Cdrskin_verbose_progresS)
printf("Writing time: %.3fs\n",Sfile_microtime(0)-start_time); printf("Writing time: %.3fs\n",Sfile_microtime(0)-start_time);
@ -4622,7 +4640,12 @@ set_driveropts:;
} }
strcpy(skin->eject_device,argv[i]+13); strcpy(skin->eject_device,argv[i]+13);
if(skin->verbosity>=Cdrskin_verbose_cmD) if(skin->verbosity>=Cdrskin_verbose_cmD)
#ifdef Cdrskin_burn_drive_eject_brokeN
printf("cdrskin: eject_device : %s\n",skin->eject_device); 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 #ifndef Cdrskin_extra_leaN

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2006.10.31.184736" #define Cdrskin_timestamP "2006.11.01.163934"

View File

@ -6,6 +6,7 @@
debug_opts= debug_opts=
def_opts= def_opts=
largefile_opts="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1"
libvers="-DCdrskin_libburn_0_2_3" libvers="-DCdrskin_libburn_0_2_3"
cleanup_src_or_obj="libburn/cleanup.o" cleanup_src_or_obj="libburn/cleanup.o"
libdax_msgs_o="libburn/libdax_msgs.o" libdax_msgs_o="libburn/libdax_msgs.o"
@ -50,6 +51,9 @@ do
elif test "$i" = "-oldfashioned" elif test "$i" = "-oldfashioned"
then then
def_opts="$def_opts -DCdrskin_oldfashioned_api_usE" def_opts="$def_opts -DCdrskin_oldfashioned_api_usE"
elif test "$i" = "-no_largefile"
then
largefile_opts=
elif test "$i" = "-do_not_compile_cdrskin" elif test "$i" = "-do_not_compile_cdrskin"
then then
compile_cdrskin=0 compile_cdrskin=0
@ -76,6 +80,7 @@ do
echo " -cvs_A60220 set macro to match libburn-CVS of 20 Feb 2006." 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_2 set macro to match libburn-0.2.2."
echo " -libburn_0_2_3 set macro to match current libburn-SVN." 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 " -do_not_compile_cdrskin omit compilation of cdrskin/cdrskin."
echo " -experimental use newly introduced libburn features." echo " -experimental use newly introduced libburn features."
echo " -oldfashioned use pre-0.2.2 libburn features only." echo " -oldfashioned use pre-0.2.2 libburn features only."
@ -99,7 +104,14 @@ echo "Build timestamp : $timestamp"
if test "$compile_cdrskin" if test "$compile_cdrskin"
then then
echo "compiling program cdrskin/cdrskin.c $static_opts $debug_opts $libvers $def_opts $cleanup_src_or_obj" 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"'"' \ -DCdrskin_build_timestamP='"'"$timestamp"'"' \
\ \
-o cdrskin/cdrskin \ -o cdrskin/cdrskin \

View File

@ -7,6 +7,7 @@
expressing a file or stream size. expressing a file or stream size.
XXX we should enforce 64-bitness for off_t 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 <sys/types.h> #include <sys/types.h>
@ -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); 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 *); 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 /** Sets drive read and write speed
@param d The drive to set speed for @param d The drive to set speed for
@param read Read speed in k/s (0 is max) @param read Read speed in k/s (0 is max)

View File

@ -129,6 +129,7 @@ static void get_bytes(struct burn_track *track, int count, unsigned char *data)
track->eos = 1; track->eos = 1;
valid = 0; valid = 0;
} }
track->sourcecount += valid;
#ifdef Libburn_log_in_and_out_streaM #ifdef Libburn_log_in_and_out_streaM
/* <<< ts A61031 */ /* <<< ts A61031 */
@ -183,15 +184,6 @@ ex:;
if(shortage) if(shortage)
memset(data + curr, 0, shortage); /* this is old icculus.org */ memset(data + curr, 0, shortage); /* this is old icculus.org */
if (track->swap_source_bytes == 1) { 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) { for (i = 1; i < count; i += 2) {
tr = data[i]; tr = data[i];
data[i] = data[i-1]; data[i] = data[i-1];
@ -202,7 +194,9 @@ ex:;
/* ts A61009 : seems to hand out sector start pointer in opts->drive->buffer /* ts A61009 : seems to hand out sector start pointer in opts->drive->buffer
and to count hand outs as well as reserved bytes */ 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 burn_drive *d = opts->drive;
struct buffer *out = d->buffer; 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); err = d->write(d, d->nwa, out);
if (err == BE_CANCELLED) if (err == BE_CANCELLED)
return NULL; return NULL;
/* ts A61101 */
if(track != NULL)
track->writecount += out->bytes;
d->nwa += out->sectors; d->nwa += out->sectors;
out->bytes = 0; out->bytes = 0;
out->sectors = 0; out->sectors = 0;
@ -257,7 +256,7 @@ static void unget_sector(struct burn_write_opts *opts, int inmode)
Ensures out->bytes >= out->sectors */ Ensures out->bytes >= out->sectors */
seclen = burn_sector_length(outmode); seclen = burn_sector_length(outmode);
if (seclen <= 0) if (seclen <= 0)
return NULL; return;
seclen += burn_subcode_length(outmode); seclen += burn_subcode_length(outmode);
out->bytes -= seclen; out->bytes -= seclen;
@ -392,7 +391,7 @@ int sector_toc(struct burn_write_opts *o, int mode)
unsigned char *data; unsigned char *data;
unsigned char subs[96]; unsigned char subs[96];
data = get_sector(o, mode); data = get_sector(o, NULL, mode);
if (data == NULL) if (data == NULL)
return 0; return 0;
/* ts A61010 */ /* ts A61010 */
@ -412,7 +411,7 @@ int sector_pregap(struct burn_write_opts *o,
unsigned char *data; unsigned char *data;
unsigned char subs[96]; unsigned char subs[96];
data = get_sector(o, mode); data = get_sector(o, NULL, mode);
if (data == NULL) if (data == NULL)
return 0; return 0;
/* ts A61010 */ /* ts A61010 */
@ -432,7 +431,7 @@ int sector_postgap(struct burn_write_opts *o,
unsigned char subs[96]; unsigned char subs[96];
unsigned char *data; unsigned char *data;
data = get_sector(o, mode); data = get_sector(o, NULL, mode);
if (data == NULL) if (data == NULL)
return 0; return 0;
/* ts A61010 */ /* 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 subs[96];
unsigned char *data; unsigned char *data;
data = get_sector(o, mode); data = get_sector(o, NULL, mode);
if (!data) if (!data)
return 0; return 0;
/* ts A61010 */ /* 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 subs[96];
unsigned char *data; unsigned char *data;
data = get_sector(o, t->mode); data = get_sector(o, t, t->mode);
if (!data) if (!data)
return 0; return 0;
/* ts A61010 */ /* ts A61010 */

View File

@ -115,9 +115,13 @@ struct burn_track *burn_track_create(void)
t->pad = 1; t->pad = 1;
t->entry = NULL; t->entry = NULL;
t->source = NULL; t->source = NULL;
t->eos = 0;
/* ts A61101 */
t->sourcecount = 0;
t->writecount = 0;
/* ts A61031 */ /* ts A61031 */
t->eos = 0;
t->open_ended = 0; t->open_ended = 0;
t->track_data_done = 0; t->track_data_done = 0;
@ -330,6 +334,19 @@ int burn_track_is_open_ended(struct burn_track *t)
return !!t->open_ended; 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 */ /* ts A61031 */
int burn_track_is_data_done(struct burn_track *t) int burn_track_is_data_done(struct burn_track *t)
{ {

View File

@ -32,6 +32,10 @@ struct burn_track
/** End of Source flag */ /** End of Source flag */
int eos; int eos;
/* ts A61101 */
off_t sourcecount;
off_t writecount;
/* ts A61031 */ /* ts A61031 */
/** Source is of undefined length */ /** Source is of undefined length */
int open_ended; int open_ended;

View File

@ -99,7 +99,7 @@ void type_to_form(int mode, unsigned char *ctladr, int *form)
*form |= 0x40; *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; 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); err = d->write(d, d->nwa, d->buffer);
if (err == BE_CANCELLED) if (err == BE_CANCELLED)
return 0; return 0;
/* A61101 */
if(track != NULL)
track->writecount += d->buffer->bytes;
d->nwa += d->buffer->sectors; d->nwa += d->buffer->sectors;
d->buffer->bytes = 0;
d->buffer->sectors = 0;
} }
d->sync_cache(d); d->sync_cache(d);
return 1; return 1;
@ -331,6 +337,15 @@ XXX this is untested :)
*/ */
if (!tar[i]->pad) { if (!tar[i]->pad) {
rem += burn_track_get_shortage(tar[i]); rem += burn_track_get_shortage(tar[i]);
/* 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) if (i +1 != ntr)
tar[i]->source->next = tar[i+1]->source; tar[i]->source->next = tar[i+1]->source;
} else if (rem) { } else if (rem) {
@ -507,10 +522,6 @@ int burn_write_track(struct burn_write_opts *o, struct burn_session *s,
sectors = burn_track_get_sectors(t); sectors = burn_track_get_sectors(t);
open_ended = burn_track_is_open_ended(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 */ /* Update progress */
d->progress.start_sector = d->nwa; d->progress.start_sector = d->nwa;
d->progress.sectors = sectors; 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); err = d->write(d, d->nwa, d->buffer);
if (err == BE_CANCELLED) if (err == BE_CANCELLED)
return 0; return 0;
/* A61101 : probably this is not payload data */
/* t->writecount += d->buffer->bytes; */
d->nwa += d->buffer->sectors; d->nwa += d->buffer->sectors;
d->buffer->bytes = 0; d->buffer->bytes = 0;
d->buffer->sectors = 0; d->buffer->sectors = 0;
} }
} }
if (o->write_type == BURN_WRITE_TAO) { if (o->write_type == BURN_WRITE_TAO) {
if (!burn_write_flush(o)) if (!burn_write_flush(o, t))
return 0; return 0;
/* ts A61030 */ /* ts A61030 */
@ -729,7 +744,7 @@ return crap. so we send the command, then ignore the result.
goto fail; goto fail;
} else } else
if (!burn_write_flush(o)) if (!burn_write_flush(o, NULL))
goto fail; goto fail;
d->nwa += first ? 6750 : 2250; 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 */ /* 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 (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; goto fail;
sleep(1); sleep(1);

View File

@ -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_session(struct burn_write_opts *o, struct burn_session *s);
int burn_write_track(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 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 */ /* ts A61030 : necessary for TAO */
int burn_write_close_track(struct burn_write_opts *o, int tnum); int burn_write_close_track(struct burn_write_opts *o, int tnum);