summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-07-14 23:07:35 +0900
committerTakashi Iwai <tiwai@suse.de>2016-07-14 16:33:50 +0200
commit709aa36bc24aad567cab799fcce11af2f93d2360 (patch)
tree729b5d50ad1458dd45fb84d550b3d31ddb81deee
parent2edffe37576e8968b8cfff2de26d8a6c756aed57 (diff)
downloadalsa-lib-709aa36bc24aad567cab799fcce11af2f93d2360.tar.gz
pcm: remove alloca() from snd_spcm_init_duplex()
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_simple.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/pcm/pcm_simple.c b/src/pcm/pcm_simple.c
index 3ae24ff8..89859876 100644
--- a/src/pcm/pcm_simple.c
+++ b/src/pcm/pcm_simple.c
@@ -218,16 +218,13 @@ int snd_spcm_init_duplex(snd_pcm_t *playback_pcm,
snd_spcm_duplex_type_t duplex_type)
{
int err, i;
- snd_pcm_hw_params_t *hw_params;
- snd_pcm_sw_params_t *sw_params;
+ snd_pcm_hw_params_t hw_params = {0};
+ snd_pcm_sw_params_t sw_params = {0};
unsigned int rrate;
unsigned int xbuffer_time, buffer_time[2];
unsigned int period_time[2];
snd_pcm_t *pcms[2];
- snd_pcm_hw_params_alloca(&hw_params);
- snd_pcm_sw_params_alloca(&sw_params);
-
assert(playback_pcm);
assert(capture_pcm);
assert(rate >= 5000 && rate <= 192000);
@@ -247,7 +244,7 @@ int snd_spcm_init_duplex(snd_pcm_t *playback_pcm,
buffer_time[i] = xbuffer_time;
period_time[i] = i > 0 ? period_time[0] : 0;
rrate = rate;
- err = set_hw_params(pcms[i], hw_params,
+ err = set_hw_params(pcms[i], &hw_params,
&rrate, channels, format, subformat,
&buffer_time[i], &period_time[i], access);
if (err < 0)
@@ -266,7 +263,7 @@ int snd_spcm_init_duplex(snd_pcm_t *playback_pcm,
*/
__sw_params:
for (i = 0; i < 2; i++) {
- err = set_sw_params(pcms[i], sw_params, xrun_type);
+ err = set_sw_params(pcms[i], &sw_params, xrun_type);
if (err < 0)
return err;
}