From 0c922cc90d7e4bc9c1e24ff06c5a6e75768b7163 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 2 Jun 2004 17:20:13 +0000 Subject: [PATCH] check error code correctly Original commit message from CVS: check error code correctly --- ChangeLog | 6 ++++++ ext/alsa/gstalsasrc.c | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8227f2c34..dd84a41352 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-06-02 Thomas Vander Stichele + + * ext/alsa/gstalsaclock.c: (gst_alsa_clock_get_type): + * ext/alsa/gstalsasrc.c: (gst_alsa_src_loop): + check error condition on available samples correctly + 2004-06-02 Thomas Vander Stichele * ext/alsa/gstalsasrc.c: (gst_alsa_src_get_time): diff --git a/ext/alsa/gstalsasrc.c b/ext/alsa/gstalsasrc.c index ea9d4856f2..db50d040bc 100644 --- a/ext/alsa/gstalsasrc.c +++ b/ext/alsa/gstalsasrc.c @@ -329,11 +329,19 @@ gst_alsa_src_loop (GstElement * element) } } - while ((avail = gst_alsa_update_avail (this)) < this->period_size) { - if (avail == -EPIPE) + /* the cast to long is explicitly needed; + * with avail = -32 and period_size = 100, avail < period_size is false */ + while ((avail = gst_alsa_update_avail (this)) < (long) this->period_size) { + if (avail == -EPIPE) { + GST_DEBUG_OBJECT (this, "got EPIPE when checking for available bytes"); continue; - if (avail < 0) + } + if (avail < 0) { + GST_DEBUG_OBJECT (this, + "got error %s (%d) when checking for available bytes", + snd_strerror (avail)); return; + } if (snd_pcm_state (this->handle) != SND_PCM_STATE_RUNNING) { if (!gst_alsa_start (this)) return;