A detail of GStreamer bus

Source: Internet
Author: User
Tags mutex gstreamer

GStreamer bus system is mainly used to provide users with internal elements event information. Using the GStreamer bus system, just call Gst_bus_add_watch and register a callback. The problem, however, is when the interface is invoked, and the thread used to handle the bus event. The callback is implemented internally with the glib source mechanism, and the source is attach to a gmaincontext, and a gmainloop is needed to listen to the context. Typically, the thread that calls Gst_bus_add_watch, without any processing, is null for the source attach Gmaincontext, which is the default Main context. The thread that listens to the default Main context is not necessarily the caller thread, so there is a multi-threaded mutex problem when the resource is reclaimed.

The method that requires the callback function to execute in the caller thread is as follows:

1. After creating the caller thread, create the thread's own gmaincontext and Gmainloop, and then call G_main_context_push_thread_default, which is the thread's own default context, and use Gmainloop to listen;

2. After calling Gst_bus_add_watch in the thread, the callback is executed in the caller thread, avoiding the problem of multi-threaded mutex.

This method avoids the problem that the main thread of the application is overburdened. In addition, all GIO-based applications also use G_main_context_push_thread_default to disperse the load on each thread.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.