Skip to content

Commit

Permalink
Merge pull request BradLarson#1103 from karlvr/front-camera-ios5-bug
Browse files Browse the repository at this point in the history
Turn off front-camera workaround on iOS 6 or later
  • Loading branch information
BradLarson committed Aug 19, 2013
2 parents 3efbda7 + 36d4d83 commit 96d01cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions framework/Source/GPUImageStillCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ - (void)capturePhotoProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFi

@end

@implementation GPUImageStillCamera
@implementation GPUImageStillCamera {
BOOL requiresFrontCameraTextureCacheCorruptionWorkaround;
}

@synthesize currentCaptureMetadata = _currentCaptureMetadata;
@synthesize jpegCompressionQuality = _jpegCompressionQuality;
Expand All @@ -66,6 +68,9 @@ - (id)initWithSessionPreset:(NSString *)sessionPreset cameraPosition:(AVCaptureD
return nil;
}

/* Detect iOS version < 6 which require a texture cache corruption workaround */
requiresFrontCameraTextureCacheCorruptionWorkaround = [[[UIDevice currentDevice] systemVersion] compare:@"6.0" options:NSNumericSearch] == NSOrderedAscending;

[self.captureSession beginConfiguration];

photoOutput = [[AVCaptureStillImageOutput alloc] init];
Expand Down Expand Up @@ -263,7 +268,7 @@ - (void)capturePhotoProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFi
{
// This is a workaround for the corrupt images that are sometimes returned when taking a photo with the front camera and using the iOS 5.0 texture caches
AVCaptureDevicePosition currentCameraPosition = [[videoInput device] position];
if ( (currentCameraPosition != AVCaptureDevicePositionFront) || (![GPUImageContext supportsFastTextureUpload]))
if ( (currentCameraPosition != AVCaptureDevicePositionFront) || (![GPUImageContext supportsFastTextureUpload]) || !requiresFrontCameraTextureCacheCorruptionWorkaround)
{
dispatch_semaphore_signal(frameRenderingSemaphore);
[self captureOutput:photoOutput didOutputSampleBuffer:imageSampleBuffer fromConnection:[[photoOutput connections] objectAtIndex:0]];
Expand Down

0 comments on commit 96d01cd

Please sign in to comment.