vdpau: fix destruction of GstVdpDevice when it failed to open

only close display in finalize and check if vdp_decoder_destroy is available
before we use it
This commit is contained in:
Carl-Anton Ingmarsson 2010-08-06 12:14:04 +02:00
parent 8996b80d62
commit b6f22c519d
2 changed files with 4 additions and 6 deletions

View file

@ -136,19 +136,16 @@ create_display_error:
return FALSE; return FALSE;
create_device_error: create_device_error:
XCloseDisplay (device->display);
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ,
"Could not create VDPAU device for display: %s", device->display_name); "Could not create VDPAU device for display: %s", device->display_name);
return FALSE; return FALSE;
get_error_string_error: get_error_string_error:
XCloseDisplay (device->display);
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ,
"Could not get vdp_get_error_string function pointer from VDPAU"); "Could not get vdp_get_error_string function pointer from VDPAU");
return FALSE; return FALSE;
function_error: function_error:
XCloseDisplay (device->display);
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ,
"Could not get function pointer from VDPAU, error returned was: %s", "Could not get function pointer from VDPAU, error returned was: %s",
device->vdp_get_error_string (status)); device->vdp_get_error_string (status));
@ -176,6 +173,7 @@ gst_vdp_device_init (GstVdpDevice * device)
device->display_name = NULL; device->display_name = NULL;
device->display = NULL; device->display = NULL;
device->device = VDP_INVALID_HANDLE; device->device = VDP_INVALID_HANDLE;
device->vdp_decoder_destroy = NULL;
} }
static void static void
@ -183,14 +181,16 @@ gst_vdp_device_finalize (GObject * object)
{ {
GstVdpDevice *device = (GstVdpDevice *) 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->vdp_device_destroy (device->device);
device->device = VDP_INVALID_HANDLE; device->device = VDP_INVALID_HANDLE;
} }
if (device->display) { if (device->display) {
XCloseDisplay (device->display); XCloseDisplay (device->display);
device->display = NULL; device->display = NULL;
} }
g_free (device->display_name); g_free (device->display_name);
device->display_name = NULL; device->display_name = NULL;

View file

@ -47,8 +47,6 @@ struct _GstVdpDeviceClass
struct _GstVdpDevice struct _GstVdpDevice
{ {
GObject object; GObject object;
gboolean constructed;
gchar *display_name; gchar *display_name;
Display *display; Display *display;