pa_threaded_mainloop_unlock (mainloop);
}
+/* called from pulse with the mainloop lock */
static void
mainloop_enter_defer_cb (pa_mainloop_api * api, void *userdata)
{
gst_element_post_message (GST_ELEMENT (pulsesink), message);
- /* signal the waiter */
+ g_return_if_fail (pulsesink->defer_pending);
+ pulsesink->defer_pending--;
pa_threaded_mainloop_signal (mainloop, 0);
}
pa_threaded_mainloop_lock (mainloop);
GST_DEBUG_OBJECT (psink, "scheduling stream status");
+ psink->defer_pending++;
pa_mainloop_api_once (pa_threaded_mainloop_get_api (mainloop),
mainloop_enter_defer_cb, psink);
return res;
}
+/* called from pulse with the mainloop lock */
static void
mainloop_leave_defer_cb (pa_mainloop_api * api, void *userdata)
{
gst_message_set_stream_status_object (message, &val);
gst_element_post_message (GST_ELEMENT (pulsesink), message);
+ g_return_if_fail (pulsesink->defer_pending);
+ pulsesink->defer_pending--;
pa_threaded_mainloop_signal (mainloop, 0);
- gst_object_unref (pulsesink);
}
/* stop playback, we flush everything. */
}
GST_DEBUG_OBJECT (psink, "scheduling stream status");
- gst_object_ref (psink);
+ psink->defer_pending++;
pa_mainloop_api_once (pa_threaded_mainloop_get_api (mainloop),
mainloop_leave_defer_cb, psink);
if (!mainloop)
return;
+ pa_threaded_mainloop_lock (mainloop);
+ while (psink->defer_pending) {
+ GST_DEBUG_OBJECT (psink, "waiting for stream status message emission");
+ pa_threaded_mainloop_wait (mainloop);
+ }
+ pa_threaded_mainloop_unlock (mainloop);
+
g_mutex_lock (pa_shared_resource_mutex);
mainloop_ref_ct--;
if (!mainloop_ref_ct) {