alsaloop: Fix thread handling

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2010-10-06 18:51:29 +02:00
parent ad0e562373
commit 4fe4d22b73
2 changed files with 21 additions and 3 deletions

View file

@ -687,7 +687,7 @@ int main(int argc, char *argv[])
} }
/* we must sort thread IDs */ /* we must sort thread IDs */
j = 0; j = -1;
do { do {
k = 0x7fffffff; k = 0x7fffffff;
for (i = 0; i < loopbacks_count; i++) { for (i = 0; i < loopbacks_count; i++) {
@ -695,11 +695,11 @@ int main(int argc, char *argv[])
loopbacks[i]->thread > j) loopbacks[i]->thread > j)
k = loopbacks[i]->thread; k = loopbacks[i]->thread;
} }
j++;
for (i = 0; i < loopbacks_count; i++) { for (i = 0; i < loopbacks_count; i++) {
if (loopbacks[i]->thread == k) if (loopbacks[i]->thread == k)
loopbacks[i]->thread = j; loopbacks[i]->thread = j;
} }
j++;
} while (k != 0x7fffffff); } while (k != 0x7fffffff);
/* fix maximum thread id */ /* fix maximum thread id */
for (i = 0, j = -1; i < loopbacks_count; i++) { 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++) for (k = 0; k < j; k++)
thread_job(&threads[k]); thread_job(&threads[k]);
logit(LOG_CRIT, "threads = %i %i\n", j, loopbacks_count);
if (j > 1) { if (j > 1) {
for (k = 0; k < j; k++) for (k = 0; k < j; k++)
pthread_join(threads[k].thread, NULL); pthread_join(threads[k].thread, NULL);

View file

@ -27,8 +27,27 @@ EOF
$DBG ./alsaloop -d --config $CFGFILE $DBG ./alsaloop -d --config $CFGFILE
} }
test3() {
echo "TEST2"
cat > $CFGFILE <<EOF
-C hw:1,0,0 -P dmix:0 --tlatency 50000 --thread 0 \
--mixer "name='Master Playback Volume'@name='Master Playback Volume'" \
--mixer "name='Master Playback Switch'@name='Master Playback Switch'" \
--mixer "name='PCM Playback Volume'"
-C hw:1,0,1 -P dmix:0 --tlatency 50000 --thread 1
-C hw:1,0,2 -P dmix:0 --tlatency 50000 --thread 2
-C hw:1,0,3 -P dmix:0 --tlatency 50000 --thread 3
-C hw:1,0,4 -P dmix:0 --tlatency 50000 --thread 4
-C hw:1,0,5 -P dmix:0 --tlatency 50000 --thread 5
-C hw:1,0,6 -P dmix:0 --tlatency 50000 --thread 6
-C hw:1,0,7 -P dmix:0 --tlatency 50000 --thread 7
EOF
$DBG ./alsaloop --config $CFGFILE
}
case "$1" in case "$1" in
test1) test1 ;; test1) test1 ;;
test2) test2 ;; test2) test2 ;;
test3) test3 ;;
*) test1 ;; *) test1 ;;
esac esac