aboutsummaryrefslogtreecommitdiffstats
path: root/codecs
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-14 14:08:19 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-14 14:08:19 +0000
commit3664249356aa4768fcb0b3b8e6cf9365fcbd0c8d (patch)
treeb68f48482e463e9c31126b2e3e24fca1dd2f6c82 /codecs
parentf9d382fc079246930a99640d7835d6ae3e4149db (diff)
This rather large commit changes the way modules are loaded.
As partly documented in loader.c and include/asterisk/module.h, modules are now expected to return all of their methods and flags into a structure 'mod_data', and are normally loaded with RTLD_NOW | RTLD_LOCAL, so symbols are resolved immediately and conflicts should be less likely. Only in a small number of cases (res_*, typically) modules are loaded RTLD_GLOBAL, so they can export symbols. The core of the change is only the two files loader.c and include/asterisk/module.h, all the rest is simply adaptation of the existing modules to the new API, a rather mechanical (but believe me, time and finger-consuming!) process whose detail you can figure out by svn diff'ing any single module. Expect some minor compilation issue after this change, please report it on mantis http://bugs.digium.com/view.php?id=6968 so we collect all the feedback in one place. I am just sorry that this change missed SVN version number 20000! git-svn-id: http://svn.digium.com/svn/asterisk/trunk@20003 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'codecs')
-rw-r--r--codecs/codec_a_mu.c27
-rw-r--r--codecs/codec_adpcm.c30
-rw-r--r--codecs/codec_alaw.c29
-rw-r--r--codecs/codec_g723_1.c27
-rw-r--r--codecs/codec_g726.c28
-rw-r--r--codecs/codec_gsm.c29
-rw-r--r--codecs/codec_ilbc.c27
-rw-r--r--codecs/codec_lpc10.c32
-rw-r--r--codecs/codec_speex.c37
-rw-r--r--codecs/codec_ulaw.c32
10 files changed, 92 insertions, 206 deletions
diff --git a/codecs/codec_a_mu.c b/codecs/codec_a_mu.c
index 2f5400de6..51e38e9cf 100644
--- a/codecs/codec_a_mu.c
+++ b/codecs/codec_a_mu.c
@@ -111,8 +111,6 @@ static struct ast_frame *ulawtoalaw_sample(void)
return &f;
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator alawtoulaw = {
.name = "alawtoulaw",
.srcfmt = AST_FORMAT_ALAW,
@@ -121,7 +119,6 @@ static struct ast_translator alawtoulaw = {
.sample = alawtoulaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
- .lockp = &me,
};
static struct ast_translator ulawtoalaw = {
@@ -132,24 +129,19 @@ static struct ast_translator ulawtoalaw = {
.sample = ulawtoalaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
- .lockp = &me,
};
/*! \brief standard module glue */
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&ulawtoalaw);
res |= ast_unregister_translator(&alawtoulaw);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
int x;
@@ -157,25 +149,22 @@ int load_module(void)
mu2a[x] = AST_LIN2A(AST_MULAW(x));
a2mu[x] = AST_LIN2MU(AST_ALAW(x));
}
- res = ast_register_translator(&alawtoulaw);
+ res = ast_register_translator(&alawtoulaw, mod);
if (!res)
- res = ast_register_translator(&ulawtoalaw);
+ res = ast_register_translator(&ulawtoalaw, mod);
else
ast_unregister_translator(&alawtoulaw);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "A-law and Mulaw direct Coder/Decoder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/codecs/codec_adpcm.c b/codecs/codec_adpcm.c
index 83ff54fba..e9ee5b35d 100644
--- a/codecs/codec_adpcm.c
+++ b/codecs/codec_adpcm.c
@@ -27,6 +27,7 @@
* \ingroup codecs
*/
+
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
@@ -326,8 +327,6 @@ static struct ast_frame *lintoadpcm_sample(void)
return &f;
}
-struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator adpcmtolin = {
.name = "adpcmtolin",
.srcfmt = AST_FORMAT_ADPCM,
@@ -338,7 +337,6 @@ static struct ast_translator adpcmtolin = {
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
- .lockp = &me,
};
static struct ast_translator lintoadpcm = {
@@ -351,7 +349,6 @@ static struct ast_translator lintoadpcm = {
.desc_size = sizeof (struct adpcm_encoder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES/ 2, /* 2 samples per byte */
- .lockp = &me,
};
static void parse_config(void)
@@ -371,47 +368,40 @@ static void parse_config(void)
}
/*! \brief standard module glue */
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintoadpcm);
res |= ast_unregister_translator(&adpcmtolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res = ast_register_translator(&adpcmtolin);
+ res = ast_register_translator(&adpcmtolin, mod);
if (!res)
- res = ast_register_translator(&lintoadpcm);
+ res = ast_register_translator(&lintoadpcm, mod);
else
ast_unregister_translator(&adpcmtolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "Adaptive Differential PCM Coder/Decoder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_alaw.c b/codecs/codec_alaw.c
index 1178f1416..d654e21e4 100644
--- a/codecs/codec_alaw.c
+++ b/codecs/codec_alaw.c
@@ -109,8 +109,6 @@ static struct ast_frame *lintoalaw_sample(void)
return &f;
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator alawtolin = {
.name = "alawtolin",
.srcfmt = AST_FORMAT_ALAW,
@@ -120,7 +118,6 @@ static struct ast_translator alawtolin = {
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
- .lockp = &me,
};
static struct ast_translator lintoalaw = {
@@ -131,7 +128,6 @@ static struct ast_translator lintoalaw = {
.sample = lintoalaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
- .lockp = &me,
};
static void parse_config(void)
@@ -152,47 +148,40 @@ static void parse_config(void)
/*! \brief standard module stuff */
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintoalaw);
res |= ast_unregister_translator(&alawtolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res = ast_register_translator(&alawtolin);
+ res = ast_register_translator(&alawtolin, mod);
if (!res)
- res = ast_register_translator(&lintoalaw);
+ res = ast_register_translator(&lintoalaw, mod);
else
ast_unregister_translator(&alawtolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "A-law Coder/Decoder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_g723_1.c b/codecs/codec_g723_1.c
index d6e1d1b22..00a5ca635 100644
--- a/codecs/codec_g723_1.c
+++ b/codecs/codec_g723_1.c
@@ -265,8 +265,6 @@ static struct ast_frame *lintog723_frameout(void *pvt)
return ast_trans_frameout(pvt, cnt, samples);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator g723tolin = {
.name =
#ifdef ANNEX_B
@@ -280,7 +278,6 @@ static struct ast_translator g723tolin = {
.framein = g723tolin_framein,
.sample = g723tolin_sample,
.desc_size = sizeof(struct ...),
- .lockp = &me,
};
static struct ast_translator lintog723 = {
@@ -297,36 +294,31 @@ static struct ast_translator lintog723 = {
.frameout = lintog723_frameout,
.destroy = g723_destroy,
.sample = lintog723_sample,
- .lockp = &me,
.desc_size = sizeof(struct ...),
};
/*! \brief standard module glue */
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintog723);
res |= ast_unregister_translator(&g723tolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
- res=ast_register_translator(&g723tolin);
+ res=ast_register_translator(&g723tolin, mod);
if (!res)
- res=ast_register_translator(&lintog723);
+ res=ast_register_translator(&lintog723, mod);
else
ast_unregister_translator(&g723tolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
#ifdef ANNEX_B
return "Annex B (floating point) G.723.1/PCM16 Codec Translator";
@@ -336,12 +328,9 @@ const char *description(void)
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_g726.c b/codecs/codec_g726.c
index e3e766b47..3b979eb63 100644
--- a/codecs/codec_g726.c
+++ b/codecs/codec_g726.c
@@ -775,8 +775,6 @@ static struct ast_frame *lintog726_sample (void)
return &f;
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator g726tolin = {
.name = "g726tolin",
.srcfmt = AST_FORMAT_G726,
@@ -788,7 +786,6 @@ static struct ast_translator g726tolin = {
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
- .lockp = &me,
};
static struct ast_translator lintog726 = {
@@ -801,7 +798,6 @@ static struct ast_translator lintog726 = {
.desc_size = sizeof(struct g726_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES/2,
- .lockp = &me,
};
static void parse_config(void)
@@ -823,47 +819,39 @@ static void parse_config(void)
/*! \brief standard module glue */
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module (void)
+static int unload_module (void *mod)
{
int res;
- ast_mutex_lock (&me.lock);
res = ast_unregister_translator (&lintog726);
res |= ast_unregister_translator (&g726tolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock (&me.lock);
return res;
}
-int load_module (void)
+static int load_module (void *mod)
{
int res;
parse_config();
- res = ast_register_translator (&g726tolin);
+ res = ast_register_translator (&g726tolin, mod);
if (!res)
- res = ast_register_translator (&lintog726);
+ res = ast_register_translator (&lintog726, mod);
else
ast_unregister_translator (&g726tolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "ITU G.726-32kbps G726 Transcoder";
}
-int usecount (void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_gsm.c b/codecs/codec_gsm.c
index df20d9b2a..e9a85bc38 100644
--- a/codecs/codec_gsm.c
+++ b/codecs/codec_gsm.c
@@ -203,8 +203,6 @@ static void gsm_destroy_stuff(struct ast_trans_pvt *pvt)
gsm_destroy(tmp->gsm);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator gsmtolin = {
.name = "gsmtolin",
.srcfmt = AST_FORMAT_GSM,
@@ -213,7 +211,6 @@ static struct ast_translator gsmtolin = {
.framein = gsmtolin_framein,
.destroy = gsm_destroy_stuff,
.sample = gsmtolin_sample,
- .lockp = &me,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.desc_size = sizeof (struct gsm_translator_pvt ),
@@ -229,7 +226,6 @@ static struct ast_translator lintogsm = {
.frameout = lintogsm_frameout,
.destroy = gsm_destroy_stuff,
.sample = lintogsm_sample,
- .lockp = &me,
.desc_size = sizeof (struct gsm_translator_pvt ),
.buf_size = (BUFFER_SAMPLES * GSM_FRAME_LEN + GSM_SAMPLES - 1)/GSM_SAMPLES,
};
@@ -252,48 +248,41 @@ static void parse_config(void)
}
/*! \brief standard module glue */
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintogsm);
if (!res)
res = ast_unregister_translator(&gsmtolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res=ast_register_translator(&gsmtolin);
+ res = ast_register_translator(&gsmtolin, mod);
if (!res)
- res=ast_register_translator(&lintogsm);
+ res=ast_register_translator(&lintogsm, mod);
else
ast_unregister_translator(&gsmtolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "GSM/PCM16 (signed linear) Codec Translator";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_ilbc.c b/codecs/codec_ilbc.c
index 1c9339403..cc4f88307 100644
--- a/codecs/codec_ilbc.c
+++ b/codecs/codec_ilbc.c
@@ -190,8 +190,6 @@ static struct ast_frame *lintoilbc_frameout(struct ast_trans_pvt *pvt)
return ast_trans_frameout(pvt, datalen, samples);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator ilbctolin = {
.name = "ilbctolin",
.srcfmt = AST_FORMAT_ILBC,
@@ -201,7 +199,6 @@ static struct ast_translator ilbctolin = {
.sample = ilbctolin_sample,
.desc_size = sizeof(struct ilbc_coder_pvt),
.buf_size = BUFFER_SAMPLES * 2,
- .lockp = &me,
};
static struct ast_translator lintoilbc = {
@@ -214,43 +211,35 @@ static struct ast_translator lintoilbc = {
.sample = lintoilbc_sample,
.desc_size = sizeof(struct ilbc_coder_pvt),
.buf_size = (BUFFER_SAMPLES * ILBC_FRAME_LEN + ILBC_SAMPLES - 1) / ILBC_SAMPLES,
- .lockp = &me,
};
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintoilbc);
res |= ast_unregister_translator(&ilbctolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
- res=ast_register_translator(&ilbctolin);
+ res = ast_register_translator(&ilbctolin, mod);
if (!res)
- res=ast_register_translator(&lintoilbc);
+ res=ast_register_translator(&lintoilbc, mod);
else
ast_unregister_translator(&ilbctolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return tdesc;
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/codecs/codec_lpc10.c b/codecs/codec_lpc10.c
index 192c94c87..1904368b9 100644
--- a/codecs/codec_lpc10.c
+++ b/codecs/codec_lpc10.c
@@ -240,8 +240,6 @@ static void lpc10_destroy(struct ast_trans_pvt *arg)
free(pvt->lpc10.enc);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator lpc10tolin = {
.name = "lpc10tolin",
.srcfmt = AST_FORMAT_LPC10,
@@ -250,7 +248,6 @@ static struct ast_translator lpc10tolin = {
.framein = lpc10tolin_framein,
.destroy = lpc10_destroy,
.sample = lpc10tolin_sample,
- .lockp = &me,
.desc_size = sizeof(struct lpc10_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.plc_samples = LPC10_SAMPLES_PER_FRAME,
@@ -266,7 +263,6 @@ static struct ast_translator lintolpc10 = {
.frameout = lintolpc10_frameout,
.destroy = lpc10_destroy,
.sample = lintolpc10_sample,
- .lockp = &me,
.desc_size = sizeof(struct lpc10_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = LPC10_BYTES_IN_COMPRESSED_FRAME * (1 + BUFFER_SAMPLES / LPC10_SAMPLES_PER_FRAME),
@@ -289,49 +285,41 @@ static void parse_config(void)
ast_config_destroy(cfg);
}
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintolpc10);
- if (!res)
- res = ast_unregister_translator(&lpc10tolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
+ res |= ast_unregister_translator(&lpc10tolin);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res=ast_register_translator(&lpc10tolin);
+ res=ast_register_translator(&lpc10tolin, mod);
if (!res)
- res=ast_register_translator(&lintolpc10);
+ res=ast_register_translator(&lintolpc10, mod);
else
ast_unregister_translator(&lpc10tolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "LPC10 2.4kbps (signed linear) Voice Coder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_speex.c b/codecs/codec_speex.c
index 86d20b52b..2f31fb4d5 100644
--- a/codecs/codec_speex.c
+++ b/codecs/codec_speex.c
@@ -337,8 +337,6 @@ static void lintospeex_destroy(struct ast_trans_pvt *arg)
speex_bits_destroy(&pvt->bits);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator speextolin = {
.name = "speextolin",
.srcfmt = AST_FORMAT_SPEEX,
@@ -350,7 +348,6 @@ static struct ast_translator speextolin = {
.desc_size = sizeof(struct speex_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
- .lockp = &me,
};
static struct ast_translator lintospeex = {
@@ -365,10 +362,8 @@ static struct ast_translator lintospeex = {
.desc_size = sizeof(struct speex_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2, /* XXX maybe a lot less ? */
- .lockp = &me,
};
-
static void parse_config(void)
{
struct ast_config *cfg = ast_config_load("codecs.conf");
@@ -479,7 +474,7 @@ static void parse_config(void)
ast_config_destroy(cfg);
}
-int reload(void)
+static int reload(void *mod)
{
/*
* XXX reloading while there are active sessions is
@@ -487,48 +482,40 @@ int reload(void)
* wouldn't work anymore...
* maybe we shuld do a standard hangup localusers ?
*/
- ast_mutex_lock(&me.lock);
+ ast_mutex_lock(&__mod_desc->lock);
parse_config();
- ast_mutex_lock(&me.lock);
+ ast_mutex_lock(&__mod_desc->lock);
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintospeex);
- if (!res)
- res = ast_unregister_translator(&speextolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
+ res |= ast_unregister_translator(&speextolin);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res=ast_register_translator(&speextolin);
+ res=ast_register_translator(&speextolin, mod);
if (!res)
- res=ast_register_translator(&lintospeex);
+ res=ast_register_translator(&lintospeex, mod);
else
ast_unregister_translator(&speextolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "Speex/PCM16 (signed linear) Codec Translator";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_ulaw.c b/codecs/codec_ulaw.c
index d1fba8247..0db01de7c 100644
--- a/codecs/codec_ulaw.c
+++ b/codecs/codec_ulaw.c
@@ -118,15 +118,12 @@ static struct ast_frame *lintoulaw_sample(void)
* \brief The complete translator for ulawToLin.
*/
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator ulawtolin = {
.name = "ulawtolin",
.srcfmt = AST_FORMAT_ULAW,
.dstfmt = AST_FORMAT_SLINEAR,
.framein = ulawtolin_framein,
.sample = ulawtolin_sample,
- .lockp = &me,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
@@ -142,7 +139,6 @@ static struct ast_translator lintoulaw = {
.dstfmt = AST_FORMAT_ULAW,
.framein = lintoulaw_framein,
.sample = lintoulaw_sample,
- .lockp = &me,
.buf_size = BUFFER_SAMPLES,
.buffer_samples = BUFFER_SAMPLES,
};
@@ -163,32 +159,27 @@ static void parse_config(void)
ast_config_destroy(cfg);
}
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintoulaw);
- if (!res)
- res = ast_unregister_translator(&ulawtolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
+ res |= ast_unregister_translator(&ulawtolin);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res = ast_register_translator(&ulawtolin);
+ res = ast_register_translator(&ulawtolin, mod);
if (!res)
- res = ast_register_translator(&lintoulaw);
+ res = ast_register_translator(&lintoulaw, mod);
else
ast_unregister_translator(&ulawtolin);
return res;
@@ -198,17 +189,14 @@ int load_module(void)
* Return a description of this module.
*/
-const char *description(void)
+static const char *description(void)
{
return "Mu-law Coder/Decoder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);