Skip to content

Commit

Permalink
Merge pull request BradLarson#492 from brettg/capture-crash
Browse files Browse the repository at this point in the history
prevent crash when captureStillImageAsynchronouslyFromConnection yields an error
  • Loading branch information
BradLarson committed Sep 30, 2012
2 parents b1a4d35 + 0d6138d commit f51b807
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion framework/Source/GPUImageStillCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ - (void)capturePhotoAsImageProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)

[photoOutput captureStillImageAsynchronouslyFromConnection:[[photoOutput connections] objectAtIndex:0] completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {

if(imageSampleBuffer == NULL){
dispatch_semaphore_signal(frameRenderingSemaphore);
block(nil, error);
return;
}

// For now, resize photos to fix within the max texture size of the GPU
CVImageBufferRef cameraFrame = CMSampleBufferGetImageBuffer(imageSampleBuffer);

Expand Down Expand Up @@ -151,6 +157,12 @@ - (void)capturePhotoAsJPEGProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)f
[photoOutput captureStillImageAsynchronouslyFromConnection:[[photoOutput connections] objectAtIndex:0] completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
// reportAvailableMemoryForGPUImage(@"Before filter processing");

if(imageSampleBuffer == NULL){
dispatch_semaphore_signal(frameRenderingSemaphore);
block(nil, error);
return;
}

// For now, resize photos to fix within the max texture size of the GPU
CVImageBufferRef cameraFrame = CMSampleBufferGetImageBuffer(imageSampleBuffer);

Expand Down Expand Up @@ -205,7 +217,13 @@ - (void)capturePhotoAsPNGProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)fi
dispatch_semaphore_wait(frameRenderingSemaphore, DISPATCH_TIME_FOREVER);

[photoOutput captureStillImageAsynchronouslyFromConnection:[[photoOutput connections] objectAtIndex:0] completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {


if(imageSampleBuffer == NULL){
dispatch_semaphore_signal(frameRenderingSemaphore);
block(nil, error);
return;
}

// For now, resize photos to fix within the max texture size of the GPU
CVImageBufferRef cameraFrame = CMSampleBufferGetImageBuffer(imageSampleBuffer);

Expand Down

0 comments on commit f51b807

Please sign in to comment.