]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: remove alloca() from snd_pcm_hw_change_timer()
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Thu, 14 Jul 2016 14:07:30 +0000 (23:07 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 14 Jul 2016 14:33:49 +0000 (16:33 +0200)
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>
src/pcm/pcm_hw.c

index 0daaccc4981abf16ae6e681e7fa2e5130d917b1a..864d5fa212eb37e28d2b5db0d1f1b02b25437aa7 100644 (file)
@@ -351,12 +351,11 @@ static void snd_pcm_hw_close_timer(snd_pcm_hw_t *hw)
 static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable)
 {
        snd_pcm_hw_t *hw = pcm->private_data;
-       snd_timer_params_t *params;
+       snd_timer_params_t params = {0};
        unsigned int suspend, resume;
        int err;
        
        if (enable) {
-               snd_timer_params_alloca(&params);
                err = snd_timer_hw_open(&hw->period_timer,
                                "hw-pcm-period-event",
                                SND_TIMER_CLASS_PCM, SND_TIMER_SCLASS_NONE,
@@ -406,11 +405,11 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable)
                                resume = 1<<SND_TIMER_EVENT_MCONTINUE;
                        }
                }
-               snd_timer_params_set_auto_start(params, 1);
-               snd_timer_params_set_ticks(params, 1);
-               snd_timer_params_set_filter(params, (1<<SND_TIMER_EVENT_TICK) |
+               snd_timer_params_set_auto_start(&params, 1);
+               snd_timer_params_set_ticks(&params, 1);
+               snd_timer_params_set_filter(&params, (1<<SND_TIMER_EVENT_TICK) |
                                            suspend | resume);
-               err = snd_timer_params(hw->period_timer, params);
+               err = snd_timer_params(hw->period_timer, &params);
                if (err < 0) {
                        snd_pcm_hw_close_timer(hw);
                        return err;