summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@noraisin.net>2009-03-19 18:39:04 +0000
committerJan Schmidt <thaytan@noraisin.net>2009-03-20 12:11:06 +0000
commit120e6bfc5c187eb6482fe13f4f55cf869feee896 (patch)
treed5273f8e27f682bbee0ee4daa851bf7f52876272
parent335891c757ba3d65cec172a728102f6e168d006a (diff)
pulse: Make sure the stream is uncorked in the write function
If the caps changes, the sink is reset without transitioning through a PAUSED->PLAYING state change, resulting in a corked stream. This avoids the problem by checking that the stream is uncorked when writing samples to it.
-rw-r--r--ext/pulse/pulsesink.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index 430d8f29..8ff41760 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -872,6 +872,7 @@ static guint
gst_pulsesink_write (GstAudioSink * asink, gpointer data, guint length)
{
GstPulseSink *pulsesink = GST_PULSESINK (asink);
+ pa_operation *o = NULL;
size_t sum = 0;
/* FIXME post message rather than using a signal (as mixer interface) */
@@ -882,6 +883,25 @@ gst_pulsesink_write (GstAudioSink * asink, gpointer data, guint length)
pulsesink->in_write = TRUE;
+ /* Make sure the stream is uncorked - it might not be on a caps change */
+ if (pa_stream_is_corked (pulsesink->stream)) {
+ if (!(o = pa_stream_cork (pulsesink->stream, FALSE, NULL, NULL))) {
+ GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED,
+ ("pa_stream_cork() failed: %s",
+ pa_strerror (pa_context_errno (pulsesink->context))), (NULL));
+ goto unlock_and_fail;
+ }
+
+ while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
+ if (gst_pulsesink_is_dead (pulsesink))
+ goto unlock_and_fail;
+ pa_threaded_mainloop_wait (pulsesink->mainloop);
+ }
+
+ pa_operation_unref (o);
+ o = NULL;
+ }
+
while (length > 0) {
size_t l;
@@ -933,6 +953,9 @@ unlock_and_fail:
pulsesink->did_reset = FALSE;
pulsesink->in_write = FALSE;
+ if (o)
+ pa_operation_unref (o);
+
pa_threaded_mainloop_unlock (pulsesink->mainloop);
return (guint) - 1;
}
@@ -1194,7 +1217,6 @@ gst_pulsesink_pause (GstPulseSink * pulsesink, gboolean b)
goto unlock;
if (!(o = pa_stream_cork (pulsesink->stream, b, NULL, NULL))) {
-
GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED,
("pa_stream_cork() failed: %s",
pa_strerror (pa_context_errno (pulsesink->context))), (NULL));
@@ -1202,15 +1224,12 @@ gst_pulsesink_pause (GstPulseSink * pulsesink, gboolean b)
}
while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
-
if (gst_pulsesink_is_dead (pulsesink))
goto unlock;
-
pa_threaded_mainloop_wait (pulsesink->mainloop);
}
unlock:
-
if (o)
pa_operation_unref (o);