Add gst_vaapi_display_{sync,flush}() helpers.

This commit is contained in:
gb 2010-03-26 11:35:20 +00:00
parent 8ea56134da
commit 9f369020b5
4 changed files with 84 additions and 4 deletions

View file

@ -133,6 +133,8 @@ GstVaapiDisplayClass
gst_vaapi_display_new_with_display
gst_vaapi_display_lock
gst_vaapi_display_unlock
gst_vaapi_display_sync
gst_vaapi_display_flush
gst_vaapi_display_get_display
gst_vaapi_display_get_width
gst_vaapi_display_get_height

View file

@ -48,10 +48,10 @@ struct _GstVaapiDisplayPrivate {
guint height_mm;
guint par_n;
guint par_d;
gboolean create_display;
GArray *profiles;
GArray *image_formats;
GArray *subpicture_formats;
guint create_display : 1;
};
enum {
@ -504,10 +504,10 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
priv->height_mm = 0;
priv->par_n = 1;
priv->par_d = 1;
priv->create_display = TRUE;
priv->profiles = NULL;
priv->image_formats = NULL;
priv->subpicture_formats = NULL;
priv->create_display = TRUE;
g_static_mutex_init(&priv->mutex);
}
@ -569,6 +569,52 @@ gst_vaapi_display_unlock(GstVaapiDisplay *display)
klass->unlock(display);
}
/**
* gst_vaapi_display_sync:
* @display: a #GstVaapiDisplay
*
* Flushes any requests queued for the windowing system and waits until
* all requests have been handled. This is often used for making sure
* that the display is synchronized with the current state of the program.
*
* This is most useful for X11. On windowing systems where requests are
* handled synchronously, this function will do nothing.
*/
void
gst_vaapi_display_sync(GstVaapiDisplay *display)
{
GstVaapiDisplayClass *klass;
g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
if (klass->sync)
klass->sync(display);
else if (klass->flush)
klass->flush(display);
}
/**
* gst_vaapi_display_sync:
* @display: a #GstVaapiDisplay
*
* Flushes any requests queued for the windowing system.
*
* This is most useful for X11. On windowing systems where requests
* are handled synchronously, this function will do nothing.
*/
void
gst_vaapi_display_flush(GstVaapiDisplay *display)
{
GstVaapiDisplayClass *klass;
g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
if (klass->flush)
klass->flush(display);
}
/**
* gst_vaapi_display_get_display:
* @display: a #GstVaapiDisplay

View file

@ -103,8 +103,10 @@ struct _GstVaapiDisplay {
* GstVaapiDisplayClass:
* @open_display: virtual function to open a display
* @close_display: virtual function to close a display
* @lock: virtual function to lock a display
* @unlock: virtual function to unlock a display
* @lock: (optional) virtual function to lock a display
* @unlock: (optional) virtual function to unlock a display
* @sync: (optional) virtual function to sync a display
* @flush: (optional) virtual function to flush pending requests of a display
* @get_display: virtual function to retrieve the #VADisplay
* @get_size: virtual function to retrieve the display dimensions, in pixels
* @get_size_mm: virtual function to retrieve the display dimensions, in millimeters
@ -120,6 +122,8 @@ struct _GstVaapiDisplayClass {
void (*close_display) (GstVaapiDisplay *display);
void (*lock) (GstVaapiDisplay *display);
void (*unlock) (GstVaapiDisplay *display);
void (*sync) (GstVaapiDisplay *display);
void (*flush) (GstVaapiDisplay *display);
VADisplay (*get_display) (GstVaapiDisplay *display);
void (*get_size) (GstVaapiDisplay *display,
guint *pwidth, guint *pheight);
@ -139,6 +143,12 @@ gst_vaapi_display_lock(GstVaapiDisplay *display);
void
gst_vaapi_display_unlock(GstVaapiDisplay *display);
void
gst_vaapi_display_sync(GstVaapiDisplay *display);
void
gst_vaapi_display_flush(GstVaapiDisplay *display);
VADisplay
gst_vaapi_display_get_display(GstVaapiDisplay *display);

View file

@ -192,6 +192,26 @@ gst_vaapi_display_x11_close_display(GstVaapiDisplay *display)
}
}
static void
gst_vaapi_display_x11_sync(GstVaapiDisplay *display)
{
GstVaapiDisplayX11Private * const priv =
GST_VAAPI_DISPLAY_X11(display)->priv;
if (priv->x11_display)
XSync(priv->x11_display, False);
}
static void
gst_vaapi_display_x11_flush(GstVaapiDisplay *display)
{
GstVaapiDisplayX11Private * const priv =
GST_VAAPI_DISPLAY_X11(display)->priv;
if (priv->x11_display)
XFlush(priv->x11_display);
}
static VADisplay
gst_vaapi_display_x11_get_va_display(GstVaapiDisplay *display)
{
@ -253,6 +273,8 @@ gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
dpy_class->open_display = gst_vaapi_display_x11_open_display;
dpy_class->close_display = gst_vaapi_display_x11_close_display;
dpy_class->sync = gst_vaapi_display_x11_sync;
dpy_class->flush = gst_vaapi_display_x11_flush;
dpy_class->get_display = gst_vaapi_display_x11_get_va_display;
dpy_class->get_size = gst_vaapi_display_x11_get_size;
dpy_class->get_size_mm = gst_vaapi_display_x11_get_size_mm;