]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsabat: add terminate status check for capture thread
authorLu, Han <han.lu@intel.com>
Sun, 17 Apr 2016 01:26:45 +0000 (09:26 +0800)
committerTakashi Iwai <tiwai@suse.de>
Mon, 18 Apr 2016 14:34:08 +0000 (16:34 +0200)
In loopback test, alsabat use pthread_join(pthread_t thread, **retval)
to wait for the capture thread to terminate. If the capture thread was
canceled, PTHREAD_CANCELED is placed in *retval, and the access to the
**retval will fail. Add status check to prevent illegal access to the
**retval.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
bat/bat.c

index e8240651fa8870a9f2d55d7f69c12af22c7d1780..1afdcb49c2758b0e71c6d4683c68191fb74212bc 100644 (file)
--- a/bat/bat.c
+++ b/bat/bat.c
@@ -192,6 +192,12 @@ static void test_loopback(struct bat *bat)
                exit(EXIT_FAILURE);
        }
 
+       /* check if capture thread is canceled or not */
+       if (thread_result_capture == PTHREAD_CANCELED) {
+               fprintf(bat->log, _("Capture canceled.\n"));
+               return;
+       }
+
        /* check capture status */
        if (*thread_result_capture != 0) {
                fprintf(bat->err, _("Exit capture thread fail: %d\n"),