All GstVaapiID are initialized to GST_VAAPI_ID_NONE by default.

Besides, all GstVaapiObject derived class shall initialize "id" to a valid value.
This commit is contained in:
gb 2010-03-24 17:38:23 +00:00
parent 0881507989
commit 9961c03c6a
8 changed files with 28 additions and 15 deletions

View file

@ -161,6 +161,8 @@ GST_VAAPI_VIDEO_BUFFER_GET_CLASS
GstVaapiID GstVaapiID
GST_VAAPI_ID_FORMAT GST_VAAPI_ID_FORMAT
GST_VAAPI_ID_ARGS GST_VAAPI_ID_ARGS
GST_VAAPI_ID
GST_VAAPI_ID_NONE
GstVaapiPoint GstVaapiPoint
GstVaapiRectangle GstVaapiRectangle
</SECTION> </SECTION>

View file

@ -444,6 +444,7 @@ gst_vaapi_image_new(
image = g_object_new( image = g_object_new(
GST_VAAPI_TYPE_IMAGE, GST_VAAPI_TYPE_IMAGE,
"display", display, "display", display,
"id", GST_VAAPI_ID(VA_INVALID_ID),
"format", format, "format", format,
"width", width, "width", width,
"height", height, "height", height,
@ -489,6 +490,7 @@ gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image)
image = g_object_new( image = g_object_new(
GST_VAAPI_TYPE_IMAGE, GST_VAAPI_TYPE_IMAGE,
"display", display, "display", display,
"id", GST_VAAPI_ID(va_image->image_id),
"image", va_image, "image", va_image,
NULL NULL
); );

View file

@ -24,7 +24,6 @@
*/ */
#include "config.h" #include "config.h"
#include "gstvaapicompat.h"
#include "gstvaapiobject.h" #include "gstvaapiobject.h"
#include "gstvaapiobject_priv.h" #include "gstvaapiobject_priv.h"
#include "gstvaapiparamspecs.h" #include "gstvaapiparamspecs.h"
@ -70,7 +69,7 @@ gst_vaapi_object_finalize(GObject *object)
{ {
GstVaapiObjectPrivate * const priv = GST_VAAPI_OBJECT(object)->priv; GstVaapiObjectPrivate * const priv = GST_VAAPI_OBJECT(object)->priv;
priv->id = VA_INVALID_ID; priv->id = GST_VAAPI_ID_NONE;
if (priv->display) { if (priv->display) {
g_object_unref(priv->display); g_object_unref(priv->display);
@ -163,7 +162,7 @@ gst_vaapi_object_class_init(GstVaapiObjectClass *klass)
gst_vaapi_param_spec_id("id", gst_vaapi_param_spec_id("id",
"ID", "ID",
"The GstVaapiID contained in this object", "The GstVaapiID contained in this object",
VA_INVALID_ID, GST_VAAPI_ID_NONE,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
/** /**
@ -191,7 +190,7 @@ gst_vaapi_object_init(GstVaapiObject *object)
object->priv = priv; object->priv = priv;
priv->display = NULL; priv->display = NULL;
priv->id = VA_INVALID_ID; priv->id = GST_VAAPI_ID_NONE;
priv->is_destroying = FALSE; priv->is_destroying = FALSE;
} }
@ -222,7 +221,7 @@ gst_vaapi_object_get_display(GstVaapiObject *object)
GstVaapiID GstVaapiID
gst_vaapi_object_get_id(GstVaapiObject *object) gst_vaapi_object_get_id(GstVaapiObject *object)
{ {
g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), VA_INVALID_ID); g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), GST_VAAPI_ID_NONE);
return object->priv->id; return object->priv->id;
} }

View file

@ -26,20 +26,13 @@
#include "config.h" #include "config.h"
#include "gstvaapiparamspecs.h" #include "gstvaapiparamspecs.h"
#include "gstvaapivalue.h" #include "gstvaapivalue.h"
#include "gstvaapicompat.h"
#ifdef GST_VAAPI_USE_OLD_VAAPI_0_29
# include <va.h>
#else
# include <va/va.h>
#endif
/* --- GstVaapiParamSpecID --- */ /* --- GstVaapiParamSpecID --- */
static void static void
gst_vaapi_param_id_init(GParamSpec *pspec) gst_vaapi_param_id_init(GParamSpec *pspec)
{ {
GST_VAAPI_PARAM_SPEC_ID(pspec)->default_value = VA_INVALID_ID; GST_VAAPI_PARAM_SPEC_ID(pspec)->default_value = GST_VAAPI_ID_NONE;
} }
static void static void

View file

@ -212,6 +212,7 @@ gst_vaapi_subpicture_new(GstVaapiImage *image)
return g_object_new(GST_VAAPI_TYPE_SUBPICTURE, return g_object_new(GST_VAAPI_TYPE_SUBPICTURE,
"display", GST_VAAPI_OBJECT_GET_DISPLAY(image), "display", GST_VAAPI_OBJECT_GET_DISPLAY(image),
"id", GST_VAAPI_ID(VA_INVALID_ID),
"image", image, "image", image,
NULL); NULL);
} }

View file

@ -298,6 +298,7 @@ gst_vaapi_surface_new(
return g_object_new(GST_VAAPI_TYPE_SURFACE, return g_object_new(GST_VAAPI_TYPE_SURFACE,
"display", display, "display", display,
"id", GST_VAAPI_ID(VA_INVALID_ID),
"width", width, "width", width,
"height", height, "height", height,
"chroma-type", chroma_type, "chroma-type", chroma_type,

View file

@ -48,6 +48,21 @@ typedef guint64 GstVaapiID;
# error "unsupported value for GST_VAAPI_TYPE_ID_SIZE" # error "unsupported value for GST_VAAPI_TYPE_ID_SIZE"
#endif #endif
/**
* GST_VAAPI_ID:
* @id: an arbitrary integer value
*
* Macro that creates a #GstVaapiID from @id.
*/
#define GST_VAAPI_ID(id) ((GstVaapiID)(id))
/**
* GST_VAAPI_ID_NONE:
*
* Macro that evaluates to the default #GstVaapiID value.
*/
#define GST_VAAPI_ID_NONE GST_VAAPI_ID(0)
/** /**
* GST_VAAPI_ID_FORMAT: * GST_VAAPI_ID_FORMAT:
* *

View file

@ -514,7 +514,7 @@ gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height)
return g_object_new(GST_VAAPI_TYPE_WINDOW_X11, return g_object_new(GST_VAAPI_TYPE_WINDOW_X11,
"display", display, "display", display,
"id", (GstVaapiID)None, "id", GST_VAAPI_ID(None),
"width", width, "width", width,
"height", height, "height", height,
NULL); NULL);
@ -542,7 +542,7 @@ gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid)
return g_object_new(GST_VAAPI_TYPE_WINDOW_X11, return g_object_new(GST_VAAPI_TYPE_WINDOW_X11,
"display", display, "display", display,
"id", (GstVaapiID)xid, "id", GST_VAAPI_ID(xid),
NULL); NULL);
} }