Merge "agm: initialize stream module list properly" into audio-platform-arintf.lnx.1.0.c10
diff --git a/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp b/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
index 2840a1c..82cd647 100644
--- a/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
+++ b/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
@@ -1190,11 +1190,27 @@
         clbk_data_obj->client_data = (void *)data.readInt64();
         sp<IBinder> binder = data.readStrongBinder();
         clbk_data_obj->cb_binder = interface_cast<ICallback>(binder);
-        list_add_tail(&clbk_data_list, &clbk_data_obj->list);
-        pthread_mutex_unlock(&clbk_data_list_lock);
+        if (clbk_data_obj->cb_func != NULL) {
+            list_add_tail(&clbk_data_list, &clbk_data_obj->list);
+            rc = ipc_agm_session_register_cb(clbk_data_obj->session_id,
+                            &ipc_cb, evnt, clbk_data_obj->client_data);
+        } else {
+            clbk_data *clbk_data_obj_tmp = NULL;
+            struct listnode *node = NULL, *next = NULL;
+            list_for_each_safe(node, next, &clbk_data_list) {
+                clbk_data_obj_tmp = node_to_item(node, clbk_data, list);
+                if ((clbk_data_obj_tmp->session_id == clbk_data_obj->session_id) &&
+                    (clbk_data_obj_tmp->client_data == clbk_data_obj->client_data)) {
+                    list_remove(&clbk_data_obj_tmp->list);
+                    free(clbk_data_obj_tmp);
+                }
+            }
+            rc = ipc_agm_session_register_cb(clbk_data_obj->session_id,
+                            NULL, evnt, clbk_data_obj->client_data);
+            free(clbk_data_obj);
+        }
 
-        rc = ipc_agm_session_register_cb(clbk_data_obj->session_id,
-                        &ipc_cb, evnt, clbk_data_obj->client_data);
+        pthread_mutex_unlock(&clbk_data_list_lock);
         reply->writeInt32(rc);
         break ; }
 
diff --git a/service/src/agm.c b/service/src/agm.c
index bc8bb0c..f56e7a4 100644
--- a/service/src/agm.c
+++ b/service/src/agm.c
@@ -648,6 +648,9 @@
     struct session_obj *obj = NULL;
     int ret = 0;
 
+    AGM_LOGI("%sconnecting aifid:%d with session id=%d\n",
+                                      (state ? "": "dis"), aif_id, session_id);
+
     ret = session_obj_get(session_id, &obj);
     if (ret) {
         AGM_LOGE("Error:%d retrieving session obj with session id=%d\n",
diff --git a/service/src/device.c b/service/src/device.c
index 808b927..5d509bc 100644
--- a/service/src/device.c
+++ b/service/src/device.c
@@ -738,9 +738,11 @@
 {
    int ret = 0;
 
+   AGM_LOGI("Setting device metadata for %s\n", dev_obj->name);
    pthread_mutex_lock(&dev_obj->lock);
    metadata_free(&dev_obj->metadata);
    ret = metadata_copy(&(dev_obj->metadata), size, metadata);
+   metadata_print(&(dev_obj->metadata));
    pthread_mutex_unlock(&dev_obj->lock);
 
    return ret;
diff --git a/service/src/graph.c b/service/src/graph.c
index f8efc1f..41d8351 100644
--- a/service/src/graph.c
+++ b/service/src/graph.c
@@ -931,6 +931,7 @@
     }
 
     if (meta_data) {
+        metadata_print(meta_data);
         memcpy (&(gsl_cmd_prop.gkv), &(meta_data->gkv),
                                        sizeof(struct gsl_key_vector));
         gsl_cmd_prop.property_id = meta_data->sg_props.prop_id;
diff --git a/service/src/session_obj.c b/service/src/session_obj.c
index be3591a..2ab9f13 100644
--- a/service/src/session_obj.c
+++ b/service/src/session_obj.c
@@ -1746,6 +1746,7 @@
     int ret = 0;
     struct aif *aif_obj = NULL;
 
+    AGM_LOGI("Setting metadata for sess aif id %d\n", aif_id);
     pthread_mutex_lock(&sess_obj->lock);
     ret = aif_obj_get(sess_obj, aif_id, &aif_obj);
     if (ret) {
@@ -1761,9 +1762,11 @@
                   sess_id:%d, aif_id:%d \n",
                   sess_obj->sess_id, aif_obj->aif_id);
     }
+    metadata_print(&(aif_obj->sess_aif_meta));
 
 done:
     pthread_mutex_unlock(&sess_obj->lock);
+    AGM_LOGI("Exit");
     return ret;
 }