[PATCH] test/pcm-multi-thread: Remove pthread_cancel, add snd_pcm_close

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Because
 1) Apparently, our thread cancellation policy is
    "don't even think about it" and we shouldn't break
    our own rules
 2) It is good practice to close pcm after usage

Signed-off-by: David Henningsson <diwic@xxxxxxxxxx>
---
 test/pcm-multi-thread.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/pcm-multi-thread.c b/test/pcm-multi-thread.c
index da1b87c..26de7db 100644
--- a/test/pcm-multi-thread.c
+++ b/test/pcm-multi-thread.c
@@ -219,18 +219,22 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
-	if (setup_params())
+	if (setup_params()) {
+		snd_pcm_close(pcm);
 		return 1;
+	}
 
 	buf = calloc(1, snd_pcm_format_size(format, bufsize) * channels);
 	if (!buf) {
 		fprintf(stderr, "cannot alloc buffer\n");
+		snd_pcm_close(pcm);
 		return 1;
 	}
 
 	for (i = 0; i < num_threads; i++) {
 		if (pthread_create(&peeper_threads[i], NULL, peeper, (void *)(long)i)) {
 			fprintf(stderr, "pthread_create error\n");
+			snd_pcm_close(pcm);
 			return 1;
 		}
 	}
@@ -255,9 +259,8 @@ int main(int argc, char **argv)
 
 	running = 0;
 	for (i = 0; i < num_threads; i++)
-		pthread_cancel(peeper_threads[i]);
-	for (i = 0; i < num_threads; i++)
 		pthread_join(peeper_threads[i], NULL);
 
+	snd_pcm_close(pcm);
 	return 1;
 }
-- 
1.9.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux