Merge "[Bugfix][T800][task-view-342] ecall t7 timeout, normal call event report id is not correct"
diff --git a/ap/app/include/audio_res_ctrl.h b/ap/app/include/audio_res_ctrl.h
index e36ffeb..fc3a5ed 100755
--- a/ap/app/include/audio_res_ctrl.h
+++ b/ap/app/include/audio_res_ctrl.h
@@ -44,6 +44,10 @@
 	REL_AUDIO_IND,      //ÇëÇóijҵÎñÄ£¿éÊÍ·ÅaudioµÄ½á¹ûÓ¦´ð£¬Èôʧ°Ü£¬¶ÏÑÔ£»»»ÑÔÖ®£¬±ØÐë³É¹¦
 	IDLE_AUDIO_INFO,     //Ö÷¿ØÍ¨ÖªËùÓÐÉêÇë¹ýAUDIO×ÊÔ´µÄÒµÎñÄ£¿é£¬¸æÖªµ±Ç°¿ÕÏУ¬ÒÔ½â¾öÒµÎñÄ£¿é´¦ÓÚ¹ÒÆð̬»ò֮ǰ±»Ç¿ÐÐÊͷŵÄÒµÎñÄ£¿é£¬ÈçMP3ÒôÀÖ²¥·ÅµÈ£»
 	EXIT_AUDIO_IND, //֪ͨÖ÷¿Ø£¬ÒµÎñÄ£¿éÍ˳öÒôƵ×ÊÔ´¾ºÕù
+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+	EXIT_AUDIO_REQ, 
+	EXIT_AUDIO_RSP,
+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 };
 
 
diff --git a/ap/app/zte_comm/zte_audio_ctrl/audio_res_ctrl.c b/ap/app/zte_comm/zte_audio_ctrl/audio_res_ctrl.c
index d7769ce..9c4237d 100755
--- a/ap/app/zte_comm/zte_audio_ctrl/audio_res_ctrl.c
+++ b/ap/app/zte_comm/zte_audio_ctrl/audio_res_ctrl.c
@@ -332,17 +332,17 @@
     slog(RTC_PRINT, SLOG_NORMAL, "%s:%s: LINE(%d), moduleId(%x), type(%x), using_type(%d), releasing_type(%d)\n",  __FILE__, __FUNCTION__, __LINE__, rel_ind_data->moduleId, rel_ind_data->type, using_type, releasing_type);
 }
 
-static void  unregister_exist_app(MSG_BUF *msg)
+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+static void  unregister_exist_app(int moduleId, int type)
 {
-	T_audio_ExitInd *exitIndData = (T_audio_ExitInd*)(msg->aucDataBuf);
 	T_exist_applist  *tmp = NULL;
 	T_exist_applist  *node = exist_apphead;
 
-	slog(RTC_PRINT, SLOG_NORMAL, "unregister_exist_app: moduleId(%x) type(%d) \n", exitIndData->moduleId, exitIndData->type);
+	slog(RTC_PRINT, SLOG_NORMAL, "unregister_exist_app: moduleId(%x) type(%d) \n", moduleId, type);
 	
 	while (node != NULL)
     {    	
-        if (node->src_id == exitIndData->moduleId && node->type == exitIndData->type)
+        if (node->tempSrcId == moduleId && node->type == type)
         {
         	if(NULL != tmp)
         	{
@@ -353,7 +353,7 @@
 				exist_apphead = node->next;
 			}
             free(node);
-			slog(RTC_PRINT, SLOG_NORMAL, "unregister_exist_app: %d moduleId(%x) type(%d) \n", __LINE__,exitIndData->moduleId, exitIndData->type);
+			slog(RTC_PRINT, SLOG_NORMAL, "unregister_exist_app: %d moduleId(%x) type(%d) \n", __LINE__,moduleId, type);
             return;
         }
 		tmp = node;
@@ -361,6 +361,17 @@
     }
 }
 
+static void  unregister_exist_app_proc(MSG_BUF *msg)
+{
+	T_audio_ExitInd *exitIndData = (T_audio_ExitInd*)(msg->aucDataBuf);
+	unregister_exist_app(exitIndData->moduleId, exitIndData->type);
+	if(EXIT_AUDIO_REQ == msg->usMsgCmd) {
+		if (0 > platform_send_msg(MODULE_ID_CODEC, exitIndData->moduleId, EXIT_AUDIO_RSP, 0, NULL))
+			softap_assert("unregister_exist_app_proc function: send USE_AUDIO_RSP msg error\n");
+    	}
+}
+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
+
 /*******************************************************************************
  *                             È«¾Öº¯Êý¶¨Òå                                   *
  ******************************************************************************/
@@ -423,7 +434,10 @@
             break;
 
 		case EXIT_AUDIO_IND:
-			unregister_exist_app(&msg);
+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+		case EXIT_AUDIO_REQ:
+			unregister_exist_app_proc(&msg);
+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 			break;
         default:
             slog(RTC_PRINT, SLOG_NORMAL, "%s: %s LINE(%d) other msg: MsgCmd(%d), srcId(%d), dstId(%d)\n", __FILE__, __FUNCTION__, __LINE__, msg.usMsgCmd, msg.src_id, msg.dst_id);
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
index a57002a..0a37eb4 100755
--- a/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
@@ -262,6 +262,10 @@
 
 void aic8800_wifi_enable(int bval)
 {	
+	// zw.wang The WiFi-related control pins gpio132 and gpio91 are still affected after the uboot removes mmc0 on 20241031 on start
+	if (get_wifi_enable() != 1)
+		return;
+	// zw.wang The WiFi-related control pins gpio132 and gpio91 are still affected after the uboot removes mmc0 on 20241031 on end
 	int ret = 0;
 	if(bval)	
 	{	
@@ -343,6 +347,10 @@
 #if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 void aic8800_wifi_disable(int bval)
 {	
+	// zw.wang The WiFi-related control pins gpio132 and gpio91 are still affected after the uboot removes mmc0 on 20241031 on start
+	if (get_wifi_enable() != 1)
+		return;
+	// zw.wang The WiFi-related control pins gpio132 and gpio91 are still affected after the uboot removes mmc0 on 20241031 on end
 	int ret = 0;
 	if(bval)	
 	{	
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
index dd600c2..287b0ba 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
@@ -46,7 +46,7 @@
 

     if [ -d "${WORKONSRC}" ] ; then

         install -d ${D}${includedir}/

-        cp -raf ${SRC-DIR}/include/ ${D}${includedir}/

+        cp -raf ${SRC-DIR}/include/lynq_qser_gnss.h ${D}${includedir}/

     fi

     if [ "${MOBILETEK_GNSS_UPDATE_ENABLE}" = "yes" ]; then

         install -d ${D}/data/gnss_update

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/lynq_qser_gnss.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/lynq_qser_gnss.h
index ed70d21..8208056 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/lynq_qser_gnss.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/lynq_qser_gnss.h
@@ -3,31 +3,20 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-struct mbtk_gnss_handle_t
-{
-    int dev_fd;
-    pthread_t  uart_pthread;
-    pthread_t  gnss_pthread;
-    gnss_handler_func_t gnss_handler_func;
-    int mode; // 0 - stop, 1 - single, 2 - periodic, 3 - start
-    pthread_mutex_t _cond_mutex;
-    int reset_state;
-    int inited;
-    ring_buffer_t ring_buffer;
-    int getap_status;
-    char *rb;
 
-#if TTFF_TEST
-    pthread_t ttff_pid;
-    int location_state;
-#endif
-    /********************
-    save handle's adr
-    phandle = &handle
-    handle  = mbtk_gnss_handle
-    *********************/
-    uint32_t *phandle; // handle's adr
-};
+typedef enum
+{
+    E_MT_LOC_MSG_ID_LOCATION_INFO = 1,          /**<  pv_data = &QL_LOC_LOCATION_INFO_T  */
+    E_MT_LOC_MSG_ID_NMEA_INFO = 3,              /**<  pv_data = &QL_LOC_NMEA_INFO_T  */
+}e_msg_id_t; //0,2reserve
+
+typedef void (*gnss_handler_func_t)
+(
+        uint32_t    h_loc,
+        e_msg_id_t  e_msg_id,
+        void        *pv_data,
+        void        *context_ptr
+);
 
 typedef struct 
 {
@@ -78,7 +67,7 @@
 };
 
 
-#endif
+
 typedef struct 
 {
     uint32_t year; // 大于1980
@@ -129,7 +118,8 @@
 int qser_Gnss_injectEphemeris(uint32_t h_gnss);
 int qser_Gnss_download_tle();
 int qser_Gnss_injectEphemeris_withpath(uint32_t h_gnss, char *path);
+
 #ifdef __cplusplus
 }
 #endif
-
+#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
index 5602ffe..6e0c903 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
@@ -4,10 +4,13 @@
 #define __MBTK_GNSS_H__
 #include <sc_bsp.h>
 #include "ringbuffer.h"
+#include "lynq_qser_gnss.h"
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+
+
 /*
 GGA: GNSS 定位数据
 $GNGGA,,,,,,0,00,99.99,,,,,,*56
@@ -132,13 +135,7 @@
     char crc;
 };
 
-typedef uint32_t gnss_client_handle_type;
 
-typedef enum
-{
-    E_MT_LOC_MSG_ID_LOCATION_INFO = 1,          /**<  pv_data = &QL_LOC_LOCATION_INFO_T  */
-    E_MT_LOC_MSG_ID_NMEA_INFO = 3,              /**<  pv_data = &QL_LOC_NMEA_INFO_T  */
-}e_msg_id_t;  //0,2reserve
 
 #define     QL_LOC_MAX_SEVER_ADDR_LENGTH    255 /**  Maximum generic server address length for the host name. */
 typedef struct 
@@ -157,13 +154,33 @@
     E_QL_LOC_STATUS_ENGINE_OFF      = 4, /**<  GPS is powered off.  */
 }E_QL_LOC_STATUS_VALUE_T;
 
-typedef void (*gnss_handler_func_t)
-(
-        uint32_t    h_loc,
-        e_msg_id_t  e_msg_id,
-        void        *pv_data,
-        void        *context_ptr
-        );
+struct mbtk_gnss_handle_t
+{
+    int dev_fd;
+    pthread_t  uart_pthread;
+    pthread_t  gnss_pthread;
+    gnss_handler_func_t gnss_handler_func;
+    int mode; // 0 - stop, 1 - single, 2 - periodic, 3 - start
+    pthread_mutex_t _cond_mutex;
+    int reset_state;
+    int inited;
+    ring_buffer_t ring_buffer;
+    int getap_status;
+    char *rb;
+    e_msg_id_t e_msg_id;
+    
+#if TTFF_TEST
+    pthread_t ttff_pid;
+    int location_state;
+#endif
+    /********************
+    存储handle的地址指针
+    phandle = &handle
+    handle  = mbtk_gnss_handle
+    *********************/
+    uint32_t *phandle; // handle的地址指针
+};
+
 
 struct mopen_location_info_t
 {
@@ -325,7 +342,6 @@
 int mopen_gnss_print_version(uint32 h_gnss);
 int lynq_gnss_client_init(uint32 *ph_gnss);
 int lynq_gnss_client_deinit(uint32 h_gnss);
-int mopen_gnss_add_rx_msg_handler(uint32 h_gnss, gnss_handler_func_t handler_ptr);
 int mopen_gnss_set_mode(uint32 h_gnss, int mode);
 int mopen_gnss_set_system_config(uint32 h_gnss, int mode);
 int mopen_gnss_set_nema_config(uint32 h_gnss, int mode);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
index 360011b..0706884 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
@@ -102,32 +102,7 @@
     }   
 }
 
-struct mbtk_gnss_handle_t
-{
-    int dev_fd;
-    pthread_t  uart_pthread;
-    pthread_t  gnss_pthread;
-    gnss_handler_func_t gnss_handler_func;
-    int mode; // 0 - stop, 1 - single, 2 - periodic, 3 - start
-    pthread_mutex_t _cond_mutex;
-    int reset_state;
-    int inited;
-    ring_buffer_t ring_buffer;
-    int getap_status;
-    char *rb;
-    e_msg_id_t e_msg_id;
-    
-#if TTFF_TEST
-    pthread_t ttff_pid;
-    int location_state;
-#endif
-    /********************
-    存储handle的地址指针
-    phandle = &handle
-    handle  = mbtk_gnss_handle
-    *********************/
-    uint32_t *phandle; // handle的地址指针
-};
+
 #if TTFF_TEST
 struct mbtk_gnss_ttff_t
 {
@@ -1412,18 +1387,6 @@
     return 0;
 }
 
-int mopen_gnss_add_rx_msg_handler(uint32 h_gnss, gnss_handler_func_t handler_ptr)
-{
-    struct mbtk_gnss_handle_t *gnss_handle = (struct mbtk_gnss_handle_t *)h_gnss;
-    if(0 == h_gnss && NULL == handler_ptr)
-    {
-        printf("%s handler invalid.\n", __func__);
-        return -1;
-    }
-    gnss_handle->gnss_handler_func = handler_ptr;
-    return 0;
-}
-
 #define AGNSS_TLE_FILE  "/mnt/userdata/agnss_tle"
 
 static void http_data_cb_func(
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/audio_res_ctrl.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/audio_res_ctrl.h
index 2ab4da9..453e877 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/audio_res_ctrl.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/audio_res_ctrl.h
@@ -47,6 +47,10 @@
 	REL_AUDIO_IND,      //ÇëÇóijҵÎñÄ£¿éÊÍ·ÅaudioµÄ½á¹ûÓ¦´ð£¬Èôʧ°Ü£¬¶ÏÑÔ£»»»ÑÔÖ®£¬±ØÐë³É¹¦
 	IDLE_AUDIO_INFO,     //Ö÷¿ØÍ¨ÖªËùÓÐÉêÇë¹ýAUDIO×ÊÔ´µÄÒµÎñÄ£¿é£¬¸æÖªµ±Ç°¿ÕÏУ¬ÒÔ½â¾öÒµÎñÄ£¿é´¦ÓÚ¹ÒÆð̬»ò֮ǰ±»Ç¿ÐÐÊͷŵÄÒµÎñÄ£¿é£¬ÈçMP3ÒôÀÖ²¥·ÅµÈ£»
 	EXIT_AUDIO_IND, //֪ͨÖ÷¿Ø£¬ÒµÎñÄ£¿éÍ˳öÒôƵ×ÊÔ´¾ºÕù
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+	EXIT_AUDIO_REQ,
+	EXIT_AUDIO_RSP,
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 };
 
 
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/audio_res_request_api.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/audio_res_request_api.c
index 85757ac..6618f5d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/audio_res_request_api.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/audio_res_request_api.c
@@ -37,7 +37,10 @@
  *							   ºê¶¨Òå								   *
  ******************************************************************************/
 #define AUDIORES_EXIT (0xff)
-#define AUDIORES_EXIT_INTERVAL_NS     10000000
+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+#define AUDIORES_EXIT_INTERVAL_SEC         1
+#define AUDIORES_REQUEST_TIMEOUT_SEC       5
+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 
 /*******************************************************************************
  *							   Êý¾ÝÀàÐͶ¨Òå 							   *
@@ -180,7 +183,9 @@
 				paudiores->callbacks->audiores_read_callback(msgbuf.usMsgCmd, (void *)msgbuf.aucDataBuf, paudiores->priv);
 			}
 		}
-		else if(AUDIORES_EXIT == msgbuf.usMsgCmd) {
+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+		else if(AUDIORES_EXIT == msgbuf.usMsgCmd || EXIT_AUDIO_RSP == msgbuf.usMsgCmd) {
+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 			if(NULL != paudiores->callbacks->audiores_destroy_callback) {
 				paudiores->callbacks->audiores_destroy_callback((long)paudiores, paudiores->priv);
 			}
@@ -198,10 +203,15 @@
 		slog(AUDIO_CTRL, SLOG_ERR,"audiores_thread_entry error num(%d): error case:%s",errno,strerror(errno));
 	}
 
-	paudiores->msgq = 0;	
+	paudiores->msgq = 0;
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START	
+	sem_post(&paudiores->semid);
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 	slog(AUDIO_CTRL, SLOG_NORMAL, "audiores_thread_entry(%s) end!\n",name);
 
-	free(paudiores);
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+	//free(paudiores);
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 }
 
 static BOOL audiores_request_by_modid(int type, int queueId, int moduleId, T_audio_UseRsp *RspData)
@@ -407,6 +417,9 @@
 {
 	struct audiores_context_t *paudiores = NULL;
 	T_audio_ExitInd exitIndData = {0}; 
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+	struct timespec ts;
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 	
 	if(AUDIORES_HANDLE_BAD == handle) {
 		slog(AUDIO_CTRL, SLOG_ERR, "Err:The handle is bad!\n");
@@ -427,10 +440,24 @@
 	exitIndData.type = paudiores->type;
 	exitIndData.moduleId = paudiores->modid;
 
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
+	platform_send_msg(paudiores->modid, MODULE_ID_CODEC, EXIT_AUDIO_REQ, sizeof(exitIndData), (unsigned char *)&exitIndData);
+	if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
+		slog(AUDIO_CTRL, SLOG_NORMAL, "audiores_close: clock_gettime fail.\n");
+	}
+	ts.tv_sec += AUDIORES_REQUEST_TIMEOUT_SEC;
+	ts.tv_nsec += 0;
+	if ((sem_timedwait(&paudiores->semid, &ts)) == -1) {
+		slog(AUDIO_CTRL, SLOG_ERR, "audiores_close: sem_timedwait timeout!errno:%d\n",errno);
 	/*Í˳ö×ÊÔ´¾ºÕù*/
-	platform_send_msg(paudiores->modid, MODULE_ID_CODEC, EXIT_AUDIO_IND, sizeof(exitIndData), (unsigned char *)&exitIndData);
+	//platform_send_msg(paudiores->modid, MODULE_ID_CODEC, EXIT_AUDIO_IND, sizeof(exitIndData), (unsigned char *)&exitIndData);
 
 	/*Í£Ö¹½ÓÊÕÏß³Ì*/
 	ipc_send_message(paudiores->modid, paudiores->modid, AUDIORES_EXIT, 0, NULL, 0);
+		sleep(AUDIORES_EXIT_INTERVAL_SEC);
+	}
+	sem_destroy(&paudiores->semid);
+	slog(AUDIO_CTRL, SLOG_NORMAL, "audiores_close: type(%d)\n ", paudiores->type);
+	free(paudiores);
+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
 }
-
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/msm_svr/audio/msm_audio.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/msm_svr/audio/msm_audio.c
index 4ca23a4..dc1f5fd 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/msm_svr/audio/msm_audio.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/msm_svr/audio/msm_audio.c
@@ -96,11 +96,27 @@
 		AUDIORES_HANDLE_BAD == pmsmaudio_ctx->audiores_handle) {

 		if(NULL != pmsmaudio_ctx) {

 			slog(MSMSVR_PRINT, SLOG_NORMAL, "audiochn_count=%d handle=0x%x\n", pmsmaudio_ctx->audiochn_count, pmsmaudio_ctx->audiores_handle);

-			if(REL_AUDIO_REQ == msgtype) {		

+			if(REL_AUDIO_REQ == msgtype) {

+				//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+				msm_audio_set_res_state(pmsmaudio_ctx, MSM_AUDIO_RES_STATE_RELEASE);

+				//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END		

 				audiores_release(pmsmaudio_ctx->audiores_handle);

 			}

 			else if(IDLE_AUDIO_INFO == msgtype) {

-				audiores_request(pmsmaudio_ctx->audiores_handle);

+			//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+				if(MSM_AUDIO_RES_STATE_RELEASE != msm_audio_get_res_state(pmsmaudio_ctx)) {

+					audiores_request(pmsmaudio_ctx->audiores_handle);

+				}

+			}

+			else if(USE_AUDIO_RSP == msgtype) {

+				server_response_data = (T_audio_UseRsp *)data;

+				slog(MSMSVR_PRINT, SLOG_DEBUG, "request result:%d type:%d using_type:%d \n", \

+					server_response_data->result, server_response_data->type, server_response_data->using_type);

+				if(0 != server_response_data->result) {

+					return 0;

+				}

+				msm_audio_set_res_state(pmsmaudio_ctx, MSM_AUDIO_RES_STATE_HOLD);

+			//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 			}

 		}

 		else {

@@ -111,35 +127,51 @@
 

 	if(!audiochn_valid_check(pmsmaudio_ctx)) {

 		slog(MSMSVR_PRINT, SLOG_DEBUG, "audiochn_valid_check return FALSE!!!\n");

-		if(REL_AUDIO_REQ == msgtype) {		

+		if(REL_AUDIO_REQ == msgtype) {

+			//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+			msm_audio_set_res_state(pmsmaudio_ctx, MSM_AUDIO_RES_STATE_RELEASE);

+			//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 			audiores_release(pmsmaudio_ctx->audiores_handle);

 		}

 		else if(IDLE_AUDIO_INFO == msgtype) {

 			audiores_request(pmsmaudio_ctx->audiores_handle);

 		}

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+		else if(USE_AUDIO_RSP == msgtype) {

+			server_response_data = (T_audio_UseRsp *)data;

+			slog(MSMSVR_PRINT, SLOG_DEBUG, "msm_audiores_read_callback request result:%d type:%d using_type:%d \n", \

+				server_response_data->result, server_response_data->type, server_response_data->using_type);

+			if(0 != server_response_data->result) {

+				return 0;

+			}

+			msm_audio_set_res_state(pmsmaudio_ctx, MSM_AUDIO_RES_STATE_HOLD);

+		}

 		return 0;

 	}

-	

-	if(REL_AUDIO_REQ == msgtype) {		

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

+	if(REL_AUDIO_REQ == msgtype) {

+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+		msm_audio_set_res_state(pmsmaudio_ctx, MSM_AUDIO_RES_STATE_RELEASE);

+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 		msm_audio_suspend(pmsmaudio_ctx);

-		/*»á´æÔÚpcm»¹Î´¹Ø±Õ£¬¶øÌáǰִÐÐÊÍ·Å£¿*/

 		audiores_release(pmsmaudio_ctx->audiores_handle);

 	}

 	else if(IDLE_AUDIO_INFO == msgtype) {

 		audiores_request(pmsmaudio_ctx->audiores_handle);

 	}

-	else if(USE_AUDIO_RSP == msgtype) {		

+	else if(USE_AUDIO_RSP == msgtype) {

 		server_response_data = (T_audio_UseRsp *)data;

 		slog(MSMSVR_PRINT, SLOG_DEBUG, "msm_audiores_read_callback request result:%d type:%d using_type:%d \n", \

 			server_response_data->result, server_response_data->type, server_response_data->using_type);

-

+ 

 		if(0 != server_response_data->result) {

 			return 0;

 		}

-		

+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+		msm_audio_set_res_state(pmsmaudio_ctx, MSM_AUDIO_RES_STATE_HOLD);

+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 		msm_audio_resume(pmsmaudio_ctx);

 	}

-	

 	return 0;

 }

 

@@ -160,6 +192,9 @@
 {

 	slog(MSMSVR_PRINT, SLOG_DEBUG, "msm_audiores_release enter.\n");

 	if(AUDIORES_HANDLE_BAD != audiores_handle) {

+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+		msm_audio_set_res_state(&msmaudio_ctx, MSM_AUDIO_RES_STATE_RELEASE);

+		//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 		audiores_release(audiores_handle);

 		audiores_close(audiores_handle);	

 	}

@@ -195,7 +230,12 @@
 

 static int msm_audio_resume(struct msm_audio_context *pmsmaudio_ctx)

 {

-	slog(MSMSVR_PRINT, SLOG_DEBUG, "msm_audio_resume enter.\n");		

+	slog(MSMSVR_PRINT, SLOG_DEBUG, "msm_audio_resume enter.\n");

+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+	if(MSM_AUDIO_RES_STATE_RELEASE == msm_audio_get_res_state(pmsmaudio_ctx)) {

+		return;

+	}

+	//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 	msm_ccm_notify_cc_status(0);

 	msm_audio_stream_event_notify(pmsmaudio_ctx, SCAUDIO_EVENT_RESUME);

 

@@ -317,7 +357,22 @@
     pipcmsg->data_len = len;

 	memcpy(pipcmsg->data, data, len);

 }

-

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+void msm_audio_set_res_state(struct msm_audio_context *pmsmaudio_ctx, unsigned int state)

+{

+    pthread_mutex_lock(&pmsmaudio_ctx->audiochn_mutex);

+    pmsmaudio_ctx->audiores_state = state;

+    pthread_mutex_unlock(&pmsmaudio_ctx->audiochn_mutex);

+}

+unsigned int msm_audio_get_res_state(struct msm_audio_context *pmsmaudio_ctx)

+{

+    unsigned int state;

+    pthread_mutex_lock(&pmsmaudio_ctx->audiochn_mutex);

+    state = pmsmaudio_ctx->audiores_state;

+    pthread_mutex_unlock(&pmsmaudio_ctx->audiochn_mutex);

+    return state;

+}

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 void audiochn_add_list(struct msm_client_node *new_audiochn, struct msm_audio_context *pmsmaudio_ctx)

 {

 	if(NULL == new_audiochn) {

diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/msm_svr/audio/msm_audio.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/msm_svr/audio/msm_audio.h
index 7941a3e..e676a08 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/msm_svr/audio/msm_audio.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/msm_svr/audio/msm_audio.h
@@ -6,7 +6,11 @@
 #include "msm_svrcall_media.h"

 

 #define MSM_AUDIO_HANDLE_INVALID  0

-

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+#define MSM_AUDIO_RES_STATE_UNKNOW    0

+#define MSM_AUDIO_RES_STATE_HOLD    1

+#define MSM_AUDIO_RES_STATE_RELEASE    2

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 struct msm_audio_channel {	

 	MM_HANDLE mm_handle;

 	unsigned int device;

@@ -34,10 +38,18 @@
 	unsigned char audiochn_count;

 

 	long audiores_handle;

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+	/*0-unknow;1-hold;2-release;*/

+	unsigned int audiores_state;

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 };

 

 BOOL msm_audio_file_check(const char *file, const char *mode);

 MSM_AUDIO_RATE_TYPE_E msm_audio_mantate_to_msmrate(int samplerate);

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START

+void msm_audio_set_res_state(struct msm_audio_context *pmsmaudio_ctx, unsigned int state);

+unsigned int msm_audio_get_res_state(struct msm_audio_context *pmsmaudio_ctx);

+//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END

 void msm_audio_ipcmsg_set(int fdsvr, int msgreq, void *data, int len, sc_ipc_msg *pipcmsg);

 void audiochn_add_list(struct msm_client_node *new_audiochn, struct msm_audio_context *pmsmaudio_ctx);

 void audiochn_del_list(struct msm_client_node *audioclient, struct msm_audio_context *pmsmaudio_ctx);