[asterisk-dev] translate.c:88 powerof: Powerof 0: No power??

Hans Petter Selasky hselasky at c2i.net
Mon Nov 20 06:12:21 MST 2006


On Sunday 19 November 2006 22:03, Hans Petter Selasky wrote:
> Hi,
>
> Does the following error indicate a channel driver error:
>
> Nov 19 21:04:22 WARNING[20585]: translate.c:133 ast_translator_build_path:
> No translator path from unknown to unknown
> Nov 19 21:16:54 WARNING[20585]: translate.c:88 powerof: Powerof 0: No
> power?? Nov 19 21:16:54 WARNING[20585]: translate.c:88 powerof: Powerof 0:
> No power??
>
> Any hints what causes it?
>
> I just looked at the code in translate.c, and it scared me that powerof()
> could return signed -1. What happens if "source == 0", while "dest == 1"
> for example. Then the following piece of code will lookup an invalid memory
> address, tr_matrix[-1][0]. Or will this never happen?
>
> /*! Build a set of translators based upon the given source and destination
> formats */
> struct ast_trans_pvt *ast_translator_build_path(int dest, int source)
> {
>         struct ast_trans_pvt *tmpr = NULL, *tmp = NULL;
>
>         source = powerof(source);
>         dest = powerof(dest);
>
>         while(source != dest) {
>                 if (!tr_matrix[source][dest].step) {
>                         /* We shouldn't have allocated any memory */
>                         ast_log(LOG_WARNING, "No translator path from %s to
> %s\n",
>                                 ast_getformatname(source),
> ast_getformatname(dest));
>                         return NULL;
>                 }
>

After some hours of debugging I have come up with a cure.

1)

Use "ast_set_read_format()" and "ast_set_write_format()" to initialize the 
format used, hence "chan->lastreadformat" was uninitialized.

     fmt = ast_best_codec(fmt);
 
+    ast_set_read_format(pbx_chan, fmt);
+    ast_set_write_format(pbx_chan, fmt);
+


2)

In my bridge routine, I only forward "AST_FRAME_VOICE" now.

But still I think asterisk has a bug, in that it cannot handle 
"AST_FRAME_NULL", hence "f->subclass == 0", and it is forwarded by 
"ast_write()" to "ast_translate_write()"!

--HPS


More information about the asterisk-dev mailing list