Merge 8f44621b0a7dc818c67d370eb34decfeda2cb5ac on remote branch

Change-Id: Ia0e377dc77951644a1f591295109ba880b626d41
diff --git a/service/src/graph.c b/service/src/graph.c
index f78f0f6..fd1a80f 100644
--- a/service/src/graph.c
+++ b/service/src/graph.c
@@ -1,6 +1,5 @@
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -28,7 +27,7 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
 ** Changes from Qualcomm Innovation Center are provided under the following license:
-** Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+** Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
 **
 ** Redistribution and use in source and binary forms, with or without
 ** modification, are permitted (subject to the limitations in the
@@ -1600,6 +1599,7 @@
 
     pthread_mutex_lock(&graph_obj->lock);
     AGM_LOGD("entry graph_handle %p", graph_obj->graph_handle);
+    metadata_print(meta_data_kv);
 
     if (dev_obj != NULL) {
         mod = NULL;
@@ -1696,7 +1696,6 @@
     change_graph.cal_key_vect.num_kvps = meta_data_kv->ckv.num_kvs;
     change_graph.cal_key_vect.kvp = (struct gsl_key_value_pair *)
                                      meta_data_kv->ckv.kv;
-    metadata_print(meta_data_kv);
     print_graph_alias(meta_data_kv);
     ret = gsl_ioctl(graph_obj->graph_handle, GSL_CMD_CHANGE_GRAPH, &change_graph,
                     sizeof(struct gsl_cmd_graph_select));
diff --git a/service/src/session_obj.c b/service/src/session_obj.c
index 8d645fc..1ae4057 100644
--- a/service/src/session_obj.c
+++ b/service/src/session_obj.c
@@ -1,6 +1,5 @@
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -26,6 +25,10 @@
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
  */
 #define LOG_TAG "AGM: session"
 
@@ -1695,9 +1698,9 @@
         ckv.num_kvs = cal_config->num_ckvs;
         metadata_update_cal(&sess_obj->sess_meta, &ckv);
         metadata_update_cal(&aif_obj->sess_aif_meta, &ckv);
+        pthread_mutex_lock(&aif_obj->dev_obj->lock);
         metadata_update_cal(&aif_obj->dev_obj->metadata, &ckv);
 
-        pthread_mutex_lock(&aif_obj->dev_obj->lock);
         merged_metadata = metadata_merge(3, &sess_obj->sess_meta,
                           &aif_obj->sess_aif_meta, &aif_obj->dev_obj->metadata);
         pthread_mutex_unlock(&aif_obj->dev_obj->lock);
@@ -1766,7 +1769,7 @@
                   sess_obj->sess_id, aif_obj->aif_id);
     }
 #ifdef AGM_DEBUG_METADATA
-    AGM_LOGI("Setting metadata for sess aif id %d\n", aif_id);
+    AGM_LOGI("Setting metadata for sess_id %d, aif id %d\n", sess_obj->sess_id, aif_id);
     metadata_print(&(aif_obj->sess_aif_meta));
 #endif
 done: