return _snd_config_make(config, 0, SND_CONFIG_TYPE_COMPOUND);
}
-static int snd_config_load1(snd_config_t *config, snd_input_t *in, int override)
+static int snd_config_load1(snd_config_t *config, snd_input_t *in, int override,
+ char *default_include_path)
{
int err;
input_t input;
fd->column = 0;
fd->next = NULL;
INIT_LIST_HEAD(&fd->include_paths);
+ if (default_include_path) {
+ err = add_include_path(fd, default_include_path);
+ if (err < 0)
+ goto _end;
+ }
input.current = fd;
input.unget = 0;
err = parse_defs(config, &input, 0, override);
*/
int snd_config_load(snd_config_t *config, snd_input_t *in)
{
- return snd_config_load1(config, in, 0);
+ return snd_config_load1(config, in, 0, NULL);
}
+#ifndef DOC_HIDDEN
+/* load config with the default include path; used internally for UCM parser */
+int _snd_config_load_with_include(snd_config_t *config, snd_input_t *in,
+ const char *default_include_path)
+{
+ int err;
+ char *s = NULL;
+
+ if (default_include_path) {
+ s = strdup(default_include_path);
+ if (!s)
+ return -ENOMEM;
+ }
+ err = snd_config_load1(config, in, 0, s);
+ if (err < 0)
+ free(s);
+ return err;
+}
+#endif
+
/**
* \brief Loads a configuration tree and overrides existing configuration nodes.
* \param config Handle to a top level configuration node.
*/
int snd_config_load_override(snd_config_t *config, snd_input_t *in)
{
- return snd_config_load1(config, in, 1);
+ return snd_config_load1(config, in, 1, NULL);
}
/**
#include <dirent.h>
#include <limits.h>
-/** The name of the environment variable containing the UCM directory */
-#define ALSA_CONFIG_UCM_VAR "ALSA_CONFIG_UCM"
-
/* Directories to store UCM configuration files for components, like
* off-soc codecs or embedded DSPs. Components can define their own
* devices and sequences, to be reused by sound cards/machines. UCM
FILE *fp;
snd_input_t *in;
snd_config_t *top;
+ const char *default_path;
int err;
fp = fopen(file, "r");
err = snd_config_top(&top);
if (err < 0)
return err;
- err = snd_config_load(top, in);
+
+ default_path = getenv(ALSA_CONFIG_UCM_VAR);
+ if (!default_path || !*default_path)
+ default_path = ALSA_CONFIG_DIR "/ucm";
+ err = _snd_config_load_with_include(top, in, default_path);
if (err < 0) {
uc_error("could not load configuration file %s", file);
snd_config_delete(top);