Add "synchronous" mode.

This commit is contained in:
gb 2010-03-26 11:30:54 +00:00
parent 15b2a9beec
commit 8ea56134da
3 changed files with 65 additions and 2 deletions

View file

@ -40,15 +40,17 @@ G_DEFINE_TYPE(GstVaapiDisplayX11,
GstVaapiDisplayX11Private))
struct _GstVaapiDisplayX11Private {
gboolean create_display;
gchar *display_name;
Display *x11_display;
int x11_screen;
guint create_display : 1;
guint synchronous : 1;
};
enum {
PROP_0,
PROP_SYNCHRONOUS,
PROP_DISPLAY_NAME,
PROP_X11_DISPLAY
};
@ -72,6 +74,18 @@ set_display_name(GstVaapiDisplayX11 *display, const gchar *display_name)
priv->display_name = NULL;
}
static void
set_synchronous(GstVaapiDisplayX11 *display, gboolean synchronous)
{
GstVaapiDisplayX11Private * const priv = display->priv;
if (priv->synchronous != synchronous) {
priv->synchronous = synchronous;
if (priv->x11_display)
XSynchronize(priv->x11_display, synchronous);
}
}
static void
gst_vaapi_display_x11_set_property(
GObject *object,
@ -83,6 +97,9 @@ gst_vaapi_display_x11_set_property(
GstVaapiDisplayX11 * const display = GST_VAAPI_DISPLAY_X11(object);
switch (prop_id) {
case PROP_SYNCHRONOUS:
set_synchronous(display, g_value_get_boolean(value));
break;
case PROP_DISPLAY_NAME:
set_display_name(display, g_value_get_string(value));
break;
@ -106,6 +123,9 @@ gst_vaapi_display_x11_get_property(
GstVaapiDisplayX11 * const display = GST_VAAPI_DISPLAY_X11(object);
switch (prop_id) {
case PROP_SYNCHRONOUS:
g_value_set_boolean(value, display->priv->synchronous);
break;
case PROP_DISPLAY_NAME:
g_value_set_string(value, display->priv->display_name);
break;
@ -147,6 +167,9 @@ gst_vaapi_display_x11_open_display(GstVaapiDisplay *display)
if (!priv->x11_display)
return FALSE;
if (priv->synchronous)
XSynchronize(priv->x11_display, True);
priv->x11_screen = DefaultScreen(priv->x11_display);
return TRUE;
}
@ -234,6 +257,21 @@ gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
dpy_class->get_size = gst_vaapi_display_x11_get_size;
dpy_class->get_size_mm = gst_vaapi_display_x11_get_size_mm;
/**
* GstVaapiDisplayX11:synchronous:
*
* When enabled, runs the X display in synchronous mode. Note that
* this is used only for debugging.
*/
g_object_class_install_property
(object_class,
PROP_SYNCHRONOUS,
g_param_spec_boolean("synchronous",
"Synchronous mode",
"Toggles X display synchronous mode",
FALSE,
G_PARAM_READWRITE));
/**
* GstVaapiDisplayX11:x11-display:
*

View file

@ -74,7 +74,8 @@ enum {
PROP_0,
PROP_DISPLAY,
PROP_FULLSCREEN
PROP_FULLSCREEN,
PROP_SYNCHRONOUS
};
static GstVaapiDisplay *
@ -120,6 +121,7 @@ gst_vaapisink_ensure_display(GstVaapiSink *sink)
sink->display = gst_vaapi_display_x11_new(sink->display_name);
if (!sink->display || !gst_vaapi_display_get_display(sink->display))
return FALSE;
g_object_set(sink, "synchronous", sink->synchronous, NULL);
}
return sink->display != NULL;
}
@ -291,6 +293,9 @@ gst_vaapisink_set_property(
case PROP_FULLSCREEN:
sink->fullscreen = g_value_get_boolean(value);
break;
case PROP_SYNCHRONOUS:
sink->synchronous = g_value_get_boolean(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@ -314,6 +319,9 @@ gst_vaapisink_get_property(
case PROP_FULLSCREEN:
g_value_set_boolean(value, sink->fullscreen);
break;
case PROP_SYNCHRONOUS:
g_value_set_boolean(value, sink->synchronous);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@ -364,6 +372,21 @@ static void gst_vaapisink_class_init(GstVaapiSinkClass *klass)
"Requests window in fullscreen state",
FALSE,
G_PARAM_READWRITE));
/**
* GstVaapiSink:synchronous:
*
* When enabled, runs the X display in synchronous mode. Note that
* this is used only for debugging.
*/
g_object_class_install_property
(object_class,
PROP_SYNCHRONOUS,
g_param_spec_boolean("synchronous",
"Synchronous mode",
"Toggles X display synchronous mode",
FALSE,
G_PARAM_READWRITE));
}
static void gst_vaapisink_init(GstVaapiSink *sink, GstVaapiSinkClass *klass)
@ -371,6 +394,7 @@ static void gst_vaapisink_init(GstVaapiSink *sink, GstVaapiSinkClass *klass)
sink->display_name = NULL;
sink->display = NULL;
sink->fullscreen = FALSE;
sink->synchronous = FALSE;
}
GstVaapiDisplay *

View file

@ -64,6 +64,7 @@ struct _GstVaapiSink {
GstVaapiWindow *window;
GstVaapiRectangle window_rect;
guint fullscreen : 1;
guint synchronous : 1;
};
struct _GstVaapiSinkClass {