dapted cdrskin pacifier to possibly unknown track size
This commit is contained in:
@ -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 <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);
|
||||
|
||||
/** 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)
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user