diff options
author | Mamadou DIOP <bossiel@yahoo.fr> | 2016-02-26 01:38:27 +0100 |
---|---|---|
committer | Mamadou DIOP <bossiel@yahoo.fr> | 2016-02-26 01:38:27 +0100 |
commit | b8cb2d5cf5c2beb5de175a0b6a95502a54d3e936 (patch) | |
tree | 3cd30efa859d8c4a7168260c77dbc3d2f642a75a /tinyDAV | |
parent | c6a8fde4aaf6fd5185814525fcee3193fedef67d (diff) | |
download | doubango-b8cb2d5cf5c2beb5de175a0b6a95502a54d3e936.zip doubango-b8cb2d5cf5c2beb5de175a0b6a95502a54d3e936.tar.gz |
Fix codec priority setting issue. The codec is removed when the priority value is > the total number of registered codecs. This happens when few codecs are registered
Diffstat (limited to 'tinyDAV')
-rwxr-xr-x | tinyDAV/src/tdav.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tinyDAV/src/tdav.c b/tinyDAV/src/tdav.c index 0fa72e8..e264f2b 100755 --- a/tinyDAV/src/tdav.c +++ b/tinyDAV/src/tdav.c @@ -473,14 +473,15 @@ int tdav_codec_set_priority(tdav_codec_id_t codec_id, int priority) { tsk_size_t i; - if(priority < 0) { + if (priority < 0) { TSK_DEBUG_ERROR("Invalid parameter"); return -1; } - for(i = 0; i < __codec_plugins_all_count && __codec_plugins_all[i]; ++i) { + for (i = 0; i < __codec_plugins_all_count && __codec_plugins_all[i]; ++i) { if(__codec_plugins_all[i]->codec_id == codec_id) { const struct tmedia_codec_plugin_def_s *codec_decl_1, *codec_decl_2; - priority = TSK_MIN(priority, (int)__codec_plugins_all_count-1); + tsk_size_t max = tmedia_codec_plugin_registered_count(__codec_plugins_all, __codec_plugins_all_count); + priority = TSK_CLAMP(0, priority, (int)(max > 0 ? (max - 1) : 0)); codec_decl_1 = __codec_plugins_all[priority]; codec_decl_2 = __codec_plugins_all[i]; |