Example #1
0
/* Begin burning the disc. */
int PortBurn_StartBurning(void *handle)
{
   PBHandle *h = (PBHandle *)handle;

   if (!h)
      return pbErrNoHandle;

   if (!h->device)
      return pbErrDeviceNotOpen;

   h->burn = DRBurnCreate(h->device);
   if (!h->burn)
      return pbErrCannotPrepareToBurn;

   h->err = DRBurnWriteLayout(h->burn, h->trackArray);
   if (h->err != noErr) {
      DRBurnAbort(h->burn);
      CFRelease(h->burn);
      h->burn = NULL;
      return pbErrCannotStartBurning;
   }

   h->frac = 0.0;

   return pbSuccess;
}
Example #2
0
/*
	druBurn
	
	Called to do a burn.  Burning is a long async process, so this function mostly
	handles providing appropriate progress and completion information to the user.
*/
int
druBurn(DRBurnRef burn, CFTypeRef layout)
{
	DRNotificationCenterRef		notificationCenter = NULL;
	CFRunLoopSourceRef			source = NULL;
	druBurnStatus				status = {0, NULL, NULL, NULL, {0}, 0};
	
	/* Create a progress bar. */
	status.progressBar = druProgressBarCreate();
	
	/* Sign up for notifications from the burn object. */
	notificationCenter = DRNotificationCenterCreate();
	source = DRNotificationCenterCreateRunLoopSource(notificationCenter);
	CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);
	DRNotificationCenterAddObserver(notificationCenter,&status,druProgressCallback, kDRBurnStatusChangedNotification, burn);
	
	/* Okay, kick off the burn. */
	DRBurnWriteLayout(burn, layout);
	
	/* Enter a runloop until the burn finishes. */
	CFRunLoopRun();
	
	/* Clean up memory and exit. */
	CFRunLoopSourceInvalidate(source);
	if (notificationCenter != NULL)	CFRelease(notificationCenter);
	if (source != NULL)				CFRelease(source);
	if (status.progressBar != NULL)	druProgressBarDispose(status.progressBar,status.success);
	if (status.success)
		printf("Burn completed.\n");
	else
		druPrintFailureMessage("Burn", status.completionStatus);
	if (status.completionStatus != NULL)	CFRelease(status.completionStatus);
	
	return status.success;
}
/* Begin burning the disc. */
int PortBurn_StartBurning(void *handle)
{
   CFMutableDictionaryRef props;

   PBHandle *h = (PBHandle *)handle;

   if (h == NULL) {
      return pbErrNoHandle;
   }

   if (h->device == NULL) {
      return pbErrDeviceNotOpen;
   }

   if (h->burn != NULL || h->erase != NULL) {
      return pbErrCannotStartBurning;
   }

   h->burn = DRBurnCreate(h->device);
   if (h->burn == NULL) {
      return pbErrCannotPrepareToBurn;
   }

   props = CFDictionaryCreateMutableCopy(NULL, 0, DRBurnGetProperties(h->burn));
   if (props == NULL) {
      DRBurnAbort(h->burn);
      CFRelease(h->burn);
      h->burn = NULL;
      return pbErrCannotPrepareToBurn;
   }

   CFDictionaryAddValue(props,
                        kDRBurnCompletionActionKey,
                        h->eject ? kDRBurnCompletionActionEject : kDRBurnCompletionActionMount);
   CFDictionaryAddValue(props,
                        kDRBurnVerifyDiscKey,
                        h->verify ? kCFBooleanTrue : kCFBooleanFalse);
   CFDictionaryAddValue(props,
                        kDRBurnUnderrunProtectionKey,
                        h->underrun ? kCFBooleanTrue : kCFBooleanFalse);
   CFDictionaryAddValue(props,
                        kDRBurnTestingKey,
                        h->test ? kCFBooleanTrue : kCFBooleanFalse);

   if (h->speed != pbSpeedDefault) {
      float speed;
      if (h->speed == pbSpeedMax) {
         speed = kDRDeviceBurnSpeedMax;
      }
      else {
         speed = h->speed * kDRDeviceBurnSpeedCD1x;
      }

      CFNumberRef num = CFNumberCreate(NULL, kCFNumberFloatType, &speed);
      if (num != NULL) {
         CFDictionaryAddValue(props,
                              kDRBurnRequestedSpeedKey,
                              num);
         CFRelease(num);
      }
   }

   DRBurnSetProperties(h->burn, props);

   CFRelease(props);

   h->frac = 0.0;

   h->err = DRBurnWriteLayout(h->burn, h->trackArray);
   if (h->err != noErr) {
      DRBurnAbort(h->burn);
      CFRelease(h->burn);
      h->burn = NULL;
      return pbErrCannotStartBurning;
   }

   return pbSuccess;
}