[Libburn] [Patch] burn_write_opts and mediacatalog

Chris Anderson chris@simoniac.com
Tue, 16 Dec 2003 02:23:45 -0500


--=-s6MMkYtDEzZgETXrBy/Q
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Changelog should explain pretty much everything.

Added:
-Added scsi_mode_data.underrun_proof
-Error checking added for the following functions:
	burn_write_opts_set_simulate()
	burn_write_opts_set_underrun_proof()
	burn_write_opts_set_write_type()
	
Removed:
-burn_write_opts.has_mediacatalog
-burn_write_opts.mediacatalog
-sector.c references to mediacatalog are now commented out
-Various other removals of references to mediacatalog
	
Changed:
-burn_write_opts_set_block type has been merged with
burn_write_opts_set_write_type
-burn_write_opts_set_simulate now returns an int
-burn_write_opts_set_underrun_proof now returns an int
-burn_write_opts_set_write_type now returns an int
-burniso and master updated to work with the write_type and block_type
changes

-Chris

--=-s6MMkYtDEzZgETXrBy/Q
Content-Disposition: attachment; filename=patch_write_opts_and_mediacatalog.diff
Content-Type: text/x-patch; name=patch_write_opts_and_mediacatalog.diff; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

? patch_burn_read_opts.diff
? patch_write_opts_and_mediacatalog.diff
? temp.diff
? libburn/.libburn.h.~1.179.~.swp
Index: libburn/drive.c
===================================================================
RCS file: /cvs/burn/burn/libburn/drive.c,v
retrieving revision 1.246
diff -p -u -r1.246 drive.c
--- libburn/drive.c	15 Dec 2003 04:52:51 -0000	1.246
+++ libburn/drive.c	16 Dec 2003 07:22:47 -0000
@@ -94,8 +94,6 @@ struct burn_drive *burn_drive_register(s
 	d->busy = BURN_DRIVE_IDLE;
 	d->toc_entries = 0;
 	d->toc_entry = NULL;
-/* remove mediacatalog from drive plz */
-	d->has_mediacatalog = 0;
 	d->disc = NULL;
 	d->erasable = 0;
 	memcpy(&drive_array[drivetop + 1], d, sizeof(struct burn_drive));
@@ -123,8 +121,6 @@ void burn_drive_release(struct burn_driv
 		burn_disc_free(d->disc);
 		d->disc = NULL;
 	}
-/* XXX remove mediacatalog from drive*/
-	d->has_mediacatalog = 0;
 }
 
 void burn_wait_all()
Index: libburn/libburn.h
===================================================================
RCS file: /cvs/burn/burn/libburn/libburn.h,v
retrieving revision 1.179
diff -p -u -r1.179 libburn.h
--- libburn/libburn.h	16 Dec 2003 03:29:28 -0000	1.179
+++ libburn/libburn.h	16 Dec 2003 07:22:48 -0000
@@ -690,14 +690,10 @@ void burn_structure_print_track(struct b
 /** Sets the write type for the write_opts struct
     @param opts The write opts to change
     @param write_type The write type to use
-*/
-void burn_write_opts_set_write_type(struct burn_write_opts *opts, enum burn_write_types write_type);
-
-/** Sets the block type for the write_opts struct
-    @param opts The write opts to change
     @param block_type The block type to use
+    @return Returns 1 on success and 0 on failure.
 */
-void burn_write_opts_set_block_type(struct burn_write_opts *opts, enum burn_block_types block_types);
+int burn_write_opts_set_write_type(struct burn_write_opts *opts, enum burn_write_types write_type, int block_type);
 
 /** Supplies toc entries for writing - not normally required for cd mastering
     @param opts The write opts to change
@@ -709,32 +705,29 @@ void burn_write_opts_set_toc_entries(str
 /** Sets the simulate value for the write_opts struct
     @param opts The write opts to change
     @param sim If non-zero, the drive will perform a simulation instead of a burn
+    @return Returns 1 on success and 0 on failure.
 */
-void burn_write_opts_set_simulate(struct burn_write_opts *opts, int simulate);
+int  burn_write_opts_set_simulate(struct burn_write_opts *opts, int simulate);
 
 /** Controls buffer underrun prevention
     @param opts The write opts to change
     @param underrun_proof if non-zero, buffer underrun protection is enabled
+    @return Returns 1 on success and 0 on failure.
 */
-void burn_write_opts_set_underrun_proof(struct burn_write_opts *opts, int underrun_proof);
+int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts, int underrun_proof);
 
 /** Sets whether to use opc or not with the write_opts struct
     @param opts The write opts to change
     @param opc If non-zero, optical power calibration will be performed at
                start of burn
+	 
 */
 void burn_write_opts_set_perform_opc(struct burn_write_opts *opts, int opc);
 
-/** Sets whether the write_opts have a media catalog */
-void burn_write_opts_has_mediacatalog(struct burn_write_opts *opts, int has_mediacatalog);
-
-/** Sets the media catalog for the write_ops struct */
-void burn_write_opts_set_mediacatalog(struct burn_write_opts *opts, unsigned char mediacatalog[13]);
-
-/** Sets whether to read in raw mode or not 
+/** Sets whether to read in raw mode or not
     @param opts The read opts to change
     @param raw_mode If non-zero, reading will be done in raw mode, so that everything in the data tracks on the
-	    disc is read, including headers.
+            disc is read, including headers.
 */
 void burn_read_opts_set_raw(struct burn_read_opts *opts, int raw);
 
Index: libburn/options.c
===================================================================
RCS file: /cvs/burn/burn/libburn/options.c,v
retrieving revision 1.9
diff -p -u -r1.9 options.c
--- libburn/options.c	16 Dec 2003 03:29:28 -0000	1.9
+++ libburn/options.c	16 Dec 2003 07:22:48 -0000
@@ -1,5 +1,6 @@
 #include "libburn.h"
 #include "options.h"
+#include "transport.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -52,14 +53,15 @@ void burn_read_opts_free(struct burn_rea
 		free(opts);
 }
 
-void burn_write_opts_set_write_type(struct burn_write_opts *opts, enum burn_write_types write_type)
+int burn_write_opts_set_write_type(struct burn_write_opts *opts, enum burn_write_types write_type, int block_type)
 {
-	opts->write_type = write_type;
-}
-
-void burn_write_opts_set_block_type(struct burn_write_opts *opts, enum burn_block_types block_type)
-{
-	opts->block_type = block_type;
+	if(opts->drive->block_types[write_type] & block_type)
+		{
+			opts->write_type = write_type;
+			opts->block_type = block_type;
+			return 1;
+		}
+	return 0;
 }
 
 void burn_write_opts_set_toc_entries(struct burn_write_opts *opts, int count, struct burn_toc_entry *toc_entries)
@@ -69,14 +71,24 @@ void burn_write_opts_set_toc_entries(str
 	memcpy(opts->toc_entry, &toc_entries, sizeof(struct burn_toc_entry) * count);
 }
 
-void burn_write_opts_set_simulate(struct burn_write_opts *opts, int sim)
-{
-	opts->simulate = sim;
-}
-
-void burn_write_opts_set_underrun_proof(struct burn_write_opts *opts, int underrun_proof)
+int burn_write_opts_set_simulate(struct burn_write_opts *opts, int sim)
 {
-	opts->underrun_proof = underrun_proof;
+	if(opts->drive->mdata->simulate)
+		{
+			opts->simulate = sim;
+			return 1;
+		}
+	return 0;
+}
+
+int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts, int underrun_proof)
+{
+	if(opts->drive->mdata->underrun_proof)
+		{
+			opts->underrun_proof = underrun_proof;
+			return 1;
+		}
+	return 0;
 }
 
 void burn_write_opts_set_perform_opc(struct burn_write_opts *opts, int opc)
@@ -84,16 +96,6 @@ void burn_write_opts_set_perform_opc(str
 	opts->perform_opc = opc;
 }
 
-void burn_write_opts_has_mediacatalog(struct burn_write_opts *opts, int has_mediacatalog)
-{
-	opts->has_mediacatalog = has_mediacatalog;
-}
-
-void burn_write_opts_set_mediacatalog(struct burn_write_opts *opts, unsigned char mediacatalog[13])
-{
-	memcpy(opts->mediacatalog, &mediacatalog, 13);
-}
-
 void burn_read_opts_set_raw_mode(struct burn_read_opts *opts, int raw)
 {
 	opts->raw = raw;
Index: libburn/options.h
===================================================================
RCS file: /cvs/burn/burn/libburn/options.h,v
retrieving revision 1.5
diff -p -u -r1.5 options.h
--- libburn/options.h	16 Dec 2003 03:29:28 -0000	1.5
+++ libburn/options.h	16 Dec 2003 07:22:48 -0000
@@ -8,7 +8,7 @@
 struct burn_write_opts
 {
 	/** Drive the write opts are good for */
-	struct drive *drive;
+	struct burn_drive *drive;
 
 	/** For internal use. */
 	int refcount;
@@ -33,8 +33,6 @@ struct burn_write_opts
 	    write. */
 	int perform_opc:1;
 	/** A disc can have a media catalog number */
-	int has_mediacatalog;
-	unsigned char mediacatalog[13];
 };
 
 /** Options for disc reading operations. This should be created with
@@ -42,7 +40,7 @@ struct burn_write_opts
 struct burn_read_opts
 {
 	/** Drive the read opts are good for */
-	struct drive *drive;
+	struct burn_drive *drive;
 
 	/** For internal use. */
 	int refcount;
Index: libburn/sector.c
===================================================================
RCS file: /cvs/burn/burn/libburn/sector.c,v
retrieving revision 1.73
diff -p -u -r1.73 sector.c
--- libburn/sector.c	15 Dec 2003 04:52:51 -0000	1.73
+++ libburn/sector.c	16 Dec 2003 07:22:48 -0000
@@ -233,8 +233,8 @@ void sector_subcodes(struct burn_drive *
 	if (d->rlba % 10 == 0) {
 		/* each of these can occur 1 in 100 */
 		if ((d->rlba / 10) % 10 == 0) {
-			if (d->has_mediacatalog)
-				qmode = 2;
+			/*	if (d->has_mediacatalog)
+			  qmode = 2;*/
 		} else if ((d->rlba / 10) % 10 == 1) {
 			if (t->has_isrc)
 				qmode = 3;
@@ -260,7 +260,7 @@ void sector_subcodes(struct burn_drive *
 		qdata[8] = dec_to_bcd(f);	/* abs frame */
 		break;
 	case 2:
-		/* media catalog number */
+		/* media catalog number 
 		qdata[0] =
 			(d->mediacatalog[0] << 4) +
 			d->mediacatalog[1];
@@ -281,9 +281,9 @@ void sector_subcodes(struct burn_drive *
 			d->mediacatalog[11];
 		qdata[6] = d->mediacatalog[12] << 4;
 
-		qdata[7] = 0;	/* zero */
+		qdata[7] = 0;  
 		burn_lba_to_msf(d->alba, &m, &s, &f);
-		qdata[8] = dec_to_bcd(f);	/* abs frame */
+		qdata[8] = dec_to_bcd(f);	 abs frame */
 		break;
 	case 3:
 		c = char_to_isrc(t->country[0]);
Index: libburn/spc.c
===================================================================
RCS file: /cvs/burn/burn/libburn/spc.c,v
retrieving revision 1.79
diff -p -u -r1.79 spc.c
--- libburn/spc.c	15 Dec 2003 21:17:17 -0000	1.79
+++ libburn/spc.c	16 Dec 2003 07:22:49 -0000
@@ -135,6 +135,7 @@ void spc_sense_caps(struct burn_drive *d
 	m->cur_write_speed = page[20] * 256 + page[21];
 	m->c2_pointers = page[5] & 16;
 	m->valid = 1;
+	m->underrun_proof = page[4] & 128;
 }
 
 void spc_sense_error_params(struct burn_drive *d)
Index: libburn/transport.h
===================================================================
RCS file: /cvs/burn/burn/libburn/transport.h,v
retrieving revision 1.98
diff -p -u -r1.98 transport.h
--- libburn/transport.h	16 Dec 2003 02:44:03 -0000	1.98
+++ libburn/transport.h	16 Dec 2003 07:22:49 -0000
@@ -76,14 +76,11 @@ struct scsi_mode_data
 	int write_page_valid;
 	int c2_pointers;
 	int valid;
+	int underrun_proof;
 };
 
 struct burn_drive
 {
-/* remove mediacatalog from drive plz*/
-int has_mediacatalog;
-unsigned char mediacatalog[13];
-
 	int host;
 	int id;
 	int channel;
Index: libburn/write.c
===================================================================
RCS file: /cvs/burn/burn/libburn/write.c,v
retrieving revision 1.36
diff -p -u -r1.36 write.c
--- libburn/write.c	16 Dec 2003 02:44:03 -0000	1.36
+++ libburn/write.c	16 Dec 2003 07:22:49 -0000
@@ -112,7 +112,6 @@ void burn_create_toc_entries(struct burn
 
 	printf("toc for %d tracks:\n", ntr);
 	d->toc_entries = ntr + 3;
-	d->has_mediacatalog = 0;
 	assert(d->toc_entry == NULL);
 	d->toc_entry = malloc(d->toc_entries * sizeof(struct burn_toc_entry));
 	e = d->toc_entry;
Index: test/burniso.c
===================================================================
RCS file: /cvs/burn/burn/test/burniso.c,v
retrieving revision 1.48
diff -p -u -r1.48 burniso.c
--- test/burniso.c	16 Dec 2003 03:29:28 -0000	1.48
+++ test/burniso.c	16 Dec 2003 07:22:49 -0000
@@ -56,8 +56,7 @@ void burn_iso(struct burn_drive *drive, 
 	}
 	o = burn_write_opts_new(drive);
 	burn_write_opts_set_perform_opc(o, 1);
-	burn_write_opts_set_write_type(o, BURN_WRITE_RAW);
-	burn_write_opts_set_block_type(o, BURN_BLOCK_RAW16);
+	burn_write_opts_set_write_type(o, BURN_WRITE_RAW, BURN_BLOCK_RAW16);
 	burn_write_opts_set_simulate(o, 1);
 	burn_write_opts_set_underrun_proof(o, 0);
 
Index: test/master.c
===================================================================
RCS file: /cvs/burn/burn/test/master.c,v
retrieving revision 1.21
diff -p -u -r1.21 master.c
--- test/master.c	16 Dec 2003 03:29:28 -0000	1.21
+++ test/master.c	16 Dec 2003 07:22:49 -0000
@@ -35,8 +35,7 @@ void burn_files(struct burn_drive *drive
 	}
 	o = burn_write_opts_new(drive);
 	burn_write_opts_set_perform_opc(o, 1);
-	burn_write_opts_set_write_type(o, BURN_WRITE_RAW);
-	burn_write_opts_set_block_type(o, BURN_BLOCK_RAW16);
+	burn_write_opts_set_write_type(o, BURN_WRITE_RAW, BURN_BLOCK_RAW16);
 	burn_write_opts_set_simulate(o, 1);
 	burn_write_opts_set_underrun_proof(o, 0);
 	burn_structure_print_disc(disc);

--=-s6MMkYtDEzZgETXrBy/Q--