diff --git a/libburn/trunk/doc/comments b/libburn/trunk/doc/comments index af0c9823..c40ac902 100644 --- a/libburn/trunk/doc/comments +++ b/libburn/trunk/doc/comments @@ -7,7 +7,7 @@ Libburnia is an open-source project for reading, mastering and writing optical discs. For now this means only CD-R and CD-RW. -Support for DVD+RW is emerging. +Support for DVD+RW and DVD-RW is emerging. The project comprises of several more or less interdependent parts which @@ -84,7 +84,7 @@ libburner is a minimal demo application for the library libburn (see: libburn/libburn.h) as provided on http://libburn.pykix.org . It can list the available devices, can blank a CD-RW and can burn to CD-R or CD-RW. -New: burning to DVD+RW (single data track, single session only). +New: burning to DVD+/-RW (single data track, single session only). It's main purpose, nevertheless, is to show you how to use libburn and also to serve the libburnia team as reference application. libburner does indeed diff --git a/libburn/trunk/test/libburner.c b/libburn/trunk/test/libburner.c index 2fd7904d..00bf4465 100644 --- a/libburn/trunk/test/libburner.c +++ b/libburn/trunk/test/libburner.c @@ -8,7 +8,8 @@ libburner is a minimal demo application for the library libburn as provided on http://libburnia.pykix.org . It can list the available devices, can - blank a CD-RW and can burn to CD-R, CD-RW or DVD+RW. + blank a CD-RW, can format a DVD-RW, and can burn to CD-R, CD-RW, DVD+RW + or DVD-RW. It's main purpose, nevertheless, is to show you how to use libburn and also to serve the libburnia team as reference application. libburner.c does indeed define the standard way how above three gestures can be implemented and @@ -25,7 +26,9 @@ libburner_aquire_by_driveno() demonstrates a scan-and-choose approach With that aquired drive you can blank a CD-RW libburner_blank_disc() - With the aquired drive you can burn to CD-R, blank CD-RW or DVD+RW + or you can format a DVD-RW to profile "Restricted Overwrite" (needed once) + libburner_format_row() + With the aquired drive you can burn to CD-R, CD-RW, DVD+RW, DVD-RW libburner_payload() When everything is done, main() releases the drive and shuts down libburn: burn_drive_release(); @@ -68,7 +71,8 @@ static unsigned int drive_count; finally released */ static int drive_is_grabbed = 0; -/** A text describing the type of media in aquired drive */ +/** A number and a text describing the type of media in aquired drive */ +static int current_profile= -1; static char current_profile_name[80]= {""}; @@ -93,7 +97,7 @@ int libburner_aquire_by_driveno(int *drive_no); */ int libburner_aquire_drive(char *drive_adr, int *driveno) { - int ret, x; + int ret; if(drive_adr != NULL && drive_adr[0] != 0) ret = libburner_aquire_by_adr(drive_adr); @@ -101,7 +105,8 @@ int libburner_aquire_drive(char *drive_adr, int *driveno) ret = libburner_aquire_by_driveno(driveno); if (ret <= 0) return ret; - burn_disc_get_profile(drive_list[0].drive, &x, current_profile_name); + burn_disc_get_profile(drive_list[0].drive, ¤t_profile, + current_profile_name); if (current_profile_name[0]) printf("Detected media type: %s\n", current_profile_name); return 1; @@ -274,7 +279,7 @@ int libburner_blank_disc(struct burn_drive *drive, int blank_fast) return 0; } else { fprintf(stderr, - "FATAL: Cannot recognize drive and media state\n"); + "FATAL: Unsuitable drive and media state\n"); return 0; } if(!burn_disc_erasable(drive)) { @@ -298,6 +303,46 @@ int libburner_blank_disc(struct burn_drive *drive, int blank_fast) } +/** Persistently changes DVD-RW profile 0014h "Sequential Recording" + to profile 0013h "Restricted Overwrite" which is usable with libburner. + + Expect a behavior similar to blanking with unusual noises from the drive. +*/ +int libburner_format_row(struct burn_drive *drive) +{ + struct burn_progress p; + int percent = 1; + + if (current_profile == 0x13) { + fprintf(stderr, "IDLE: DVD-RW media is already formatted\n"); + return 2; + } else if (current_profile != 0x14) { + fprintf(stderr, "FATAL: Can only format DVD-RW\n"); + return 0; + } + printf("Beginning to format media.\n"); + burn_disc_format(drive, 0); + sleep(1); + while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) { + if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */ + percent = 1.0 + ((double) p.sector+1.0) + / ((double) p.sectors) * 98.0; + printf("Formatting ( %d%% done )\n", percent); + sleep(1); + } + burn_disc_get_profile(drive_list[0].drive, ¤t_profile, + current_profile_name); + printf("Media type now: %4.4xh \"%s\"\n", + current_profile, current_profile_name); + if (current_profile != 0x13) { + fprintf(stderr, + "FATAL: Failed to change media profile to desired value\n"); + return 0; + } + return 1; +} + + /** Brings preformatted track images (ISO 9660, audio, ...) onto media. To make sure a data image is fully readable on any Linux machine, this function adds 300 kB of padding to the (usualy single) track. @@ -431,7 +476,8 @@ int libburner_payload(struct burn_drive *drive, burn_track_free(tracklist[trackno]); burn_session_free(session); burn_disc_free(target_disc); - if (multi && strcmp(current_profile_name, "DVD+RW") != 0) + if (multi && strcmp(current_profile_name, "DVD+RW") != 0 && + current_profile != 0x13) printf("NOTE: Media left appendable.\n"); if (simulate_burn) printf("\n*** Did TRY to SIMULATE burning ***\n\n"); @@ -490,6 +536,9 @@ int libburner_setup(int argc, char **argv) } strcpy(drive_adr, argv[i]); } + } else if (!strcmp(argv[i], "--format_overwrite")) { + do_blank = 101; + } else if (!strcmp(argv[i], "--multi")) { do_multi = 1; @@ -528,7 +577,8 @@ int libburner_setup(int argc, char **argv) if (print_help || insuffient_parameters ) { printf("Usage: %s\n", argv[0]); printf(" [--drive
|