From 94803b005511f8baf3281ec4e922be99f62b4186 Mon Sep 17 00:00:00 2001 From: Taylor Holberton Date: Thu, 1 Dec 2016 16:07:14 -0800 Subject: Added const specifier in pcm_open Added const specifier to the struct pcm_config argument. Changed the way default values of the config structure are set and accessed. They're accessed through the pointer from the argument list and set through the pointer in the pcm structure. --- src/pcm.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/pcm.c') diff --git a/src/pcm.c b/src/pcm.c index 73debb4..29c69a7 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -808,7 +808,7 @@ int pcm_close(struct pcm *pcm) * @ingroup libtinyalsa-pcm */ struct pcm *pcm_open(unsigned int card, unsigned int device, - unsigned int flags, struct pcm_config *config) + unsigned int flags, const struct pcm_config *config) { struct pcm *pcm; struct snd_pcm_info info; @@ -823,14 +823,14 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, if (config == NULL) { config = &pcm->config; - config->channels = 2; - config->rate = 48000; - config->period_size = 1024; - config->period_count = 4; - config->format = PCM_FORMAT_S16_LE; - config->start_threshold = config->period_count * config->period_size; - config->stop_threshold = config->period_count * config->period_size; - config->silence_threshold = 0; + pcm->config.channels = 2; + pcm->config.rate = 48000; + pcm->config.period_size = 1024; + pcm->config.period_count = 4; + pcm->config.format = PCM_FORMAT_S16_LE; + pcm->config.start_threshold = config->period_count * config->period_size; + pcm->config.stop_threshold = config->period_count * config->period_size; + pcm->config.silence_threshold = 0; } else { pcm->config = *config; } @@ -890,8 +890,8 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, } /* get our refined hw_params */ - config->period_size = param_get_int(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); - config->period_count = param_get_int(¶ms, SNDRV_PCM_HW_PARAM_PERIODS); + pcm->config.period_size = param_get_int(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); + pcm->config.period_count = param_get_int(¶ms, SNDRV_PCM_HW_PARAM_PERIODS); pcm->buffer_size = config->period_count * config->period_size; if (flags & PCM_MMAP) { -- cgit v1.2.3