diff options
author | Stefan Kost <ensonic@users.sf.net> | 2009-04-10 21:42:13 +0300 |
---|---|---|
committer | Stefan Kost <ensonic@users.sf.net> | 2009-04-10 21:42:13 +0300 |
commit | b3d66d5e8df0287cdc684eb3bbcbb539b3a786c0 (patch) | |
tree | 36ab43c9e436634b3015af4b7996cadbd01c3c80 | |
parent | 963b343548b0da29dc7f4f28db76b74c431d53fc (diff) |
pulse: make it work on 0.9.12
First we ignore request to fill the ringbuffer which are less then a segment.
The small request where causing stutter.
Then we disable flushing the stream when running against pa 0.9.12 as this
triggers an assertiong in the sound server and terminates it. It does not happen
with 0.9.10 and 0.9.14.
-rw-r--r-- | ext/pulse/pulsesink.c | 32 | ||||
-rw-r--r-- | ext/pulse/pulsesink.h | 2 |
2 files changed, 22 insertions, 12 deletions
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index 48bd7f2f2..92b618840 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -482,8 +482,10 @@ gst_pulsering_stream_request_cb (pa_stream * s, size_t length, void *userdata) GST_LOG_OBJECT (psink, "got request for length %" G_GSIZE_FORMAT, length); - if (pbuf->in_commit) { - /* only signal when we are waiting in the commit thread */ + if (pbuf->in_commit && (length >= rbuf->spec.segsize)) { + /* only signal when we are waiting in the commit thread + * and got request for atleast a segment + */ pa_threaded_mainloop_signal (psink->mainloop, 0); } } @@ -729,6 +731,8 @@ gst_pulsering_set_corked (GstPulseRingBuffer * pbuf, gboolean corked, goto server_dead; } pbuf->corked = corked; + } else { + GST_DEBUG_OBJECT (psink, "skipping, already in requested state"); } res = TRUE; @@ -818,18 +822,19 @@ gst_pulseringbuffer_stop (GstRingBuffer * buf) pa_threaded_mainloop_signal (psink->mainloop, 0); } - /* then try to flush, it's not fatal when this fails */ - GST_DEBUG_OBJECT (psink, "flushing"); - if ((o = pa_stream_flush (pbuf->stream, gst_pulsering_success_cb, pbuf))) { - while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) { - GST_DEBUG_OBJECT (psink, "wait for completion"); - pa_threaded_mainloop_wait (psink->mainloop); - if (gst_pulsering_is_dead (psink, pbuf)) - goto server_dead; + if (strcmp (psink->pa_version, "0.9.12")) { + /* then try to flush, it's not fatal when this fails */ + GST_DEBUG_OBJECT (psink, "flushing"); + if ((o = pa_stream_flush (pbuf->stream, gst_pulsering_success_cb, pbuf))) { + while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) { + GST_DEBUG_OBJECT (psink, "wait for completion"); + pa_threaded_mainloop_wait (psink->mainloop); + if (gst_pulsering_is_dead (psink, pbuf)) + goto server_dead; + } + GST_DEBUG_OBJECT (psink, "flush completed"); } - GST_DEBUG_OBJECT (psink, "flush completed"); } - res = TRUE; cleanup: @@ -1377,6 +1382,9 @@ gst_pulsesink_init (GstPulseSink * pulsesink, GstPulseSinkClass * klass) pulsesink->notify = 0; + /* needed for conditional execution */ + pulsesink->pa_version = pa_get_library_version (); + g_assert ((pulsesink->mainloop = pa_threaded_mainloop_new ())); g_assert (pa_threaded_mainloop_start (pulsesink->mainloop) == 0); diff --git a/ext/pulse/pulsesink.h b/ext/pulse/pulsesink.h index 2f74ac3af..cee17faf3 100644 --- a/ext/pulse/pulsesink.h +++ b/ext/pulse/pulsesink.h @@ -62,6 +62,8 @@ struct _GstPulseSink gdouble volume; gboolean volume_set; gint notify; + + const gchar *pa_version; }; struct _GstPulseSinkClass |