Parse libconfig info during init.
This commit is contained in:
+33
-2
@@ -35,7 +35,7 @@
|
||||
#include "audio.h"
|
||||
|
||||
static void help(void);
|
||||
static int init(int argc, char **argv);
|
||||
static int init(int argc, char **argv, config_t* cfgp);
|
||||
static void deinit(void);
|
||||
static void start(int sample_rate);
|
||||
static void play(short buf[], int samples);
|
||||
@@ -93,7 +93,10 @@ static void help(void) {
|
||||
);
|
||||
}
|
||||
|
||||
static int init(int argc, char **argv) {
|
||||
static int init(int argc, char **argv, config_t *cfgp) {
|
||||
const char *str;
|
||||
int value;
|
||||
|
||||
int hardware_mixer = 0;
|
||||
|
||||
optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour
|
||||
@@ -127,6 +130,34 @@ static int init(int argc, char **argv) {
|
||||
|
||||
if (optind < argc)
|
||||
die("Invalid audio argument: %s", argv[optind]);
|
||||
|
||||
if (cfgp!=NULL) {
|
||||
/* Get the Output Device Name. */
|
||||
if(config_lookup_string(cfgp, "alsa.output_device", &str)) {
|
||||
alsa_out_dev = (char*)str;
|
||||
}
|
||||
|
||||
/* Get the Mixer Type setting. */
|
||||
if(config_lookup_string(cfgp, "alsa.mixer_type", &str)) {
|
||||
if (strcasecmp(str,"software")==0)
|
||||
hardware_mixer=0;
|
||||
else if (strcasecmp(str,"hardware")==0)
|
||||
hardware_mixer=1;
|
||||
else
|
||||
die("Invalid alsa mixer option choice \"%s\". It should be \"software\" or \"hardware\"");
|
||||
}
|
||||
|
||||
/* Get the Mixer Device Name. */
|
||||
if(config_lookup_string(cfgp, "alsa.mixer_device", &str)) {
|
||||
alsa_mix_dev = (char*)str;
|
||||
}
|
||||
|
||||
/* Get the Mixer Control Name. */
|
||||
if(config_lookup_string(cfgp, "alsa.mixer_control_name", &str)) {
|
||||
alsa_mix_ctrl = (char*)str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!hardware_mixer)
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user