ret = snd_pcm_hw_params_any(handle, hwparams);
ret |= snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
ret = snd_pcm_hw_params_any(handle, hwparams);
ret |= snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
ret |= snd_pcm_hw_params_set_channels(handle, hwparams, stereo ? 2 : 1);
ret |= snd_pcm_hw_params_set_rate_near(handle, hwparams, &rate, 0);
ret |= snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size);
ret |= snd_pcm_hw_params_set_channels(handle, hwparams, stereo ? 2 : 1);
ret |= snd_pcm_hw_params_set_rate_near(handle, hwparams, &rate, 0);
ret |= snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size);
snd_pcm_hw_params_get_period_size(hwparams, &period_size, NULL);
snd_pcm_hw_params_get_channels(hwparams, &channels);
snd_pcm_hw_params_get_period_size(hwparams, &period_size, NULL);
snd_pcm_hw_params_get_channels(hwparams, &channels);
- silent_period = realloc(silent_period, period_size * 2 * channels);
- if (silent_period != NULL)
- memset(silent_period, 0, period_size * 2 * channels);
+ silent_period = calloc(period_size * channels, 2);
int ret = snd_pcm_drop(handle);
if (ret != 0)
fprintf(stderr, PFX "snd_pcm_drop failed: %d\n", ret);
int ret = snd_pcm_drop(handle);
if (ret != 0)
fprintf(stderr, PFX "snd_pcm_drop failed: %d\n", ret);