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.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@423414 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2014-09-18 16:37:47 +00:00
parent 5c5aee4458
commit 23a375be5f
4 changed files with 34 additions and 0 deletions

View File

@@ -5327,6 +5327,11 @@ static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set,
ast_assert(rawformat != NULL);
cap_native = ast_channel_nativeformats(chan);
if (ast_format_cap_empty(cap_native)) {
ast_log(LOG_ERROR, "Unable to set format because channel %s supports no formats\n",
ast_channel_name(chan));
return -1;
}
/* Find a translation path from the native format to one of the desired formats */
if (!direction) {