diff options
author | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-06-27 00:36:25 +0200 |
---|---|---|
committer | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-06-28 11:11:52 +0200 |
commit | 00fd85c0f527e2ec85409778c5a5b1037937ccb6 (patch) | |
tree | 3f9687b119074ad9aeae70a18b0b10e4d89b63c4 /sys | |
parent | 8e59521efa34029837ef33ec8b072bc690b00b70 (diff) | |
download | gstreamer-plugins-bad-00fd85c0f527e2ec85409778c5a5b1037937ccb6.tar.gz |
vdpau: fix error handling when plugging "vdpauvideopostprocess ! fakesink"
Diffstat (limited to 'sys')
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpoutputsrcpad.c | 76 | ||||
-rw-r--r-- | sys/vdpau/gstvdpvideopostprocess.c | 9 |
2 files changed, 44 insertions, 41 deletions
diff --git a/sys/vdpau/gstvdp/gstvdpoutputsrcpad.c b/sys/vdpau/gstvdp/gstvdpoutputsrcpad.c index bc93f33fc..7f39f8343 100644 --- a/sys/vdpau/gstvdp/gstvdpoutputsrcpad.c +++ b/sys/vdpau/gstvdp/gstvdpoutputsrcpad.c @@ -221,6 +221,38 @@ device_error: return FALSE; } +static GstFlowReturn +gst_vdp_output_src_pad_alloc_with_caps (GstVdpOutputSrcPad * vdp_pad, + GstCaps * caps, GstVdpOutputBuffer ** output_buf, GError ** error) +{ + GstFlowReturn ret; + + ret = gst_pad_alloc_buffer ((GstPad *) vdp_pad, 0, 0, caps, + (GstBuffer **) output_buf); + if (ret != GST_FLOW_OK) + return ret; + + if (!gst_caps_is_equal_fixed (caps, GST_BUFFER_CAPS (*output_buf))) + goto wrong_caps; + + if (!GST_IS_VDP_OUTPUT_BUFFER (*output_buf)) + goto invalid_buf; + + return GST_FLOW_OK; + +wrong_caps: + gst_buffer_unref (GST_BUFFER (*output_buf)); + g_set_error (error, GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, + "Sink element returned buffer with wrong caps"); + return GST_FLOW_ERROR; + +invalid_buf: + gst_buffer_unref (GST_BUFFER (*output_buf)); + g_set_error (error, GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, + "Sink element returned buffer of wrong type"); + return GST_FLOW_ERROR; +} + GstFlowReturn gst_vdp_output_src_pad_alloc_buffer (GstVdpOutputSrcPad * vdp_pad, GstVdpOutputBuffer ** output_buf, GError ** error) @@ -251,17 +283,11 @@ gst_vdp_output_src_pad_alloc_buffer (GstVdpOutputSrcPad * vdp_pad, case GST_VDP_OUTPUT_SRC_PAD_FORMAT_VDPAU: { - GstStructure *structure; - - ret = gst_pad_alloc_buffer ((GstPad *) vdp_pad, 0, 0, caps, - (GstBuffer **) output_buf); + ret = gst_vdp_output_src_pad_alloc_with_caps (vdp_pad, caps, output_buf, + error); if (ret != GST_FLOW_OK) return ret; - structure = gst_caps_get_structure (GST_BUFFER_CAPS (*output_buf), 0); - if (!gst_structure_has_name (structure, "video/x-vdpau-output")) - goto wrong_caps; - if (G_UNLIKELY (!vdp_pad->device)) { vdp_pad->device = g_object_ref (GST_VDP_VIDEO_BUFFER (*output_buf)->device); @@ -279,12 +305,6 @@ gst_vdp_output_src_pad_alloc_buffer (GstVdpOutputSrcPad * vdp_pad, return GST_FLOW_OK; -wrong_caps: - gst_buffer_unref (GST_BUFFER_CAST (*output_buf)); - - g_set_error (error, GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, - "Sink element returned buffer with wrong caps"); - return GST_FLOW_ERROR; } gboolean @@ -365,12 +385,12 @@ gst_vdp_output_src_pad_get_device (GstVdpOutputSrcPad * vdp_pad, GstStructure *structure; src_caps = gst_pad_get_allowed_caps (GST_PAD (vdp_pad)); - gst_pad_fixate_caps (GST_PAD (vdp_pad), src_caps); if (gst_caps_is_empty (src_caps)) { gst_caps_unref (src_caps); return GST_FLOW_NOT_NEGOTIATED; } + gst_pad_fixate_caps (GST_PAD (vdp_pad), src_caps); structure = gst_caps_get_structure (src_caps, 0); if (gst_structure_has_name (structure, "video/x-raw-rgb")) { @@ -382,21 +402,17 @@ gst_vdp_output_src_pad_get_device (GstVdpOutputSrcPad * vdp_pad, else { GstFlowReturn ret; - GstBuffer *buf; + GstVdpOutputBuffer *buf; - ret = gst_pad_alloc_buffer (GST_PAD (vdp_pad), 0, 0, src_caps, &buf); + ret = gst_vdp_output_src_pad_alloc_with_caps (vdp_pad, src_caps, + &buf, error); if (ret != GST_FLOW_OK) { gst_caps_unref (src_caps); - goto alloc_failed; - } - - if (!gst_caps_is_equal_fixed (src_caps, GST_BUFFER_CAPS (buf))) { - gst_caps_unref (src_caps); - gst_buffer_unref (buf); - goto wrong_caps; + return ret; } - vdp_pad->device = g_object_ref (GST_VDP_OUTPUT_BUFFER (buf)->device); + vdp_pad->device = g_object_ref (buf->device); + gst_buffer_unref (GST_BUFFER (buf)); } gst_caps_unref (src_caps); @@ -404,16 +420,6 @@ gst_vdp_output_src_pad_get_device (GstVdpOutputSrcPad * vdp_pad, *device = vdp_pad->device; return GST_FLOW_OK; - -alloc_failed: - g_set_error (error, GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, - "Couldn't allocate buffer"); - return GST_FLOW_ERROR; - -wrong_caps: - g_set_error (error, GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, - "Sink element returned buffer with wrong caps"); - return GST_FLOW_ERROR; } static GstCaps * diff --git a/sys/vdpau/gstvdpvideopostprocess.c b/sys/vdpau/gstvdpvideopostprocess.c index 1c4c567fd..cd45b4dbf 100644 --- a/sys/vdpau/gstvdpvideopostprocess.c +++ b/sys/vdpau/gstvdpvideopostprocess.c @@ -359,6 +359,7 @@ gst_vdp_vpp_post_error (GstVdpVideoPostProcess * vpp, GError * error) message = gst_message_new_error (GST_OBJECT (vpp), error, NULL); gst_element_post_message (GST_ELEMENT (vpp), message); + g_error_free (error); } static GstFlowReturn @@ -372,10 +373,8 @@ gst_vdp_vpp_open_device (GstVdpVideoPostProcess * vpp) ret = gst_vdp_output_src_pad_get_device (GST_VDP_OUTPUT_SRC_PAD (vpp->srcpad), &vpp->device, &err); - if (ret == GST_FLOW_ERROR) { + if (ret == GST_FLOW_ERROR) gst_vdp_vpp_post_error (vpp, err); - g_error_free (err); - } return ret; } @@ -716,10 +715,8 @@ gst_vdp_vpp_drain (GstVdpVideoPostProcess * vpp) break; output_pad_error: - if (ret == GST_FLOW_ERROR && err != NULL) { + if (ret == GST_FLOW_ERROR && err != NULL) gst_vdp_vpp_post_error (vpp, err); - g_error_free (err); - } break; } |