]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added symbol versioning for dlsym-callbacks.
authorJaroslav Kysela <perex@perex.cz>
Wed, 15 Aug 2001 12:12:16 +0000 (12:12 +0000)
committerJaroslav Kysela <perex@perex.cz>
Wed, 15 Aug 2001 12:12:16 +0000 (12:12 +0000)
Removed snd_config_refer_load from confmisc.c and pcm.c.

43 files changed:
include/conf.h
include/control.h
include/global.h
include/hwdep.h
include/local.h
include/pcm.h
include/rawmidi.h
include/seq.h
include/timer.h
src/Makefile.am
src/conf.c
src/confmisc.c
src/control/control.c
src/control/control_hw.c
src/control/control_shm.c
src/dlmisc.c [new file with mode: 0644]
src/hwdep/hwdep.c
src/hwdep/hwdep_hw.c
src/pcm/pcm.c
src/pcm/pcm_adpcm.c
src/pcm/pcm_alaw.c
src/pcm/pcm_copy.c
src/pcm/pcm_file.c
src/pcm/pcm_hooks.c
src/pcm/pcm_hw.c
src/pcm/pcm_linear.c
src/pcm/pcm_meter.c
src/pcm/pcm_mulaw.c
src/pcm/pcm_multi.c
src/pcm/pcm_null.c
src/pcm/pcm_plug.c
src/pcm/pcm_rate.c
src/pcm/pcm_route.c
src/pcm/pcm_share.c
src/pcm/pcm_shm.c
src/rawmidi/rawmidi.c
src/rawmidi/rawmidi_hw.c
src/seq/seq.c
src/seq/seq_hw.c
src/timer/timer.c
src/timer/timer_hw.c
src/timer/timer_query.c
src/timer/timer_query_hw.c

index eea2958dbf2f8a144a7e54c58c1bb0c7183029c7..825925c535bd46fd8e4d3e3cee0d123b3a6b2ca4 100644 (file)
@@ -4,6 +4,11 @@
  *  \{
  */
 
+/** dlsym version for config evaluate callback */
+#define SND_CONFIG_DLSYM_VERSION_EVALUATE      _dlsym_config_evaluate_001
+/** dlsym version for config hook callback */
+#define SND_CONFIG_DLSYM_VERSION_HOOK          _dlsym_config_hook_001
+
 /** Config node type */
 typedef enum _snd_config_type {
        /** Integer number */
index 05b38f66515fd837afdfdb4f5aa9b4217d6cfd49..3574b4ab6c0d437896654542cc63116939d6d0cd 100644 (file)
@@ -11,6 +11,9 @@
  *  \{
  */
 
+/** dlsym version for interface entry callback */
+#define SND_CONTROL_DLSYM_VERSION      _dlsym_control_001
+
 /** IEC958 structure */
 typedef struct sndrv_aes_iec958 snd_aes_iec958_t;
 
index 13cf47c6df507988aefb966f33f9eb4c237070ee..a17f9639d4049cfd981dd2e5a2a4f707b62c803d 100644 (file)
 
 /** \} */
 
+#define __SND_DLSYM_VERSION(name, version) _ ## name ## version
+#define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version)
+#define SND_DLSYM_VERSION(version) __STRING(version)
+
+int snd_dlsym_verify(void *handle, const char *name, const char *version);
+
 /** Async notification client handler */
 typedef struct _snd_async_handler snd_async_handler_t;
 
index 3636edac7edd411ddb7d5c2b86e8ae3bf301addd..48bf4be2d668bde9880c0a2a5e461a3e37f7d870 100644 (file)
@@ -11,6 +11,9 @@
  *  \{
  */
 
+/** dlsym version for interface entry callback */
+#define SND_HWDEP_DLSYM_VERSION                _dlsym_hwdep_001
+
 /** HwDep information container */
 typedef struct _snd_hwdep_info snd_hwdep_info_t;
 
index b3f5f5c67b1a5a8c7cb2950f61ae9d98cbf247b6..db15b0da433d624b9b0d1333f702beed134172ef 100644 (file)
@@ -24,8 +24,6 @@
 
 #include "config.h"
 
-#define ALSA_LIB "libasound.so"
-
 #define _snd_config_iterator list_head
 #define _snd_interval sndrv_interval
 #define _snd_pcm_info sndrv_pcm_info
index 6df82ae42291d80505447b001387d157f815ab17..68996d7b93635694cbb7af3ce290717dda587847 100644 (file)
@@ -11,6 +11,9 @@
  *  \{
  */
 
+/** dlsym version for interface entry callback */
+#define SND_PCM_DLSYM_VERSION          _dlsym_pcm_001
+
 /** PCM generic info container */
 typedef struct _snd_pcm_info snd_pcm_info_t;
 /** PCM hardware configuration space container */
index b982cd666a7bbffc81caa8e9c7f6253e713a4346..e7e6f8a3cd13dc2bb52f78a7968e62c21844dd3e 100644 (file)
@@ -11,6 +11,9 @@
  *  \{
  */
 
+/** dlsym version for interface entry callback */
+#define SND_RAWMIDI_DLSYM_VERSION      _dlsym_rawmidi_001
+
 /** RawMidi information container */
 typedef struct _snd_rawmidi_info snd_rawmidi_info_t;
 /** RawMidi settings container */
index 75736b7e4bdb635892011772a60ac6218a2ae73b..60a35f557536d387a4527a80b662d7b79cbebb4b 100644 (file)
@@ -9,6 +9,9 @@ extern "C" {
  *  \{
  */
 
+/** dlsym version for interface entry callback */
+#define SND_SEQ_DLSYM_VERSION          _dlsym_seq_001
+
 /** Sequencer handle */
 typedef struct _snd_seq snd_seq_t;
 
index 8c1cb22d3eaaeef6df4f4f44aa1d99aef1a0f765..8a25e146d66da8bb072218713b54fd6bf2f4a6d6 100644 (file)
  *  \{
  */
 
+/** dlsym version for interface entry callback */
+#define SND_TIMER_DLSYM_VERSION                _dlsym_timer_001
+/** dlsym version for interface entry callback */
+#define SND_TIMER_QUERY_DLSYM_VERSION  _dlsym_timer_query_001
+
 /** timer identification structure */
 typedef struct _snd_timer_id snd_timer_id_t;
 /** timer info structure */
index 6409d9709af05ea4b297ac3c5696329f299eb23f..7aefd18c8cbf971fede00bab37525421879b851c 100644 (file)
@@ -2,7 +2,7 @@ SUBDIRS=control mixer pcm rawmidi timer hwdep seq instr compat conf
 COMPATNUM=@LIBTOOL_VERSION_INFO@
 
 lib_LTLIBRARIES = libasound.la
-libasound_la_SOURCES = conf.c confmisc.c input.c output.c async.c error.c 
+libasound_la_SOURCES = conf.c confmisc.c input.c output.c async.c error.c dlmisc.c
 libasound_la_LIBADD = control/libcontrol.la mixer/libmixer.la pcm/libpcm.la \
                       rawmidi/librawmidi.la timer/libtimer.la \
                      hwdep/libhwdep.la seq/libseq.la instr/libinstr.la \
index ff542821496f8725334a982651962cdaf3897a32..5c2a0cc43350e8aa1945a48c5d9382ab6ff63e50 100644 (file)
@@ -1801,18 +1801,18 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, void
                buf[len-1] = '\0';
                func_name = buf;
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
+       if ((err = snd_dlsym_verify(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_HOOK))) < 0)
+               goto _err;
        func = h ? dlsym(h, func_name) : NULL;
        err = 0;
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
-               return -ENOENT;
+               err = -ENOENT;
        } else if (!func) {
                SNDERR("symbol %s is not defined inside %s", func_name, lib);
                dlclose(h);
-               return -ENXIO;
+               err = -ENXIO;
        }
        _err:
        if (func_conf)
@@ -1877,6 +1877,7 @@ static int snd_config_hooks(snd_config_t *config, void *private_data)
  * \param private_data Private data
  * \return zero if success, otherwise a negative error code
  */
+SND_DLSYM_BUILD_VERSION(snd_config_hook_load, SND_CONFIG_DLSYM_VERSION_HOOK);
 int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t **dst, void *private_data)
 {
        snd_config_t *n, *res = NULL;
@@ -2011,6 +2012,7 @@ int snd_determine_driver(int card, char **driver);
  * \param private_data Private data
  * \return zero if success, otherwise a negative error code
  */
+SND_DLSYM_BUILD_VERSION(snd_config_hook_load_for_all_cards, SND_CONFIG_DLSYM_VERSION_HOOK);
 int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, snd_config_t **dst, void *private_data ATTRIBUTE_UNUSED)
 {
        int card = -1, err;
@@ -2504,10 +2506,12 @@ static int _snd_config_evaluate(snd_config_t *src,
                        buf[len-1] = '\0';
                        func_name = buf;
                }
-               if (!lib)
-                       lib = ALSA_LIB;
                h = dlopen(lib, RTLD_NOW);
-               func = h ? dlsym(h, func_name) : NULL;
+               if (h) {
+                       if ((err = snd_dlsym_verify(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_EVALUATE))) < 0)
+                               goto _err;
+                       func = dlsym(h, func_name);
+               }
                err = 0;
                if (!h) {
                        SNDERR("Cannot open shared library %s", lib);
index 516b2463574b5e964108427f37ec9da07f32d036..12104ecd49429d9f314b2415f1d91a2c08071f08 100644 (file)
@@ -139,96 +139,11 @@ int snd_config_get_ctl_iface(snd_config_t *conf)
        return err;
 }
 
-/**
- * \brief Refer the configuration block to another
- * \param dst new configuration block (if *dst != root -> dst needs to be deleted)
- * \param name the identifier of new configuration block
- * \param root the root of all configurations
- * \param config redirect configuration
- */
-int snd_config_refer_load(snd_config_t **dst,
-                         char **name,
-                         snd_config_t *root,
-                         snd_config_t *config)
-{
-       int err;
-       snd_config_t *result, *c;
-       char *rname;
-
-       assert(dst);
-       assert(name);
-       assert(root);
-       assert(config);
-       if (snd_config_get_type(config) == SND_CONFIG_TYPE_STRING) {
-               const char *str;
-               snd_config_get_string(config, &str);
-               *name = strdup(str);
-               if (*name == NULL)
-                       return -ENOMEM;
-               *dst = root;
-               return 0;
-       }
-       if (snd_config_get_type(config) != SND_CONFIG_TYPE_COMPOUND)
-               return -EINVAL;
-       result = root;
-       rname = NULL;
-       if (snd_config_search(config, "file", &c) >= 0) {
-               snd_config_t *rconfig;
-               const char *filename;
-               snd_input_t *input;
-               err = snd_config_copy(&rconfig, root);
-               if (err < 0)
-                       return err;
-               if (snd_config_get_type(c) == SND_CONFIG_TYPE_STRING) {
-                       snd_config_get_string(c, &filename);
-               } else {
-                       err = -EINVAL;
-                     __filename_error:
-                       snd_config_delete(rconfig);
-                       return err;
-               }
-               err = snd_input_stdio_open(&input, filename, "r");
-               if (err < 0) {
-                       SNDERR("Unable to open filename %s: %s", filename, snd_strerror(err));
-                       goto __filename_error;
-               }
-               err = snd_config_load(rconfig, input);
-               if (err < 0) {
-                       snd_input_close(input);
-                       goto __filename_error;
-               }
-               snd_input_close(input);
-               result = rconfig;
-       }
-       if (snd_config_search(config, "name", &c) >= 0) {
-               const char *ptr;
-               if ((err = snd_config_get_string(c, &ptr)) < 0)
-                       goto __error;
-               rname = strdup(ptr);
-               if (rname == NULL) {
-                       err = -ENOMEM;
-                       goto __error;
-               }
-       }
-       if (rname == NULL) {
-               err = -EINVAL;
-               goto __error;
-       }
-       *dst = result;
-       *name = rname;
-       return 0;
-      __error:
-       if (rname)
-               free(rname);
-       if (result != root)
-               snd_config_delete(result);
-       return err;
-}
-
 /*
  *  Helper functions for the configuration file
  */
 
+SND_DLSYM_BUILD_VERSION(snd_func_getenv, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
 {
        snd_config_t *n, *d;
@@ -307,6 +222,7 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v
        return err;
 }
 
+SND_DLSYM_BUILD_VERSION(snd_func_igetenv, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
 {
        snd_config_t *d;
@@ -331,8 +247,8 @@ int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
  _end:
        return err;
 }
-       
-       
+               
+SND_DLSYM_BUILD_VERSION(snd_func_concat, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
 {
        snd_config_t *n;
@@ -397,6 +313,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v
        return err;
 }
 
+SND_DLSYM_BUILD_VERSION(snd_func_datadir, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_datadir(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
                     snd_config_t *src, void *private_data ATTRIBUTE_UNUSED)
 {
@@ -428,6 +345,7 @@ static int string_from_integer(char **dst, long v)
 }
 #endif
 
+SND_DLSYM_BUILD_VERSION(snd_func_private_string, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, void *private_data)
 {
        int err;
@@ -472,6 +390,7 @@ int snd_determine_driver(int card, char **driver)
        return err;
 }
 
+SND_DLSYM_BUILD_VERSION(snd_func_private_card_strtype, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_private_card_strtype(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, void *private_data)
 {
        char *driver;
@@ -486,6 +405,7 @@ int snd_func_private_card_strtype(snd_config_t **dst, snd_config_t *root ATTRIBU
        return err;
 }
 
+SND_DLSYM_BUILD_VERSION(snd_func_card_strtype, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_card_strtype(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
 {
        snd_config_t *n;
@@ -518,6 +438,7 @@ int snd_func_card_strtype(snd_config_t **dst, snd_config_t *root, snd_config_t *
        return snd_func_private_card_strtype(dst, root, src, (void *)v);
 }
 
+SND_DLSYM_BUILD_VERSION(snd_func_card_id, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
 {
        snd_config_t *n;
@@ -568,6 +489,7 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
        return err;
 }
 
+SND_DLSYM_BUILD_VERSION(snd_func_pcm_id, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
 {
        snd_config_t *n;
@@ -640,6 +562,7 @@ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v
        return err;
 }
 
+SND_DLSYM_BUILD_VERSION(snd_func_private_pcm_subdevice, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, void *private_data)
 {
        char *res = NULL;
@@ -664,6 +587,7 @@ int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIB
        return err;
 }
 
+SND_DLSYM_BUILD_VERSION(snd_func_refer, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
 {
        snd_config_t *n;
index 5f4abc8fb7e4271ed8e18c1d37c0b012d5c147b9..77f6bc99a6776babd36e8113058986e43fd458ac 100644 (file)
@@ -502,10 +502,14 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
                open_name = buf;
                snprintf(buf, sizeof(buf), "_snd_ctl_%s_open", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
-       open_func = h ? dlsym(h, open_name) : NULL;
+       if (h) {
+               if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION))) < 0) {
+                       dlclose(h);
+                       goto _err;
+               }
+               open_func = dlsym(h, open_name);
+       }
        err = 0;
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
index 5374c9a224824d41b8b793a35f91b90772ed9dfc..e880142e9cb0fe4a27a660ed069ec295f25e7a2c 100644 (file)
@@ -318,6 +318,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_ctl_hw_open, SND_CONTROL_DLSYM_VERSION);
 int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf)
 {
        snd_config_iterator_t i, next;
index f04834f68e0e0b5a8ba514fcfd56123abbeccc40..4e7329e8a04599751411bfa8292885cbc74b38b7 100644 (file)
@@ -525,6 +525,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname
        return result;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_ctl_shm_open, SND_CONTROL_DLSYM_VERSION);
 int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_config_t *conf, int mode)
 {
        snd_config_iterator_t i, next;
diff --git a/src/dlmisc.c b/src/dlmisc.c
new file mode 100644 (file)
index 0000000..2d5ce75
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * \file dlmisc.c
+ * \brief dynamic loader helpers
+ * \author Jaroslav Kysela <perex@suse.cz>
+ * \date 2001
+ *
+ * Dynamic loader helpers
+ */
+/*
+ *  Dynamic loader helpers
+ *  Copyright (c) 2000 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 <dlfcn.h>
+#include "local.h"
+
+/**
+ * \brief Verify dynamically loaded symbol
+ * \param handle dlopen handle
+ * \param name name of symbol
+ * \param version version of symbol
+ * \return zero is success, otherwise a negative error code
+ */
+int snd_dlsym_verify(void *handle, const char *name, const char *version)
+{
+       int res;
+       char *vname;
+       
+       if (handle == NULL)
+               return -EINVAL;
+       vname = alloca(1 + strlen(name) + strlen(version) + 1);
+       vname[0] = '_';
+       strcpy(vname + 1, name);
+       strcat(vname, version);
+       res = dlsym(handle, vname) == NULL ? -ENOENT : 0;
+       printf("dlsym verify: %i, vname = '%s'\n", res, vname);
+       if (res < 0)
+               SNDERR("unable to verify version for symbol %s", name);
+       return res;
+}
index c3621e05169a07de60b2eee200fb4221685de067..ac76f46974687871c0315f1e0622230473d91414 100644 (file)
@@ -102,10 +102,14 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep,
                open_name = buf;
                snprintf(buf, sizeof(buf), "_snd_hwdep_%s_open", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
-       open_func = h ? dlsym(h, open_name) : NULL;
+       if (h) {
+               if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_HWDEP_DLSYM_VERSION))) < 0) {
+                       dlclose(h);
+                       goto _err;
+               }
+               open_func = dlsym(h, open_name);
+       }
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                err = -ENOENT;
index fbbfa7dc87a1023484f5ad399abb758ef928c4a7..2a43617146bb243d16685f06cf4a4cb57e4645e3 100644 (file)
@@ -137,6 +137,7 @@ int snd_hwdep_hw_open(snd_hwdep_t **handle, const char *name, int card, int devi
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_hwdep_hw_open, SND_HWDEP_DLSYM_VERSION);
 int _snd_hwdep_hw_open(snd_hwdep_t **hwdep, char *name,
                       snd_config_t *root ATTRIBUTE_UNUSED,
                       snd_config_t *conf, int mode)
index e6d989160a854bbd15dcfb5f74b81e2fac830ea6..2a53b234219a76e84c18c02b8edc6331620a0dcf 100644 (file)
@@ -1056,10 +1056,14 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
                open_name = buf;
                snprintf(buf, sizeof(buf), "_snd_pcm_%s_open", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
-       open_func = h ? dlsym(h, open_name) : NULL;
+       if (h) {
+               if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION))) < 0) {
+                       dlclose(h);
+                       goto _err;
+               }
+               open_func = dlsym(h, open_name);
+       }
        err = 0;
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
@@ -1079,25 +1083,12 @@ static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root,
                                 const char *name, snd_pcm_stream_t stream, int mode)
 {
        int err;
-       snd_config_t *pcm_conf, *n;
+       snd_config_t *pcm_conf;
        err = snd_config_search_definition(root, "pcm", name, &pcm_conf);
        if (err < 0) {
                SNDERR("Unknown PCM %s", name);
                return err;
        }
-       if (snd_config_search(pcm_conf, "refer", &n) >= 0) {
-               snd_config_t *refer;
-               char *new_name;
-               err = snd_config_refer_load(&refer, &new_name, root, n);
-               if (err < 0) {
-                       SNDERR("Unable to load refered block in PCM %s: %s", name, snd_strerror(err));
-                       return err;
-               }
-               err = snd_pcm_open_noupdate(pcmp, refer, new_name, stream, mode);
-               if (refer != root)
-                       snd_config_delete(refer);
-               return err;
-       }
        err = snd_pcm_open_conf(pcmp, name, root, pcm_conf, stream, mode);
        snd_config_delete(pcm_conf);
        return err;
index b8f0611228f16ec62c281ea761bfc6d28fcf94a7..2b43154db402769b1dd913cf768aea38cee6bf0e 100644 (file)
@@ -541,6 +541,7 @@ int snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfor
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_adpcm_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
                        snd_config_t *root, snd_config_t *conf, 
                        snd_pcm_stream_t stream, int mode)
index 230bf9476ab25b56bb6c2aa09a1f03a5a365fd62..dd1e9d9b7018c0c20e4630d23184433d5a8a6b8a 100644 (file)
@@ -414,6 +414,7 @@ int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sform
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_alaw_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
                       snd_config_t *root, snd_config_t *conf, 
                       snd_pcm_stream_t stream, int mode)
index 8c6b4863db34ee21eeb397475fd3342bdfff1c07..796b76335e712b06474d4d5b20d68092d2feab02 100644 (file)
@@ -184,6 +184,7 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_copy_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
                       snd_config_t *root, snd_config_t *conf, 
                       snd_pcm_stream_t stream, int mode)
index 669711248caffaa9e5f84be3e8db5fc1f7af6670..cbd0fdb17cee2e966a8b15c5d25b61f22b666eca 100644 (file)
@@ -449,6 +449,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_file_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
                       snd_config_t *root, snd_config_t *conf, 
                       snd_pcm_stream_t stream, int mode)
index 49a59c1dd1c3ce0b560f8f9849bf722fa5358169..98879465645b5b8ac6631c4e1944fbcadd235f7d 100644 (file)
@@ -394,8 +394,6 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
                install = buf;
                snprintf(buf, sizeof(buf), "_snd_pcm_hook_%s_install", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
        install_func = h ? dlsym(h, install) : NULL;
        err = 0;
@@ -425,6 +423,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_hooks_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
                        snd_config_t *root, snd_config_t *conf, 
                        snd_pcm_stream_t stream, int mode)
index 327aad2a7141b03fcb406c8559cf98d9e91db324..adab12c59bb769dba1c1d155a80e6e022178ed12 100644 (file)
@@ -640,6 +640,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, int card, int device, in
        return ret;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_hw_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
                     snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf,
                     snd_pcm_stream_t stream, int mode)
index 6bbe90febd8c467c0e3a930ab1b25e68594375bb..3b4a68dc39a4b7552422a97bafa38acded16a961 100644 (file)
@@ -319,6 +319,7 @@ int snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_linear_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
                         snd_config_t *root, snd_config_t *conf, 
                         snd_pcm_stream_t stream, int mode)
index 0b1c49d9c2b65002a754f4e6d9779b309991742d..01b2868cffe6e694198d3f1e5946e2a4b0083ba5 100644 (file)
@@ -704,8 +704,6 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
                open_name = buf;
                snprintf(buf, sizeof(buf), "_snd_pcm_scope_%s_open", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
        open_func = h ? dlsym(h, open_name) : NULL;
        err = 0;
@@ -724,6 +722,7 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
 }
 
                        
+SND_DLSYM_BUILD_VERSION(_snd_pcm_meter_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
                        snd_config_t *root, snd_config_t *conf, 
                        snd_pcm_stream_t stream, int mode)
index a8a32efa9380756e98d33d9de86b9e99b3ee4dcd..620d7ac731ef38879ea270bb7950b78834e790bc 100644 (file)
@@ -429,6 +429,7 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfor
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_mulaw_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
                        snd_config_t *root, snd_config_t *conf, 
                        snd_pcm_stream_t stream, int mode)
index de59198b5a92e8bcd28835cbbca17758b89b4ab7..a8a5003bfc88f642f83f671de64b93192b682993 100644 (file)
@@ -643,6 +643,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_multi_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
                        snd_config_t *root, snd_config_t *conf,
                        snd_pcm_stream_t stream, int mode)
index 0e6a3c6372595fb792418c7c01875bf09f781a0d..6360be385ffcb13d64c5ac5c1c9a1bfb1184daa1 100644 (file)
@@ -358,6 +358,7 @@ int snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t strea
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_null_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_null_open(snd_pcm_t **pcmp, const char *name,
                       snd_config_t *conf, 
                       snd_pcm_stream_t stream, int mode)
index 7463b6000c3f3de220a7650e43a45312c848ddb7..1ee99496cf005b9837a4e540a1b7b79f90d5110d 100644 (file)
@@ -771,6 +771,7 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp,
 
 #define MAX_CHANNELS 64
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_plug_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
                       snd_config_t *root, snd_config_t *conf, 
                       snd_pcm_stream_t stream, int mode)
index fd8030c7f1ee4a95bfac7766880a2fdee4686785..8aee151790674ad8c9d4dd8104040ffe7255e8c0 100644 (file)
@@ -528,6 +528,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sform
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_rate_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
                       snd_config_t *root, snd_config_t *conf, 
                       snd_pcm_stream_t stream, int mode)
index 776e15005dbcf47b7369fce61a14d358f2e4b2e4..a229cb0c110ac0cc435adad26c4db8a3e56bc2c8 100644 (file)
@@ -833,6 +833,7 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
 
 #define MAX_CHANNELS 32
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_route_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
                        snd_config_t *root, snd_config_t *conf, 
                        snd_pcm_stream_t stream, int mode)
index 529fad16bdc1b925dd5de3857be45a2c9e02baaf..65fab30eea581fb6d6a88d56971ebd2edb13d568 100644 (file)
@@ -1359,6 +1359,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname,
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_share_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
                        snd_config_t *root, snd_config_t *conf,
                        snd_pcm_stream_t stream, int mode)
index bdba92151fb628d242171655faaf0f1e1e39ead1..0b1770c550d53d113082da9fc8f8bfabb0ffb116 100644 (file)
@@ -710,6 +710,7 @@ int is_local(struct hostent *hent)
        return i < numreqs;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_pcm_shm_open, SND_PCM_DLSYM_VERSION);
 int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
                      snd_config_t *root, snd_config_t *conf,
                      snd_pcm_stream_t stream, int mode)
index 92fa167985beb7386f5bac47ab5929e659988757..5718d96affba04f93e0e53714a12df805baae760 100644 (file)
@@ -128,10 +128,14 @@ static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp
                open_name = buf;
                snprintf(buf, sizeof(buf), "_snd_rawmidi_%s_open", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
-       open_func = h ? dlsym(h, open_name) : NULL;
+       if (h) {
+               if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_RAWMIDI_DLSYM_VERSION))) < 0) {
+                       dlclose(h);
+                        goto _err;
+               }
+               open_func = dlsym(h, open_name);
+       }
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                err = -ENOENT;
index 49bb4fa42c1444bc2b1e6de54be335275a4dee5d..b5103d681cc10a2969b200022aaddfb05a2207e9 100644 (file)
@@ -302,6 +302,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
        return -ENOMEM;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_rawmidi_hw_open, SND_RAWMIDI_DLSYM_VERSION);
 int _snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
                         char *name, snd_config_t *root ATTRIBUTE_UNUSED,
                         snd_config_t *conf, int mode)
index 1596b32f804f4b800ebe449d9712dd58c7abc1c7..1fa300a3d0a57662fb4021d314d65832d85bec93 100644 (file)
@@ -129,10 +129,14 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name,
                open_name = buf;
                snprintf(buf, sizeof(buf), "_snd_seq_%s_open", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
-       open_func = h ? dlsym(h, open_name) : NULL;
+       if (h) {
+               if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_SEQ_DLSYM_VERSION))) < 0) {
+                       dlclose(h);
+                       goto _err;
+               }
+               open_func = dlsym(h, open_name);
+       }
        err = 0;
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
index 6a239bfc6ef8d33c27eb6e752ca63e6ae4d1c668..a66376650bbe54a2e68e5c41778417248713ee85 100644 (file)
@@ -503,6 +503,7 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode)
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_seq_hw_open, SND_SEQ_DLSYM_VERSION);
 int _snd_seq_hw_open(snd_seq_t **handlep, char *name,
                     snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf,
                     int streams, int mode)
index f507843667df1b8a2f230bdbfb36aca1c6a0a8bd..cdf41a08c07a91cf556a1fb4a0622f6e339adf9f 100644 (file)
@@ -101,10 +101,14 @@ static int snd_timer_open_conf(snd_timer_t **timer,
                open_name = buf;
                snprintf(buf, sizeof(buf), "_snd_timer_%s_open", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
-       open_func = h ? dlsym(h, open_name) : NULL;
+       if (h) {
+               if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_TIMER_DLSYM_VERSION))) < 0) {
+                       dlclose(h);
+                        goto _err;
+               }
+               open_func = dlsym(h, open_name);
+       }
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                err = -ENOENT;
index bea2519605a9fbd5bef5fd3b16dd59471e16e8ab..dd1f20d7d4f299183437d312d50711c09819555a 100644 (file)
@@ -200,6 +200,7 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_timer_hw_open, SND_TIMER_DLSYM_VERSION);
 int _snd_timer_hw_open(snd_timer_t **timer, char *name,
                       snd_config_t *root ATTRIBUTE_UNUSED,
                       snd_config_t *conf, int mode)
index 1492e1ed44256f7769fda655949f90c9577ef31e..ebdd65c34bfeb1dd240958df088793acb57fa1b3 100644 (file)
@@ -100,10 +100,14 @@ static int snd_timer_query_open_conf(snd_timer_query_t **timer,
                open_name = buf;
                snprintf(buf, sizeof(buf), "_snd_timer_query_%s_open", str);
        }
-       if (!lib)
-               lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
-       open_func = h ? dlsym(h, open_name) : NULL;
+       if (h) {
+               if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_TIMER_QUERY_DLSYM_VERSION))) < 0) {
+                       dlclose(h);
+                        goto _err;
+               }
+               open_func = dlsym(h, open_name);
+       }
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                err = -ENOENT;
index 6d70a317d7ac79459e28b990578e51675bf6f64b..e63a48114ac23c2fa752bdf9f50a93fc44b679c5 100644 (file)
@@ -88,6 +88,7 @@ int snd_timer_query_hw_open(snd_timer_query_t **handle, const char *name, int mo
        return 0;
 }
 
+SND_DLSYM_BUILD_VERSION(_snd_timer_query_hw_open, SND_TIMER_QUERY_DLSYM_VERSION);
 int _snd_timer_query_hw_open(snd_timer_query_t **timer, char *name,
                             snd_config_t *root ATTRIBUTE_UNUSED,
                             snd_config_t *conf, int mode)