diff options
author | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-07-30 22:27:49 +0200 |
---|---|---|
committer | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-07-30 22:27:49 +0200 |
commit | b37869c315284b1bd426a06201f81c1ba6ea3840 (patch) | |
tree | 3c6894f83457d815917dd68277fd4cb54177c237 | |
parent | 57e05fdc76239feab890a6b7df814ce65c331ce4 (diff) |
vdpau: add error reporting to device creation
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpdecoder.c | 7 | ||||
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpdevice.c | 147 | ||||
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpdevice.h | 2 | ||||
-rw-r--r-- | sys/vdpau/gstvdpau.c | 6 | ||||
-rw-r--r-- | sys/vdpau/gstvdpsink.c | 32 | ||||
-rw-r--r-- | sys/vdpau/gstvdpvideopostprocess.c | 7 |
6 files changed, 102 insertions, 99 deletions
diff --git a/sys/vdpau/gstvdp/gstvdpdecoder.c b/sys/vdpau/gstvdp/gstvdpdecoder.c index 8870398b2..5e14fac44 100644 --- a/sys/vdpau/gstvdp/gstvdpdecoder.c +++ b/sys/vdpau/gstvdp/gstvdpdecoder.c @@ -188,5 +188,7 @@ gst_vdp_decoder_start (GstBaseVideoDecoder * base_video_decoder) + GError *err; GstVdpVideoSrcPad *vdp_pad; - vdp_decoder->device = gst_vdp_get_device (vdp_decoder->display); + err = NULL; + vdp_decoder->device = gst_vdp_get_device (vdp_decoder->display, &err); if (G_UNLIKELY (!vdp_decoder->device)) @@ -203,4 +205,3 @@ gst_vdp_decoder_start (GstBaseVideoDecoder * base_video_decoder) device_error: - GST_ELEMENT_ERROR (vdp_decoder, RESOURCE, OPEN_READ, - ("Couldn't create GstVdpDevice"), (NULL)); + gst_vdp_decoder_post_error (vdp_decoder, err); return FALSE; diff --git a/sys/vdpau/gstvdp/gstvdpdevice.c b/sys/vdpau/gstvdp/gstvdpdevice.c index 8867e4e34..2e441b93c 100644 --- a/sys/vdpau/gstvdp/gstvdpdevice.c +++ b/sys/vdpau/gstvdp/gstvdpdevice.c @@ -39,35 +39,5 @@ G_DEFINE_TYPE_WITH_CODE (GstVdpDevice, gst_vdp_device, G_TYPE_OBJECT, -static void -gst_vdp_device_init (GstVdpDevice * device) -{ - device->display_name = NULL; - device->display = NULL; - device->device = VDP_INVALID_HANDLE; - - device->constructed = FALSE; -} - -static void -gst_vdp_device_finalize (GObject * object) +static gboolean +gst_vdp_device_open (GstVdpDevice * device, GError ** error) { - GstVdpDevice *device = (GstVdpDevice *) object; - - if (device->device != VDP_INVALID_HANDLE) { - 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; - - G_OBJECT_CLASS (gst_vdp_device_parent_class)->finalize (object); -} - -static void -gst_vdp_device_constructed (GObject * object) -{ - GstVdpDevice *device = (GstVdpDevice *) object; gint screen; @@ -137,7 +107,4 @@ gst_vdp_device_constructed (GObject * object) device->display = XOpenDisplay (device->display_name); - if (!device->display) { - GST_ERROR_OBJECT (device, "Could not open X display with name: %s", - device->display_name); - return; - } + if (!device->display) + goto create_display_error; @@ -147,10 +114,4 @@ gst_vdp_device_constructed (GObject * object) &device->vdp_get_proc_address); - if (status != VDP_STATUS_OK) { - GST_ERROR_OBJECT (device, "Could not create VDPAU device"); - device->device = VDP_INVALID_HANDLE; - XCloseDisplay (device->display); - device->display = NULL; - - return; - } + if (status != VDP_STATUS_OK) + goto create_device_error; @@ -158,7 +119,4 @@ gst_vdp_device_constructed (GObject * object) VDP_FUNC_ID_GET_ERROR_STRING, (void **) &device->vdp_get_error_string); - if (status != VDP_STATUS_OK) { - GST_ERROR_OBJECT (device, - "Could not get vdp_get_error_string function pointer from VDPAU"); - goto error; - } + if (status != VDP_STATUS_OK) + goto get_error_string_error; @@ -168,15 +126,60 @@ gst_vdp_device_constructed (GObject * object) - if (status != VDP_STATUS_OK) { - GST_ERROR_OBJECT (device, "Could not get function pointer from VDPAU," - " error returned was: %s", device->vdp_get_error_string (status)); - goto error; - } + if (status != VDP_STATUS_OK) + goto function_error; } - device->constructed = TRUE; - return; + return TRUE; + +create_display_error: + g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, + "Could not open X display with name: %s", device->display_name); + return FALSE; -error: +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)); + return FALSE; +} + +static GstVdpDevice * +gst_vdp_device_new (const gchar * display_name, GError ** error) +{ + GstVdpDevice *device; + + device = g_object_new (GST_TYPE_VDP_DEVICE, "display", display_name, NULL); + + if (!gst_vdp_device_open (device, error)) { + g_object_unref (device); + return NULL; + } + + return device; +} + +static void +gst_vdp_device_init (GstVdpDevice * device) +{ + device->display_name = NULL; device->display = NULL; + device->device = VDP_INVALID_HANDLE; +} + +static void +gst_vdp_device_finalize (GObject * object) +{ + GstVdpDevice *device = (GstVdpDevice *) object; @@ -186,2 +189,10 @@ error: } + if (device->display) { + XCloseDisplay (device->display); + device->display = NULL; + } + g_free (device->display_name); + device->display_name = NULL; + + G_OBJECT_CLASS (gst_vdp_device_parent_class)->finalize (object); } @@ -233,3 +244,2 @@ gst_vdp_device_class_init (GstVdpDeviceClass * klass) - object_class->constructed = gst_vdp_device_constructed; object_class->finalize = gst_vdp_device_finalize; @@ -246,17 +256,2 @@ gst_vdp_device_class_init (GstVdpDeviceClass * klass) -static GstVdpDevice * -gst_vdp_device_new (const gchar * display_name) -{ - GstVdpDevice *device; - - device = g_object_new (GST_TYPE_VDP_DEVICE, "display", display_name, NULL); - - if (!device->constructed) { - g_object_unref (device); - return NULL; - } - - return device; -} - typedef struct @@ -290,3 +285,3 @@ device_destroyed_cb (gpointer data, GObject * object) GstVdpDevice * -gst_vdp_get_device (const gchar * display_name) +gst_vdp_get_device (const gchar * display_name, GError ** error) { @@ -312,3 +307,3 @@ gst_vdp_get_device (const gchar * display_name) if (!device) { - device = gst_vdp_device_new (display_name); + device = gst_vdp_device_new (display_name, error); if (device) { diff --git a/sys/vdpau/gstvdp/gstvdpdevice.h b/sys/vdpau/gstvdp/gstvdpdevice.h index df1367524..6010e7554 100644 --- a/sys/vdpau/gstvdp/gstvdpdevice.h +++ b/sys/vdpau/gstvdp/gstvdpdevice.h @@ -98,3 +98,3 @@ GType gst_vdp_device_get_type (void); -GstVdpDevice *gst_vdp_get_device (const gchar *display_name); +GstVdpDevice *gst_vdp_get_device (const gchar *display_name, GError **error); diff --git a/sys/vdpau/gstvdpau.c b/sys/vdpau/gstvdpau.c index 7e47e85a1..2ec57afb4 100644 --- a/sys/vdpau/gstvdpau.c +++ b/sys/vdpau/gstvdpau.c @@ -24,7 +24,7 @@ vdpau_init (GstPlugin * vdpau_plugin) gst_element_register (vdpau_plugin, "vdpauh264dec", - GST_RANK_NONE, GST_TYPE_VDP_H264_DEC); + GST_RANK_PRIMARY, GST_TYPE_VDP_H264_DEC); gst_element_register (vdpau_plugin, "vdpauvideopostprocess", - GST_RANK_MARGINAL, GST_TYPE_VDP_VIDEO_POST_PROCESS); + GST_RANK_PRIMARY, GST_TYPE_VDP_VIDEO_POST_PROCESS); gst_element_register (vdpau_plugin, "vdpausink", - GST_RANK_NONE, GST_TYPE_VDP_SINK); + GST_RANK_PRIMARY, GST_TYPE_VDP_SINK); diff --git a/sys/vdpau/gstvdpsink.c b/sys/vdpau/gstvdpsink.c index 70bcd6bfe..2f7c5d059 100644 --- a/sys/vdpau/gstvdpsink.c +++ b/sys/vdpau/gstvdpsink.c @@ -571,2 +571,12 @@ gst_vdp_sink_get_allowed_caps (GstVdpDevice * device, GValue * par) +static void +gst_vdp_sink_post_error (VdpSink * vdp_sink, GError * error) +{ + GstMessage *message; + + message = gst_message_new_error (GST_OBJECT (vdp_sink), error, NULL); + gst_element_post_message (GST_ELEMENT (vdp_sink), message); + g_error_free (error); +} + static gboolean @@ -575,6 +585,8 @@ gst_vdp_sink_open_device (VdpSink * vdp_sink) GstVdpDevice *device; + GError *err; - vdp_sink->device = device = gst_vdp_get_device (vdp_sink->display_name); - if (!vdp_sink->device) - return FALSE; + err = NULL; + vdp_sink->device = device = gst_vdp_get_device (vdp_sink->display_name, &err); + if (!device) + goto device_error; @@ -596,2 +608,6 @@ gst_vdp_sink_open_device (VdpSink * vdp_sink) return TRUE; + +device_error: + gst_vdp_sink_post_error (vdp_sink, err); + return FALSE; } @@ -900,12 +916,2 @@ gst_vdp_sink_event (GstBaseSink * sink, GstEvent * event) -static void -gst_vdp_sink_post_error (VdpSink * vdp_sink, GError * error) -{ - GstMessage *message; - - message = gst_message_new_error (GST_OBJECT (vdp_sink), error, NULL); - gst_element_post_message (GST_ELEMENT (vdp_sink), message); - g_error_free (error); -} - /* Buffer management diff --git a/sys/vdpau/gstvdpvideopostprocess.c b/sys/vdpau/gstvdpvideopostprocess.c index 4658f901d..adaabf4bc 100644 --- a/sys/vdpau/gstvdpvideopostprocess.c +++ b/sys/vdpau/gstvdpvideopostprocess.c @@ -598,2 +598,3 @@ gst_vdp_vpp_start (GstVdpVideoPostProcess * vpp) gint i; + GError *err; @@ -615,3 +616,4 @@ gst_vdp_vpp_start (GstVdpVideoPostProcess * vpp) - vpp->device = gst_vdp_get_device (vpp->display); + err = NULL; + vpp->device = gst_vdp_get_device (vpp->display, &err); if (G_UNLIKELY (!vpp->device)) @@ -624,4 +626,3 @@ gst_vdp_vpp_start (GstVdpVideoPostProcess * vpp) device_error: - GST_ELEMENT_ERROR (vpp, RESOURCE, OPEN_READ, - ("Couldn't create GstVdpDevice"), (NULL)); + gst_vdp_vpp_post_error (vpp, err); return FALSE; |