vdpau: fix destruction of GstVdpDevice when it failed to open
authorCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
Fri, 6 Aug 2010 10:14:04 +0000 (12:14 +0200)
committerCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
Fri, 6 Aug 2010 10:14:30 +0000 (12:14 +0200)
only close display in finalize and check if vdp_decoder_destroy is available
before we use it

sys/vdpau/gstvdp/gstvdpdevice.c
sys/vdpau/gstvdp/gstvdpdevice.h

index 2e441b93c19c75001d50360815357002127c4182..359874b167a3da4c28f9ac078d8585c4f8c794e7 100644 (file)
@@ -136,19 +136,16 @@ create_display_error:
   return FALSE;
 
 create_device_error:
-  XCloseDisplay (device->display);
   g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ,
       "Could not create VDPAU device for display: %s", device->display_name);
   return FALSE;
 
 get_error_string_error:
-  XCloseDisplay (device->display);
   g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ,
       "Could not get vdp_get_error_string function pointer from VDPAU");
   return FALSE;
 
 function_error:
-  XCloseDisplay (device->display);
   g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ,
       "Could not get function pointer from VDPAU, error returned was: %s",
       device->vdp_get_error_string (status));
@@ -176,6 +173,7 @@ gst_vdp_device_init (GstVdpDevice * device)
   device->display_name = NULL;
   device->display = NULL;
   device->device = VDP_INVALID_HANDLE;
+  device->vdp_decoder_destroy = NULL;
 }
 
 static void
@@ -183,14 +181,16 @@ gst_vdp_device_finalize (GObject * object)
 {
   GstVdpDevice *device = (GstVdpDevice *) object;
 
-  if (device->device != VDP_INVALID_HANDLE) {
+  if (device->device != VDP_INVALID_HANDLE && device->vdp_decoder_destroy) {
     device->vdp_device_destroy (device->device);
     device->device = VDP_INVALID_HANDLE;
   }
+
   if (device->display) {
     XCloseDisplay (device->display);
     device->display = NULL;
   }
+
   g_free (device->display_name);
   device->display_name = NULL;
 
index 6010e75548b36915caad4e720229c99771f9dacb..3fda2b29db5309536fd87be4baffcc834c531553 100644 (file)
@@ -47,8 +47,6 @@ struct _GstVdpDeviceClass
 struct _GstVdpDevice
 {
   GObject object;
-
-  gboolean constructed;
   
   gchar *display_name;
   Display *display;