summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-07-14 23:07:25 +0900
committerTakashi Iwai <tiwai@suse.de>2016-07-14 16:33:48 +0200
commit3219c8d474febda859513fe7c3625265786c3002 (patch)
tree2c88de9ae26e2dd88bf4ebee7b0557542afe0eb6
parent37e0e89d33303de64e44b330c235417956db0257 (diff)
downloadalsa-lib-3219c8d474febda859513fe7c3625265786c3002.tar.gz
pcm: remove alloca() from snd_pcm_direct_initialize_poll_fd()
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_direct.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
index 8a53cef3..dbd7e2b3 100644
--- a/src/pcm/pcm_direct.c
+++ b/src/pcm/pcm_direct.c
@@ -1176,23 +1176,22 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
{
int ret;
- snd_pcm_info_t *info;
+ snd_pcm_info_t info = {0};
char name[128];
int capture = dmix->type == SND_PCM_TYPE_DSNOOP ? 1 : 0;
dmix->tread = 1;
dmix->timer_need_poll = 0;
- snd_pcm_info_alloca(&info);
- ret = snd_pcm_info(dmix->spcm, info);
+ ret = snd_pcm_info(dmix->spcm, &info);
if (ret < 0) {
SNDERR("unable to info for slave pcm");
return ret;
}
sprintf(name, "hw:CLASS=%i,SCLASS=0,CARD=%i,DEV=%i,SUBDEV=%i",
(int)SND_TIMER_CLASS_PCM,
- snd_pcm_info_get_card(info),
- snd_pcm_info_get_device(info),
- snd_pcm_info_get_subdevice(info) * 2 + capture);
+ snd_pcm_info_get_card(&info),
+ snd_pcm_info_get_device(&info),
+ snd_pcm_info_get_subdevice(&info) * 2 + capture);
ret = snd_timer_open(&dmix->timer, name,
SND_TIMER_OPEN_NONBLOCK | SND_TIMER_OPEN_TREAD);
if (ret < 0) {