maincontext: Add a way to remove all currently attached sources by user_data in a thread safe way.
@thiblahute
Submitted by Thibault Saunier Link to original bug (#732116)
Description
It looks like currently there is no easy way to "clean up" a GMainContext from all the sources that have been attached to it. In the new GstAggregator[0] base class, we needed that feature and to do so we ended up creating a dedicated mutex protecting the maincontext in order to make sure that we do not end up adding a source right in time we are actually removing all the others, (which would leads to "g_source_attach: assertion '!SOURCE_DESTROYED (source)' failed").
We might have missed something but looking at the API it looked like the best solution right now.
Adding such a feature would make our code simpler, and avoid having 2 Mutexes that do mostly the same thing (as GMainContext also as its own mutex) which is not great performance-wise.
[0] http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/gst-libs/gst/base/gstaggregator.c