mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-06 23:28:04 -04:00
alsa: don't leak memory
This commit is contained in:
parent
515ac0b9d2
commit
9b87077e93
1 changed files with 4 additions and 3 deletions
|
@ -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_period_size(hwparams, &period_size, NULL);
|
||||||
snd_pcm_hw_params_get_channels(hwparams, &channels);
|
snd_pcm_hw_params_get_channels(hwparams, &channels);
|
||||||
|
|
||||||
silent_period = realloc(silent_period, period_size * 2 * channels);
|
silent_period = calloc(period_size * channels, 2);
|
||||||
if (silent_period != NULL)
|
|
||||||
memset(silent_period, 0, period_size * 2 * channels);
|
|
||||||
|
|
||||||
ret = snd_pcm_prepare(handle);
|
ret = snd_pcm_prepare(handle);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
@ -104,6 +102,9 @@ void sndout_alsa_stop(void)
|
||||||
int ret = snd_pcm_drop(handle);
|
int ret = snd_pcm_drop(handle);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
fprintf(stderr, PFX "snd_pcm_drop failed: %d\n", ret);
|
fprintf(stderr, PFX "snd_pcm_drop failed: %d\n", ret);
|
||||||
|
|
||||||
|
free(silent_period);
|
||||||
|
silent_period = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sndout_alsa_wait(void)
|
void sndout_alsa_wait(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue