David Henningsson wrote: > 2) It is good practice to close pcm after usage > [...] > 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; > } > } Any previously created threads are already running. Calling some snd_* function on an already-closed device is worse than letting the OS clean up after the program exits. If we'd wanted to be strictly correct, we would have to send a message to the threads and wait for them to exit (as the cleanup code below already does). > running = 0; This variable should be volatile. > - 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); Regards, Clemens _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel