Skip to contentSkip to conversation

alsa-utils: speaker-test: fix infinite loop

PATCH In review David Henningsson 2 participants 2 messages Oct 15, 2010 – Oct 17, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alsa-utils: speaker-test: fix infinite loop

I'm using speaker-test in an Ubuntu-specific bug triaging script/application ("ubuntu-bug audio"), and without showing the terminal that speaker-test outputs. So when the stream cannot be opened for one reason or another, my application hangs indefinitely and the user cannot report the bug.

Looking at the code, seems like Takashi removed all error loops except this one four years ago, so there shouldn't be any controversy in removing this one as well.

Signature · 2 lines
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
Quoted 1 line

From f51771c4064ec5f18ec46aeec2d5fe294a4a372c Mon Sep 17 00:00:00 2001

From: David Henningsson <[email protected]>
Date: Fri, 15 Oct 2010 12:30:44 +0200
Subject: [PATCH] speaker-test: Don't retry after fatal errors

Fixup commit 9b1a2566: Remove error loop

---
 speaker-test/speaker-test.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
speaker-test/speaker-test.c +2 -2
index 458a8d7..3029110 100644
@@ -993,9 +993,9 @@ int main(int argc, char *argv[]) {
 
   }
 
-  while ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
+  if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
     printf(_("Playback open error: %d,%s\n"), err,snd_strerror(err));
-    sleep(1);
+    exit(EXIT_FAILURE);
   }
 
   if ((err = set_hwparams(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
Signature · 1 line
1.7.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#1 lore raw

At Fri, 15 Oct 2010 12:35:31 +0200,

Quoted 10 lines · David Henningsson

I'm using speaker-test in an Ubuntu-specific bug triaging script/application ("ubuntu-bug audio"), and without showing the terminal that speaker-test outputs. So when the stream cannot be opened for one reason or another, my application hangs indefinitely and the user cannot report the bug.

Looking at the code, seems like Takashi removed all error loops except this one four years ago, so there shouldn't be any controversy in removing this one as well.

Looks good to me.
Applied now. Thanks!

Takashi

Quoted 36 lines
Signature · 4 lines
-- 
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
[2 0001-speaker-test-Don-t-retry-after-fatal-errors.patch <text/x-patch (7bit)>]
Quoted 1 line

From f51771c4064ec5f18ec46aeec2d5fe294a4a372c Mon Sep 17 00:00:00 2001

From: David Henningsson <[email protected]>
Date: Fri, 15 Oct 2010 12:30:44 +0200
Subject: [PATCH] speaker-test: Don't retry after fatal errors

Fixup commit 9b1a2566: Remove error loop

---
 speaker-test/speaker-test.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
speaker-test/speaker-test.c +2 -2
index 458a8d7..3029110 100644
@@ -993,9 +993,9 @@ int main(int argc, char *argv[]) {
 
   }
 
-  while ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
+  if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
     printf(_("Playback open error: %d,%s\n"), err,snd_strerror(err));
-    sleep(1);
+    exit(EXIT_FAILURE);
   }
 
   if ((err = set_hwparams(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
Signature · 1 line
1.7.1