X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=linux%2Fsndout_alsa.c;h=f1d9ca3e2d129013a3407e85dd3b71d3f2018169;hb=HEAD;hp=95cc39177947a600848bc0815374f25fe16c1d9f;hpb=9028744c193c011a7a0b1ed2e069208f57ffa2fa;p=libpicofe.git diff --git a/linux/sndout_alsa.c b/linux/sndout_alsa.c index 95cc391..9297967 100644 --- a/linux/sndout_alsa.c +++ b/linux/sndout_alsa.c @@ -51,7 +51,7 @@ int sndout_alsa_start(int rate_, int stereo) 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_format(handle, hwparams, SND_PCM_FORMAT_S16_LE); + ret |= snd_pcm_hw_params_set_format(handle, hwparams, SND_PCM_FORMAT_S16); 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); @@ -72,9 +72,7 @@ int sndout_alsa_start(int rate_, int stereo) 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); ret = snd_pcm_prepare(handle); if (ret != 0) { @@ -104,6 +102,9 @@ void sndout_alsa_stop(void) int ret = snd_pcm_drop(handle); if (ret != 0) fprintf(stderr, PFX "snd_pcm_drop failed: %d\n", ret); + + free(silent_period); + silent_period = NULL; } void sndout_alsa_wait(void)