pulsesink: Track the corked/uncorked state ourselves
authorJan Schmidt <thaytan@noraisin.net>
Fri, 20 Mar 2009 13:27:59 +0000 (13:27 +0000)
committerJan Schmidt <thaytan@noraisin.net>
Fri, 20 Mar 2009 13:27:59 +0000 (13:27 +0000)
Use an instance variable to track whether the stream is corked or not,
instead of using PA API that was only introduced in 0.9.11

ext/pulse/pulsesink.c
ext/pulse/pulsesink.h

index 8ff41760605bd6af75a42b754f25a8866f4724ff..7d2af9d5a566f7231cf03a8f4897a4e14334ad7d 100644 (file)
@@ -822,6 +822,7 @@ gst_pulsesink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
             pa_strerror (pa_context_errno (pulsesink->context))), (NULL));
     goto unlock_and_fail;
   }
+  pulsesink->corked = TRUE;
 
   for (;;) {
     pa_stream_state_t state;
@@ -884,7 +885,7 @@ 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 (pulsesink->corked) {
     if (!(o = pa_stream_cork (pulsesink->stream, FALSE, NULL, NULL))) {
       GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED,
           ("pa_stream_cork() failed: %s",
@@ -897,6 +898,7 @@ gst_pulsesink_write (GstAudioSink * asink, gpointer data, guint length)
         goto unlock_and_fail;
       pa_threaded_mainloop_wait (pulsesink->mainloop);
     }
+    pulsesink->corked = FALSE;
 
     pa_operation_unref (o);
     o = NULL;
@@ -1228,6 +1230,7 @@ gst_pulsesink_pause (GstPulseSink * pulsesink, gboolean b)
       goto unlock;
     pa_threaded_mainloop_wait (pulsesink->mainloop);
   }
+  pulsesink->corked = b;
 
 unlock:
   if (o)
index 70fd8a6551031574606c1a3fd5d4faab9de094c3..9ec626cd53a86e6bb792f546b247f1b5afbceffc 100644 (file)
@@ -68,6 +68,7 @@ struct _GstPulseSink
 
   gboolean operation_success;
   gboolean did_reset, in_write;
+  gboolean corked;
   gint notify;
 };