summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-04-16 13:48:00 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-04-16 18:54:37 +0200
commit0bd929dfa275e648abae82406704290868453d09 (patch)
treee1d4fe380ee272a9a45c098f1244c9b89a7974ed
parent2db47c0ade98b4e4e1359dab23aa48f9b15c69b7 (diff)
surfaceproxy: drop user-data support from GstVaapiSurfaceProxy.
Drop user-data support from GstVaapiSurfaceProxy. Rather make it explicit to call some user-provided function when the surface proxy is released.
-rw-r--r--docs/reference/libs/libs-sections.txt3
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurfaceproxy.c66
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurfaceproxy.h11
-rw-r--r--gst/vaapi/gstvaapidecode.c4
-rw-r--r--tests/simple-decoder.c4
5 files changed, 36 insertions, 52 deletions
diff --git a/docs/reference/libs/libs-sections.txt b/docs/reference/libs/libs-sections.txt
index 33f645b5..81b4b9a5 100644
--- a/docs/reference/libs/libs-sections.txt
+++ b/docs/reference/libs/libs-sections.txt
@@ -523,11 +523,10 @@ GST_VAAPI_DECODER_VC1_GET_CLASS
<TITLE>GstVaapiSurfaceProxy</TITLE>
gst_vaapi_surface_proxy_get_surface
gst_vaapi_surface_proxy_get_surface_id
-gst_vaapi_surface_proxy_get_user_data
gst_vaapi_surface_proxy_new_from_pool
gst_vaapi_surface_proxy_ref
gst_vaapi_surface_proxy_replace
-gst_vaapi_surface_proxy_set_user_data
+gst_vaapi_surface_proxy_set_destroy_notify
gst_vaapi_surface_proxy_unref
<SUBSECTION Standard>
GST_VAAPI_SURFACE_PROXY_SURFACE
diff --git a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
index e802eab4..83faf191 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
+++ b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
@@ -45,11 +45,16 @@ struct _GstVaapiSurfaceProxy {
GstVaapiVideoPool *pool;
GstVaapiSurface *surface;
+ GDestroyNotify destroy_func;
+ gpointer destroy_data;
};
static void
gst_vaapi_surface_proxy_finalize(GstVaapiSurfaceProxy *proxy)
{
+ if (proxy->destroy_func)
+ proxy->destroy_func(proxy->destroy_data);
+
if (proxy->surface) {
if (proxy->pool)
gst_vaapi_video_pool_put_object(proxy->pool, proxy->surface);
@@ -85,6 +90,7 @@ gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool *pool)
proxy->surface = gst_vaapi_video_pool_get_object(proxy->pool);
if (!proxy->surface)
goto error;
+ proxy->destroy_func = NULL;
g_object_ref(proxy->surface);
return proxy;
@@ -145,45 +151,6 @@ gst_vaapi_surface_proxy_replace(GstVaapiSurfaceProxy **old_proxy_ptr,
}
/**
- * gst_vaapi_surface_proxy_get_user_data:
- * @proxy: a #GstVaapiSurfaceProxy
- *
- * Gets user-provided data set on the object via a previous call to
- * gst_vaapi_surface_proxy_set_user_data().
- *
- * Returns: (transfer none): The previously set user_data
- */
-gpointer
-gst_vaapi_surface_proxy_get_user_data(GstVaapiSurfaceProxy *proxy)
-{
- g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
-
- return gst_vaapi_mini_object_get_user_data(GST_VAAPI_MINI_OBJECT(proxy));
-}
-
-/**
- * gst_vaapi_surface_proxy_set_user_data:
- * @proxy: a #GstVaapiSurfaceProxy
- * @user_data: user-provided data
- * @destroy_notify: (closure user_data): a #GDestroyNotify
- *
- * Sets @user_data on the object and the #GDestroyNotify that will be
- * called when the data is freed.
- *
- * If some @user_data was previously set, then the former @destroy_notify
- * function will be called before the @user_data is replaced.
- */
-void
-gst_vaapi_surface_proxy_set_user_data(GstVaapiSurfaceProxy *proxy,
- gpointer user_data, GDestroyNotify destroy_notify)
-{
- g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
-
- gst_vaapi_mini_object_set_user_data(GST_VAAPI_MINI_OBJECT(proxy),
- user_data, destroy_notify);
-}
-
-/**
* gst_vaapi_surface_proxy_get_surface:
* @proxy: a #GstVaapiSurfaceProxy
*
@@ -215,3 +182,24 @@ gst_vaapi_surface_proxy_get_surface_id(GstVaapiSurfaceProxy *proxy)
return GST_VAAPI_OBJECT_ID(proxy->surface);
}
+
+/**
+ * gst_vaapi_surface_proxy_set_destroy_notify:
+ * @proxy: a @GstVaapiSurfaceProxy
+ * @destroy_func: a #GDestroyNotify function
+ * @user_data: some extra data to pass to the @destroy_func function
+ *
+ * Sets @destroy_func as the function to call when the surface @proxy
+ * was released. At this point, the proxy object is considered
+ * released, i.e. the underlying data storage is no longer valid and
+ * the callback function shall not expect anything from that.
+ */
+void
+gst_vaapi_surface_proxy_set_destroy_notify(GstVaapiSurfaceProxy *proxy,
+ GDestroyNotify destroy_func, gpointer user_data)
+{
+ g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
+
+ proxy->destroy_func = destroy_func;
+ proxy->destroy_data = user_data;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.h b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.h
index 467699da..ef8ee691 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.h
+++ b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.h
@@ -50,19 +50,16 @@ void
gst_vaapi_surface_proxy_replace(GstVaapiSurfaceProxy **old_proxy_ptr,
GstVaapiSurfaceProxy *new_proxy);
-gpointer
-gst_vaapi_surface_proxy_get_user_data(GstVaapiSurfaceProxy *proxy);
-
-void
-gst_vaapi_surface_proxy_set_user_data(GstVaapiSurfaceProxy *proxy,
- gpointer user_data, GDestroyNotify destroy_notify);
-
GstVaapiSurface *
gst_vaapi_surface_proxy_get_surface(GstVaapiSurfaceProxy *proxy);
GstVaapiID
gst_vaapi_surface_proxy_get_surface_id(GstVaapiSurfaceProxy *proxy);
+void
+gst_vaapi_surface_proxy_set_destroy_notify(GstVaapiSurfaceProxy *proxy,
+ GDestroyNotify destroy_func, gpointer user_data);
+
G_END_DECLS
#endif /* GST_VAAPI_SURFACE_PROXY_H */
diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c
index a12c0c81..f0e5654a 100644
--- a/gst/vaapi/gstvaapidecode.c
+++ b/gst/vaapi/gstvaapidecode.c
@@ -284,8 +284,8 @@ gst_vaapidecode_push_decoded_frames(GstVideoDecoder *vdec)
if (!GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY(out_frame)) {
proxy = gst_video_codec_frame_get_user_data(out_frame);
- gst_vaapi_surface_proxy_set_user_data(proxy,
- decode, (GDestroyNotify)gst_vaapidecode_release);
+ gst_vaapi_surface_proxy_set_destroy_notify(proxy,
+ (GDestroyNotify)gst_vaapidecode_release, decode);
#if GST_CHECK_VERSION(1,0,0)
ret = gst_video_decoder_allocate_output_frame(vdec, out_frame);
diff --git a/tests/simple-decoder.c b/tests/simple-decoder.c
index 04625a62..7e33f0c6 100644
--- a/tests/simple-decoder.c
+++ b/tests/simple-decoder.c
@@ -266,8 +266,8 @@ decoder_thread(gpointer data)
status = gst_vaapi_decoder_get_surface(app->decoder, &proxy);
switch (status) {
case GST_VAAPI_DECODER_STATUS_SUCCESS:
- gst_vaapi_surface_proxy_set_user_data(proxy,
- app, (GDestroyNotify)decoder_release);
+ gst_vaapi_surface_proxy_set_destroy_notify(proxy,
+ (GDestroyNotify)decoder_release, app);
rfp = render_frame_new();
if (!rfp)
SEND_ERROR("failed to allocate render frame");