[gst-devel] running g_main_loop_run in separate thread question.

Nicholas Panayis dime at dimebar.f2s.com
Wed Mar 24 15:59:22 CET 2010


Hi,

Why not use:
  gst_bus_enable_sync_message_emission(bus);
  gst_bus_set_sync_handler(bus, (GstBusSyncHandler) my_sync_handler, 
&my_var);
  gst_object_unref(bus);

?

Dime


Edward Hervey wrote:
> On Wed, 2010-03-24 at 06:29 -0800, wanting2learn wrote:
>   
>> I have the following code:
>>     
> [...]
>   
>> int main()
>> {
>>
>>      start_pipeline();
>>
>>      while(1)
>>      {
>>         //do stuff here
>>      }
>>
>>      //blah blah
>> }
>>
>> Now my pipeline runs fine but I have kicked off a new thread to handle the
>> bus messages:
>> boost::thread thread_gstreamer2(task_gstreamer);
>>
>> void task_gstreamer()
>> {
>>    g_main_loop_run (g_Loop); 
>> }
>>
>>
>> The reason I have added this in a new thread is because of the while(1) loop
>> in my main() function.  If I put the g_main_loop_run in my main() before my
>> while(1) loop then it would block.
>> But the problem is that I do not receive any bus messages at all when I
>> implement it like this.  
>> Can I do it this way?? 
>>
>>
>>     
>
>  I don't get it... why are you asking again and again about the same
> question ? Tim replied to you a week ago how to handle bus messages when
> you already have a main loop yet your persist in wanting to add a
> GMainLoop.
>
>   So, to summarize:
>   1) DO NOT USE GMAINLOOP IF YOU ALREADY HAVE A MAIN LOOP
>   2) Read 1) again at least 50 times times
>   3) Do as follow in your main()
>
> int main()
> {
>
>      start_pipeline();
>
>      while(1)
>      {
>         // Do stuff here
>         // See if we have pending messages on the bus and handle them
>         while ((msg = gst_bus_pop (g_bus))) {
>           // Call your bus message handler
>           bus_call (g_bus, msg, nada);
>           gst_message_unref (msg);
>         } 
>      }
>
>      // Stuff before we exit the application
> }
>
>   4) DO NOT USE GMAINLOOP IF YOU ALREADY HAVE A MAIN LOOP
>
> Also : http://en.wikipedia.org/wiki/Event_loop will be an interesting
> read if you still see a difference between GMainLoop and "Main Loop"
>
>    Now, start2digest
>
>     Edward
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>   





More information about the gstreamer-devel mailing list