From ccda7615621f8b1e882d1ce4890923f5198eaf09 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 14 Sep 2009 16:05:30 +0200 Subject: pulsesink: handle stream events Handle stream events and request a PAUSE/PLAY state change from the application when we receive a CORK/UNCORK event. --- ext/pulse/pulsesink.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'ext') 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. */ -- cgit