Added period == buffer_size check to prevent misusing

This commit is contained in:
Jaroslav Kysela 2001-02-28 09:01:45 +00:00
parent 65dde04e4e
commit 946078f8c4

View file

@ -777,12 +777,16 @@ static void set_params(void)
assert(period_time >= 0); assert(period_time >= 0);
err = snd_pcm_hw_params(handle, params); err = snd_pcm_hw_params(handle, params);
if (err < 0) { if (err < 0) {
fprintf(stderr, "Unable to install hw params:\n"); error("Unable to install hw params:");
snd_pcm_hw_params_dump(params, log); snd_pcm_hw_params_dump(params, log);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
chunk_size = snd_pcm_hw_params_get_period_size(params, 0); chunk_size = snd_pcm_hw_params_get_period_size(params, 0);
buffer_size = snd_pcm_hw_params_get_buffer_size(params); buffer_size = snd_pcm_hw_params_get_buffer_size(params);
if (chunk_size == buffer_size) {
error("Can't use period equal to buffer size (%u == %lu)", chunk_size, buffer_size);
exit(EXIT_FAILURE);
}
snd_pcm_sw_params_current(handle, swparams); snd_pcm_sw_params_current(handle, swparams);
xfer_align = snd_pcm_sw_params_get_xfer_align(swparams); xfer_align = snd_pcm_sw_params_get_xfer_align(swparams);
if (sleep_min) if (sleep_min)