From edb5e50fcd52d6f0ed9d2decb5c874dfd9395998 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Fri, 9 Oct 2009 08:56:58 -0500 Subject: [PATCH] make alsa code more readable This changes the code to use constants for the parameters to snd_pcm_set_params. This makes it easier to read the code and to update the values if needed. --- alsa.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/alsa.c b/alsa.c index fa9e526..bae9798 100644 --- a/alsa.c +++ b/alsa.c @@ -32,6 +32,9 @@ static pthread_mutex_t audio_mutex = PTHREAD_MUTEX_INITIALIZER; static snd_pcm_t *handle; +static const unsigned int channels = 1; +static const int soft_resample = 1; +static const unsigned int latency = 125000; static void lock_audio_mutex(void) { @@ -92,10 +95,10 @@ int init_audio(unsigned int rate) err = snd_pcm_set_params(handle, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, - 1, + channels, rate, - 1, - 0); + soft_resample, + latency); if (err < 0) { fprintf(stderr, "Playback open error: %s\n", snd_strerror(err)); return err;