В исходниках нашел эти строки./* returns the index of the lowest bit set */
static int powerof(int d)
{
int x;
for (x = 0; x < MAX_FORMAT; x++)
if ((1 << x) & d)
return x;
ast_log(LOG_WARNING, "Powerof %d: No power??\n", d);
return -1;
}
/*! Build a chain of translators based upon the given source and dest formats */
struct ast_trans_pvt *ast_translator_build_path(int dest, int source)
{
struct ast_trans_pvt *head = NULL, *tail = NULL;
source = powerof(source);
dest = powerof(dest);
while (source != dest) {
struct ast_trans_pvt *cur;
struct ast_translator *t = tr_matrix[source][dest].step;
if (t == NULL) {
ast_log(LOG_WARNING, "No translator path from %s to %s\n",
ast_getformatname(source), ast_getformatname(dest));
return NULL;
}
cur = newpvt(t);
if (!cur) {
ast_log(LOG_WARNING, "Failed to build translator step from %d to %d\n", source, dest);
if (head)
ast_translator_free_path(head);
return NULL;
}
if (!head)
head = cur;
else
tail->next = cur;
tail = cur;
cur->nextin = cur->nextout = ast_tv(0, 0);
/* Keep going if this isn't the final destination */
source = cur->t->dstfmt;
}
return head;
}