mirror of
https://git.code.sf.net/p/quake/quake2forge
synced 2024-11-10 07:12:01 +00:00
Dramatically reduced latency in ALSA sound driver. Also used safer set_*_near in leiu of set_*.
This commit is contained in:
parent
ea82053181
commit
cdc2e36cf7
1 changed files with 20 additions and 6 deletions
|
@ -31,6 +31,9 @@
|
|||
static snd_pcm_t *pcm_handle;
|
||||
static snd_pcm_hw_params_t *hw_params;
|
||||
|
||||
static snd_pcm_uframes_t period_size;
|
||||
static snd_pcm_uframes_t buffer_size;
|
||||
|
||||
static struct sndinfo * si;
|
||||
|
||||
static int sample_bytes;
|
||||
|
@ -149,9 +152,20 @@ qboolean SNDDMA_Init(struct sndinfo *s){
|
|||
return false;
|
||||
}
|
||||
|
||||
if((err = snd_pcm_hw_params_set_period_size(pcm_handle, hw_params,
|
||||
BUFFER_SAMPLES / si->dma->channels, 0)) < 0){
|
||||
si->Com_Printf("ALSA: cannot set period size(%s)\n", snd_strerror(err));
|
||||
period_size = BUFFER_SAMPLES / 2 / si->dma->channels;
|
||||
|
||||
if((err = snd_pcm_hw_params_set_period_size_near(pcm_handle,
|
||||
hw_params, &period_size, 0)) < 0){
|
||||
si->Com_Printf("ALSA: cannot set period size near(%s)\n", snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer_size = period_size * 2;
|
||||
|
||||
if((err = snd_pcm_hw_params_set_buffer_size_near(pcm_handle,
|
||||
hw_params, &buffer_size)) < 0){
|
||||
si->Com_Printf("ALSA: cannot set buffer size near(%s)\n", snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue