Avoided error message and nonzero exit with trailing trash on .wav
This commit is contained in:
parent
c44643e01b
commit
41f26dc5fb
@ -48,6 +48,9 @@ struct CdrfifO {
|
|||||||
int source_fd;
|
int source_fd;
|
||||||
double in_counter;
|
double in_counter;
|
||||||
|
|
||||||
|
double fd_in_counter;
|
||||||
|
double fd_in_limit;
|
||||||
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int buffer_size;
|
int buffer_size;
|
||||||
int buffer_is_full;
|
int buffer_is_full;
|
||||||
@ -72,17 +75,27 @@ struct CdrfifO {
|
|||||||
double empty_counter;
|
double empty_counter;
|
||||||
double full_counter;
|
double full_counter;
|
||||||
|
|
||||||
|
|
||||||
/* (sequential) fd chaining */
|
/* (sequential) fd chaining */
|
||||||
|
/* fds: 0=source, 1=dest */
|
||||||
int follow_up_fds[Cdrfifo_ffd_maX][2];
|
int follow_up_fds[Cdrfifo_ffd_maX][2];
|
||||||
|
|
||||||
/* index of first byte in buffer which does not belong to predecessor fd */
|
/* index of first byte in buffer which does not belong to predecessor fd */
|
||||||
int follow_up_eop[Cdrfifo_ffd_maX];
|
int follow_up_eop[Cdrfifo_ffd_maX];
|
||||||
|
|
||||||
/* index of first byte in buffer which belongs to [this] fd pair */
|
/* index of first byte in buffer which belongs to [this] fd pair */
|
||||||
int follow_up_sod[Cdrfifo_ffd_maX];
|
int follow_up_sod[Cdrfifo_ffd_maX];
|
||||||
|
|
||||||
|
/* values for fd_in_limit */
|
||||||
|
double follow_up_in_limits[Cdrfifo_ffd_maX];
|
||||||
|
|
||||||
/* number of defined follow-ups */
|
/* number of defined follow-ups */
|
||||||
int follow_up_fd_counter;
|
int follow_up_fd_counter;
|
||||||
|
|
||||||
/* index of currently active (i.e. reading) follow-up */
|
/* index of currently active (i.e. reading) follow-up */
|
||||||
int follow_up_fd_idx;
|
int follow_up_fd_idx;
|
||||||
|
|
||||||
|
|
||||||
/* (simultaneous) peer chaining */
|
/* (simultaneous) peer chaining */
|
||||||
struct CdrfifO *next;
|
struct CdrfifO *next;
|
||||||
struct CdrfifO *prev;
|
struct CdrfifO *prev;
|
||||||
@ -117,6 +130,8 @@ int Cdrfifo_new(struct CdrfifO **ff, int source_fd, int dest_fd,
|
|||||||
buffer_size+= chunk_size-(buffer_size%chunk_size);
|
buffer_size+= chunk_size-(buffer_size%chunk_size);
|
||||||
o->source_fd= source_fd;
|
o->source_fd= source_fd;
|
||||||
o->in_counter= 0.0;
|
o->in_counter= 0.0;
|
||||||
|
o->fd_in_counter= 0;
|
||||||
|
o->fd_in_limit= -1.0;
|
||||||
o->buffer= NULL;
|
o->buffer= NULL;
|
||||||
o->buffer_is_full= 0;
|
o->buffer_is_full= 0;
|
||||||
o->buffer_size= buffer_size;
|
o->buffer_size= buffer_size;
|
||||||
@ -140,6 +155,7 @@ int Cdrfifo_new(struct CdrfifO **ff, int source_fd, int dest_fd,
|
|||||||
for(i= 0; i<Cdrfifo_ffd_maX; i++) {
|
for(i= 0; i<Cdrfifo_ffd_maX; i++) {
|
||||||
o->follow_up_fds[i][0]= o->follow_up_fds[i][1]= -1;
|
o->follow_up_fds[i][0]= o->follow_up_fds[i][1]= -1;
|
||||||
o->follow_up_eop[i]= o->follow_up_sod[i]= -1;
|
o->follow_up_eop[i]= o->follow_up_sod[i]= -1;
|
||||||
|
o->follow_up_in_limits[i]= -1.0;
|
||||||
}
|
}
|
||||||
o->follow_up_fd_counter= 0;
|
o->follow_up_fd_counter= 0;
|
||||||
o->follow_up_fd_idx= -1;
|
o->follow_up_fd_idx= -1;
|
||||||
@ -224,6 +240,26 @@ int Cdrfifo_set_speed_limit(struct CdrfifO *o, double bytes_per_second,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Set a fixed size for input in order to cut off any unwanted tail
|
||||||
|
@param o The fifo object
|
||||||
|
@param idx index for fds attached via Cdrfifo_attach_follow_up_fds(),
|
||||||
|
first attached is 0, <0 directs limit to active fd limit
|
||||||
|
(i.e. first track is -1, second track is 0, third is 1, ...)
|
||||||
|
*/
|
||||||
|
int Cdrfifo_set_fd_in_limit(struct CdrfifO *o, double fd_in_limit, int idx,
|
||||||
|
int flag)
|
||||||
|
{
|
||||||
|
if(idx<0) {
|
||||||
|
o->fd_in_limit= fd_in_limit;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
if(idx >= o->follow_up_fd_counter)
|
||||||
|
return(0);
|
||||||
|
o->follow_up_in_limits[idx]= fd_in_limit;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int Cdrfifo_set_fds(struct CdrfifO *o, int source_fd, int dest_fd, int flag)
|
int Cdrfifo_set_fds(struct CdrfifO *o, int source_fd, int dest_fd, int flag)
|
||||||
{
|
{
|
||||||
o->source_fd= source_fd;
|
o->source_fd= source_fd;
|
||||||
@ -244,6 +280,7 @@ int Cdrfifo_get_fds(struct CdrfifO *o, int *source_fd, int *dest_fd, int flag)
|
|||||||
fifo buffer when its predecessors are exhausted. Reading will start as
|
fifo buffer when its predecessors are exhausted. Reading will start as
|
||||||
soon as reading of the predecessor encounters EOF. Writing will start
|
soon as reading of the predecessor encounters EOF. Writing will start
|
||||||
as soon as all pending predecessor data are written.
|
as soon as all pending predecessor data are written.
|
||||||
|
@return index number of new item + 1, <=0 indicates error
|
||||||
*/
|
*/
|
||||||
int Cdrfifo_attach_follow_up_fds(struct CdrfifO *o, int source_fd, int dest_fd,
|
int Cdrfifo_attach_follow_up_fds(struct CdrfifO *o, int source_fd, int dest_fd,
|
||||||
int flag)
|
int flag)
|
||||||
@ -253,7 +290,7 @@ int Cdrfifo_attach_follow_up_fds(struct CdrfifO *o, int source_fd, int dest_fd,
|
|||||||
o->follow_up_fds[o->follow_up_fd_counter][0]= source_fd;
|
o->follow_up_fds[o->follow_up_fd_counter][0]= source_fd;
|
||||||
o->follow_up_fds[o->follow_up_fd_counter][1]= dest_fd;
|
o->follow_up_fds[o->follow_up_fd_counter][1]= dest_fd;
|
||||||
o->follow_up_fd_counter++;
|
o->follow_up_fd_counter++;
|
||||||
return(1);
|
return(o->follow_up_fd_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -567,7 +604,12 @@ after_write:;
|
|||||||
can_read= o->chunk_size;
|
can_read= o->chunk_size;
|
||||||
if(o->write_idx<o->read_idx && o->write_idx+can_read > o->read_idx)
|
if(o->write_idx<o->read_idx && o->write_idx+can_read > o->read_idx)
|
||||||
can_read= o->read_idx - o->write_idx;
|
can_read= o->read_idx - o->write_idx;
|
||||||
ret= read(o->source_fd,o->buffer+o->write_idx,can_read);
|
if(o->fd_in_limit>=0.0)
|
||||||
|
if(can_read > o->fd_in_limit - o->fd_in_counter)
|
||||||
|
can_read= o->fd_in_limit - o->fd_in_counter;
|
||||||
|
ret= 0;
|
||||||
|
if(can_read>0)
|
||||||
|
ret= read(o->source_fd,o->buffer+o->write_idx,can_read);
|
||||||
if(ret==-1) {
|
if(ret==-1) {
|
||||||
|
|
||||||
/* >>> handle input error */;
|
/* >>> handle input error */;
|
||||||
@ -599,6 +641,8 @@ after_write:;
|
|||||||
sod= 0;
|
sod= 0;
|
||||||
o->follow_up_sod[idx]= sod;
|
o->follow_up_sod[idx]= sod;
|
||||||
o->write_idx= sod;
|
o->write_idx= sod;
|
||||||
|
o->fd_in_counter= 0;
|
||||||
|
o->fd_in_limit= o->follow_up_in_limits[idx];
|
||||||
if(Cdrfifo_debuG || (flag&1))
|
if(Cdrfifo_debuG || (flag&1))
|
||||||
fprintf(stderr,"\ncdrfio: new fifo source fd : %d\n",o->source_fd);
|
fprintf(stderr,"\ncdrfio: new fifo source fd : %d\n",o->source_fd);
|
||||||
} else {
|
} else {
|
||||||
@ -608,6 +652,7 @@ after_write:;
|
|||||||
did_work= 1;
|
did_work= 1;
|
||||||
o->put_counter++;
|
o->put_counter++;
|
||||||
o->in_counter+= ret;
|
o->in_counter+= ret;
|
||||||
|
o->fd_in_counter+= ret;
|
||||||
o->write_idx+= ret;
|
o->write_idx+= ret;
|
||||||
if(o->write_idx>=o->buffer_size)
|
if(o->write_idx>=o->buffer_size)
|
||||||
o->write_idx= 0;
|
o->write_idx= 0;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/** The fifo buffer which will smoothen the data stream from data provider
|
/** The fifo buffer which will smoothen the data stream from data provider
|
||||||
to data consumer. Although this is not a mandatory lifesavier for modern
|
to data consumer. Although this is not a mandatory lifesaver for modern
|
||||||
burners any more, a fifo can speed up burning of data which is delivered
|
burners any more, a fifo can speed up burning of data which is delivered
|
||||||
with varying bandwidths (e.g. compressed archives created on the fly
|
with varying bandwidths (e.g. compressed archives created on the fly
|
||||||
or mkisofs running at its speed limit.).
|
or mkisofs running at its speed limit.).
|
||||||
@ -64,6 +64,16 @@ int Cdrfifo_get_sizes(struct CdrfifO *o, int *chunk_size, int *buffer_size,
|
|||||||
int Cdrfifo_set_speed_limit(struct CdrfifO *o, double bytes_per_second,
|
int Cdrfifo_set_speed_limit(struct CdrfifO *o, double bytes_per_second,
|
||||||
int flag);
|
int flag);
|
||||||
|
|
||||||
|
/** Set a fixed size for input in order to cut off any unwanted tail
|
||||||
|
@param o The fifo object
|
||||||
|
@param idx index for fds attached via Cdrfifo_attach_follow_up_fds(),
|
||||||
|
first attached is 0, <0 directs limit to active fd limit
|
||||||
|
(i.e. first track is -1, second track is 0, third is 1, ...)
|
||||||
|
*/
|
||||||
|
int Cdrfifo_set_fd_in_limit(struct CdrfifO *o, double fd_in_limit, int idx,
|
||||||
|
int flag);
|
||||||
|
|
||||||
|
|
||||||
int Cdrfifo_set_fds(struct CdrfifO *o, int source_fd, int dest_fd, int flag);
|
int Cdrfifo_set_fds(struct CdrfifO *o, int source_fd, int dest_fd, int flag);
|
||||||
int Cdrfifo_get_fds(struct CdrfifO *o, int *source_fd, int *dest_fd, int flag);
|
int Cdrfifo_get_fds(struct CdrfifO *o, int *source_fd, int *dest_fd, int flag);
|
||||||
|
|
||||||
@ -72,6 +82,7 @@ int Cdrfifo_get_fds(struct CdrfifO *o, int *source_fd, int *dest_fd, int flag);
|
|||||||
fifo buffer when its predecessors are exhausted. Reading will start as
|
fifo buffer when its predecessors are exhausted. Reading will start as
|
||||||
soon as reading of the predecessor encounters EOF. Writing will start
|
soon as reading of the predecessor encounters EOF. Writing will start
|
||||||
as soon as all pending predecessor data are written.
|
as soon as all pending predecessor data are written.
|
||||||
|
@return index number of new item + 1, <=0 indicates error
|
||||||
*/
|
*/
|
||||||
int Cdrfifo_attach_follow_up_fds(struct CdrfifO *o, int source_fd, int dest_fd,
|
int Cdrfifo_attach_follow_up_fds(struct CdrfifO *o, int source_fd, int dest_fd,
|
||||||
int flag);
|
int flag);
|
||||||
|
@ -772,17 +772,28 @@ struct CdrtracK {
|
|||||||
int track_type_by_default;
|
int track_type_by_default;
|
||||||
int swap_audio_bytes;
|
int swap_audio_bytes;
|
||||||
|
|
||||||
|
/* wether the data source is a container of defined size with possible tail */
|
||||||
|
int extracting_container;
|
||||||
|
|
||||||
/** Optional fifo between input fd and libburn. It uses a pipe(2) to transfer
|
/** Optional fifo between input fd and libburn. It uses a pipe(2) to transfer
|
||||||
data to libburn.
|
data to libburn.
|
||||||
*/
|
*/
|
||||||
int fifo_enabled;
|
int fifo_enabled;
|
||||||
/** The fifo object knows the real input fd and the fd[1] of the pipe. */
|
|
||||||
|
/** The eventual own fifo object managed by this track object. */
|
||||||
struct CdrfifO *fifo;
|
struct CdrfifO *fifo;
|
||||||
|
|
||||||
/** fd[0] of the fifo pipe. This is from where libburn reads its data. */
|
/** fd[0] of the fifo pipe. This is from where libburn reads its data. */
|
||||||
int fifo_outlet_fd;
|
int fifo_outlet_fd;
|
||||||
int fifo_size;
|
int fifo_size;
|
||||||
int fifo_start_empty;
|
int fifo_start_empty;
|
||||||
|
|
||||||
|
/** The possibly external fifo object which knows the real input fd and
|
||||||
|
the fd[1] of the pipe. */
|
||||||
|
struct CdrfifO *ff_fifo;
|
||||||
|
/** The index number if fifo follow up fd item, -1= own fifo */
|
||||||
|
int ff_idx;
|
||||||
|
|
||||||
struct burn_track *libburn_track;
|
struct burn_track *libburn_track;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -828,11 +839,14 @@ int Cdrtrack_new(struct CdrtracK **track, struct CdrskiN *boss,
|
|||||||
o->sector_size= 2048.0;
|
o->sector_size= 2048.0;
|
||||||
o->track_type_by_default= 1;
|
o->track_type_by_default= 1;
|
||||||
o->swap_audio_bytes= 0;
|
o->swap_audio_bytes= 0;
|
||||||
|
o->extracting_container= 0;
|
||||||
o->fifo_enabled= 0;
|
o->fifo_enabled= 0;
|
||||||
o->fifo= NULL;
|
o->fifo= NULL;
|
||||||
o->fifo_outlet_fd= -1;
|
o->fifo_outlet_fd= -1;
|
||||||
o->fifo_size= 0;
|
o->fifo_size= 0;
|
||||||
o->fifo_start_empty= 0;
|
o->fifo_start_empty= 0;
|
||||||
|
o->ff_fifo= NULL;
|
||||||
|
o->ff_idx= -1;
|
||||||
o->libburn_track= NULL;
|
o->libburn_track= NULL;
|
||||||
ret= Cdrskin_get_source(boss,o->source_path,&(o->fixed_size),&(o->padding),
|
ret= Cdrskin_get_source(boss,o->source_path,&(o->fixed_size),&(o->padding),
|
||||||
&(o->set_by_padsize),&(skin_track_type),
|
&(o->set_by_padsize),&(skin_track_type),
|
||||||
@ -989,6 +1003,7 @@ int Cdrtrack_extract_audio(struct CdrtracK *track, int *fd, off_t *xtr_size,
|
|||||||
if(ret<=0)
|
if(ret<=0)
|
||||||
{ret= -1*!!ret; goto ex;}
|
{ret= -1*!!ret; goto ex;}
|
||||||
track->swap_audio_bytes= !!msb_first;
|
track->swap_audio_bytes= !!msb_first;
|
||||||
|
track->extracting_container= 1;
|
||||||
fprintf(stderr,"cdrskin: NOTE : %.f %saudio bytes in '%s'\n",
|
fprintf(stderr,"cdrskin: NOTE : %.f %saudio bytes in '%s'\n",
|
||||||
(double) *xtr_size, (msb_first ? "" : "(-swab) "),
|
(double) *xtr_size, (msb_first ? "" : "(-swab) "),
|
||||||
track->source_path);
|
track->source_path);
|
||||||
@ -1087,6 +1102,7 @@ int Cdrtrack_open_source_path(struct CdrtracK *track, int *fd, int flag)
|
|||||||
bit0= Debugging verbosity
|
bit0= Debugging verbosity
|
||||||
bit1= Do not create and attach a new fifo
|
bit1= Do not create and attach a new fifo
|
||||||
but attach new follow-up fd pair to previous_fifo
|
but attach new follow-up fd pair to previous_fifo
|
||||||
|
bit2= Do not enforce fixed_size if not container extraction
|
||||||
@return <=0 error, 1 success
|
@return <=0 error, 1 success
|
||||||
*/
|
*/
|
||||||
int Cdrtrack_attach_fifo(struct CdrtracK *track, int *outlet_fd,
|
int Cdrtrack_attach_fifo(struct CdrtracK *track, int *outlet_fd,
|
||||||
@ -1108,7 +1124,9 @@ int Cdrtrack_attach_fifo(struct CdrtracK *track, int *outlet_fd,
|
|||||||
if(flag&2) {
|
if(flag&2) {
|
||||||
ret= Cdrfifo_attach_follow_up_fds(previous_fifo,source_fd,pipe_fds[1],0);
|
ret= Cdrfifo_attach_follow_up_fds(previous_fifo,source_fd,pipe_fds[1],0);
|
||||||
if(ret<=0)
|
if(ret<=0)
|
||||||
return(ret);
|
return(ret);
|
||||||
|
track->ff_fifo= previous_fifo;
|
||||||
|
track->ff_idx= ret-1;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* >>> ??? obtain track sector size and use instead of 2048 ? */
|
/* >>> ??? obtain track sector size and use instead of 2048 ? */
|
||||||
@ -1118,9 +1136,14 @@ int Cdrtrack_attach_fifo(struct CdrtracK *track, int *outlet_fd,
|
|||||||
return(ret);
|
return(ret);
|
||||||
if(previous_fifo!=NULL)
|
if(previous_fifo!=NULL)
|
||||||
Cdrfifo_attach_peer(previous_fifo,ff,0);
|
Cdrfifo_attach_peer(previous_fifo,ff,0);
|
||||||
track->fifo= ff;
|
track->fifo= track->ff_fifo= ff;
|
||||||
|
track->ff_idx= -1;
|
||||||
}
|
}
|
||||||
track->fifo_outlet_fd= pipe_fds[0];
|
track->fifo_outlet_fd= pipe_fds[0];
|
||||||
|
|
||||||
|
if((track->extracting_container || !(flag&4)) && track->fixed_size>0)
|
||||||
|
Cdrfifo_set_fd_in_limit(track->ff_fifo,track->fixed_size,track->ff_idx,0);
|
||||||
|
|
||||||
if(flag&1)
|
if(flag&1)
|
||||||
printf(
|
printf(
|
||||||
"cdrskin_debug: track %d fifo replaced source_address '%s' by '#%d'\n",
|
"cdrskin_debug: track %d fifo replaced source_address '%s' by '#%d'\n",
|
||||||
@ -2524,6 +2547,8 @@ int Cdrskin_attach_fifo(struct CdrskiN *skin, int flag)
|
|||||||
skin->fifo= NULL;
|
skin->fifo= NULL;
|
||||||
for(i=0;i<skin->track_counter;i++) {
|
for(i=0;i<skin->track_counter;i++) {
|
||||||
hflag= (skin->verbosity>=Cdrskin_verbose_debuG);
|
hflag= (skin->verbosity>=Cdrskin_verbose_debuG);
|
||||||
|
if(i==skin->track_counter-1)
|
||||||
|
hflag|= 4;
|
||||||
if(skin->verbosity>=Cdrskin_verbose_cmD) {
|
if(skin->verbosity>=Cdrskin_verbose_cmD) {
|
||||||
if(skin->fifo_per_track)
|
if(skin->fifo_per_track)
|
||||||
printf("cdrskin: track %d establishing fifo of %d bytes\n",
|
printf("cdrskin: track %d establishing fifo of %d bytes\n",
|
||||||
|
@ -1 +1 @@
|
|||||||
#define Cdrskin_timestamP "2006.11.07.152018"
|
#define Cdrskin_timestamP "2006.11.08.165648"
|
||||||
|
Loading…
Reference in New Issue
Block a user