GPUImage icon indicating copy to clipboard operation
GPUImage copied to clipboard

[GPUImageVideoCamera release] will call dealloc, but will crash at - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection

Open andrewzeus opened this issue 14 years ago • 3 comments

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

andrewzeus avatar May 22 '12 23:05 andrewzeus

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?

andrewzeus avatar May 23 '12 01:05 andrewzeus

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];
}

BradLarson avatar May 23 '12 14:05 BradLarson

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

andrewzeus avatar May 24 '12 01:05 andrewzeus