Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added autorelease pool to capture delegate. Thanks Josh Snyder

  • Loading branch information...
commit ca9a3286a09a5f14b56aa51e98b7a9af4fdd6ea8 1 parent 238ba47
Erica Sadun authored
Showing with 8 additions and 1 deletion.
  1. +3 −0  CameraImageHelper.m
  2. +4 −0 Makefile
  3. +1 −1  main.m
View
3  CameraImageHelper.m
@@ -14,8 +14,10 @@ @implementation CameraImageHelper
@synthesize session, image;
static CameraImageHelper *sharedInstance = nil;
+// Autorelease pool added thanks to suggestion by Josh Snyder
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer,0);
uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer);
@@ -33,6 +35,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
CGImageRelease(newImage);
+ [pool drain];
}
- (void) initialize
View
4 Makefile
@@ -6,3 +6,7 @@ git:
clean:
rm -rf */*/build
+
+sync:
+ cp *.[hm] ~/Desktop/11-New\ Edition\ Sample\ Code/01-Essential\ Recipes/C07-Images/99-Live\ Input\ Buffer
+
View
2  main.m
@@ -42,7 +42,7 @@ - (void) snap
imageView.image = [CameraImageHelper image];
}
-- (void)viewDidLoad
+- (void) viewDidLoad
{
self.navigationController.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR;
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
Please sign in to comment.
Something went wrong with that request. Please try again.