From 4fe4d22b73dd205521348583f8105de1c155f4a6 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 6 Oct 2010 18:51:29 +0200 Subject: [PATCH 19/38] alsaloop: Fix thread handling Signed-off-by: Jaroslav Kysela --- alsaloop/alsaloop.c | 5 ++--- alsaloop/test.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/alsaloop/alsaloop.c b/alsaloop/alsaloop.c index 0001358..743e0ef 100644 --- a/alsaloop/alsaloop.c +++ b/alsaloop/alsaloop.c @@ -687,7 +687,7 @@ int main(int argc, char *argv[]) } /* we must sort thread IDs */ - j = 0; + j = -1; do { k = 0x7fffffff; for (i = 0; i < loopbacks_count; i++) { @@ -695,11 +695,11 @@ int main(int argc, char *argv[]) loopbacks[i]->thread > j) k = loopbacks[i]->thread; } + j++; for (i = 0; i < loopbacks_count; i++) { if (loopbacks[i]->thread == k) loopbacks[i]->thread = j; } - j++; } while (k != 0x7fffffff); /* fix maximum thread id */ for (i = 0, j = -1; i < loopbacks_count; i++) { @@ -729,7 +729,6 @@ int main(int argc, char *argv[]) for (k = 0; k < j; k++) thread_job(&threads[k]); - logit(LOG_CRIT, "threads = %i %i\n", j, loopbacks_count); if (j > 1) { for (k = 0; k < j; k++) pthread_join(threads[k].thread, NULL); diff --git a/alsaloop/test.sh b/alsaloop/test.sh index 2033add..bc42480 100755 --- a/alsaloop/test.sh +++ b/alsaloop/test.sh @@ -27,8 +27,27 @@ EOF $DBG ./alsaloop -d --config $CFGFILE } +test3() { + echo "TEST2" +cat > $CFGFILE <