diff options
author | Chris Robinson <[email protected]> | 2008-01-14 15:30:52 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2008-01-14 15:30:52 -0800 |
commit | dfc0118b8bfb5406a6adaf8032ed8f75ed7245d7 (patch) | |
tree | d2221597dff8bcc4061975504fe655a45136e7b4 | |
parent | d9ef062cafbac12dbb25fe3c58efdf1b53525ff2 (diff) |
Add an option for disabling ALSA mmap
-rw-r--r-- | Alc/alsa.c | 10 | ||||
-rw-r--r-- | openalrc.sample | 6 |
2 files changed, 15 insertions, 1 deletions
@@ -281,6 +281,8 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam unsigned int periods; alsa_data *data; char driver[64]; + const char *str; + int allowmmap; char *err; int i; @@ -360,12 +362,18 @@ open_alsa: periods = 4; bufferSizeInFrames = device->UpdateFreq / periods; + str = GetConfigValue("alsa", "mmap", "true"); + allowmmap = (strcasecmp(str, "true") == 0 || + strcasecmp(str, "yes") == 0 || + strcasecmp(str, "on") == 0 || + atoi(str) != 0); + psnd_pcm_hw_params_malloc(&p); #define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1)) /* start with the largest configuration space possible */ if(!(ok(psnd_pcm_hw_params_any(data->pcmHandle, p), "any") && /* set interleaved access */ - (ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set access") || + ((allowmmap && ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set access")) || ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_RW_INTERLEAVED), "set access")) && /* set format (implicitly sets sample bits) */ ok(psnd_pcm_hw_params_set_format(data->pcmHandle, p, data->format), "set format") && diff --git a/openalrc.sample b/openalrc.sample index 37325d14..0e33e648 100644 --- a/openalrc.sample +++ b/openalrc.sample @@ -55,6 +55,12 @@ periods = 4 # Sets the number of update buffers. Default is 4 capture = default # Sets the device name for the default capture device. # Default is default +mmap = true # Sets whether to try using mmap mode (helps reduce latencies and + # CPU consumption). If mmap isn't available, it will automatically + # fall back to non-mmap mode. True, yes, on, and non-0 values will + # attempt to use mmap. 0 and anything else will force mmap off. + # Default is true. + [oss] # OSS backend stuff device = /dev/dsp # Sets the device name for OSS output. Default is /dev/dsp |