diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2016-07-14 23:07:39 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2016-07-14 16:33:51 +0200 |
commit | d745fcd5f7811d8e13d53dda73b74c4ce1e29b94 (patch) | |
tree | 4e39cb4600199f784f150568259614f3cff0fb2c | |
parent | df00246841948ca3b2773ca3484446f852097e60 (diff) | |
download | alsa-lib-d745fcd5f7811d8e13d53dda73b74c4ce1e29b94.tar.gz |
pcm: remove alloca() from _snd_pcm_softvol_open()
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | src/pcm/pcm_softvol.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c index e2345b35..61357785 100644 --- a/src/pcm/pcm_softvol.c +++ b/src/pcm/pcm_softvol.c @@ -995,7 +995,7 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, snd_config_t *slave = NULL, *sconf; snd_config_t *control = NULL; snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN; - snd_ctl_elem_id_t *ctl_id; + snd_ctl_elem_id_t ctl_id = {0}; int resolution = PRESET_RESOLUTION; double min_dB = PRESET_MIN_DB; double max_dB = ZERO_DB; @@ -1074,7 +1074,6 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, mode, conf); snd_config_delete(sconf); } else { - snd_ctl_elem_id_alloca(&ctl_id); err = snd_pcm_slave_conf(root, slave, &sconf, 1, SND_PCM_HW_PARAM_FORMAT, 0, &sformat); if (err < 0) @@ -1093,13 +1092,13 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, snd_config_delete(sconf); if (err < 0) return err; - err = snd_pcm_parse_control_id(control, ctl_id, &card, + err = snd_pcm_parse_control_id(control, &ctl_id, &card, &cchannels, NULL); if (err < 0) { snd_pcm_close(spcm); return err; } - err = snd_pcm_softvol_open(pcmp, name, sformat, card, ctl_id, + err = snd_pcm_softvol_open(pcmp, name, sformat, card, &ctl_id, cchannels, min_dB, max_dB, resolution, spcm, 1); if (err < 0) |