2 * Mixer Interface - simple abstact module - base library (dlopen function)
3 * Copyright (c) 2005 by Jaroslav Kysela <perex@perex.cz>
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include <sys/ioctl.h>
32 #include "asoundlib.h"
33 #include "mixer_abst.h"
36 #define SO_PATH ALSA_PLUGIN_DIR "/smixer"
38 int mixer_simple_basic_dlopen(snd_mixer_class_t *class,
39 bclass_base_ops_t **ops)
41 struct bclass_private *priv = snd_mixer_sbasic_get_private(class);
42 const char *lib = "smixer-sbase.so";
43 void (*initpriv)(snd_mixer_class_t *class, struct bclass_private *priv);
49 priv = calloc(1, sizeof(*priv));
54 path = getenv("ALSA_MIXER_SIMPLE_MODULES");
57 xlib = malloc(strlen(lib) + strlen(path) + 1 + 1);
66 h = snd_dlopen(xlib, RTLD_NOW);
68 SNDERR("Unable to open library '%s'", xlib);
71 initpriv = dlsym(h, "alsa_mixer_sbasic_initpriv");
72 if (initpriv == NULL) {
73 SNDERR("Symbol 'alsa_mixer_sbasic_initpriv' was not found in '%s'", xlib);
76 priv->ops.event = dlsym(h, "alsa_mixer_sbasic_event");
77 if (priv->ops.event == NULL) {
78 SNDERR("Symbol 'alsa_mixer_sbasic_event' was not found in '%s'", xlib);
81 priv->ops.selreg = dlsym(h, "alsa_mixer_sbasic_selreg");
82 if (priv->ops.selreg == NULL) {
83 SNDERR("Symbol 'alsa_mixer_sbasic_selreg' was not found in '%s'", xlib);
86 priv->ops.sidreg = dlsym(h, "alsa_mixer_sbasic_sidreg");
87 if (priv->ops.sidreg == NULL) {
88 SNDERR("Symbol 'alsa_mixer_sbasic_sidreg' was not found in '%s'", xlib);
93 initpriv(class, priv);