[Asterisk-code-review] res_stasis.c: Add compare function for bridges moh container (asterisk[16.14])

Hajek Michal asteriskteam at digium.com
Wed Sep 16 08:01:30 CDT 2020


Hajek Michal has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14927 )


Change subject: res_stasis.c: Add compare function for bridges moh container
......................................................................

res_stasis.c: Add compare function for bridges moh container

Sometimes not play MOH on bridge.

ASTERISK-29081
Reported-by: Michal Hajek <michal.hajek at daktela.com>

Change-Id: I760c73e0c9be1d340303b5d1c18a00c4759e8232
---
M res/res_stasis.c
1 file changed, 29 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/27/14927/1

diff --git a/res/res_stasis.c b/res/res_stasis.c
index 3f8ae74..60cdd83 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -425,6 +425,34 @@
 	);
 };
 
+/*! AO2 comparison function for bridges moh container */
+static int bridges_channel_compare(void *obj, void *arg, int flags)
+{
+    const struct stasis_app_bridge_channel_wrapper *object_left = obj;
+    const struct stasis_app_bridge_channel_wrapper *object_right = arg;
+    const char *right_key = arg;
+    int cmp;
+
+    switch (flags & OBJ_SEARCH_MASK) {
+    case OBJ_SEARCH_OBJECT:
+            right_key = object_right->bridge_id;
+    case OBJ_SEARCH_KEY:
+            cmp = strcmp(object_left->bridge_id, right_key);
+            break;
+    case OBJ_SEARCH_PARTIAL_KEY:
+            cmp = strncmp(object_left->bridge_id, right_key, strlen(right_key));
+            break;
+    default:
+            cmp = 0;
+            break;
+    }
+    if (cmp) {
+        return 0;
+    }
+    return CMP_MATCH;
+}
+
+
 static void stasis_app_bridge_channel_wrapper_destructor(void *obj)
 {
 	struct stasis_app_bridge_channel_wrapper *wrapper = obj;
@@ -2321,7 +2349,7 @@
 		BRIDGES_NUM_BUCKETS, bridges_hash, NULL, bridges_compare);
 	app_bridges_moh = ao2_container_alloc_hash(
 		AO2_ALLOC_OPT_LOCK_MUTEX, 0,
-		37, bridges_channel_hash_fn, NULL, NULL);
+		37, bridges_channel_hash_fn, NULL, bridges_channel_compare);
 	app_bridges_playback = ao2_container_alloc_hash(
 		AO2_ALLOC_OPT_LOCK_MUTEX, AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT,
 		37, bridges_channel_hash_fn, bridges_channel_sort_fn, NULL);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14927
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16.14
Gerrit-Change-Id: I760c73e0c9be1d340303b5d1c18a00c4759e8232
Gerrit-Change-Number: 14927
Gerrit-PatchSet: 1
Gerrit-Owner: Hajek Michal <michal.hajek at daktela.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200916/ea9e3350/attachment.html>


More information about the asterisk-code-review mailing list