[Bugfix][T106][task-view-423] apply RIL_UNSOL_AUDIODEV_SAMPLERATE for
rtp
Only Configure: No
Affected branch: unknown
Affected module: ecall
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: yes
Doc Update: no
Change-Id: I85a1525a5bbd2db520d4248f89a23ee55fce76f8
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/mtk_ril_unsol_commands.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/mtk_ril_unsol_commands.h
index 5c4f022..48c7c83 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/mtk_ril_unsol_commands.h
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/mtk_ril_unsol_commands.h
@@ -51,4 +51,7 @@
{RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR, responseStrings, WAKE_PARTIAL},
{RIL_UNSOL_CALL_INFO_INDICATION, responseStrings, WAKE_PARTIAL},
{RIL_UNSOL_SIM_STATUS_COMMAND, responseSimStatus, WAKE_PARTIAL},
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+{RIL_UNSOL_AUDIO_DEV_SAMPLERATE, responseInts, WAKE_PARTIAL},
+#endif
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
index 0899cbf..c4a4318 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
@@ -4996,6 +4996,13 @@
handleRingbackTone(data, datalen, soc_id);
break;
}
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+ case RIL_UNSOL_AUDIO_DEV_SAMPLERATE:
+ {
+ handleAudioDevSampleRate(data, datalen, soc_id);
+ break;
+ }
+#endif
default:
break;
}
@@ -5611,6 +5618,9 @@
case LYNQ_REQUEST_GET_SMSDATABASE_STATE: return "LYNQ_REQUEST_GET_SMSDATABASE_STATE";
case RIL_REQUEST_GET_MSISDN: return "GET MSISDN";
case RIL_REQUEST_RESET_SIMCARD: return "RESET SIMCARD";
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+ case RIL_UNSOL_AUDIO_DEV_SAMPLERATE: return "UNSOL_AUDIO_DEV_SAMPLERATE";
+#endif
/*warren add for t800 ril service 2022/1/22 end*/
default: return "<unknown request>";
}
@@ -5816,7 +5826,7 @@
if(utils::is_suppport_dsss()) {
int id = Phone_utils::get_enable_sim_for_dsss();
init(id);
- }
+ }
}
@@ -5930,6 +5940,9 @@
case RIL_UNSOL_ON_USSI: return 1;
case RIL_UNSOL_ECC_NUM: return 1;
case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return 1;
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+ case RIL_UNSOL_AUDIO_DEV_SAMPLERATE: return 1;
+#endif
default: return 0;
}
}
@@ -6177,7 +6190,7 @@
RLOGE("setnonblocking Failed");
exit(1);
}
-
+
/* create epoll fd,add socket to epoll */
ep_fd = epoll_create(LYNQ_SOCKET_ENVNT_FD_MAX);
//int len = sizeof(struct sockaddr_in);
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.cpp
index 6a8aeeb..1bfd08e 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.cpp
@@ -39,6 +39,10 @@
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
static LYNQ_Audio_Mode s_current_audio_mode=AUDIO_MODE_CODEC;
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+#define INVALIDE_SAMPLE_RATE (-1)
+static int s_current_sample_rate=INVALIDE_SAMPLE_RATE;
+#endif
int lock_rtp_audio_mtx()
{
@@ -129,6 +133,55 @@
return rsp_code;
}
#ifdef MOBILETEK_TARGET_PLATFORM_T106
+void handleAudioDevSampleRate(const void* data, int datalen, RIL_SOCKET_ID soc_id) {
+ if (data == NULL || datalen < sizeof(int)*2) {
+ if (data == NULL) {
+ RLOGE("handleAudioDevSampleRate invalid response: NULL");
+ } else {
+ RLOGE("handleAudioDevSampleRate: invalid response length %d expecting len: %d",
+ datalen, sizeof(int)*2);
+ }
+ return ;
+ }
+
+ int dev_open = ((int *)data)[0];
+ int sample_rate=0;
+ if(dev_open)
+ {
+ sample_rate= ((int *) data)[1];
+ set_voice_sample_rate(sample_rate,soc_id);
+ }
+
+ RLOGD("handleAudioDevSampleRate, dev_open: %d, sample_rate: %d",dev_open, sample_rate);
+}
+
+
+int exe_set_voice_only_sample_rate(LYNQ_Audio_Mode audio_mode, int sample_rate)
+{
+ char cmd[256];
+
+ RLOGD("%s %d %d",__FUNCTION__,audio_mode,sample_rate);
+ if(audio_mode==AUDIO_MODE_RTP)
+ {
+ system("killall lynq_vb_demo");
+ sprintf(cmd, "echo voice_buffer_rtp_test_start %d | lynq_vb_demo &>/dev/null &", sample_rate);
+ system(cmd);
+ }
+ else if(audio_mode==AUDIO_MODE_FILE)
+ {
+ system("killall lynq_vb_demo");
+ sprintf(cmd, "echo voice_buffer_test_start %d | lynq_vb_demo &>/dev/null &", sample_rate);
+ system(cmd);
+ }
+ else if(audio_mode==AUDIO_MODE_LOOP_BACK)
+ {
+ system("killall lynq_vb_demo");
+ sprintf(cmd, "echo voice_buffer_loop_test_start %d | lynq_vb_demo &>/dev/null &", sample_rate);
+ system(cmd);
+ }
+ return RESULT_OK;
+}
+
int is_use_voice_buffer(LYNQ_Audio_Mode* cur_mode)
{
(*cur_mode)=exe_get_voice_audio_mode();
@@ -138,6 +191,62 @@
}
return false;
}
+
+int set_voice_sample_rate(int sample_rate,RIL_SOCKET_ID socket_id)
+{
+ int s = lock_rtp_audio_mtx();
+ if(s != 0) {
+ RLOGE("%s lock_rtp_audio_mtx fail",__FUNCTION__);
+ }
+
+ int old_sample_rate;
+ old_sample_rate=s_current_sample_rate;
+ s_current_sample_rate= sample_rate;
+
+ int rsp_code=0;
+ if((get_call_status() == CALL_ON) && getSpeechStatus() == NORMAL_SPEECH_ON)
+ {
+ if(s_current_sample_rate!=old_sample_rate)
+ {
+ LYNQ_Audio_Mode cur_mode;
+ if(is_use_voice_buffer(&cur_mode)==false)
+ {
+ goto set_sample_rate_end;
+ }
+
+ if(is_exit_call_in_callist_and_all_call_not_active((int) socket_id))
+ {
+ RLOGE("%s in real time before active from %d to %d",__FUNCTION__,old_sample_rate,s_current_sample_rate);
+ if(exe_set_voice_audio_mode(cur_mode))
+ {
+ rsp_code=5;
+ }
+ }
+ else
+ {
+ RLOGE("%s in real time after active from %d to %d",__FUNCTION__,old_sample_rate,s_current_sample_rate);
+ if(exe_set_voice_only_sample_rate(cur_mode,s_current_sample_rate))
+ {
+ rsp_code=4;
+ }
+ }
+ }
+ }
+
+set_sample_rate_end:
+
+ if(rsp_code!=0)
+ {
+ s_current_sample_rate=old_sample_rate;
+ }
+
+ s = unlock_rtp_audio_mtx();
+ if(s != 0) {
+ RLOGE("%s, unlock_rtp_audio_mtx fail",__FUNCTION__);
+ }
+ RLOGE("%s %d ret is %d",__FUNCTION__,sample_rate,rsp_code);
+ return rsp_code;
+}
#endif
#if 0
@@ -571,9 +680,6 @@
int exe_set_voice_audio_mode(const LYNQ_Audio_Mode audio_mode)
{
#ifdef MOBILETEK_TARGET_PLATFORM_T106
- int ret;
-
-
char* cmd1="AT+VOICE_PROCESS=0";
char* cmd2="AT+VOICE_BUFFER=1,1";
char* cmd3="AT+VOICE_BUFFER=0,1";
@@ -586,32 +692,42 @@
RLOGD("%s %d",__FUNCTION__,audio_mode);
if(audio_mode==AUDIO_MODE_RTP)
{
- system("killall lynq_vb_demo");
- argv[1] = cmd2;
+ system("killall lynq_vb_demo");
+ argv[1] = cmd2;
lynqSendAt(2,argv,1012);
-
- sprintf(cmd, "echo voice_buffer_rtp_test_start %d | lynq_vb_demo &>/dev/null &", 16000);
+ if(s_current_sample_rate==INVALIDE_SAMPLE_RATE)
+ {
+ s_current_sample_rate=16000;
+ }
+ sprintf(cmd, "echo voice_buffer_rtp_test_start %d | lynq_vb_demo &>/dev/null &", s_current_sample_rate);
system(cmd);
}
else if(audio_mode==AUDIO_MODE_FILE)
- {
+ {
system("killall lynq_vb_demo");
argv[1] = cmd2;
- lynqSendAt(2,argv,1012);
- sprintf(cmd, "echo voice_buffer_test_start %d | lynq_vb_demo &>/dev/null &", 16000);
+ lynqSendAt(2,argv,1012);
+ if(s_current_sample_rate==INVALIDE_SAMPLE_RATE)
+ {
+ s_current_sample_rate=16000;
+ }
+ sprintf(cmd, "echo voice_buffer_test_start %d | lynq_vb_demo &>/dev/null &", s_current_sample_rate);
system(cmd);
}
else if(audio_mode==AUDIO_MODE_LOOP_BACK)
{
- system("killall lynq_vb_demo");
+ system("killall lynq_vb_demo");
argv[1] = cmd1;
lynqSendAt(2,argv,1011);
argv[1] = cmd2;
lynqSendAt(2,argv,1012);
- sprintf(cmd, "echo voice_buffer_loop_test_start %d | lynq_vb_demo &>/dev/null &", 16000);
+ if(s_current_sample_rate==INVALIDE_SAMPLE_RATE)
+ {
+ s_current_sample_rate=16000;
+ }
+ sprintf(cmd, "echo voice_buffer_loop_test_start %d | lynq_vb_demo &>/dev/null &", s_current_sample_rate);
system(cmd);
-
}
else // audio_mode==AUDIO_MODE_ALL_CLOSE /AUDIO_MODE_INIT/AUDIO_MODE_CODEC
{
@@ -619,7 +735,8 @@
argv[1] = cmd3;
lynqSendAt(2,argv,1013);
argv[1] = cmd4;
- lynqSendAt(2,argv,1014);
+ lynqSendAt(2,argv,1014);
+ s_current_sample_rate=INVALIDE_SAMPLE_RATE;
}
RLOGD("%s %d suc",__FUNCTION__,audio_mode);
#endif
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.h
index 03cc9f1..fbb79e1 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.h
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.h
@@ -29,6 +29,8 @@
int exe_set_voice_audio_mode(const LYNQ_Audio_Mode audio_mode);
LYNQ_Audio_Mode exe_get_voice_audio_mode();
#ifdef MOBILETEK_TARGET_PLATFORM_T106
+int set_voice_sample_rate(int sample_rate,RIL_SOCKET_ID socket_id);
+void handleAudioDevSampleRate(const void* data, int datalen, RIL_SOCKET_ID soc_id);
int is_use_voice_buffer(LYNQ_Audio_Mode* cur_mode);
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/include/telephony/mtk_ril_ivt.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/include/telephony/mtk_ril_ivt.h
index dad33d5..24708a9 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/include/telephony/mtk_ril_ivt.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/include/telephony/mtk_ril_ivt.h
@@ -354,6 +354,22 @@
//only for libvendor-ril
#define RIL_UNSOL_LOCAL_UPDATE_PDN_INFO_CHANGED (RIL_UNSOL_VENDOR_IVT_BASE + 22)
+//LYNQ_ZXW_BUG423_CR_20240520CBA2FB95_Q.HUANG_20241209_START
+#define RIL_UNSOL_VENDOR_LYNQ_BASE 9800
+
+/**
+ * RIL_UNSOL_AUDIO_DEV_SAMPLERATE
+ * same to RIL_UNSOL_AUDIODEV_SAMPLERATE
+ *
+ * Indicates that audio device sample rate.
+ *
+ * "data" is an int *
+ * ((int *)data)[0] is current audio device state. 0 for close ,1 for open.
+ * ((int *)data)[1] is sample rate.value is 8000 0r 16000.
+ */
+#define RIL_UNSOL_AUDIO_DEV_SAMPLERATE (RIL_UNSOL_VENDOR_LYNQ_BASE + 0)
+//LYNQ_ZXW_BUG423_CR_20240520CBA2FB95_Q.HUANG_20241209_END
+
/// @}
/// M
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/mtk_ril_ivt.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/mtk_ril_ivt.h
index dad33d5..24708a9 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/mtk_ril_ivt.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/mtk_ril_ivt.h
@@ -354,6 +354,22 @@
//only for libvendor-ril
#define RIL_UNSOL_LOCAL_UPDATE_PDN_INFO_CHANGED (RIL_UNSOL_VENDOR_IVT_BASE + 22)
+//LYNQ_ZXW_BUG423_CR_20240520CBA2FB95_Q.HUANG_20241209_START
+#define RIL_UNSOL_VENDOR_LYNQ_BASE 9800
+
+/**
+ * RIL_UNSOL_AUDIO_DEV_SAMPLERATE
+ * same to RIL_UNSOL_AUDIODEV_SAMPLERATE
+ *
+ * Indicates that audio device sample rate.
+ *
+ * "data" is an int *
+ * ((int *)data)[0] is current audio device state. 0 for close ,1 for open.
+ * ((int *)data)[1] is sample rate.value is 8000 0r 16000.
+ */
+#define RIL_UNSOL_AUDIO_DEV_SAMPLERATE (RIL_UNSOL_VENDOR_LYNQ_BASE + 0)
+//LYNQ_ZXW_BUG423_CR_20240520CBA2FB95_Q.HUANG_20241209_END
+
/// @}
/// M
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
index e05893b..d7aa113 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
@@ -926,7 +926,7 @@
if(m == 0 || m == 1) {
result[0] = m;
result[1] = k;
- RIL_onUnsolicitedResponse(RIL_UNSOL_AUDIODEV_SAMPLERATE, (char *) result, sizeof(result));
+ RIL_onUnsolicitedResponse(RIL_UNSOL_AUDIO_DEV_SAMPLERATE, (char *) result, sizeof(result));//LYNQ_ZXW_BUG423_CR_20240520CBA2FB95_Q.HUANG_20241209_CHANGE RIL_UNSOL_AUDIODEV_SAMPLERATE to RIL_UNSOL_AUDIO_DEV_SAMPLERATE
}
else if (m == 2) { /*֪ͨ¿ªÊ¼²¥·Å±¾µØÕñÁåÒô*/
cc_voice_play_ring_back();