ext/alsa/gstalsasink.c: Fix for negotiation order problem. This would show when the

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.
This commit is contained in:
Ronald S. Bultje 2004-11-12 10:07:46 +00:00
parent 99032c54d3
commit 618e9b77f9
2 changed files with 21 additions and 9 deletions

View file

@ -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>

View 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 */