Commit 4126a32c authored by Felix Paul Kühne's avatar Felix Paul Kühne

avcapture: drop legacy NSAutoreleasePool pattern

parent 7b2b08ec
......@@ -70,7 +70,6 @@ vlc_module_end ()
demux_t *p_avcapture;
CVImageBufferRef currentImageBuffer;
CMVideoDimensions videoDimensions;
mtime_t currentPts;
mtime_t previousPts;
......@@ -167,18 +166,18 @@ vlc_module_end ()
return currentPts;
}
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@autoreleasepool {
CVImageBufferRef imageBufferToRelease;
CMTime presentationtimestamp = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
CVImageBufferRef videoFrame = CMSampleBufferGetImageBuffer(sampleBuffer);
CVBufferRetain(videoFrame);
[self getVideoDimensions:sampleBuffer];
@synchronized (self)
{
@synchronized (self) {
imageBufferToRelease = currentImageBuffer;
currentImageBuffer = videoFrame;
currentPts = (mtime_t)presentationtimestamp.value;
......@@ -186,7 +185,7 @@ vlc_module_end ()
}
CVBufferRelease(imageBufferToRelease);
[pool release];
}
}
- (mtime_t)copyCurrentFrameToBuffer:(void *)buffer
......@@ -257,13 +256,12 @@ static int Open(vlc_object_t *p_this)
char *psz_uid = NULL;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/* Only when selected */
if ( *p_demux->psz_access == '\0' )
return VLC_EGENERIC;
if ( p_demux->psz_location && *p_demux->psz_location )
@autoreleasepool {
if (p_demux->psz_location && *p_demux->psz_location)
psz_uid = strdup(p_demux->psz_location);
msg_Dbg(p_demux, "avcapture uid = %s", psz_uid);
......@@ -280,7 +278,8 @@ static int Open(vlc_object_t *p_this)
if ( !p_sys )
return VLC_ENOMEM;
myVideoDevices = [[[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo] arrayByAddingObjectsFromArray:[AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed]] retain];
myVideoDevices = [[[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]
arrayByAddingObjectsFromArray:[AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed]] retain];
if ( [myVideoDevices count] == 0 )
{
dialog_FatalWait(p_demux, _("No video devices found"),
......@@ -355,16 +354,15 @@ static int Open(vlc_object_t *p_this)
msg_Dbg(p_demux, "AVCapture: Video device ready!");
[pool release];
return VLC_SUCCESS;
error:
error:
msg_Err(p_demux, "Error");
[input release];
free(p_sys);
[pool release];
return VLC_EGENERIC;
}
}
/*****************************************************************************
......@@ -372,10 +370,10 @@ error:
*****************************************************************************/
static void Close(vlc_object_t *p_this)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
@autoreleasepool {
msg_Dbg(p_demux,"Close AVCapture");
// Perform this on main thread, as the framework itself will sometimes try to synchronously
......@@ -385,8 +383,7 @@ static void Close(vlc_object_t *p_this)
[p_sys->session performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
free(p_sys);
[pool release];
}
}
/*****************************************************************************
......@@ -397,8 +394,7 @@ static int Demux(demux_t *p_demux)
demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_block;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@autoreleasepool {
@synchronized ( p_sys->output )
{
p_block = block_Alloc([p_sys->output width] * [p_sys->output bytesPerRow]);
......@@ -415,7 +411,6 @@ static int Demux(demux_t *p_demux)
{
/* Nothing to display yet, just forget */
block_Release(p_block);
[pool release];
msleep(10000);
return 1;
}
......@@ -434,7 +429,7 @@ static int Demux(demux_t *p_demux)
es_out_Control(p_demux->out, ES_OUT_SET_PCR, p_block->i_pts);
es_out_Send(p_demux->out, p_sys->p_es_video, p_block);
[pool release];
}
return 1;
}
......
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