Resend: g_idle_add patch proposal
- From: Roland Peffer <gdevel clixxun com>
 
- To: grilo-list gnome org
 
- Subject: Resend: g_idle_add patch proposal
 
- Date: Sat, 25 May 2013 08:38:24 +0200
 
As I did not get any answers I just resend my last proposal.
On 21.05.2013, at 20:43, Roland Peffer wrote:
Hi
I noticed that when I tried to resolve an url of an url media object from vimeo or youtube my program often 
got frozen for a few seconds.
After stepping through the code I realized that the idle functions called by g_add_idle and  g_add_idle_full 
in grl-source.c and other parts ended up in blocking functions like curl_perform_easy.
At least the  clutter_stage repainting sources also running on the same GMainContext got blocked that way.
I found a workaround for that that should not change the normal behavior:
I added our own grl_idle_add /grl_idle_add_full functions in grl-util.h/.c that behave exactly the same like 
the glib implementations,
except if a GMainContext was created in a separate thread and activated by 
g_main_context_push_thread_default(thread_context);,
then calling grl_resolve or other grill operations from that thread will not block the Default Main Context 
anymore.
Here is what I did: 
1) Change g_idle_add and  grl_idle_add_full in every grilo file  in the libray an d plugin section like 
grilo-0.2.6/src/grl-source.c
grilo-plugins-0.2.7/src/vimeo/gvimeo.c
grilo-plugins-0.2.7/src/apple-trailers/grl-apple-trailers.c
etc. ( just search for it )
Then add these snippets to 
grl-util.h: -------------------------------------------
guint
grl_idle_add_full (gint            priority,
                GSourceFunc     function,
                gpointer        data,
                GDestroyNotify  notify);
guint
grl_idle_add  (GSourceFunc     function,
              gpointer        data);
and grl-util.c:--------------------------------------------
guint
grl_idle_add_full (gint            priority,
                GSourceFunc     function,
                gpointer        data,
                GDestroyNotify  notify)
{
 GSource *source;
 guint id;
 GMainContext *main_context =
     g_main_context_get_thread_default();
 g_return_val_if_fail (function != NULL, 0);
 source = g_idle_source_new ();
 if (priority != G_PRIORITY_DEFAULT_IDLE)
   g_source_set_priority (source, priority);
 g_source_set_callback (source, function, data, notify);
 id = g_source_attach (source, main_context);
 g_source_unref (source);
 return id;
}
guint
grl_idle_add  (GSourceFunc     function,
            gpointer        data)
{
 return grl_idle_add_full(G_PRIORITY_DEFAULT_IDLE,function,data, NULL);
}
--------------------------------------------
Now the software works smooth without any glitches!
I hope you can add this for the next release!
Roland
_______________________________________________
grilo-list mailing list
grilo-list gnome org
https://mail.gnome.org/mailman/listinfo/grilo-list
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]