mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
test/pcm: Fix error messages in async callback and add snd_pcm_start() condition
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
1dd1ba94a3
commit
16cc295a3c
1 changed files with 8 additions and 6 deletions
14
test/pcm.c
14
test/pcm.c
|
|
@ -385,11 +385,11 @@ static void async_callback(snd_async_handler_t *ahandler)
|
||||||
generate_sine(areas, 0, period_size, &data->phase);
|
generate_sine(areas, 0, period_size, &data->phase);
|
||||||
err = snd_pcm_writei(handle, samples, period_size);
|
err = snd_pcm_writei(handle, samples, period_size);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printf("Initial write error: %s\n", snd_strerror(err));
|
printf("Write error: %s\n", snd_strerror(err));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (err != period_size) {
|
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);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
avail = snd_pcm_avail_update(handle);
|
avail = snd_pcm_avail_update(handle);
|
||||||
|
|
@ -424,10 +424,12 @@ static int async_loop(snd_pcm_t *handle,
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = snd_pcm_start(handle);
|
if (snd_pcm_state(handle) == SND_PCM_STATE_PREPARED) {
|
||||||
if (err < 0) {
|
err = snd_pcm_start(handle);
|
||||||
printf("Start error: %s\n", snd_strerror(err));
|
if (err < 0) {
|
||||||
exit(EXIT_FAILURE);
|
printf("Start error: %s\n", snd_strerror(err));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* because all other work is done in the signal handler,
|
/* because all other work is done in the signal handler,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue