Commit 94eb4afe authored by Yann Diorcet's avatar Yann Diorcet
Browse files

Fix IOS leak

Fix ms osx view refresh
parent 8daca1b7
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
-(void) setSize:(MSVideoSize) size; -(void) setSize:(MSVideoSize) size;
-(MSVideoSize*) getSize; -(MSVideoSize*) getSize;
-(void) openDevice:(const char*) deviceId; -(void) openDevice:(const char*) deviceId;
-(void) startPreview:(id) obj; -(void) startPreview;
-(void) stopPreview:(id) obj; -(void) stopPreview;
-(void) setFps:(float) value; -(void) setFps:(float) value;
@end @end
...@@ -224,8 +224,6 @@ didOutputSampleBuffer:(CMSampleBufferRef) sampleBuffer ...@@ -224,8 +224,6 @@ didOutputSampleBuffer:(CMSampleBufferRef) sampleBuffer
} }
- (void)dealloc { - (void)dealloc {
[self stop];
[session removeInput:input]; [session removeInput:input];
[session removeOutput:output]; [session removeOutput:output];
[output release]; [output release];
...@@ -355,7 +353,7 @@ static AVCaptureVideoOrientation devideOrientation2AVCaptureVideoOrientation(int ...@@ -355,7 +353,7 @@ static AVCaptureVideoOrientation devideOrientation2AVCaptureVideoOrientation(int
} }
} }
- (void)startPreview:(id) src { - (void)startPreview {
if([preview contentMode] == UIViewContentModeScaleAspectFit) { if([preview contentMode] == UIViewContentModeScaleAspectFit) {
captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspect; captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspect;
} else if([preview contentMode] == UIViewContentModeScaleAspectFill) { } else if([preview contentMode] == UIViewContentModeScaleAspectFill) {
...@@ -367,7 +365,7 @@ static AVCaptureVideoOrientation devideOrientation2AVCaptureVideoOrientation(int ...@@ -367,7 +365,7 @@ static AVCaptureVideoOrientation devideOrientation2AVCaptureVideoOrientation(int
[preview.layer addSublayer:captureVideoPreviewLayer]; [preview.layer addSublayer:captureVideoPreviewLayer];
} }
- (void)stopPreview:(id) src { - (void)stopPreview {
[captureVideoPreviewLayer removeFromSuperlayer]; [captureVideoPreviewLayer removeFromSuperlayer];
} }
...@@ -379,6 +377,7 @@ static void v4ios_init(MSFilter *f) { ...@@ -379,6 +377,7 @@ static void v4ios_init(MSFilter *f) {
static void v4ios_uninit(MSFilter *f) { static void v4ios_uninit(MSFilter *f) {
IOSMsWebCam *webcam=(IOSMsWebCam*)f->data; IOSMsWebCam *webcam=(IOSMsWebCam*)f->data;
[webcam stop]; [webcam stop];
[webcam release]; [webcam release];
} }
...@@ -399,11 +398,18 @@ static void v4ios_process(MSFilter * obj) { ...@@ -399,11 +398,18 @@ static void v4ios_process(MSFilter * obj) {
static void v4ios_preprocess(MSFilter *f) { static void v4ios_preprocess(MSFilter *f) {
IOSMsWebCam *webcam=(IOSMsWebCam*)f->data; IOSMsWebCam *webcam=(IOSMsWebCam*)f->data;
if (webcam->preview) {
[webcam performSelectorOnMainThread:@selector(startPreview) withObject:nil waitUntilDone:NO];
}
[webcam start]; [webcam start];
} }
static void v4ios_postprocess(MSFilter *f) { static void v4ios_postprocess(MSFilter *f) {
IOSMsWebCam *webcam=(IOSMsWebCam*)f->data; IOSMsWebCam *webcam=(IOSMsWebCam*)f->data;
if (webcam->preview) {
[webcam performSelectorOnMainThread:@selector(stopPreview) withObject:nil waitUntilDone:NO];
}
[webcam stop];
} }
static int v4ios_get_fps(MSFilter *f, void *arg) { static int v4ios_get_fps(MSFilter *f, void *arg) {
...@@ -443,13 +449,17 @@ static int v4ios_set_native_window(MSFilter *f, void *arg) { ...@@ -443,13 +449,17 @@ static int v4ios_set_native_window(MSFilter *f, void *arg) {
return 0; //nothing else to do return 0; //nothing else to do
} }
if (webcam->preview) { if (webcam->preview) {
[webcam stopPreview:nil]; if (webcam->session.running) {
[webcam performSelectorOnMainThread:@selector(stopPreview) withObject:nil waitUntilDone:NO];
}
[webcam->preview release]; [webcam->preview release];
} }
webcam->preview = *(UIView**)(arg); webcam->preview = *(UIView**)(arg);
[webcam->preview retain]; [webcam->preview retain];
[webcam performSelectorOnMainThread:@selector(startPreview:) withObject:nil waitUntilDone:NO]; if (webcam->session.running) {
[webcam performSelectorOnMainThread:@selector(startPreview) withObject:nil waitUntilDone:NO];
}
return 0; return 0;
} }
...@@ -461,7 +471,7 @@ static int v4ios_get_native_window(MSFilter *f, void *arg) { ...@@ -461,7 +471,7 @@ static int v4ios_get_native_window(MSFilter *f, void *arg) {
static int v4ios_set_device_orientation (MSFilter *f, void *arg) { static int v4ios_set_device_orientation (MSFilter *f, void *arg) {
IOSMsWebCam *webcam=(IOSMsWebCam*)f->data; IOSMsWebCam *webcam=(IOSMsWebCam*)f->data;
if ( webcam->mDeviceOrientation != *(int*)(arg)) { if ( webcam->mDeviceOrientation != *(int*)(arg)) {
webcam->mDeviceOrientation = *(int*)(arg); webcam->mDeviceOrientation = *(int*)(arg);
if ([webcam->captureVideoPreviewLayer isOrientationSupported]) if ([webcam->captureVideoPreviewLayer isOrientationSupported])
webcam->captureVideoPreviewLayer.orientation = devideOrientation2AVCaptureVideoOrientation(webcam->mDeviceOrientation); webcam->captureVideoPreviewLayer.orientation = devideOrientation2AVCaptureVideoOrientation(webcam->mDeviceOrientation);
......
...@@ -232,7 +232,7 @@ static void osx_gl_process(MSFilter* f) { ...@@ -232,7 +232,7 @@ static void osx_gl_process(MSFilter* f) {
ogl_display_set_yuv_to_display(s->glLayer->display_helper, m); ogl_display_set_yuv_to_display(s->glLayer->display_helper, m);
// Force redraw // Force redraw
[s->glLayer setNeedsDisplay]; [s->glLayer performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:FALSE];
} }
} }
ms_queue_flush(f->inputs[0]); ms_queue_flush(f->inputs[0]);
...@@ -243,7 +243,7 @@ static void osx_gl_process(MSFilter* f) { ...@@ -243,7 +243,7 @@ static void osx_gl_process(MSFilter* f) {
ogl_display_set_preview_yuv_to_display(s->glLayer->display_helper, m); ogl_display_set_preview_yuv_to_display(s->glLayer->display_helper, m);
// Force redraw // Force redraw
[s->glLayer setNeedsDisplay]; [s->glLayer performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:FALSE];
} }
} }
ms_queue_flush(f->inputs[1]); ms_queue_flush(f->inputs[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