summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-09-14 16:05:30 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-09-14 16:05:30 +0200
commitccda7615621f8b1e882d1ce4890923f5198eaf09 (patch)
treeeb83731700c9e503c74a7e42452f563376dfef7d /ext
parent78eeb6636e3e8297a9d739c8dd1196f57f91a085 (diff)
pulsesink: handle stream events
Handle stream events and request a PAUSE/PLAY state change from the application when we receive a CORK/UNCORK event.
Diffstat (limited to 'ext')
-rw-r--r--ext/pulse/pulsesink.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index 0501dd1f..9b3b1d4d 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -559,6 +559,35 @@ gst_pulsering_stream_latency_cb (pa_stream * s, void *userdata)
info->sink_usec, sink_usec);
}
+#if HAVE_PULSE_0_9_15
+static void
+gst_pulsering_stream_event_cb (pa_stream * p, const char *name,
+ pa_proplist * pl, void *userdata)
+{
+ GstPulseSink *psink;
+ GstPulseRingBuffer *pbuf;
+
+ pbuf = GST_PULSERING_BUFFER_CAST (userdata);
+ psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
+
+ if (!strcmp (name, PA_STREAM_EVENT_REQUEST_CORK)) {
+ /* the stream wants to PAUSE, post a message for the application. */
+ GST_DEBUG_OBJECT (psink, "got request for CORK");
+ gst_element_post_message (GST_ELEMENT_CAST (psink),
+ gst_message_new_request_state (GST_OBJECT_CAST (psink),
+ GST_STATE_PAUSED));
+
+ } else if (!strcmp (name, PA_STREAM_EVENT_REQUEST_UNCORK)) {
+ GST_DEBUG_OBJECT (psink, "got request for UNCORK");
+ gst_element_post_message (GST_ELEMENT_CAST (psink),
+ gst_message_new_request_state (GST_OBJECT_CAST (psink),
+ GST_STATE_PLAYING));
+ } else {
+ GST_DEBUG_OBJECT (psink, "got unknown event %s", name);
+ }
+}
+#endif
+
/* This method should create a new stream of the given @spec. No playback should
* start yet so we start in the corked state. */
static gboolean
@@ -623,6 +652,10 @@ gst_pulseringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
gst_pulsering_stream_overflow_cb, pbuf);
pa_stream_set_latency_update_callback (pbuf->stream,
gst_pulsering_stream_latency_cb, pbuf);
+#if HAVE_PULSE_0_9_15
+ pa_stream_set_event_callback (pbuf->stream,
+ gst_pulsering_stream_event_cb, pbuf);
+#endif
/* buffering requirements. When setting prebuf to 0, the stream will not pause
* when we cause an underrun, which causes time to continue. */