mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	pcm: remove alloca() from snd_spcm_init()
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>
This commit is contained in:
		
							parent
							
								
									6a0c93a03d
								
							
						
					
					
						commit
						2edffe3757
					
				
					 1 changed files with 4 additions and 7 deletions
				
			
		| 
						 | 
					@ -164,14 +164,11 @@ int snd_spcm_init(snd_pcm_t *pcm,
 | 
				
			||||||
		  snd_spcm_xrun_type_t xrun_type)
 | 
							  snd_spcm_xrun_type_t xrun_type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
	snd_pcm_hw_params_t *hw_params;
 | 
						snd_pcm_hw_params_t hw_params = {0};
 | 
				
			||||||
	snd_pcm_sw_params_t *sw_params;
 | 
						snd_pcm_sw_params_t sw_params = {0};
 | 
				
			||||||
	unsigned int rrate;
 | 
						unsigned int rrate;
 | 
				
			||||||
	unsigned int buffer_time;
 | 
						unsigned int buffer_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	snd_pcm_hw_params_alloca(&hw_params);
 | 
					 | 
				
			||||||
	snd_pcm_sw_params_alloca(&sw_params);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	assert(pcm);
 | 
						assert(pcm);
 | 
				
			||||||
	assert(rate >= 5000 && rate <= 192000);
 | 
						assert(rate >= 5000 && rate <= 192000);
 | 
				
			||||||
	assert(channels >= 1 && channels <= 512);
 | 
						assert(channels >= 1 && channels <= 512);
 | 
				
			||||||
| 
						 | 
					@ -180,13 +177,13 @@ int snd_spcm_init(snd_pcm_t *pcm,
 | 
				
			||||||
	err = set_buffer_time(latency, &buffer_time);
 | 
						err = set_buffer_time(latency, &buffer_time);
 | 
				
			||||||
	if (err < 0)
 | 
						if (err < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	err = set_hw_params(pcm, hw_params,
 | 
						err = set_hw_params(pcm, &hw_params,
 | 
				
			||||||
			    &rrate, channels, format, subformat,
 | 
								    &rrate, channels, format, subformat,
 | 
				
			||||||
			    &buffer_time, NULL, access);
 | 
								    &buffer_time, NULL, access);
 | 
				
			||||||
	if (err < 0)
 | 
						if (err < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = set_sw_params(pcm, sw_params, xrun_type);
 | 
						err = set_sw_params(pcm, &sw_params, xrun_type);
 | 
				
			||||||
	if (err < 0)
 | 
						if (err < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue