/* * Now drop voice frames past the limit, currently 2 voice frames. */ if (vqlen > 2) { AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, cur, frame_list) { if (cur->frametype == AST_FRAME_VOICE) { AST_LIST_REMOVE_CURRENT(&chan->readq, frame_list); ast_frfree(cur); vqlen--; if (vqlen <= 2) break; } } AST_LIST_TRAVERSE_SAFE_END; } /* See if the last frame on the queue is a hangup, if so don't queue anything */ if ((cur = AST_LIST_LAST(&chan->readq)) && (cur->frametype == AST_FRAME_CONTROL) && (cur->subclass == AST_CONTROL_HANGUP)) { ast_frfree(f); ast_channel_unlock(chan); return 0; } /* Count how many frames exist on the queue */ AST_LIST_TRAVERSE(&chan->readq, cur, frame_list) { qlen++; } /* Allow up to 96 voice frames outstanding, and up to 128 total frames */ if (((fin->frametype == AST_FRAME_VOICE) && (qlen > 96)) || (qlen > 128)) { if (fin->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Exceptionally long queue length queuing to %s\n", chan->name); CRASH; } else { if (option_debug) ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name); ast_frfree(f); ast_channel_unlock(chan); return 0; } }