Introduced fifo reference into isoburn object

This commit is contained in:
Thomas Schmitt 2007-10-08 20:40:52 +00:00
parent 3ea67e86a4
commit a903d19024
4 changed files with 105 additions and 23 deletions

View File

@ -9,7 +9,7 @@
Copyright 2007 Thomas Schmitt, <scdbackup@gmx.net> Copyright 2007 Thomas Schmitt, <scdbackup@gmx.net>
*/ */
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo = 0,1600 /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo
#define Hardcoded_cd_rW 1 #define Hardcoded_cd_rW 1
#define Hardcoded_cd_rw_c1 12999 #define Hardcoded_cd_rw_c1 12999
#define Hardcoded_cd_rw_nwA 152660 #define Hardcoded_cd_rw_nwA 152660
@ -289,20 +289,41 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
int ret, multi= 1; int ret, multi= 1;
struct isoburn *o; struct isoburn *o;
struct burn_drive *drive; struct burn_drive *drive;
char reasons[BURN_REASONS_LEN];
enum burn_write_types write_type;
drive= burn_write_opts_get_drive(opts); drive= burn_write_opts_get_drive(opts);
ret= isoburn_find_emulator(&o, drive, 0); ret= isoburn_find_emulator(&o, drive, 0);
if(ret<0) if(ret<0)
return; return;
if(o!=NULL) { if(o!=NULL) {
o->wrote_well= -1;
if(o->emulation_mode!=0) { if(o->emulation_mode!=0) {
multi= 0; multi= 0;
if(o->emulation_mode>0 && o->nwa >= 0) if(o->emulation_mode>0 && o->nwa >= 0)
burn_write_opts_set_start_byte(opts, ((off_t) o->nwa) * (off_t) 2048); burn_write_opts_set_start_byte(opts, ((off_t) o->nwa) * (off_t) 2048);
} }
} }
/* fprintf(stderr, "isoburn_EXPERIMENTAL: multi = %d\n", multi); */
/* burn_write_opts_set_simulate(opts, 1); */
burn_write_opts_set_multi(opts, multi); burn_write_opts_set_multi(opts, multi);
write_type= burn_write_opts_auto_write_type(opts, disc, reasons, 0);
if (write_type == BURN_WRITE_NONE) {
fprintf(stderr, "Failed to find a suitable write mode:\n%s\n", reasons);
o->wrote_well= 0;
return;
}
/*
sprintf(reasons, "%d", (int) write_type);
fprintf(stderr, "isoburn_EXPERIMENTAL: write_type = %s\n",
(write_type == BURN_WRITE_SAO ? "SAO" :
(write_type == BURN_WRITE_TAO ? "TAO" : reasons)));
*/
#ifdef Hardcoded_cd_rW #ifdef Hardcoded_cd_rW
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
fprintf(stderr, "Setting write address to LBA %d\n", Hardcoded_cd_rw_nwA); fprintf(stderr, "Setting write address to LBA %d\n", Hardcoded_cd_rw_nwA);
@ -380,24 +401,37 @@ ex:
} }
#ifdef Libburn_obsoleted_on_its_way_ouT int isoburn_drive_wrote_well(struct burn_drive *d)
void isoburn_write_opts_set_start_byte(struct burn_write_opts *opts,
off_t value)
{ {
int ret; int ret;
struct isoburn *o; struct isoburn *o;
struct burn_drive *drive;
drive= burn_write_opts_get_drive(opts); ret= isoburn_find_emulator(&o, d, 0);
ret= isoburn_find_emulator(&o, drive, 0); if(ret<0)
if(ret<=0) /* no emulation, no burn_write_opts_set_start_byte() */ return(-1);
return; if(ret>0)
ret = isoburn_set_start_byte(o, value, 0); if(o->wrote_well>=0)
if(ret<=0) return(o->wrote_well);
return; ret= burn_drive_wrote_well(d);
burn_write_opts_set_start_byte(opts, ((off_t) o->nwa) * (off_t) 2048); return ret;
}
int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes,
char **status_text)
{
int ret;
struct isoburn *o;
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0)
return(-1);
if(o==NULL)
return(0);
if(o->fifo==NULL)
return(0);
ret= burn_fifo_inquire_status(o->fifo, size, free_bytes, status_text);
return(ret);
} }
#endif /* Libburn_obsoleted_on_its_way_ouT */

View File

@ -49,6 +49,8 @@ int isoburn_new(struct isoburn **objpt, int flag)
o->emulation_mode= 0; o->emulation_mode= 0;
o->min_start_byte= 0; o->min_start_byte= 0;
o->nwa= 0; o->nwa= 0;
o->fifo= NULL;
o->wrote_well= -1;
o->src= NULL; o->src= NULL;
o->fabricated_disc_status= BURN_DISC_UNREADY; o->fabricated_disc_status= BURN_DISC_UNREADY;
for(i=0;i<65536;i++) for(i=0;i<65536;i++)
@ -83,6 +85,8 @@ int isoburn_destroy(struct isoburn **objpt, int flag)
if(o->target_volset!=NULL) if(o->target_volset!=NULL)
iso_volset_free(o->target_volset); iso_volset_free(o->target_volset);
if(o->fifo!=NULL)
burn_source_free(o->fifo);
free((char *) o); free((char *) o);
*objpt= NULL; *objpt= NULL;
@ -228,7 +232,7 @@ static
int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc, int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts, int new_img) struct isoburn_source_opts *opts, int new_img)
{ {
struct burn_source *wsrc, *fifo_src; struct burn_source *wsrc;
struct burn_session *session; struct burn_session *session;
struct burn_track *track; struct burn_track *track;
struct isoburn *o; struct isoburn *o;
@ -237,8 +241,10 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
int ret; int ret;
ret= isoburn_find_emulator(&o, d, 0); ret= isoburn_find_emulator(&o, d, 0);
if(ret<0) if(ret<0 || o==NULL)
return -1; return -1;
o->wrote_well= 0; /* early end will be registered as failure */
state = isoburn_disc_get_status(d); state = isoburn_disc_get_status(d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE
@ -287,10 +293,11 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
if (wsrc == NULL) if (wsrc == NULL)
return -1; return -1;
// TODO check return values for failure. propertly clean-up on error /* TODO check return values for failure. propertly clean-up on error */
fifo_src = burn_fifo_source_new(wsrc, 2048, 2000, 0); o->fifo = burn_fifo_source_new(wsrc, 2048, 2000, 0);
if (fifo_src == NULL) { burn_source_free(wsrc);
if (o->fifo == NULL) {
fprintf(stderr, "Cannot attach fifo\n"); fprintf(stderr, "Cannot attach fifo\n");
return -1; return -1;
} }
@ -298,9 +305,10 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
session = burn_session_create(); session = burn_session_create();
burn_disc_add_session(*disc, session, BURN_POS_END); burn_disc_add_session(*disc, session, BURN_POS_END);
track = burn_track_create(); track = burn_track_create();
burn_track_set_source(track, fifo_src); burn_track_set_source(track, o->fifo);
burn_session_add_track(session, track, BURN_POS_END); burn_session_add_track(session, track, BURN_POS_END);
o->wrote_well= -1; /* neutral */
return 1; return 1;
} }

View File

@ -46,6 +46,17 @@ struct isoburn {
*/ */
enum burn_disc_status fabricated_disc_status; enum burn_disc_status fabricated_disc_status;
/* The fifo which is installed between track and libisofs burn_source
*/
struct burn_source *fifo;
/* Indicator wether the most recent burn run worked :
-1 = undetermined, ask libburn , 0 = failure , 1 = success
To be inquired by isoburn_drive_wrote_well()
*/
int wrote_well;
/* --- Vreixo's part --- */ /* --- Vreixo's part --- */
/* The data source for reading the old image */ /* The data source for reading the old image */

View File

@ -233,6 +233,35 @@ int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
void isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc); void isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc);
/** Inquire state and fill parameters of the fifo which is attached to
the emerging track. This should be done in the pacifier loop while
isoburn_disc_write() or burn_disc_write() are active.
Hint: If only burn_write_opts and not burn_drive is known, then the drive
can be obtained by burn_write_opts_get_drive().
@parm d The drive to which the track with the fifo gets burned.
@param size The total size of the fifo
@param free_bytes The current free capacity of the fifo
@param status_text Returns a pointer to a constant text, see below
@return <0 reply invalid, >=0 fifo status code:
bit0+1=input status, bit2=consumption status, i.e:
0="standby" : data processing not started yet
1="active" : input and consumption are active
2="ending" : input has ended without error
3="failing" : input had error and ended,
4="unused" : ( consumption has ended before processing start )
5="abandoned" : consumption has ended prematurely
6="ended" : consumption has ended without input error
7="aborted" : consumption has ended after input error
*/
int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes,
char **status_text);
/** Inquire whether the most recent write run was successful.
Wrapper for: burn_drive_wrote_well()
*/
int isoburn_drive_wrote_well(struct burn_drive *d);
/** Call this after isoburn_disc_write has finished and burn_drive_wrote_well() /** Call this after isoburn_disc_write has finished and burn_drive_wrote_well()
indicates success. It will eventually complete the emulation of indicates success. It will eventually complete the emulation of
multi-session functionality, if needed at all. Let libisoburn decide. multi-session functionality, if needed at all. Let libisoburn decide.
@ -246,7 +275,7 @@ int isoburn_activate_session(struct burn_drive *drive);
@param pacifier_func If not NULL: a function to produce appeasing messages. @param pacifier_func If not NULL: a function to produce appeasing messages.
See burn_abort_pacifier() in libburn.h for an example. See burn_abort_pacifier() in libburn.h for an example.
*/ */
// TODO implement this /* TODO implement this */
int isoburn_perform_write(struct burn_write_opts *o, int isoburn_perform_write(struct burn_write_opts *o,
int (*pacifier_func)(void *handle, int patience, int (*pacifier_func)(void *handle, int patience,
int elapsed)); int elapsed));