ext/alsa/gstalsasink.c: Fix for negotiation order problem. This would show when the
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Fri, 12 Nov 2004 10:07:46 +0000 (10:07 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Fri, 12 Nov 2004 10:07:46 +0000 (10:07 +0000)
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsa_sink_loop):
Fix for negotiation order problem. This would show when the
ALSA loopfuction was called before any other function. ALSA
wouldn't do anything because we're not negotiated yet, leading
to an infinite loop. Showed in e.g. Rhythmbox. Fixes #158006.

ChangeLog
ext/alsa/gstalsasink.c

index 229346b..93896ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-11-12  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
+
+       * ext/alsa/gstalsasink.c: (gst_alsa_sink_loop):
+         Fix for negotiation order problem. This would show when the
+         ALSA loopfuction was called before any other function. ALSA
+         wouldn't do anything because we're not negotiated yet, leading
+         to an infinite loop. Showed in e.g. Rhythmbox. Fixes #158006.
+
 2004-11-11  Tim-Philipp Müller  <t.i.m@zen.co.uk>
 
        reviewed by:  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
index 25a1685..4954975 100644 (file)
@@ -364,17 +364,11 @@ sink_restart:
     goto sink_restart;
   if (avail < 0)
     return;
-  if (avail > 0) {
 
-    /* Not enough space. We grab data nonetheless and sleep afterwards */
-    if (avail < this->period_size) {
-      avail = this->period_size;
-    }
+  if (avail > 0 || (avail == 0 && !this->format)) {
+
+    bytes = G_MAXINT;
 
-    /* check how many bytes we still have in all our bytestreams */
-    /* initialize this value to a somewhat sane state, we might alloc
-     * this much data below (which would be a bug, but who knows)... */
-    bytes = this->period_size * this->period_count * element->numpads * 8;      /* must be > max sample size in bytes */
     for (i = 0; i < element->numpads; i++) {
       GstBuffer *buf;
 
@@ -492,6 +486,16 @@ sink_restart:
       bytes = MIN (bytes, sink->size[i]);
     }
 
+    /* check how many bytes we still have in all our bytestreams */
+    /* initialize this value to a somewhat sane state, we might alloc
+     * this much data below (which would be a bug, but who knows)... */
+    bytes = MIN (bytes,
+        this->period_size * this->period_count * element->numpads * 8);
+    /* must be > max sample size in bytes */
+
+    /* Not enough space. We grab data nonetheless and sleep afterwards */
+    if (avail < this->period_size)
+      avail = this->period_size;
     avail = MIN (avail, gst_alsa_bytes_to_samples (this, bytes));
 
     /* wait until the hw buffer has enough space */