aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2016-10-14 20:05:30 -0400
committerTaylor Holberton <taylorcholberton@gmail.com>2016-10-14 20:05:30 -0400
commitf319eb0c88a048b63d8691a654fab964f283cb4d (patch)
tree51e18891eb55e49593a4333f0e0b5f3ac06e336e /src
parent6a38d5fa49fa08e4bf8d20c6fb4741eaedee9dc1 (diff)
Added support for default config
Diffstat (limited to 'src')
-rw-r--r--src/pcm.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/pcm.c b/src/pcm.c
index a45ce75..b185f5e 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -796,10 +796,22 @@ struct pcm *pcm_open(unsigned int card, unsigned int device,
int rc;
pcm = calloc(1, sizeof(struct pcm));
- if (!pcm || !config)
- return &bad_pcm; /* TODO: could support default config here */
-
- pcm->config = *config;
+ if (!pcm)
+ return &bad_pcm;
+
+ 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;
+ } else {
+ pcm->config = *config;
+ }
snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device,
flags & PCM_IN ? 'c' : 'p');