mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 12:16:31 +01:00
speaker-test: Fix floating-point exception bug
The period_size an buffer_size parameters must be taken after calling snd_pcm_hw_params(). Otherwise they could be undefined numbers. For example, period_size gets 0 when pcsp driver is used, resulting in a floating-point exception error. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
6232f1c96c
commit
0d6134450e
1 changed files with 8 additions and 7 deletions
|
@ -422,6 +422,14 @@ static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_
|
|||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/* write the parameters to device */
|
||||
err = snd_pcm_hw_params(handle, params);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, _("Unable to set hw params for playback: %s\n"), snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
|
||||
snd_pcm_hw_params_get_period_size(params, &period_size, NULL);
|
||||
printf(_("was set period_size = %lu\n"),period_size);
|
||||
|
@ -431,13 +439,6 @@ static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* write the parameters to device */
|
||||
err = snd_pcm_hw_params(handle, params);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, _("Unable to set hw params for playback: %s\n"), snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue