aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2016-12-01 16:07:14 -0800
committerTaylor Holberton <taylorcholberton@gmail.com>2016-12-01 16:07:14 -0800
commit94803b005511f8baf3281ec4e922be99f62b4186 (patch)
treeaad55e1e749f478a0293bd6482b327b53558b640
parentba285cfbf416af5fbda1040e3c3ce74165e3e11c (diff)
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.
-rw-r--r--src/pcm.c22
1 files changed, 11 insertions, 11 deletions
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(&params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
- config->period_count = param_get_int(&params, SNDRV_PCM_HW_PARAM_PERIODS);
+ pcm->config.period_size = param_get_int(&params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
+ pcm->config.period_count = param_get_int(&params, SNDRV_PCM_HW_PARAM_PERIODS);
pcm->buffer_size = config->period_count * config->period_size;
if (flags & PCM_MMAP) {