diff options
author | George Joseph <gjoseph@digium.com> | 2016-06-28 08:00:32 -0600 |
---|---|---|
committer | George Joseph <gjoseph@digium.com> | 2016-06-28 13:38:28 -0600 |
commit | d07c8a050445cf48591105f1676c190f477a7af1 (patch) | |
tree | 1819065588c5f87fedc3be5a120805e0cf90b235 /main/codec_builtin.c | |
parent | f3d236ca7fdf8b03106f1e50474ff6a79f3efb20 (diff) |
codecs: Fix ABI incompatibility created by adding format_name to ast_codec
Adding format_name even to the end of ast_codec caused issued with
binary codec modules because the pointer would be garbage in asterisk
when they registered. So, the ast_codec structure was reverted and an
internal_ast_codec structure was created just for use in codec.c. A new
internal-only API was also added (__ast_codec_register_with_format) so
that codec_builtin could register codecs with the format_name in a
separate parameter rather than in the ast_codec structure.
ASTERISK-26144 #close
Reported-by: Alexei Gradinari
Change-Id: I6df1b08f6a6ae089db23adfe1ebc8636330265ba
Diffstat (limited to 'main/codec_builtin.c')
-rw-r--r-- | main/codec_builtin.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/main/codec_builtin.c b/main/codec_builtin.c index d7d253ab8..d3f65174c 100644 --- a/main/codec_builtin.c +++ b/main/codec_builtin.c @@ -38,6 +38,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/format_cache.h" #include "asterisk/frame.h" +int __ast_codec_register_with_format(struct ast_codec *codec, const char *format_name, + struct ast_module *mod); + enum frame_type { TYPE_HIGH, /* 0x0 */ TYPE_LOW, /* 0x1 */ @@ -774,8 +777,7 @@ static struct ast_codec t140 = { int __res_ ## __LINE__ = 0; \ struct ast_format *__fmt_ ## __LINE__; \ struct ast_codec *__codec_ ## __LINE__; \ - codec.format_name = (codec).name; \ - res |= __ast_codec_register(&(codec), NULL); \ + res |= __ast_codec_register_with_format(&(codec), (codec).name, NULL); \ __codec_ ## __LINE__ = ast_codec_get((codec).name, (codec).type, (codec).sample_rate); \ __fmt_ ## __LINE__ = __codec_ ## __LINE__ ? ast_format_create(__codec_ ## __LINE__) : NULL; \ res |= ast_format_cache_set(__fmt_ ## __LINE__); \ @@ -789,8 +791,7 @@ static struct ast_codec t140 = { int __res_ ## __LINE__ = 0; \ struct ast_format *__fmt_ ## __LINE__; \ struct ast_codec *__codec_ ## __LINE__; \ - codec.format_name = fmt_name; \ - res |= __ast_codec_register(&(codec), NULL); \ + res |= __ast_codec_register_with_format(&(codec), fmt_name, NULL); \ __codec_ ## __LINE__ = ast_codec_get((codec).name, (codec).type, (codec).sample_rate); \ __fmt_ ## __LINE__ = ast_format_create_named((fmt_name), __codec_ ## __LINE__); \ res |= ast_format_cache_set(__fmt_ ## __LINE__); \ |