osxvideosink: fix setting window handle after transition
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Mon, 15 Apr 2013 15:37:01 +0000 (17:37 +0200)
committerAndoni Morales Alastruey <ylatuya@gmail.com>
Thu, 2 May 2013 12:03:43 +0000 (14:03 +0200)
The destroyed flag was not reset properly and it's also not needed
as we can check osxwindow != NULL

sys/osxvideo/osxvideosink.h
sys/osxvideo/osxvideosink.m

index 831ed39..cf0410f 100644 (file)
@@ -135,8 +135,6 @@ GType gst_osx_video_sink_get_type(void);
 
 @interface GstOSXVideoSinkObject : NSObject
 {
-  BOOL destroyed;
-
   @public
   GstOSXVideoSink *osxvideosink;
 }
index cf939b1..f235c8b 100644 (file)
@@ -862,7 +862,7 @@ gst_osx_video_sink_get_type (void)
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   GstBuffer *buf = object->buf;
 
-  if (!destroyed)
+  if (osxvideosink->osxwindow != NULL)
   {
     gst_buffer_map (buf, &info, GST_MAP_READ);
     viewdata = (guint8 *) [osxvideosink->osxwindow->gstview getTextureBuffer];
@@ -880,25 +880,26 @@ gst_osx_video_sink_get_type (void)
 -(void) destroy
 {
   NSAutoreleasePool *pool;
+  GstOSXWindow *osxwindow;
 
   pool = [[NSAutoreleasePool alloc] init];
 
-  destroyed = TRUE;
+  osxwindow = osxvideosink->osxwindow;
+  osxvideosink->osxwindow = NULL;
 
-  if (osxvideosink->osxwindow) {
+  if (osxwindow) {
     if (osxvideosink->superview) {
-      [osxvideosink->osxwindow->gstview removeFromSuperview];
+      [osxwindow->gstview removeFromSuperview];
     }
-    [osxvideosink->osxwindow->gstview release];
-    if (osxvideosink->osxwindow->internal) {
-      if (!osxvideosink->osxwindow->closed) {
-        osxvideosink->osxwindow->closed = TRUE;
-        [osxvideosink->osxwindow->win release];
+    [osxwindow->gstview release];
+    if (osxwindow->internal) {
+      if (!osxwindow->closed) {
+        osxwindow->closed = TRUE;
+        [osxwindow->win release];
       }
     }
 
-    g_free (osxvideosink->osxwindow);
-    osxvideosink->osxwindow = NULL;
+    g_free (osxwindow);
   }
   [pool release];
 }