summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-01-05 16:44:44 +0100
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-01-06 10:59:45 +0100
commit6853d479d4e6fa52427289eac6360bf8c2f750c8 (patch)
treefc0e627c0ed2e2ffc409a44ae57a39466341d02e
parent9df1027ed9ae2e8874097e9ebf80a6038fb164d3 (diff)
downloadgstreamer-vaapi-6853d479d4e6fa52427289eac6360bf8c2f750c8.tar.gz
surfaceproxy: simplify destruction.
Also make sure to always make sure to release the surface back to the pool of surfaces in the associated VA context, if any.
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurfaceproxy.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
index f1a9206c..80201c5f 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
+++ b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
@@ -55,19 +55,9 @@ static void
gst_vaapi_surface_proxy_finalize(GObject *object)
{
GstVaapiSurfaceProxy * const proxy = GST_VAAPI_SURFACE_PROXY(object);
- GstVaapiSurfaceProxyPrivate * const priv = proxy->priv;
- if (priv->surface) {
- if (priv->context)
- gst_vaapi_context_put_surface(priv->context, priv->surface);
- g_object_unref(priv->surface);
- priv->surface = NULL;
- }
-
- if (priv->context) {
- g_object_unref(priv->context);
- priv->context = NULL;
- }
+ gst_vaapi_surface_proxy_set_surface(proxy, NULL);
+ gst_vaapi_surface_proxy_set_context(proxy, NULL);
G_OBJECT_CLASS(gst_vaapi_surface_proxy_parent_class)->finalize(object);
}
@@ -226,16 +216,19 @@ gst_vaapi_surface_proxy_set_context(
GstVaapiContext *context
)
{
+ GstVaapiSurfaceProxyPrivate *priv;
+
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
- g_return_if_fail(GST_VAAPI_IS_CONTEXT(context));
- if (proxy->priv->context) {
- g_object_unref(proxy->priv->context);
- proxy->priv->context = NULL;
+ priv = proxy->priv;
+
+ if (priv->context) {
+ g_object_unref(priv->context);
+ priv->context = NULL;
}
if (context)
- proxy->priv->context = g_object_ref(context);
+ priv->context = g_object_ref(context);
}
/**
@@ -269,16 +262,21 @@ gst_vaapi_surface_proxy_set_surface(
GstVaapiSurface *surface
)
{
+ GstVaapiSurfaceProxyPrivate *priv;
+
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
- g_return_if_fail(GST_VAAPI_IS_SURFACE(surface));
- if (proxy->priv->surface) {
- g_object_unref(proxy->priv->surface);
- proxy->priv->surface = NULL;
+ priv = proxy->priv;
+
+ if (priv->surface) {
+ if (priv->context)
+ gst_vaapi_context_put_surface(priv->context, priv->surface);
+ g_object_unref(priv->surface);
+ priv->surface = NULL;
}
if (surface)
- proxy->priv->surface = g_object_ref(surface);
+ priv->surface = g_object_ref(surface);
}
/**