Commit 01744abf authored by Felix Paul Kühne's avatar Felix Paul Kühne

Don't double free objects on error. Pointed by Pierre

parent d9421a57
...@@ -86,7 +86,8 @@ vlc_module_end(); ...@@ -86,7 +86,8 @@ vlc_module_end();
} }
- (void)dealloc - (void)dealloc
{ {
@synchronized (self) { @synchronized (self)
{
CVBufferRelease(currentImageBuffer); CVBufferRelease(currentImageBuffer);
currentImageBuffer = nil; currentImageBuffer = nil;
} }
...@@ -101,7 +102,8 @@ vlc_module_end(); ...@@ -101,7 +102,8 @@ vlc_module_end();
CVBufferRetain(videoFrame); CVBufferRetain(videoFrame);
@synchronized (self) { @synchronized (self)
{
imageBufferToRelease = currentImageBuffer; imageBufferToRelease = currentImageBuffer;
currentImageBuffer = videoFrame; currentImageBuffer = videoFrame;
currentPts = [sampleBuffer presentationTime].timeValue; currentPts = [sampleBuffer presentationTime].timeValue;
...@@ -113,16 +115,19 @@ vlc_module_end(); ...@@ -113,16 +115,19 @@ vlc_module_end();
{ {
CVImageBufferRef imageBuffer; CVImageBufferRef imageBuffer;
mtime_t pts; mtime_t pts;
@synchronized (self) {
if(!currentImageBuffer) return 0; if(!currentImageBuffer)
return 0;
@synchronized (self)
{
imageBuffer = CVBufferRetain(currentImageBuffer); imageBuffer = CVBufferRetain(currentImageBuffer);
pts = currentPts; pts = currentPts;
CVPixelBufferLockBaseAddress(imageBuffer, 0); CVPixelBufferLockBaseAddress(imageBuffer, 0);
void * pixels = CVPixelBufferGetBaseAddress(imageBuffer); void * pixels = CVPixelBufferGetBaseAddress(imageBuffer);
memcpy( buffer, pixels, CVPixelBufferGetBytesPerRow(imageBuffer) * CVPixelBufferGetHeight(imageBuffer) ); memcpy( buffer, pixels, CVPixelBufferGetBytesPerRow(imageBuffer) * CVPixelBufferGetHeight(imageBuffer) );
CVPixelBufferUnlockBaseAddress(imageBuffer, 0); CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
} }
CVBufferRelease(imageBuffer); CVBufferRelease(imageBuffer);
...@@ -281,9 +286,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -281,9 +286,6 @@ static int Open( vlc_object_t *p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
[input release]; [input release];
[p_sys->device release];
[p_sys->output release];
[p_sys->session release];
[pool release]; [pool release];
free( p_sys ); free( p_sys );
...@@ -329,7 +331,8 @@ static int Demux( demux_t *p_demux ) ...@@ -329,7 +331,8 @@ static int Demux( demux_t *p_demux )
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
@synchronized (p_sys->output) { @synchronized (p_sys->output)
{
p_block->i_pts = [p_sys->output copyCurrentFrameToBuffer: p_block->p_buffer]; p_block->i_pts = [p_sys->output copyCurrentFrameToBuffer: p_block->p_buffer];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment