From fa6313ad29153c17786b88693729f7a413e3f3e8 Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Thu, 18 Sep 2014 16:38:26 +0000 Subject: Add API call to determine if format capability structure is "empty". Empty here means that there are no formats in the format_cap structure or the only format in it is the "none" format. I've added calls to check the emptiness of a format_cap in a few places in order to short-circuit operations that would otherwise be pointless as well as to prevent some assertions from being triggered in cases where channels with no formats are used. ........ Merged revisions 423414 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423415 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/format_cap.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'main/format_cap.c') diff --git a/main/format_cap.c b/main/format_cap.c index 65e469fc1..364c924bf 100644 --- a/main/format_cap.c +++ b/main/format_cap.c @@ -700,3 +700,18 @@ const char *ast_format_cap_get_names(struct ast_format_cap *cap, struct ast_str return ast_str_buffer(*buf); } + +int ast_format_cap_empty(struct ast_format_cap *cap) +{ + int count = ast_format_cap_count(cap); + + if (count > 1) { + return 0; + } + + if (count == 0 || AST_VECTOR_GET(&cap->preference_order, 0)->format == ast_format_none) { + return 1; + } + + return 0; +} -- cgit v1.2.3