From: Jaroslav Kysela Date: Mon, 15 Sep 2008 13:14:58 +0000 (+0200) Subject: test/pcm: Fix error messages in async callback and add snd_pcm_start() condition X-Git-Tag: v1.0.18~3 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=16cc295a3c076ceb58fd9dd598c71e4aaa0800ac;p=alsa-lib.git test/pcm: Fix error messages in async callback and add snd_pcm_start() condition Signed-off-by: Jaroslav Kysela --- diff --git a/test/pcm.c b/test/pcm.c index ecd0afab..ee274223 100644 --- a/test/pcm.c +++ b/test/pcm.c @@ -385,11 +385,11 @@ static void async_callback(snd_async_handler_t *ahandler) generate_sine(areas, 0, period_size, &data->phase); err = snd_pcm_writei(handle, samples, period_size); if (err < 0) { - printf("Initial write error: %s\n", snd_strerror(err)); + printf("Write error: %s\n", snd_strerror(err)); exit(EXIT_FAILURE); } if (err != period_size) { - printf("Initial write error: written %i expected %li\n", err, period_size); + printf("Write error: written %i expected %li\n", err, period_size); exit(EXIT_FAILURE); } avail = snd_pcm_avail_update(handle); @@ -424,10 +424,12 @@ static int async_loop(snd_pcm_t *handle, exit(EXIT_FAILURE); } } - err = snd_pcm_start(handle); - if (err < 0) { - printf("Start error: %s\n", snd_strerror(err)); - exit(EXIT_FAILURE); + if (snd_pcm_state(handle) == SND_PCM_STATE_PREPARED) { + err = snd_pcm_start(handle); + if (err < 0) { + printf("Start error: %s\n", snd_strerror(err)); + exit(EXIT_FAILURE); + } } /* because all other work is done in the signal handler,