summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>2009-07-03 05:06:45 -0400
committerWim Taymans <wim.taymans@collabora.co.uk>2009-07-14 18:44:21 +0200
commitb2e9f0a7c9123284b6a806a59b519f9e1e9f2392 (patch)
treef3b4a39aaa9a676088672a280ddd7ececb7c3277
parentb0643b745ae2b3a70c56bd206e6dfc8d8495a78e (diff)
pulsesink: Emit stream-status enter message
Emit stream-status messages for the pulse thread. Don't use our own GCond for signaling but simply use the pulse mainloop mechanisms for synchronisation. See #587695
-rw-r--r--ext/pulse/pulsesink.c30
-rw-r--r--ext/pulse/pulsesink.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index 5fea282f7..836e71f17 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -843,6 +843,27 @@ gst_pulseringbuffer_clear (GstRingBuffer * buf)
pa_threaded_mainloop_unlock (psink->mainloop);
}
+static void
+mainloop_enter_defer_cb (pa_mainloop_api * api, void *userdata)
+{
+ GstPulseSink *pulsesink = GST_PULSESINK (userdata);
+ GstMessage *message;
+ GValue val = { 0 };
+
+ g_value_init (&val, G_TYPE_POINTER);
+ g_value_set_pointer (&val, g_thread_self ());
+
+ GST_DEBUG_OBJECT (pulsesink, "posting ENTER stream status");
+ message = gst_message_new_stream_status (GST_OBJECT (pulsesink),
+ GST_STREAM_STATUS_TYPE_ENTER, GST_ELEMENT (pulsesink));
+ gst_message_set_stream_status_object (message, &val);
+ gst_element_post_message (GST_ELEMENT (pulsesink), message);
+
+ /* signal the waiter */
+ pulsesink->pa_defer_ran = TRUE;
+ pa_threaded_mainloop_signal (pulsesink->mainloop, 0);
+}
+
/* start/resume playback ASAP, we don't uncork here but in the commit method */
static gboolean
gst_pulseringbuffer_start (GstRingBuffer * buf)
@@ -854,6 +875,15 @@ gst_pulseringbuffer_start (GstRingBuffer * buf)
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
pa_threaded_mainloop_lock (psink->mainloop);
+
+ GST_DEBUG_OBJECT (psink, "scheduling stream status");
+ psink->pa_defer_ran = FALSE;
+ pa_mainloop_api_once (pa_threaded_mainloop_get_api (psink->mainloop),
+ mainloop_enter_defer_cb, psink);
+
+ while (psink->pa_defer_ran == FALSE)
+ pa_threaded_mainloop_wait (psink->mainloop);
+
GST_DEBUG_OBJECT (psink, "starting");
pbuf->paused = FALSE;
gst_pulsering_set_corked (pbuf, FALSE, FALSE);
diff --git a/ext/pulse/pulsesink.h b/ext/pulse/pulsesink.h
index cee17faf3..8db3cbd1a 100644
--- a/ext/pulse/pulsesink.h
+++ b/ext/pulse/pulsesink.h
@@ -64,6 +64,8 @@ struct _GstPulseSink
gint notify;
const gchar *pa_version;
+
+ gboolean pa_defer_ran;
};
struct _GstPulseSinkClass