{
GMutex *glwin_lock;
GMutex *x_lock;
+ GCond *cond_x_event;
GCond *cond_send_message;
gboolean running;
g_mutex_unlock (priv->glwin_lock);
g_mutex_unlock (priv->x_lock);
+
if (priv->cond_send_message)
+ {
g_cond_free (priv->cond_send_message);
+ priv->cond_send_message = NULL;
+ }
if (priv->x_lock)
+ {
g_mutex_free (priv->x_lock);
+ priv->x_lock = NULL;
+ }
+
+ if (priv->cond_x_event)
+ {
+ g_cond_free (priv->cond_x_event);
+ priv->cond_x_event = NULL;
+ }
if (priv->glwin_lock)
+ {
g_mutex_free (priv->glwin_lock);
+ priv->glwin_lock = NULL;
+ }
G_OBJECT_CLASS (gst_gl_window_parent_class)->finalize (object);
priv->glwin_lock = g_mutex_new ();
priv->x_lock = g_mutex_new ();
+ priv->cond_x_event = g_cond_new ();
priv->cond_send_message = g_cond_new ();
priv->running = TRUE;
XSync(priv->device, FALSE);
+ g_cond_signal (priv->cond_x_event);
+
g_mutex_unlock (priv->x_lock);
}
XSendEvent (priv->device, priv->internal_win_id, FALSE, ExposureMask, &event);
+ XSync (priv->device, FALSE);
+
+ g_cond_signal (priv->cond_x_event);
+
g_mutex_unlock (priv->x_lock);
}
while (priv->running)
{
+ gboolean running = priv->running;
g_mutex_unlock (priv->glwin_lock);
while (XPending (priv->device))
{
+
XEvent event;
XNextEvent(priv->device, &event);
if (event.xclient.message_type == priv->atom_custom)
{
-
- if (priv->running)
+ if (running)
{
GstGLWindowCB custom_cb = (GstGLWindowCB) event.xclient.data.l[0];
gpointer custom_data = (gpointer) event.xclient.data.l[1];
g_debug ("Close\n");
- priv->running = FALSE;
+ g_mutex_lock (priv->glwin_lock);
+ running = priv->running = FALSE;
+ g_mutex_unlock (priv->glwin_lock);
+
if (priv->close_cb)
priv->close_cb (priv->close_data);
}// while XPending
- g_mutex_unlock (priv->x_lock);
+ g_debug ("wait loop\n");
+ if (running && !XPending (priv->device))
+ g_cond_wait (priv->cond_x_event, priv->x_lock);
+ g_debug ("wake loop\n");
- g_usleep (10000);
+ g_mutex_unlock (priv->x_lock);
g_mutex_lock (priv->glwin_lock);
priv->running = FALSE;
+ g_cond_signal (priv->cond_x_event);
+
g_mutex_unlock (priv->glwin_lock);
}
g_debug ("QUIT LOOP OUT\n");
XSendEvent (priv->device, priv->internal_win_id, FALSE, NoEventMask, &event);
XFlush (priv->device);
+ XSync (priv->device, FALSE);
g_mutex_unlock (priv->x_lock);
+ g_cond_signal (priv->cond_x_event);
+
+ g_debug("signal\n");
+
g_cond_wait (priv->cond_send_message, priv->glwin_lock);
+
}
g_mutex_unlock (priv->glwin_lock);