diff options
-rw-r--r-- | Alc/ALc.c | 4 | ||||
-rw-r--r-- | Alc/alsa.c | 24 | ||||
-rw-r--r-- | openalrc.sample | 8 |
3 files changed, 21 insertions, 15 deletions
@@ -1172,9 +1172,9 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName) device->FrameSize = aluBytesFromFormat(device->Format) * device->Channels; - device->UpdateFreq = GetConfigValueInt(NULL, "refresh", 0); + device->UpdateFreq = GetConfigValueInt(NULL, "refresh", 8192); if((ALint)device->UpdateFreq <= 0) - device->UpdateFreq = 8192 * device->Frequency / 22050; + device->UpdateFreq = 8192; // Find a playback device to open for(i = 0;BackendList[i].Init;i++) @@ -67,6 +67,7 @@ MAKE_FUNC(snd_pcm_hw_params_set_rate_near); MAKE_FUNC(snd_pcm_hw_params_set_rate); MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_near); MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_min); +MAKE_FUNC(snd_pcm_hw_params_get_period_size); MAKE_FUNC(snd_pcm_hw_params_get_access); MAKE_FUNC(snd_pcm_hw_params); MAKE_FUNC(snd_pcm_prepare); @@ -355,10 +356,8 @@ open_alsa: AL_PRINT("Unknown format?! %x\n", device->Format); } - periods = GetConfigValueInt("alsa", "periods", 4); - if((int)periods <= 0) - periods = 4; - bufferSizeInFrames = device->UpdateFreq / periods; + periods = GetConfigValueInt("alsa", "periods", 0); + bufferSizeInFrames = device->UpdateFreq; str = GetConfigValue("alsa", "mmap", "true"); allowmmap = (strcasecmp(str, "true") == 0 || @@ -378,7 +377,7 @@ open_alsa: /* set channels (implicitly sets frame bits) */ ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, device->Channels), "set channels") && /* set periods (implicitly constrains period/buffer parameters) */ - ok(psnd_pcm_hw_params_set_periods_near(data->pcmHandle, p, &periods, NULL), "set periods near") && + (!periods || ok(psnd_pcm_hw_params_set_periods_near(data->pcmHandle, p, &periods, NULL), "set periods near")) && /* set rate (implicitly constrains period/buffer parameters) */ ok(psnd_pcm_hw_params_set_rate_near(data->pcmHandle, p, &device->Frequency, NULL), "set rate near") && /* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */ @@ -403,6 +402,15 @@ open_alsa: return ALC_FALSE; } + if((i=psnd_pcm_hw_params_get_period_size(p, &bufferSizeInFrames, NULL)) < 0) + { + AL_PRINT("get_period_size failed: %s\n", psnd_strerror(i)); + psnd_pcm_hw_params_free(p); + psnd_pcm_close(data->pcmHandle); + free(data); + return ALC_FALSE; + } + psnd_pcm_hw_params_free(p); device->MaxNoOfSources = 256; @@ -467,7 +475,6 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam { snd_pcm_format_t alsaFormat; snd_pcm_hw_params_t *p; - unsigned int periods = 4; snd_pcm_uframes_t bufferSizeInFrames; alsa_data *data; char driver[64]; @@ -534,7 +541,7 @@ open_alsa: AL_PRINT("Unknown format?! %x\n", format); } - bufferSizeInFrames = SampleSize / periods; + bufferSizeInFrames = SampleSize; psnd_pcm_hw_params_malloc(&p); #define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1)) @@ -546,8 +553,6 @@ open_alsa: ok(psnd_pcm_hw_params_set_format(data->pcmHandle, p, alsaFormat), "set format") && /* set channels (implicitly sets frame bits) */ ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, pDevice->Channels), "set channels") && - /* set periods (implicitly constrains period/buffer parameters) */ - ok(psnd_pcm_hw_params_set_periods_near(data->pcmHandle, p, &periods, NULL), "set periods near") && /* set rate (implicitly constrains period/buffer parameters) */ ok(psnd_pcm_hw_params_set_rate(data->pcmHandle, p, frequency, 0), "set rate") && /* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */ @@ -737,6 +742,7 @@ LOAD_FUNC(snd_pcm_hw_params_set_rate_near); LOAD_FUNC(snd_pcm_hw_params_set_rate); LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_near); LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_min); +LOAD_FUNC(snd_pcm_hw_params_get_period_size); LOAD_FUNC(snd_pcm_hw_params_get_access); LOAD_FUNC(snd_pcm_hw_params); LOAD_FUNC(snd_pcm_prepare); diff --git a/openalrc.sample b/openalrc.sample index 0e33e648..4650e5a0 100644 --- a/openalrc.sample +++ b/openalrc.sample @@ -36,9 +36,8 @@ cf_level = 0 # Sets the crossfeed level for stereo output. Valid values are: frequency = 44100 # Sets the output frequency. Default is 44100 -refresh = 0 # Sets the number of frames-per-update. Default is calculated as - # 8192*frequency/22050. Note that the actual granularity may or - # may not be less than this. +refresh = 8192 # Sets the buffer size, in frames. Default is 8192. Note that + # the actual granularity may or may not be less than this. drivers = # Sets the backend driver list order, comma-seperated. Unknown # backends and duplicated names are ignored, and unlisted backends @@ -50,7 +49,8 @@ drivers = # Sets the backend driver list order, comma-seperated. Unknown device = default # Sets the device name for the default playback device. # Default is default -periods = 4 # Sets the number of update buffers. Default is 4 +periods = 0 # Sets the number of update buffers for playback. A value of 0 + # means auto-select. Default is 0 capture = default # Sets the device name for the default capture device. # Default is default |