[GPUImageVideoCamera release] will call dealloc, but will crash at - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
hi, Brad,
I tried to release GPUImageVideoCamera when i am done with the videoCamera by dealloc-ing this object, yet to no avail. [GPUImageVideoCamera release] will call dealloc, but will crash at - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection.
It turned out that at [self processVideoSampleBuffer:sampleBuffer], "self" object has already been deallocated and thus will return a BAD_MEM_ACCESS error. Is there a way to release GPUImageVideoCamera by exiting the videocamera screen?
thanks a lot in advance.
Andrew
In dealloc, I also uncommented " // [videoOutput setSampleBufferDelegate:nil queue:dispatch_get_main_queue()]; ", which seems to do me no good either. Is there a way to stop the SampleBuffer queue from dispatching those queued video frames once the GPUImageVideoCamera is deallocated?
I probably should have a more robust way of handling this, but I added the following code in the FilterShowcase to stop sending frames and prevent these kinds of errors:
- (void)viewWillDisappear:(BOOL)animated
{
// Note: I needed to stop camera capture before the view went off the screen in order to prevent a crash from the camera still sending frames
[videoCamera stopCameraCapture];
[super viewWillDisappear:animated];
}
thanks a bunch, Brad. it seems to have fixed the issue. :-)
On May 23, 2012, at 10:29 PM, Brad Larson wrote:
I probably should have a more robust way of handling this, but I added the following code in the FilterShowcase to stop sending frames and prevent these kinds of errors:
(void)viewWillDisappear:(BOOL)animated { // Note: I needed to stop camera capture before the view went off the screen in order to prevent a crash from the camera still sending frames [videoCamera stopCameraCapture];
[super viewWillDisappear:animated]; }
Reply to this email directly or view it on GitHub: https://github.com/BradLarson/GPUImage/issues/154#issuecomment-5874297