[Bugfix][T108-GSW][bug-view-1462]if no voice init, call gsw_voice_set_speaker_volume will segment fault.
Only Configure: No
Affected branch: unknown
Affected module: network
Is it affected on both ZXIC and ASR: only ASR
Self-test: yes
Doc Update: no
Change-Id: If303e6764dad9d71e2f46ebde07da1156ad44f52
diff --git a/mbtk/libgsw_lib/gsw_voice_interface.c b/mbtk/libgsw_lib/gsw_voice_interface.c
index d74802a..ab38493 100755
--- a/mbtk/libgsw_lib/gsw_voice_interface.c
+++ b/mbtk/libgsw_lib/gsw_voice_interface.c
@@ -309,6 +309,15 @@
mbtk_log(LOG_ERR_LEVEL, "%s#%s: "GSW_VOICE"" fmt, ptr_1001 + 1, line_1001, ##args); \
} while(0)
+#define MODULE_INIT_CHECK(init_flag) \
+ if(init_flag == 0) \
+ { \
+ return GSW_HAL_ERROR_GNSS_DATA_CALL_DEINIT; \
+ }
+
+#define VOICE_MODULE_INIT_CHECK() MODULE_INIT_CHECK(gsw_voice_init_flag)
+
+
static int mbtk_rtp_api_import()
{
mbtk_rtp_init = (int (*)(void))dlsym(dlHandle_mbtk, "mbtk_rtp_init");
@@ -656,51 +665,7 @@
{
//UNUSED(volume);
-#if 0
-
- if(volume < 0 || volume > 5)
- {
- level_call = 0;
- }
- else
- {
- //支持-36~12
- switch(volume)
- {
- case 0 :
- level_call = -20;
- break;
- case 1 :
- level_call = -14;
- break;
- case 2 :
- level_call = -8;
- break;
- case 3 :
- level_call = 0;
- break;
- case 4 :
- level_call = 5;
- break;
- case 5 :
- level_call = 12;
- break;
- default:
- break;
- }
- }
-
- mbtk_audio_dsp_set(1, level_call);
- if(err)
- {
- LOGE("Error : %d\n", err);
- return -1;
- }
- else
- {
- LOGE("Set success.\n");
- }
-#endif
+ VOICE_MODULE_INIT_CHECK();
char cmd[128] = {0};
int lv = 0;
@@ -767,10 +732,7 @@
*/
int32_t gsw_voice_normal_voice_start(CallHandle *handle, const char *callNumber)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
+ VOICE_MODULE_INIT_CHECK();
mbtk_call_info_t reg = {0};
int ret = -1;
@@ -816,10 +778,7 @@
*/
int32_t gsw_voice_answer(CallHandle handle)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
+ VOICE_MODULE_INIT_CHECK();
int ret = -1;
@@ -848,10 +807,7 @@
*/
int32_t gsw_voice_hangup(CallHandle handle)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
+ VOICE_MODULE_INIT_CHECK();
int ret = -1;
@@ -878,11 +834,8 @@
*/
int32_t gsw_voice_set_auto_answer_mode(int32_t mode)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
-
+ VOICE_MODULE_INIT_CHECK();
+
if(mode == 1)
{
int ret = -1;
@@ -904,11 +857,8 @@
int32_t gsw_voice_get_current_call_end_reason(CallHandle handle)
{
- if(gsw_voice_init_flag == 0 || call_info_handle == NULL)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
-
+ VOICE_MODULE_INIT_CHECK();
+
int reason = gsw_global_end_reason;
return reason;
@@ -925,10 +875,7 @@
*/
int32_t gsw_voice_set_audio_mode(AudioMode audioMode)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
+ VOICE_MODULE_INIT_CHECK();
int ret=mbtk_rtp_enable(audioMode);
if(ret !=0 )
@@ -947,10 +894,7 @@
*/
int32_t gsw_voice_set_remote_rtp_ip(const char *ip, int32_t len)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
+ VOICE_MODULE_INIT_CHECK();
int ret=mbtk_rtp_remote_ip_set(ip);
if(ret !=0 )
@@ -969,10 +913,7 @@
*/
int32_t gsw_voice_set_rtp_port(RTPMode rtpMode, int32_t port)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
+ VOICE_MODULE_INIT_CHECK();
int ret;
if(rtpMode==GSW_RTP_CLIENT)
@@ -1000,10 +941,7 @@
*/
int32_t gsw_voice_set_rtp_param(int32_t clockRate, int32_t channel, int32_t latency)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
+ VOICE_MODULE_INIT_CHECK();
int ret=mbtk_rtp_channel_set(channel);
if(ret==0)
@@ -1025,10 +963,7 @@
*/
int32_t gsw_voice_set_rtp_vlan_info(const char *interfaceName)
{
- if(gsw_voice_init_flag == 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
+ VOICE_MODULE_INIT_CHECK();
int ret=mbtk_rtp_vlan_set(interfaceName);
diff --git a/mbtk/test/libgsw_lib/gsw_voice_test.c b/mbtk/test/libgsw_lib/gsw_voice_test.c
index 366b58a..28098c2 100755
--- a/mbtk/test/libgsw_lib/gsw_voice_test.c
+++ b/mbtk/test/libgsw_lib/gsw_voice_test.c
@@ -274,7 +274,7 @@
ret = gsw_voice_sdk_init(gsw_test_callback);
if(ret != 0)
{
- printf("gsw_voice_sdk_init fail\n");
+ printf("gsw_voice_sdk_init fail, ret is %d\n",ret);
}
else
{
@@ -293,7 +293,7 @@
ret = gsw_voice_normal_voice_start(&call_handle, number);
if(ret < 0)
{
- printf("gsw_voice_normal_voice_start fail\n");
+ printf("gsw_voice_normal_voice_start fail, ret is %d\n", ret);
}
else
{
@@ -308,7 +308,7 @@
ret = gsw_voice_hangup(call_handle);
if(ret < 0)
{
- printf("gsw_voice_hangup fail\n");
+ printf("gsw_voice_hangup fail, ret is %d\n",ret);
}
else
{
@@ -345,7 +345,7 @@
ret = gsw_voice_set_auto_answer_mode(mode);
if(ret < 0)
{
- printf("gsw_voice_set_auto_answer_mode fail\n");
+ printf("gsw_voice_set_auto_answer_mode fail, ret is %d\n",ret);
}
else
{
@@ -368,7 +368,7 @@
ret = gsw_voice_set_speaker_volume(volume);
if(ret < 0)
{
- printf("gsw_voice_set_speaker_volume fail\n");
+ printf("gsw_voice_set_speaker_volume fail, ret is %d\n",ret);
}
else
{
@@ -391,7 +391,7 @@
ret = gsw_voice_set_audio_mode(mode);
if(ret != 0)
{
- printf("gsw_voice_set_audio_mode fail\n");
+ printf("gsw_voice_set_audio_mode fail, ret is %d\n",ret);
}
else
{
@@ -414,7 +414,7 @@
ret = gsw_voice_set_remote_rtp_ip(remote_ip_addr,strlen(remote_ip_addr)+1);
if(ret != 0)
{
- printf("gsw_voice_set_remote_rtp_ip fail\n");
+ printf("gsw_voice_set_remote_rtp_ip fail, ret is %d\n",ret);
}
else
{
@@ -442,7 +442,7 @@
ret = gsw_voice_set_rtp_port(mode,port);
if(ret != 0)
{
- printf("gsw_voice_set_rtp_port fail\n");
+ printf("gsw_voice_set_rtp_port fail, ret is %d\n",ret);
}
else
{
@@ -473,7 +473,7 @@
ret = gsw_voice_set_rtp_param(clockRate, channel, latency);
if(ret != 0)
{
- printf("gsw_voice_set_rtp_param fail\n");
+ printf("gsw_voice_set_rtp_param fail, ret is %d\n",ret);
}
else
{
@@ -495,7 +495,7 @@
ret = gsw_voice_set_rtp_vlan_info(interface);
if(ret != 0)
{
- printf("gsw_voice_set_rtp_vlan_info fail\n");
+ printf("gsw_voice_set_rtp_vlan_info fail, ret is %d\n",ret);
}
else
{