static char *alsa_mix_get_channels(struct mixer_handle *handle)
{
+ int ret;
char *list = NULL;
snd_mixer_selem_id_t *sid;
snd_mixer_elem_t *elem;
- snd_mixer_selem_id_alloca(&sid);
+ ret = snd_mixer_selem_id_malloc(&sid);
+ assert(ret >= 0);
elem = snd_mixer_first_elem(handle->mixer);
for (; elem; elem = snd_mixer_elem_next(elem)) {
char *tmp = list;
name);
free(tmp);
}
+ snd_mixer_selem_id_free(sid);
return list;
}
if (!mixer_channel)
mixer_channel = "Master";
- snd_mixer_selem_id_alloca(&sid);
+ ret = snd_mixer_selem_id_malloc(&sid);
+ assert(ret >= 0);
snd_mixer_selem_id_set_index(sid, selem_id);
snd_mixer_selem_id_set_name(sid, mixer_channel);
h->elem = snd_mixer_find_selem(h->mixer, sid);
PARA_NOTICE_LOG("unable to find simple control '%s',%i\n",
snd_mixer_selem_id_get_name(sid),
snd_mixer_selem_id_get_index(sid));
- return -E_BAD_CHANNEL;
+ ret = -E_BAD_CHANNEL;
+ goto out;
}
ret = snd_mixer_selem_get_playback_volume_range(h->elem,
&h->pmin, &h->pmax);
if (ret < 0) {
PARA_NOTICE_LOG("unable to get %s range (%s): %s\n",
mixer_channel, h->card, snd_strerror(ret));
- return -E_ALSA_MIX_RANGE;
+ ret = -E_ALSA_MIX_RANGE;
+ goto out;
}
if (h->pmin >= h->pmax) {
PARA_NOTICE_LOG("alsa reported %s range %ld-%ld (%s)\n",
mixer_channel, h->pmin, h->pmax, h->card);
- return -E_ALSA_MIX_RANGE;
+ ret = -E_ALSA_MIX_RANGE;
+ goto out;
}
- return 1;
+ ret = 1;
+out:
+ snd_mixer_selem_id_free(sid);
+ return ret;
}
static int alsa_mix_get(struct mixer_handle *h)
static int alsa_init(struct private_alsa_write_data *pad,
struct alsa_write_args_info *conf)
{
- snd_pcm_hw_params_t *hwparams;
- snd_pcm_sw_params_t *swparams;
+ snd_pcm_hw_params_t *hwparams = NULL;
+ snd_pcm_sw_params_t *swparams = NULL;
snd_pcm_uframes_t start_threshold, stop_threshold;
snd_pcm_uframes_t buffer_size, period_size;
snd_output_t *output_log;
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if (ret < 0)
goto fail;
- snd_pcm_hw_params_alloca(&hwparams);
+ ret = snd_pcm_hw_params_malloc(&hwparams);
+ assert(ret >= 0);
msg = "Broken alsa configuration";
ret = snd_pcm_hw_params_any(pad->handle, hwparams);
if (ret < 0)
goto fail;
/* software parameter setup */
- snd_pcm_sw_params_alloca(&swparams);
+ ret = snd_pcm_sw_params_malloc(&swparams);
+ assert(ret >= 0);
snd_pcm_sw_params_current(pad->handle, swparams);
snd_pcm_sw_params_set_avail_min(pad->handle, swparams, period_size);
if (buffer_size < 1)
}
snd_output_close(output_log);
}
- return 1;
+ ret = 1;
+ goto out;
fail:
if (ret < 0)
PARA_ERROR_LOG("%s: %s\n", msg, snd_strerror(-ret));
else
PARA_ERROR_LOG("%s\n", msg);
- return -E_ALSA;
+ ret = -E_ALSA;
+out:
+ snd_pcm_hw_params_free(hwparams);
+ snd_pcm_sw_params_free(swparams);
+ return ret;
}
static void alsa_write_pre_select(struct sched *s, void *context)