From 0df96e1c3be63770672b097e43fac119a8434316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 7 May 2015 15:57:26 +0200 Subject: [PATCH] vaapisink: error handling if rendering fails This patch enhance the code path when an error is found when rendering a buffer. If the video meta doesn't contain a surface proxy or a surface, a warning message is printed. If the rendering backend fails, a error message is posted in the bus. https://bugzilla.gnome.org/show_bug.cgi?id=749382 --- gst/vaapi/gstvaapisink.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/gst/vaapi/gstvaapisink.c b/gst/vaapi/gstvaapisink.c index 8f4eb02046..82769684e6 100644 --- a/gst/vaapi/gstvaapisink.c +++ b/gst/vaapi/gstvaapisink.c @@ -1356,19 +1356,19 @@ gst_vaapisink_show_frame_unlocked (GstVaapiSink * sink, GstBuffer * src_buffer) proxy = gst_vaapi_video_meta_get_surface_proxy (meta); if (!proxy) - goto error; + goto no_surface; surface = gst_vaapi_video_meta_get_surface (meta); if (!surface) - goto error; + goto no_surface; /* Validate view component to display */ view_id = GST_VAAPI_SURFACE_PROXY_VIEW_ID (proxy); if (G_UNLIKELY (sink->view_id == -1)) sink->view_id = view_id; else if (sink->view_id != view_id) { - gst_buffer_unref (buffer); - return GST_FLOW_OK; + ret = GST_FLOW_OK; + goto done; } gst_vaapisink_ensure_colorbalance (sink); @@ -1404,13 +1404,24 @@ gst_vaapisink_show_frame_unlocked (GstVaapiSink * sink, GstBuffer * src_buffer) /* Retain VA surface until the next one is displayed */ gst_buffer_replace (&sink->video_buffer, buffer); - gst_buffer_unref (buffer); - return GST_FLOW_OK; + ret = GST_FLOW_OK; + +done: + gst_buffer_unref (buffer); + return ret; error: - gst_buffer_unref (buffer); - return GST_FLOW_EOS; + GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, + ("Internal error: could not render surface"), (NULL)); + ret = GST_FLOW_ERROR; + goto done; + +no_surface: + /* No surface or surface proxy. That's very bad! */ + GST_WARNING_OBJECT (sink, "could not get surface"); + ret = GST_FLOW_ERROR; + goto done; } static GstFlowReturn