Ejemplo n.º 1
0
void h2o_cache_release(h2o_cache_t *cache, h2o_cache_ref_t *ref)
{
    if (__sync_fetch_and_sub(&ref->_refcnt, 1) == 1) {
        assert(!h2o_linklist_is_linked(&ref->_lru_link));
        assert(!h2o_linklist_is_linked(&ref->_age_link));
        if (cache->destroy_cb != NULL)
            cache->destroy_cb(ref->value);
        free(ref->key.base);
        free(ref);
    }
}
Ejemplo n.º 2
0
static void
search_completed (DialogData *data)
{
	char *text;

	data->searching = FALSE;
	gtk_widget_set_sensitive (GET_WIDGET ("cancel_search_button"), FALSE);
	text = g_strdup_printf ("%u", data->total_files);
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("progress_label")), text);

	g_free (text);

	if (data->destroy)
		destroy_cb (NULL, data);
}
Ejemplo n.º 3
0
/* Called in the gl thread */
void
gst_gl_window_run_loop (GstGLWindow * window)
{
  GstGLWindowPrivate *priv = window->priv;

  g_debug ("begin loop\n");

  g_mutex_lock (priv->x_lock);

  while (priv->running) {
    XEvent event;
    XEvent pending_event;

    g_mutex_unlock (priv->x_lock);

    /* XSendEvent (which are called in other threads) are done from another display structure */
    XNextEvent (priv->device, &event);

    g_mutex_lock (priv->x_lock);

    // use in generic/cube and other related uses
    priv->allow_extra_expose_events = XPending (priv->device) <= 2;

    switch (event.type) {
      case ClientMessage:
      {

        Atom wm_delete = XInternAtom (priv->device, "WM_DELETE_WINDOW", True);
        Atom wm_gl = XInternAtom (priv->device, "WM_GL_WINDOW", True);
        Atom wm_quit_loop = XInternAtom (priv->device, "WM_QUIT_LOOP", True);

        if (wm_delete == None)
          g_debug ("Cannot create WM_DELETE_WINDOW\n");
        if (wm_gl == None)
          g_debug ("Cannot create WM_GL_WINDOW\n");
        if (wm_quit_loop == None)
          g_debug ("Cannot create WM_QUIT_LOOP\n");

        /* Message sent with gst_gl_window_send_message */
        if (wm_gl != None && event.xclient.message_type == wm_gl) {
          if (priv->running) {
#if SIZEOF_VOID_P == 8
            GstGLWindowCB custom_cb =
                (GstGLWindowCB) (((event.xclient.data.
                        l[0] & 0xffffffff) << 32) | (event.xclient.data.
                    l[1] & 0xffffffff));
            gpointer custom_data =
                (gpointer) (((event.xclient.data.
                        l[2] & 0xffffffff) << 32) | (event.xclient.data.
                    l[3] & 0xffffffff));
#else
            GstGLWindowCB custom_cb = (GstGLWindowCB) event.xclient.data.l[0];
            gpointer custom_data = (gpointer) event.xclient.data.l[1];
#endif

            if (!custom_cb || !custom_data)
              g_debug ("custom cb not initialized\n");

            custom_cb (custom_data);
          }

          g_cond_signal (priv->cond_send_message);
        }

        /* User clicked on the cross */
        else if (wm_delete != None
            && (Atom) event.xclient.data.l[0] == wm_delete) {
          g_debug ("Close %lud\n", (gulong) priv->internal_win_id);

          if (priv->close_cb)
            priv->close_cb (priv->close_data);

          priv->draw_cb = NULL;
          priv->draw_data = NULL;
          priv->resize_cb = NULL;
          priv->resize_data = NULL;
          priv->close_cb = NULL;
          priv->close_data = NULL;
        }

        /* message sent with gst_gl_window_quit_loop */
        else if (wm_quit_loop != None
            && event.xclient.message_type == wm_quit_loop) {
#if SIZEOF_VOID_P == 8
          GstGLWindowCB destroy_cb =
              (GstGLWindowCB) (((event.xclient.data.
                      l[0] & 0xffffffff) << 32) | (event.xclient.data.
                  l[1] & 0xffffffff));
          gpointer destroy_data =
              (gpointer) (((event.xclient.data.
                      l[2] & 0xffffffff) << 32) | (event.xclient.data.
                  l[3] & 0xffffffff));
#else
          GstGLWindowCB destroy_cb = (GstGLWindowCB) event.xclient.data.l[0];
          gpointer destroy_data = (gpointer) event.xclient.data.l[1];
#endif

          g_debug ("Quit loop message %lud\n", (gulong) priv->internal_win_id);

          /* exit loop */
          priv->running = FALSE;

          /* make sure last pendings send message calls are executed */
          XFlush (priv->device);
          while (XCheckTypedEvent (priv->device, ClientMessage, &pending_event)) {
#if SIZEOF_VOID_P == 8
            GstGLWindowCB custom_cb =
                (GstGLWindowCB) (((event.xclient.data.
                        l[0] & 0xffffffff) << 32) | (event.xclient.data.
                    l[1] & 0xffffffff));
            gpointer custom_data =
                (gpointer) (((event.xclient.data.
                        l[2] & 0xffffffff) << 32) | (event.xclient.data.
                    l[3] & 0xffffffff));
#else
            GstGLWindowCB custom_cb = (GstGLWindowCB) event.xclient.data.l[0];
            gpointer custom_data = (gpointer) event.xclient.data.l[1];
#endif
            g_debug ("execute last pending custom x events\n");

            if (!custom_cb || !custom_data)
              g_debug ("custom cb not initialized\n");

            custom_cb (custom_data);

            g_cond_signal (priv->cond_send_message);
          }

          /* Finally we can destroy opengl ressources (texture/shaders/fbo) */
          if (!destroy_cb || !destroy_data)
            g_debug ("destroy cb not correclty set\n");

          destroy_cb (destroy_data);

        } else
          g_debug ("client message not reconized \n");
        break;
      }

      case CreateNotify:
      case ConfigureNotify:
      {
        if (priv->resize_cb)
          priv->resize_cb (priv->resize_data, event.xconfigure.width,
              event.xconfigure.height);
        break;
      }

      case DestroyNotify:
        g_debug ("DestroyNotify\n");
        break;

      case Expose:
        if (priv->draw_cb) {
          priv->draw_cb (priv->draw_data);
          glFlush ();
          eglSwapBuffers (priv->gl_display, priv->gl_surface);
        }
        break;

      case VisibilityNotify:
      {
        switch (event.xvisibility.state) {
          case VisibilityUnobscured:
            if (priv->draw_cb)
              priv->draw_cb (priv->draw_data);
            break;

          case VisibilityPartiallyObscured:
            if (priv->draw_cb)
              priv->draw_cb (priv->draw_data);
            break;

          case VisibilityFullyObscured:
            break;

          default:
            g_debug ("unknown xvisibility event: %d\n",
                event.xvisibility.state);
            break;
        }
        break;
      }

      default:
        g_debug ("unknow\n");
        break;

    }                           // switch

  }                             // while running

  g_mutex_unlock (priv->x_lock);

  g_debug ("end loop\n");
}