title: AVFoundation screenRecording issue
body: <p>Hello I'm trying to use AVFoundation framework to make a screen recored.
  And I'v got 2 problems:
  1) the recording is starting with a delay after the button is pressed.
  2) If I insert breakpoint to throw all the exceptions it get stuck at :</p>
  
  <pre><code>[session startRunning];
  </code></pre>
  
  <p>The code is:</p>
  
  <pre><code>-(void)initAVRecord{
      session = [[AVCaptureSession alloc]init];
      if ([session canSetSessionPreset:AVCaptureSessionPresetHigh]){
          session.sessionPreset = AVCaptureSessionPresetHigh;
      }
      display = CGMainDisplayID();
      captureScreenInput = [[AVCaptureScreenInput alloc]initWithDisplayID:display];
      if ([session canAddInput:captureScreenInput]){
          [session addInput:captureScreenInput];
          NSLog(@"screen device added to session ");
      }else{
          NSLog(@"no screen device added to session");
      }
  
      audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
      NSError *error;
      captureAudioInput = [[AVCaptureDeviceInput alloc]initWithDevice:audioDevice error:&amp;error];
      if ([session canAddInput:captureAudioInput]){
          [session addInput:captureAudioInput];
          NSLog(@"audio device added to session ");
      }else{
          NSLog(@" no audio device added");
      }
  
      movieOutput = [[AVCaptureMovieFileOutput alloc]init];
      [movieOutput setDelegate:self];
      if ([session canAddOutput:movieOutput]){
          [session addOutput:movieOutput];
      }
      [session startRunning];
  }
  
  
  - (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error
  {
      [[NSWorkspace sharedWorkspace] openURL:outputFileURL];
  }
  
  -(BOOL)captureOutputShouldProvideSampleAccurateRecordingStart:(AVCaptureOutput *)captureOutput{
      return NO;
  }
  
  
  
  - (IBAction)recordButton:(id)sender {
      if ([[recordButton title] isEqualToString:@"Record"]){
          [recordButton setTitle:@"Stop"];
          NSLog(@"Minimum Frame Duration: %f, Crop Rect: %@, Scale Factor: %f, Capture Mouse Clicks: %@, Capture Mouse Cursor: %@, Remove Duplicate Frames: %@",
                CMTimeGetSeconds([self.captureScreenInput minFrameDuration]),
                NSStringFromRect(NSRectFromCGRect([self.captureScreenInput cropRect])),
                [self.captureScreenInput scaleFactor],
                [self.captureScreenInput capturesMouseClicks] ? @"Yes" : @"No",
                [self.captureScreenInput capturesCursor] ? @"Yes" : @"No",
                [self.captureScreenInput removesDuplicateFrames] ? @"Yes" : @"No");
          char *tempNameBytes = tempnam([[@"~/Desktop/" stringByStandardizingPath]fileSystemRepresentation],"screenRec1_");
          NSString *tempName = [[NSString alloc]initWithBytesNoCopy:tempNameBytes length:strlen(tempNameBytes) encoding:NSUTF8StringEncoding freeWhenDone:YES];
          [movieOutput startRecordingToOutputFileURL:[NSURL fileURLWithPath:[tempName stringByAppendingPathExtension:@"mov"]] recordingDelegate:self];
  
      }else if ([[recordButton title] isEqualToString:@"Stop"]){
          [recordButton setTitle:@"Record"];
          [movieOutput stopRecording];
      }
  
  }
  </code></pre>
  
  <p>Can someone tells me what I'm doing wrong ?</p>