diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-14 14:08:19 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-14 14:08:19 +0000 |
commit | 3664249356aa4768fcb0b3b8e6cf9365fcbd0c8d (patch) | |
tree | b68f48482e463e9c31126b2e3e24fca1dd2f6c82 /formats | |
parent | f9d382fc079246930a99640d7835d6ae3e4149db (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 'formats')
-rw-r--r-- | formats/format_g723.c | 19 | ||||
-rw-r--r-- | formats/format_g726.c | 24 | ||||
-rw-r--r-- | formats/format_g729.c | 19 | ||||
-rw-r--r-- | formats/format_gsm.c | 19 | ||||
-rw-r--r-- | formats/format_h263.c | 19 | ||||
-rw-r--r-- | formats/format_h264.c | 19 | ||||
-rw-r--r-- | formats/format_ilbc.c | 20 | ||||
-rw-r--r-- | formats/format_jpeg.c | 17 | ||||
-rw-r--r-- | formats/format_ogg_vorbis.c | 20 | ||||
-rw-r--r-- | formats/format_pcm.c | 23 | ||||
-rw-r--r-- | formats/format_sln.c | 19 | ||||
-rw-r--r-- | formats/format_vox.c | 19 | ||||
-rw-r--r-- | formats/format_wav.c | 19 | ||||
-rw-r--r-- | formats/format_wav_gsm.c | 19 |
14 files changed, 101 insertions, 174 deletions
diff --git a/formats/format_g723.c b/formats/format_g723.c index 4beba0c64..5de56d86c 100644 --- a/formats/format_g723.c +++ b/formats/format_g723.c @@ -138,8 +138,6 @@ static off_t g723_tell(struct ast_filestream *fs) return -1; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format g723_1_f = { .name = "g723sf", .exts = "g723|g723sf", @@ -150,30 +148,27 @@ static const struct ast_format g723_1_f = { .tell = g723_tell, .read = g723_read, .buf_size = G723_MAX_SIZE + AST_FRIENDLY_OFFSET, - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&g723_1_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(g723_1_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "G.723.1 Simple Timestamp File Format"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_g726.c b/formats/format_g726.c index d72f48991..61b06b47e 100644 --- a/formats/format_g726.c +++ b/formats/format_g726.c @@ -190,8 +190,6 @@ static off_t g726_tell(struct ast_filestream *fs) return -1; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format f[] = { { .name = "g726-40", @@ -206,7 +204,7 @@ static const struct ast_format f[] = { .read = g726_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct g726_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }, { .name = "g726-32", @@ -221,7 +219,7 @@ static const struct ast_format f[] = { .read = g726_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct g726_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }, { .name = "g726-24", @@ -236,7 +234,7 @@ static const struct ast_format f[] = { .read = g726_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct g726_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }, { .name = "g726-16", @@ -251,7 +249,7 @@ static const struct ast_format f[] = { .read = g726_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct g726_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }, { .format = 0 } /* terminator */ }; @@ -259,7 +257,7 @@ static const struct ast_format f[] = { /* * Module interface (load_module, unload_module, usecount, description, key) */ -int load_module() +static int load_module(void *mod) { int i; @@ -272,7 +270,7 @@ int load_module() return 0; } -int unload_module() +static int unload_module(void *mod) { int i; @@ -283,18 +281,14 @@ int unload_module() return(0); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Raw G.726 (16/24/32/40kbps) data"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } +STD_MOD1; diff --git a/formats/format_g729.c b/formats/format_g729.c index 1719e3a5c..387641e7a 100644 --- a/formats/format_g729.c +++ b/formats/format_g729.c @@ -134,8 +134,6 @@ static off_t g729_tell(struct ast_filestream *fs) return (offset/BUF_SIZE)*G729A_SAMPLES; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format g729_f = { .name = "g729", .exts = "g729", @@ -146,30 +144,27 @@ static const struct ast_format g729_f = { .tell = g729_tell, .read = g729_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&g729_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(g729_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Raw G729 data"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_gsm.c b/formats/format_gsm.c index 423088c17..46d943394 100644 --- a/formats/format_gsm.c +++ b/formats/format_gsm.c @@ -156,8 +156,6 @@ static off_t gsm_tell(struct ast_filestream *fs) return (offset/GSM_FRAME_SIZE)*GSM_SAMPLES; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format gsm_f = { .name = "gsm", .exts = "gsm", @@ -168,30 +166,27 @@ static const struct ast_format gsm_f = { .tell = gsm_tell, .read = gsm_read, .buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET, /* 2 gsm frames */ - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&gsm_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(gsm_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Raw GSM data"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_h263.c b/formats/format_h263.c index c64e001fd..602943dbc 100644 --- a/formats/format_h263.c +++ b/formats/format_h263.c @@ -163,8 +163,6 @@ static off_t h263_tell(struct ast_filestream *fs) return offset; /* XXX totally bogus, needs fixing */ } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format h263_f = { .name = "h263", .exts = "h264", @@ -177,30 +175,27 @@ static const struct ast_format h263_f = { .read = h263_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct h263_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&h263_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(h263_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Raw h263 data"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_h264.c b/formats/format_h264.c index 26db782e5..5c4ddf8f0 100644 --- a/formats/format_h264.c +++ b/formats/format_h264.c @@ -156,8 +156,6 @@ static off_t h264_tell(struct ast_filestream *fs) return offset; /* XXX totally bogus, needs fixing */ } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format h264_f = { .name = "h264", .exts = "h264", @@ -170,30 +168,27 @@ static const struct ast_format h264_f = { .read = h264_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct h264_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&h264_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(h264_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Raw h264 data"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c index 940abf25f..154dc17ab 100644 --- a/formats/format_ilbc.c +++ b/formats/format_ilbc.c @@ -132,8 +132,6 @@ static off_t ilbc_tell(struct ast_filestream *fs) return (offset/ILBC_BUF_SIZE)*ILBC_SAMPLES; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format ilbc_f = { .name = "iLBC", .exts = "ilbc", @@ -144,31 +142,27 @@ static const struct ast_format ilbc_f = { .tell = ilbc_tell, .read = ilbc_read, .buf_size = ILBC_BUF_SIZE + AST_FRIENDLY_OFFSET, - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&ilbc_f); } - -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(ilbc_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Raw iLBC data"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c index 01f4d929a..a66b21fbc 100644 --- a/formats/format_jpeg.c +++ b/formats/format_jpeg.c @@ -115,30 +115,25 @@ static struct ast_imager jpeg_format = { jpeg_write_image, }; -int load_module() +static int load_module(void *mod) { return ast_image_register(&jpeg_format); } -int unload_module() +static int unload_module(void *mod) { ast_image_unregister(&jpeg_format); return 0; } -int usecount() -{ - /* We never really have any users */ - return 0; -} - -const char *description() +static const char *description(void) { return desc; } - -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c index ee12e6a8f..69a43f0fd 100644 --- a/formats/format_ogg_vorbis.c +++ b/formats/format_ogg_vorbis.c @@ -523,8 +523,6 @@ static off_t ogg_vorbis_tell(struct ast_filestream *s) return -1; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format vorbis_f = { .name = "ogg_vorbis", .exts = "ogg", @@ -539,31 +537,27 @@ static const struct ast_format vorbis_f = { .close = ogg_vorbis_close, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct vorbis_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&vorbis_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(vorbis_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "OGG/Vorbis audio"; } - -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_pcm.c b/formats/format_pcm.c index 889e7afc2..c2b626240 100644 --- a/formats/format_pcm.c +++ b/formats/format_pcm.c @@ -414,8 +414,6 @@ static off_t au_tell(struct ast_filestream *fs) return offset - AU_HEADER_SIZE; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format alaw_f = { .name = "alaw", .exts = "alaw|al", @@ -426,7 +424,7 @@ static const struct ast_format alaw_f = { .tell = pcm_tell, .read = pcm_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, - .lockp = &me, + .module = &mod_data, /* XXX */ #ifdef REALTIME_WRITE .open = pcma_open, .rewrite = pcma_rewrite, @@ -444,7 +442,7 @@ static const struct ast_format pcm_f = { .tell = pcm_tell, .read = pcm_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, - .lockp = &me, + .module = &mod_data, /* XXX */ }; static const struct ast_format au_f = { @@ -459,10 +457,10 @@ static const struct ast_format au_f = { .tell = au_tell, .read = pcm_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, /* this many shorts */ - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { int index; @@ -476,23 +474,20 @@ int load_module() || ast_format_register(&au_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(pcm_f.name) || ast_format_unregister(alaw_f.name) || ast_format_unregister(au_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Raw/Sun uLaw/ALaw 8khz Audio support (PCM,PCMA,AU)"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_sln.c b/formats/format_sln.c index 3e4d2e0c9..4a78aa900 100644 --- a/formats/format_sln.c +++ b/formats/format_sln.c @@ -116,8 +116,6 @@ static off_t slinear_tell(struct ast_filestream *fs) return ftello(fs->f) / 2; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format slin_f = { .name = "sln", .exts = "sln|raw", @@ -128,30 +126,27 @@ static const struct ast_format slin_f = { .tell = slinear_tell, .read = slinear_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&slin_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(slin_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Raw Signed Linear Audio support (SLN)"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_vox.c b/formats/format_vox.c index b1f7e688a..8e5220143 100644 --- a/formats/format_vox.c +++ b/formats/format_vox.c @@ -121,8 +121,6 @@ static off_t vox_tell(struct ast_filestream *fs) return offset; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format vox_f = { .name = "vox", .exts = "vox", @@ -133,30 +131,27 @@ static const struct ast_format vox_f = { .tell = vox_tell, .read = vox_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&vox_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(vox_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Dialogic VOX (ADPCM) File Format"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_wav.c b/formats/format_wav.c index eb3b2d5ad..cc610ef53 100644 --- a/formats/format_wav.c +++ b/formats/format_wav.c @@ -498,8 +498,6 @@ static off_t wav_tell(struct ast_filestream *fs) return (offset - 44)/2; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format wav_f = { .name = "wav", .exts = "wav", @@ -514,30 +512,27 @@ static const struct ast_format wav_f = { .close = wav_close, .buf_size = WAV_BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct wav_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&wav_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(wav_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Microsoft WAV format (8000hz Signed Linear)"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c index dedc8f9d9..d3abbd2f0 100644 --- a/formats/format_wav_gsm.c +++ b/formats/format_wav_gsm.c @@ -541,8 +541,6 @@ static off_t wav_tell(struct ast_filestream *fs) return (offset - MSGSM_DATA_OFFSET)/MSGSM_FRAME_SIZE*MSGSM_SAMPLES; } -static struct ast_format_lock me = { .usecnt = -1 }; - static const struct ast_format wav49_f = { .name = "wav49", .exts = "WAV|wav49", @@ -557,30 +555,27 @@ static const struct ast_format wav49_f = { .close = wav_close, .buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct wavg_desc), - .lockp = &me, + .module = &mod_data, /* XXX */ }; -int load_module() +static int load_module(void *mod) { return ast_format_register(&wav49_f); } -int unload_module() +static int unload_module(void *mod) { return ast_format_unregister(wav49_f.name); } -int usecount() -{ - return me.usecnt; -} - -const char *description() +static const char *description(void) { return "Microsoft WAV format (Proprietary GSM)"; } -const char *key() +static const char *key(void) { return ASTERISK_GPL_KEY; } + +STD_MOD1; |