aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-07-16 16:52:19 +0000
committerEric Wong <normalperson@yhbt.net>2006-07-16 16:52:19 +0000
commit8224e837ef60278a9a1140515d79650d9024757e (patch)
tree7563078b9f4a129c9fb9a09cbf7c37dd5da1cf3b /src
parent3c8e88b053e901de804a7d38f709056444155161 (diff)
downloadmpd-8224e837ef60278a9a1140515d79650d9024757e.tar.gz
mpd-8224e837ef60278a9a1140515d79650d9024757e.tar.xz
mpd-8224e837ef60278a9a1140515d79650d9024757e.zip
audioOutput_alsa: add use_mmap, period_time, buffer_time options
ALSA support in libao supports configuring of these variables, and some hardware setups may benefit from having these things as tweakable. git-svn-id: https://svn.musicpd.org/mpd/trunk@4363 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/audioOutputs/audioOutput_alsa.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c
index 0842b9f83..bc727c556 100644
--- a/src/audioOutputs/audioOutput_alsa.c
+++ b/src/audioOutputs/audioOutput_alsa.c
@@ -46,6 +46,8 @@ typedef struct _AlsaData {
char * device;
snd_pcm_t * pcmHandle;
alsa_writei_t * writei;
+ unsigned int buffer_time;
+ unsigned int period_time;
int sampleSize;
int useMmap;
int canPause;
@@ -59,6 +61,8 @@ static AlsaData * newAlsaData() {
ret->pcmHandle = NULL;
ret->writei = snd_pcm_writei;
ret->useMmap = 0;
+ ret->buffer_time = MPD_ALSA_BUFFER_TIME;
+ ret->period_time = MPD_ALSA_PERIOD_TIME;
return ret;
}
@@ -70,17 +74,23 @@ static void freeAlsaData(AlsaData * ad) {
}
static int alsa_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
- BlockParam * bp = NULL;
- AlsaData * ad;
-
- if(param) bp = getBlockParam(param, "device");
-
- ad = newAlsaData();
-
+ AlsaData * ad = newAlsaData();
+
+ if (param) {
+ BlockParam * bp = getBlockParam(param, "device");
+ ad->device = bp ? strdup(bp->value) : strdup("default");
+
+ if ((bp = getBlockParam(param, "use_mmap")) &&
+ (!strcasecmp(bp->value, "yes") ||
+ !strcasecmp(bp->value, "true")))
+ ad->useMmap = 1;
+ if ((bp = getBlockParam(param, "buffer_time")))
+ ad->buffer_time = atoi(bp->value);
+ if ((bp = getBlockParam(param, "period_time")))
+ ad->period_time = atoi(bp->value);
+ }
audioOutput->data = ad;
- ad->device = bp ? strdup(bp->value) : strdup("default");
-
return 0;
}
@@ -118,8 +128,6 @@ static int alsa_openDevice(AudioOutput * audioOutput)
unsigned int channels = audioFormat->channels;
snd_pcm_uframes_t alsa_buffer_size;
snd_pcm_uframes_t alsa_period_size;
- unsigned int alsa_buffer_time = MPD_ALSA_BUFFER_TIME;
- unsigned int alsa_period_time = MPD_ALSA_PERIOD_TIME;
int err;
char * cmd = NULL;
@@ -210,14 +218,14 @@ static int alsa_openDevice(AudioOutput * audioOutput)
cmd = "snd_pcm_hw_params_set_buffer_time_near";
err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams,
- &alsa_buffer_time, 0);
+ &ad->buffer_time, 0);
if(err < 0) goto error;
- if (!alsa_period_time && sampleRate > 0)
- alsa_period_time = 1000000 * MPD_ALSA_SAMPLE_XFER / sampleRate;
+ if (!ad->period_time && sampleRate > 0)
+ ad->period_time = 1000000 * MPD_ALSA_SAMPLE_XFER / sampleRate;
cmd = "snd_pcm_hw_params_set_period_time_near";
err = snd_pcm_hw_params_set_period_time_near(ad->pcmHandle, hwparams,
- &alsa_period_time, 0);
+ &ad->period_time, 0);
if(err < 0) goto error;
cmd = "snd_pcm_hw_params";