gst-libs/gst/audio/gstbaseaudiosink.c: Use new basesink method to make our EOS drain...
authorWim Taymans <wim.taymans@gmail.com>
Wed, 10 Oct 2007 15:36:56 +0000 (15:36 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Wed, 10 Oct 2007 15:36:56 +0000 (15:36 +0000)
Original commit message from CVS:
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_drain):
Use new basesink method to make our EOS drain interruptable.

ChangeLog
gst-libs/gst/audio/gstbaseaudiosink.c

index 13e0af7..e3a0abc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-10-10  Wim Taymans  <wim.taymans@gmail.com>
+
+       * gst-libs/gst/audio/gstbaseaudiosink.c:
+       (gst_base_audio_sink_drain):
+       Use new basesink method to make our EOS drain interruptable.
+
 2007-10-10  Jan Schmidt  <Jan.Schmidt@sun.com>
 
        * gst-libs/gst/rtp/gstrtppayloads.c:
index ee39bbb..b668ef8 100644 (file)
@@ -547,9 +547,7 @@ gst_base_audio_sink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
   *end = GST_CLOCK_TIME_NONE;
 }
 
-/* FIXME, this waits for the drain to happen but it cannot be
- * canceled.
- */
+/* This waits for the drain to happen and can be canceled */
 static gboolean
 gst_base_audio_sink_drain (GstBaseAudioSink * sink)
 {
@@ -559,33 +557,28 @@ gst_base_audio_sink_drain (GstBaseAudioSink * sink)
     return TRUE;
 
   /* need to start playback before we can drain, but only when
-   * we have successfully negotiated a format and thus aqcuired the
+   * we have successfully negotiated a format and thus acquired the
    * ringbuffer. */
   if (gst_ring_buffer_is_acquired (sink->ringbuffer))
     gst_ring_buffer_start (sink->ringbuffer);
 
   if (sink->next_sample != -1) {
     GstClockTime time;
-    GstClock *clock;
 
+    /* convert next expected sample to time */
     time =
         gst_util_uint64_scale_int (sink->next_sample, GST_SECOND,
         sink->ringbuffer->spec.rate);
 
-    GST_OBJECT_LOCK (sink);
-    if ((clock = GST_ELEMENT_CLOCK (sink)) != NULL) {
-      GstClockID id = gst_clock_new_single_shot_id (clock, time);
-
-      GST_OBJECT_UNLOCK (sink);
+    GST_DEBUG_OBJECT (sink,
+        "last sample %" G_GUINT64_FORMAT ", time %" GST_TIME_FORMAT,
+        sink->next_sample, GST_TIME_ARGS (time));
 
-      GST_DEBUG_OBJECT (sink, "waiting for last sample to play");
-      gst_clock_id_wait (id, NULL);
+    /* wait for the EOS time to be reached, this is the time when the last
+     * sample is played. */
+    gst_base_sink_wait_eos (GST_BASE_SINK (sink), time, NULL);
 
-      gst_clock_id_unref (id);
-      sink->next_sample = -1;
-    } else {
-      GST_OBJECT_UNLOCK (sink);
-    }
+    sink->next_sample = -1;
   }
   return TRUE;
 }