aboutsummaryrefslogtreecommitdiffstats
path: root/main/translate.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-31 21:36:17 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-31 21:36:17 +0000
commit1b9c0dc91e1e0f365ac65a842cffbe9eeca7683a (patch)
tree02a3efdbb322db18e9fe090b7b3c52c8c95d054e /main/translate.c
parent49f2f8b000aaebaaa9d25375d43852a17dfdd1ae (diff)
revert changes that were the wrong way to address this... proper fix coming
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46713 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/translate.c')
-rw-r--r--main/translate.c87
1 files changed, 39 insertions, 48 deletions
diff --git a/main/translate.c b/main/translate.c
index d821d2ec7..c7172619b 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -650,65 +650,58 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
return -1;
}
- if (!t->seen) {
- t->seen = 1;
+ if (!t->buf_size) {
+ ast_log(LOG_WARNING, "empty buf size, you need to supply one\n");
+ return -1;
+ }
- if (!t->buf_size) {
- ast_log(LOG_WARNING, "empty buf size, you need to supply one\n");
+ t->module = mod;
+ if (t->plc_samples) {
+ if (t->buffer_samples < t->plc_samples) {
+ ast_log(LOG_WARNING, "plc_samples %d buffer_samples %d\n",
+ t->plc_samples, t->buffer_samples);
return -1;
}
-
- t->module = mod;
- if (t->plc_samples) {
- if (t->buffer_samples < t->plc_samples) {
- ast_log(LOG_WARNING, "plc_samples %d buffer_samples %d\n",
- t->plc_samples, t->buffer_samples);
- return -1;
- }
- if (t->dstfmt != AST_FORMAT_SLINEAR)
- ast_log(LOG_WARNING, "plc_samples %d format %x\n",
- t->plc_samples, t->dstfmt);
- }
- t->srcfmt = powerof(t->srcfmt);
- t->dstfmt = powerof(t->dstfmt);
- /* XXX maybe check that it is not existing yet ? */
- if (t->srcfmt >= MAX_FORMAT) {
- ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt));
- return -1;
- }
- if (t->dstfmt >= MAX_FORMAT) {
- ast_log(LOG_WARNING, "Destination format %s is larger than MAX_FORMAT\n", ast_getformatname(t->dstfmt));
- return -1;
- }
- if (t->buf_size) {
- /*
- * Align buf_size properly, rounding up to the machine-specific
- * alignment for pointers.
- */
- struct _test_align { void *a, *b; } p;
- int align = (char *)&p.b - (char *)&p.a;
- t->buf_size = ((t->buf_size + align - 1) / align) * align;
- }
- if (t->frameout == NULL)
- t->frameout = default_frameout;
-
- calc_cost(t, 1);
+ if (t->dstfmt != AST_FORMAT_SLINEAR)
+ ast_log(LOG_WARNING, "plc_samples %d format %x\n",
+ t->plc_samples, t->dstfmt);
+ }
+ t->srcfmt = powerof(t->srcfmt);
+ t->dstfmt = powerof(t->dstfmt);
+ /* XXX maybe check that it is not existing yet ? */
+ if (t->srcfmt >= MAX_FORMAT) {
+ ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt));
+ return -1;
}
-
+ if (t->dstfmt >= MAX_FORMAT) {
+ ast_log(LOG_WARNING, "Destination format %s is larger than MAX_FORMAT\n", ast_getformatname(t->dstfmt));
+ return -1;
+ }
+ if (t->buf_size) {
+ /*
+ * Align buf_size properly, rounding up to the machine-specific
+ * alignment for pointers.
+ */
+ struct _test_align { void *a, *b; } p;
+ int align = (char *)&p.b - (char *)&p.a;
+ t->buf_size = ((t->buf_size + align - 1) / align) * align;
+ }
+ if (t->frameout == NULL)
+ t->frameout = default_frameout;
+
+ calc_cost(t, 1);
if (option_verbose > 1) {
char tmp[80];
ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %s to %s, cost %d\n",
- term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
- ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt), t->cost);
+ term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
+ ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt), t->cost);
}
-
+ AST_LIST_LOCK(&translators);
if (!added_cli) {
ast_cli_register_multiple(cli_translate, sizeof(cli_translate) / sizeof(struct ast_cli_entry));
added_cli++;
}
- AST_LIST_LOCK(&translators);
-
/* find any existing translators that provide this same srcfmt/dstfmt,
and put this one in order based on cost */
AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) {
@@ -727,9 +720,7 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
AST_LIST_INSERT_HEAD(&translators, t, list);
rebuild_matrix(0);
-
AST_LIST_UNLOCK(&translators);
-
return 0;
}