+# Include a new configuration file
+<filename>
+
+# Replace with an environment variable
+# (default value is used if envvar is not present or empty)
+<@envvar[,envvar1][,envvar2...]:defaultval@>
+
# Server definition
server.NAME {
host STR # host where the server is located (if map to local address
int snd_card_get_name(int card, char **name);
int snd_card_get_longname(int card, char **name);
-int snd_defaults_card(void);
-int snd_defaults_mixer_card(void);
-int snd_defaults_pcm_card(void);
-int snd_defaults_pcm_device(void);
-int snd_defaults_rawmidi_card(void);
-int snd_defaults_rawmidi_device(void);
-
int snd_card_type_string_to_enum(const char *strid, snd_card_type_t *enumid);
int snd_card_type_enum_to_string(snd_card_type_t enumid, char **strid);
+#
+# ALSA library configuration file
+#
pcm.default {
type plug
slave.pcm {
type hw
- card 0
- device 0
+ card <@ALSA_PCM_CARD,ALSA_CARD:0@>
+ device <@ALSA_PCM_DEVICE:0@>
}
}
$.1 DEV
$.CARD {
type integer
+ default <@ALSA_SURROUND40_CARD,ALSA_PCM_CARD,ALSA_CARD:0@>
}
$.DEV {
type integer
- default 0
+ default <@ALSA_SURROUND40_DEVICE:0@>
}
type surround
card $CARD
$.1 DEV
$.CARD {
type integer
+ default <@ALSA_SURROUND51_CARD,ALSA_PCM_CARD,ALSA_CARD:0@>
}
$.DEV {
type integer
- default 0
+ default <@ALSA_SURROUND51_DEVICE:0@>
}
type surround
card $CARD
ctl.default {
type hw
- card 0
+ card <@ALSA_CARD:0@>
}
ctl.hw {
ctl $PCM
}
+rawmidi.default {
+ type hw
+ card <@ALSA_RAWMIDI_CARD,ALSA_CARD:0@>
+ device <@ALSA_RAWMIDI_DEVICE:0@>
+}
+
rawmidi.hw {
$.0 CARD
$.1 DEV
subdevice $SUBDEV
}
+seq.default {
+ type hw
+}
+
seq.hw {
type hw
}
}
}
}
-
UNTERMINATED_QUOTE = -2,
UNEXPECTED_CHAR = -3,
UNEXPECTED_EOF = -4,
+ BAD_ENV_DEFAULT = -5,
} error;
} input_t;
while (1) {
c = get_char(input);
if (c == '<') {
- char *file;
+ char *str;
snd_input_t *in;
struct filedesc *fd;
- int err = get_delimstring(&file, '>', input);
- if (err < 0)
- return err;
- err = snd_input_stdio_open(&in, file, "r");
+ int err = get_delimstring(&str, '>', input);
if (err < 0)
return err;
+ if (strlen(str) < 3 ||
+ str[0] != '@' ||
+ str[strlen(str)-1] != '@' ||
+ strchr(str, ':') == NULL) {
+ err = snd_input_stdio_open(&in, str, "r");
+ if (err < 0)
+ return err;
+ } else {
+ char *envvar = str + 1;
+ char *envdef = strchr(str, ':');
+ char *env, *end;
+
+ str[strlen(str)-1] = '\0';
+ *envdef++ = '\0';
+ if (*envdef == '\0') {
+ free(str);
+ input->error = BAD_ENV_DEFAULT;
+ return -EINVAL;
+ }
+ while (1) {
+ end = strchr(envvar, ',');
+ if (end)
+ *end = '\0';
+ env = getenv(envvar);
+ if (env != NULL && *env != '\0')
+ break;
+ if (end) {
+ *end = ','; /* repair for fd->name */
+ envvar = end + 1;
+ } else {
+ env = envdef;
+ break;
+ }
+ }
+ err = snd_input_buffer_open(&in, env, strlen(env));
+ if (err < 0)
+ return err;
+ }
fd = malloc(sizeof(*fd));
if (!fd)
return -ENOMEM;
- fd->name = file;
+ fd->name = str;
fd->in = in;
fd->next = input->current;
fd->line = 1;
case UNEXPECTED_EOF:
str = "Unexpected end of file";
break;
+ case BAD_ENV_DEFAULT:
+ str = "Bad environment default value";
+ break;
default:
assert(0);
break;
}
/** Environment variable containing files list for #snd_config_update */
-#define ASOUND_CONFIGS_VAR "ASOUND_CONFIGS"
+#define ALSA_CONFIG_PATH_VAR "ALSA_CONFIG_PATH"
/** Default files used by #snd_config_update */
-#define ASOUND_CONFIGS_DEFAULT DATADIR "/alsa/alsa.conf:/etc/asound.conf:~/.asoundrc"
+#define ALSA_CONFIG_PATH_DEFAULT DATADIR "/alsa/alsa.conf:/etc/asound.conf:~/.asoundrc"
/** \ingroup Config
* Config top node */
/**
* \brief Update #snd_config rereading (if needed) files specified in
- * environment variable ASOUND_CONFIGS. If it's not set the default value is
+ * environment variable ALSA_CONFIG_PATH. If it's not set the default value is
* "/usr/share/alsa/alsa.conf:/etc/asound.conf:~/.asoundrc"
* \return 0 if no action is needed, 1 if tree has been rebuilt otherwise a negative error code
*
size_t l;
struct finfo *fi;
unsigned int fi_count;
- configs = getenv(ASOUND_CONFIGS_VAR);
+ configs = getenv(ALSA_CONFIG_PATH_VAR);
if (!configs)
- configs = ASOUND_CONFIGS_DEFAULT;
+ configs = ALSA_CONFIG_PATH_DEFAULT;
for (k = 0, c = configs; (l = strcspn(c, ": ")) > 0; ) {
c += l;
k++;
}
/**
- * \brief Return an iterator pointing to next leaf
+q * \brief Return an iterator pointing to next leaf
* \param iterator Config node iterator
* \return iterator value for next leaf
*/
EXTRA_LTLIBRARIES = libcontrol.la
-libcontrol_la_SOURCES = cards.c cards_id.c hcontrol.c defaults.c \
+libcontrol_la_SOURCES = cards.c cards_id.c hcontrol.c \
control.c control_hw.c control_shm.c \
setup.c
+++ /dev/null
-/*
- * Control Interface - defaults
- * Copyright (c) 1998 by Jaroslav Kysela <perex@suse.cz>
- *
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include "local.h"
-
-static int defaults_card(const char *env)
-{
- char *e;
-
- e = getenv(env);
- if (!e)
- return -ENOENT;
- return snd_card_get_index(e);
-}
-
-static int defaults_device(const char *env)
-{
- char *e;
- int dev;
-
- e = getenv(env);
- if (e) {
- dev = atoi(env);
- if (dev >= 0 && dev < 1024 * 1024)
- return dev;
- }
- return 0;
-}
-
-int snd_defaults_card(void)
-{
- int result;
-
- result = defaults_card("ALSA_CARD");
- if (result >= 0)
- return result;
- result = -1;
- if (snd_card_next(&result))
- return -ENOENT;
- return result;
-}
-
-int snd_defaults_mixer_card(void)
-{
- int result;
-
- result = defaults_card("ALSA_MIXER_CARD");
- if (result >= 0)
- return result;
- return snd_defaults_card();
-}
-
-int snd_defaults_pcm_card(void)
-{
- int result;
-
- result = defaults_card("ALSA_PCM_CARD");
- if (result >= 0)
- return result;
- return snd_defaults_card();
-}
-
-int snd_defaults_pcm_device(void)
-{
- snd_ctl_t *handle;
- char id[16];
- int result;
-
- result = defaults_device("ALSA_PCM_DEVICE");
- if (result >= 0)
- return result;
- sprintf(id, "hw:%i", snd_defaults_pcm_card());
- if (snd_ctl_open(&handle, id, 0) < 0)
- return -ENOENT;
- result = -1;
- if (snd_ctl_pcm_next_device(handle, &result) < 0) {
- snd_ctl_close(handle);
- return -ENOENT;
- }
- return result;
-}
-
-int snd_defaults_rawmidi_card(void)
-{
- int result;
-
- result = defaults_card("ALSA_RAWMIDI_CARD");
- if (result >= 0)
- return result;
- return snd_defaults_card();
-}
-
-int snd_defaults_rawmidi_device(void)
-{
- snd_ctl_t *handle;
- char id[16];
- int result;
-
- result = defaults_device("ALSA_RAWMIDI_DEVICE");
- if (result >= 0)
- return result;
- sprintf(id, "hw:%i", snd_defaults_rawmidi_card());
- if (snd_ctl_open(&handle, id, 0) < 0)
- return -ENOENT;
- result = -1;
- if (snd_ctl_rawmidi_next_device(handle, &result) < 0) {
- snd_ctl_close(handle);
- return -ENOENT;
- }
- return result;
-}
AC_LANG_RESTORE
dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
-AC_CHECK_LIB([asound], [snd_defaults_card],,
+AC_CHECK_LIB([asound], [snd_seq_create_event],,
[ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)])
alsa_found=no]
)