From 0d7d11889db452eb7d2a77f7347be01c61764f02 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 7 Nov 2002 15:18:45 +0000 Subject: [PATCH] Added missing snd_dlclose() calls --- src/Makefile.am | 2 +- src/control/control.c | 13 ++++++++++++- src/control/control_local.h | 1 + src/dlmisc.c | 2 ++ src/hwdep/hwdep.c | 10 +++++++++- src/hwdep/hwdep_local.h | 1 + src/pcm/pcm.c | 13 ++++++++++++- src/pcm/pcm_local.h | 1 + src/rawmidi/rawmidi.c | 4 ++++ src/rawmidi/rawmidi_local.h | 1 + 10 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 519c1041..95c7c587 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,7 @@ libasound_la_SOURCES = conf.c confmisc.c input.c output.c async.c error.c dlmisc 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 \ - compat/libcompat.la -lm -ldl -lpthread + compat/libcompat.la -lm -ldl -lpthread libasound_la_LDFLAGS = -version-info $(COMPATNUM) LDFLAGS = -Wl,--version-script=Versions diff --git a/src/control/control.c b/src/control/control.c index 7a65ce30..5f0f1bc3 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -96,6 +96,8 @@ int snd_ctl_close(snd_ctl_t *ctl) err = ctl->ops->close(ctl); if (ctl->name) free(ctl->name); + if (ctl->dl_handle) + snd_dlclose(ctl->dl_handle); free(ctl); return err; } @@ -589,7 +591,16 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name, _err: if (type_conf) snd_config_delete(type_conf); - return err >= 0 ? open_func(ctlp, name, ctl_root, ctl_conf, mode) : err; + if (err >= 0) { + err = open_func(ctlp, name, ctl_root, ctl_conf, mode); + if (err >= 0) { + (*ctlp)->dl_handle = h; + return 0; + } else { + snd_dlclose(h); + } + } + return err; } static int snd_ctl_open_noupdate(snd_ctl_t **ctlp, snd_config_t *root, const char *name, int mode) diff --git a/src/control/control_local.h b/src/control/control_local.h index 4891f368..80081c43 100644 --- a/src/control/control_local.h +++ b/src/control/control_local.h @@ -48,6 +48,7 @@ typedef struct _snd_ctl_ops { struct _snd_ctl { + void *dl_handle; char *name; snd_ctl_type_t type; snd_ctl_ops_t *ops; diff --git a/src/dlmisc.c b/src/dlmisc.c index a5d174d7..d275ad68 100644 --- a/src/dlmisc.c +++ b/src/dlmisc.c @@ -48,6 +48,8 @@ struct snd_dlsym_link *snd_dlsym_start = NULL; */ void *snd_dlopen(const char *name, int mode) { + void *res; + #ifndef PIC if (name == NULL) return &snd_dlsym_start; diff --git a/src/hwdep/hwdep.c b/src/hwdep/hwdep.c index 53eb18fe..994e74b7 100644 --- a/src/hwdep/hwdep.c +++ b/src/hwdep/hwdep.c @@ -131,7 +131,15 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep, _err: if (type_conf) snd_config_delete(type_conf); - return err >= 0 ? open_func(hwdep, name, hwdep_root, hwdep_conf, mode) : err; + if (err >= 0) { + err = open_func(hwdep, name, hwdep_root, hwdep_conf, mode); + if (err >= 0) { + (*hwdep)->dl_handle = h; + } else { + snd_dlclose(h); + } + } + return err; } static int snd_hwdep_open_noupdate(snd_hwdep_t **hwdep, snd_config_t *root, const char *name, int mode) diff --git a/src/hwdep/hwdep_local.h b/src/hwdep/hwdep_local.h index 9ab545e2..8767d4f4 100644 --- a/src/hwdep/hwdep_local.h +++ b/src/hwdep/hwdep_local.h @@ -34,6 +34,7 @@ typedef struct { } snd_hwdep_ops_t; struct _snd_hwdep { + void *dl_handle; char *name; snd_hwdep_type_t type; int mode; diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index c08469fc..d6ef9078 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -678,6 +678,8 @@ int snd_pcm_close(snd_pcm_t *pcm) free(pcm->hw.link_dst); if (pcm->appl.link_dst) free(pcm->appl.link_dst); + if (pcm->dl_handle) + snd_dlclose(pcm->dl_handle); free(pcm); return 0; } @@ -1790,7 +1792,16 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, _err: if (type_conf) snd_config_delete(type_conf); - return err >= 0 ? open_func(pcmp, name, pcm_root, pcm_conf, stream, mode) : err; + if (err >= 0) { + err = open_func(pcmp, name, pcm_root, pcm_conf, stream, mode); + if (err >= 0) { + (*pcmp)->dl_handle = h; + return 0; + } else { + snd_dlclose(h); + } + } + return err; } static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root, diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 07904f8a..fa8e4cce 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -157,6 +157,7 @@ typedef struct { } snd_pcm_fast_ops_t; struct _snd_pcm { + void *dl_handle; char *name; snd_pcm_type_t type; snd_pcm_stream_t stream; diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 24994901..a942435d 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -256,11 +256,13 @@ static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp if (err < 0) return err; if (inputp) { + (*inputp)->dl_handle = h; h = NULL; snd_rawmidi_params_default(*inputp, ¶ms); err = snd_rawmidi_params(*inputp, ¶ms); assert(err >= 0); } if (outputp) { + (*outputp)->dl_handle = h; snd_rawmidi_params_default(*outputp, ¶ms); err = snd_rawmidi_params(*outputp, ¶ms); assert(err >= 0); @@ -340,6 +342,8 @@ int snd_rawmidi_close(snd_rawmidi_t *rawmidi) return err; if (rawmidi->name) free(rawmidi->name); + if (rawmidi->dl_handle) + snd_dlclose(rawmidi->dl_handle); free(rawmidi); return 0; } diff --git a/src/rawmidi/rawmidi_local.h b/src/rawmidi/rawmidi_local.h index dcecc199..2e110460 100644 --- a/src/rawmidi/rawmidi_local.h +++ b/src/rawmidi/rawmidi_local.h @@ -37,6 +37,7 @@ typedef struct { } snd_rawmidi_ops_t; struct _snd_rawmidi { + void *dl_handle; char *name; snd_rawmidi_type_t type; snd_rawmidi_stream_t stream; -- 2.47.3