diff options
author | Taylor Holberton <taylorcholberton@gmail.com> | 2016-10-14 20:05:30 -0400 |
---|---|---|
committer | Taylor Holberton <taylorcholberton@gmail.com> | 2016-10-14 20:05:30 -0400 |
commit | f319eb0c88a048b63d8691a654fab964f283cb4d (patch) | |
tree | 51e18891eb55e49593a4333f0e0b5f3ac06e336e | |
parent | 6a38d5fa49fa08e4bf8d20c6fb4741eaedee9dc1 (diff) |
Added support for default config
-rw-r--r-- | src/pcm.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -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'); |