(meancoot/iOS) Add workaround for flickering with camera - still

some problems when Cocoa interface is brought up during camera
core and then we go back to the camera core
This commit is contained in:
twinaphex 2013-12-05 13:04:17 +01:00
parent 61d66b7f19
commit 4ab33d5b3b

View File

@ -219,12 +219,13 @@ static bool g_is_syncing = true;
[self viewWillLayoutSubviews]; [self viewWillLayoutSubviews];
} }
-(void)processFrame:(CMSampleBufferRef)sampleBuffer void event_process_camera_frame(void* pixelBufferPtr)
{ {
CVPixelBufferRef pixelBuffer = (CVPixelBufferRef)pixelBufferPtr;
int width, height; int width, height;
CVReturn ret; CVReturn ret;
CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
width = CVPixelBufferGetWidth(pixelBuffer); width = CVPixelBufferGetWidth(pixelBuffer);
height = CVPixelBufferGetHeight(pixelBuffer); height = CVPixelBufferGetHeight(pixelBuffer);
@ -258,14 +259,18 @@ static bool g_is_syncing = true;
CVOpenGLESTextureCacheFlush(textureCache, 0); CVOpenGLESTextureCacheFlush(textureCache, 0);
CFRelease(renderTexture); CFRelease(renderTexture);
CFRelease(pixelBuffer);
pixelBuffer = 0;
} }
- (void)captureOutput:(AVCaptureOutput *)captureOutput - (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection fromConnection:(AVCaptureConnection *)connection
{ {
[self processFrame:sampleBuffer]; // TODO: Don't post if event queue is full
} CVPixelBufferRef pixelBuffer = CVPixelBufferRetain(CMSampleBufferGetImageBuffer(sampleBuffer));
apple_frontend_post_event(event_process_camera_frame, pixelBuffer);}
- (void) onCameraInit - (void) onCameraInit
{ {