summaryrefslogtreecommitdiffstats
path: root/ext/pulse
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-06-29 15:20:31 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-06-29 15:21:37 +0200
commit1e98580204663cd816d53277247aff9fc7ce4f0a (patch)
treeb4738f1c1c84cc43c5f889da6576581fca787b43 /ext/pulse
parent9ab7cfd976af5f0a74c9cf5d70914314ea60975f (diff)
pulsesink: clear ringbuffer when asked to
Since we map the ringbuffer to the pulseaudio internal ringbuffer, flush the pulseaudio buffer when we are asked to clear the ringbuffer. This avoids some leftover audio after a seek.
Diffstat (limited to 'ext/pulse')
-rw-r--r--ext/pulse/pulsesink.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index f30abf04..a261c1eb 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -132,6 +132,7 @@ static gboolean gst_pulseringbuffer_release (GstRingBuffer * buf);
static gboolean gst_pulseringbuffer_start (GstRingBuffer * buf);
static gboolean gst_pulseringbuffer_pause (GstRingBuffer * buf);
static gboolean gst_pulseringbuffer_stop (GstRingBuffer * buf);
+static void gst_pulseringbuffer_clear (GstRingBuffer * buf);
static guint gst_pulseringbuffer_commit (GstRingBuffer * buf,
guint64 * sample, guchar * data, gint in_samples, gint out_samples,
gint * accum);
@@ -188,6 +189,8 @@ gst_pulseringbuffer_class_init (GstPulseRingBufferClass * klass)
gstringbuffer_class->pause = GST_DEBUG_FUNCPTR (gst_pulseringbuffer_pause);
gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_pulseringbuffer_start);
gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_pulseringbuffer_stop);
+ gstringbuffer_class->clear_all =
+ GST_DEBUG_FUNCPTR (gst_pulseringbuffer_clear);
gstringbuffer_class->commit = GST_DEBUG_FUNCPTR (gst_pulseringbuffer_commit);
@@ -798,6 +801,26 @@ cork_failed:
}
}
+static void
+gst_pulseringbuffer_clear (GstRingBuffer * buf)
+{
+ GstPulseSink *psink;
+ GstPulseRingBuffer *pbuf;
+ pa_operation *o = NULL;
+
+ pbuf = GST_PULSERING_BUFFER_CAST (buf);
+ psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
+
+ pa_threaded_mainloop_lock (psink->mainloop);
+ GST_DEBUG_OBJECT (psink, "clearing");
+ if (pbuf->stream) {
+ /* don't wait for the flush to complete */
+ if ((o = pa_stream_flush (pbuf->stream, NULL, pbuf)))
+ pa_operation_unref (o);
+ }
+ pa_threaded_mainloop_unlock (psink->mainloop);
+}
+
/* start/resume playback ASAP, we don't uncork here but in the commit method */
static gboolean
gst_pulseringbuffer_start (GstRingBuffer * buf)