From d7b4254835e164235d99c3aa45cd219f69a1ca8b Mon Sep 17 00:00:00 2001 From: wangzijiao Date: Tue, 25 Dec 2018 19:33:29 +0800 Subject: [PATCH] add enable_xunfei_case config to netease voice && fix cc compile error for new tina code --- .../wifi/{controlApi.go => controlApi.go.bak} | 0 .../interface/keypad/matrix4x3/matrix4x3.go | 2 +- .../nembd/motion/servo/servo.go | 5 ++--- app/netease_voice_common_module/Config.in | 8 +++----- app/netease_voice_common_module/Makefile | 3 +++ app/netease_voice_common_module/src/cae.c | 4 ++++ .../src/comm/AudioQueue.c | 7 ++++--- .../src/include/cae.h | 4 +++- .../src/include/msc.h | 15 ++++++++++++-- app/netease_voice_common_module/src/main.c | 20 ++++++++++++------- app/netease_voice_common_module/src/msc.c | 3 +++ .../src/nduilite.c | 3 +-- app/netease_voice_common_module/src/record.c | 15 ++++++++++++-- 13 files changed, 63 insertions(+), 26 deletions(-) rename app/netease_control_center_common_module/src/netease_control_center/modules/wifi/{controlApi.go => controlApi.go.bak} (100%) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/wifi/controlApi.go b/app/netease_control_center_common_module/src/netease_control_center/modules/wifi/controlApi.go.bak similarity index 100% rename from app/netease_control_center_common_module/src/netease_control_center/modules/wifi/controlApi.go rename to app/netease_control_center_common_module/src/netease_control_center/modules/wifi/controlApi.go.bak diff --git a/app/netease_control_center_common_module/src/netease_control_center/nembd/interface/keypad/matrix4x3/matrix4x3.go b/app/netease_control_center_common_module/src/netease_control_center/nembd/interface/keypad/matrix4x3/matrix4x3.go index 6ef984f..7bacb5e 100644 --- a/app/netease_control_center_common_module/src/netease_control_center/nembd/interface/keypad/matrix4x3/matrix4x3.go +++ b/app/netease_control_center_common_module/src/netease_control_center/nembd/interface/keypad/matrix4x3/matrix4x3.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "github.com/kidoman/embd" + embd "netease_control_center/nembd" ) type Key int diff --git a/app/netease_control_center_common_module/src/netease_control_center/nembd/motion/servo/servo.go b/app/netease_control_center_common_module/src/netease_control_center/nembd/motion/servo/servo.go index 456eaf5..379ab7a 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/nembd/motion/servo/servo.go +++ b/app/netease_control_center_common_module/src/netease_control_center/nembd/motion/servo/servo.go @@ -1,9 +1,9 @@ // Package servo allows control of servos using a PWM controller. package servo +import "netease_control_center/nembd/util" + import ( - "github.com/golang/glog" - "github.com/kidoman/embd/util" "netease_control_center/interfaces/log" ) @@ -42,6 +42,5 @@ func (s *Servo) SetAngle(angle int) error { us := util.Map(int64(angle), 0, 180, int64(s.Minus), int64(s.Maxus)) log.Printf(log.DebugLog, "servo: given angle %v calculated %v us\n", angle, us) - return s.PWM.SetMicroseconds(int(us)) } diff --git a/app/netease_voice_common_module/Config.in b/app/netease_voice_common_module/Config.in index 3ec0272..a2c918e 100644 --- a/app/netease_voice_common_module/Config.in +++ b/app/netease_voice_common_module/Config.in @@ -16,7 +16,7 @@ endchoice choice prompt "Selected CAE SDK" - default XUNFEI_CAE_SDK + default NETEASE_DUILITE_SDK config NETEASE_CAE_SDK bool "Used netease CAE SDK" @@ -24,12 +24,10 @@ choice config XUNFEI_CAE_SDK bool "Used xunfei CAE SDK" + config NETEASE_DUILITE_SDK + bool "Used duilite CAE SDK" endchoice -config NETEASE_DUILITE_SDK - bool "Used duilite CAE SDK" - default y - choice prompt "Selected TTS SDK" default XUNFEI_TTS_SDK diff --git a/app/netease_voice_common_module/Makefile b/app/netease_voice_common_module/Makefile index 0f94f83..aa3689e 100644 --- a/app/netease_voice_common_module/Makefile +++ b/app/netease_voice_common_module/Makefile @@ -31,6 +31,7 @@ define Package/$(PKG_NAME) ifeq ('$(CONFIG_XUNFEI_CAE_SDK)', 'y') DEPENDS+= +libcae + TARGET_CFLAGS+= -DENABLE_MODULE_XUNFEICAE=1 endif ifeq ('$(CONFIG_NETEASE_MSC_SDK)', 'y') @@ -43,6 +44,7 @@ define Package/$(PKG_NAME) ifeq ('$(CONFIG_NETEASE_DUILITE_SDK)', 'y') DEPENDS+= +libduilite + TARGET_CFLAGS+= -DENABLE_MODULE_DUILITE=1 endif ifeq ('$(CONFIG_USED_DC_SDK)', 'y') @@ -93,6 +95,7 @@ define Build/Configure endef define Build/Compile + $(info TARGET_CFLAGS=$(TARGET_CFLAGS)) $(MAKE) -C $(PKG_BUILD_DIR)/src \ ARCH="$(TARGET_ARCH)" \ AR="$(TARGET_AR)" \ diff --git a/app/netease_voice_common_module/src/cae.c b/app/netease_voice_common_module/src/cae.c index 7f166c2..4e1aca5 100644 --- a/app/netease_voice_common_module/src/cae.c +++ b/app/netease_voice_common_module/src/cae.c @@ -20,6 +20,8 @@ when who why /* ------------------------------------------------------------------------ ** Includes ** ------------------------------------------------------------------------ */ +#ifdef ENABLE_MODULE_XUNFEICAE + #include "cae_lib.h" #include "error.h" #include @@ -216,3 +218,5 @@ int Netease_CAESetShowLog(int show_log) { CAESetShowLog(show_log); #endif } + +#endif \ No newline at end of file diff --git a/app/netease_voice_common_module/src/comm/AudioQueue.c b/app/netease_voice_common_module/src/comm/AudioQueue.c index 992dd36..afbca29 100644 --- a/app/netease_voice_common_module/src/comm/AudioQueue.c +++ b/app/netease_voice_common_module/src/comm/AudioQueue.c @@ -112,6 +112,7 @@ int queue_full(audio_queue_t *queue) { int queue_write(audio_queue_t *queue, char data[], int dataLen) { if (queue == NULL || data == NULL || dataLen <= 0) { + printf("Input is null, return! datalen:%d\n", dataLen); return false; } pthread_mutex_lock(&(queue->mutex)); @@ -139,7 +140,7 @@ int queue_write(audio_queue_t *queue, char data[], int dataLen) { queue->rear = (queue->rear + dataLen) % queue->capacity; pthread_mutex_unlock(&(queue->mutex)); native_event_set(queue->sync_event); - // printf("queue_write end \n"); + //printf("queue_write end queue:0x%p\n", queue); return true; } @@ -153,7 +154,7 @@ int queue_read(audio_queue_t *queue, char **data) { if (queue == NULL || data == NULL) { return 0; } - //printf("queue_read pthread_cond_wait begin\n"); + //printf("queue_read pthread_cond_wait begin 0x%p\n", queue); native_event_wait(queue->sync_event, 0x7fffffff); pthread_mutex_lock(&(queue->mutex)); queueBase = (char *)(queue + 1); @@ -163,7 +164,7 @@ int queue_read(audio_queue_t *queue, char **data) { temp_buff = (char *)malloc(queueLen); if (NULL == temp_buff) { - printf("queue_read malloc error queueLen%d\n", queueLen); + //printf("queue_read malloc error queueLen%d\n", queueLen); pthread_mutex_unlock(&(queue->mutex)); return 0; } diff --git a/app/netease_voice_common_module/src/include/cae.h b/app/netease_voice_common_module/src/include/cae.h index 73618fb..9b27024 100644 --- a/app/netease_voice_common_module/src/include/cae.h +++ b/app/netease_voice_common_module/src/include/cae.h @@ -19,8 +19,9 @@ when who why #ifndef __CAE_H__ #define __CAE_H__ +#if ENABLE_MODULE_XUNFEICAE -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif /* C++ */ @@ -46,4 +47,5 @@ int Netease_CAESetShowLog(int show_log); } /* extern "C" */ #endif /* C++ */ +#endif /* ENABLE_MODULE_XUNFEICAE */ #endif /* __CAE_H__ */ diff --git a/app/netease_voice_common_module/src/include/msc.h b/app/netease_voice_common_module/src/include/msc.h index c015640..47072bc 100644 --- a/app/netease_voice_common_module/src/include/msc.h +++ b/app/netease_voice_common_module/src/include/msc.h @@ -35,15 +35,22 @@ extern "C" { //#define ENABLE_YUNXIN #if USED_NETEASE_FMAE + #include + #else + +#ifdef ENABLE_MODULE_XUNFEICAE #include "cae.h" -#include "cae_lib.h" -#include "cae_thread.h" #include #include #endif +#endif + +#include "cae_lib.h" +#include "cae_thread.h" + struct IAT_HD; typedef enum { @@ -90,8 +97,12 @@ struct IAT_HD { void Netease_IAT_DeInit(); int Netease_IAT_Init(); void Netease_IAT_write(const void *audiobuf, int audiolen); + +#if ENABLE_MODULE_XUNFEICAE int Netease_MSP_Init(CAEDATA **cdata); int Netease_MSP_Deinit(); +#endif + void Netease_IAT_checkflag(int angle); // 1: fail, 0: success diff --git a/app/netease_voice_common_module/src/main.c b/app/netease_voice_common_module/src/main.c index 7788357..9f60b6d 100644 --- a/app/netease_voice_common_module/src/main.c +++ b/app/netease_voice_common_module/src/main.c @@ -41,10 +41,13 @@ when who why #if USED_NETEASE_DUILITE // speech voice cb #include "nduilite.h" -#include #include #endif +#if ENABLE_MODULE_XUNFEICAE +#include +#endif + /* ------------------------------------------------------------------------ ** Macros ** ------------------------------------------------------------------------ */ @@ -76,7 +79,7 @@ typedef struct _FMAEUserData { } FMAEUserData; FMAE_HANDLE g_hFMAE; const char *g_fmaeCfgPath = "/usr/share/fmae_res/config.ini"; -#else +#elif ENABLE_MODULE_XUNFEICAE CAEDATA *caeconfig = NULL; #endif @@ -316,6 +319,7 @@ static void record_audio_cb(const void *audio, unsigned int audio_len, if (caeconfig != NULL && caeconfig->cae != NULL) { // n_debug("write audio to cae !\n"); #endif + #if USED_NETEASE_DC // unsigned char* pBuf = (unsigned char*)audio; #if 1 @@ -350,11 +354,11 @@ static void record_audio_cb(const void *audio, unsigned int audio_len, debug_waste_time("__cacheCAEAudio", &cachetime); #endif -#if USED_NETEASE_FMAE +#if USED_NETEASE_FMAE && ENABLE_MODULE_XUNFEICAE ret = FMAEAudioWrite(g_hFMAE, audio, audio_len); // printf("write %d at %p ret = %d\n", audio_len, audio, ret); -#elif USED_XUNFEI_CAE +#elif ENABLE_MODULE_XUNFEICAE Netease_CAEAudioWrite(caeconfig, audio, audio_len); #endif // n_debug("write finish!\n"); @@ -396,11 +400,13 @@ static PDBUS_MSG_PACK DBusMessageCb(uv_loop_t *pLoop, DBusConnection *pConn, case CMD_CC_MSC_BEGIN_SESSION: n_toast("Recv cc create session command! msg:%s\n", pMsg->pMsg); - if (been_wakedup == 0 && caeconfig != NULL) { + if (been_wakedup == 0) { // todo do not waked up, do wake here n_toast("has not waked up!todo waked up!"); -#if USED_XUNFEI_CAE - Netease_CAESetRealBeam(caeconfig, 0); + +#if ENABLE_MODULE_XUNFEICAE + if (NULL != caeconfig) + Netease_CAESetRealBeam(caeconfig, 0); #endif } js = json_loadb(pMsg->pMsg, pMsg->msgSize, 0, NULL); diff --git a/app/netease_voice_common_module/src/msc.c b/app/netease_voice_common_module/src/msc.c index de0daad..1e1b0eb 100644 --- a/app/netease_voice_common_module/src/msc.c +++ b/app/netease_voice_common_module/src/msc.c @@ -75,7 +75,10 @@ when who why * Global Variable Definitions * * ------------------------------------------------------------------------ */ +#if ENABLE_MODULE_XUNFEICAE CAEDATA **cae; +#endif + struct IAT_HD *iathd; static char isBeginSession = 0; static int audiostate = MSP_AUDIO_SAMPLE_CONTINUE; diff --git a/app/netease_voice_common_module/src/nduilite.c b/app/netease_voice_common_module/src/nduilite.c index 2f5fd4b..9290dc7 100644 --- a/app/netease_voice_common_module/src/nduilite.c +++ b/app/netease_voice_common_module/src/nduilite.c @@ -33,7 +33,6 @@ when who why #include "msc.h" #include "nduilite.h" -#include #include /* ------------------------------------------------------------------------ @@ -395,7 +394,7 @@ void Netease_nduilite_writeaudio(const void *audioData, return; } - //n_debug("Write nduilite data, len:%d\n", audio_len); + n_debug("Write nduilite data, len:%d\n", audio_len); ret = duilite_fespa_feed(fespa, audioData, audio_len); #if 0 diff --git a/app/netease_voice_common_module/src/record.c b/app/netease_voice_common_module/src/record.c index 12fca7f..af5ad51 100644 --- a/app/netease_voice_common_module/src/record.c +++ b/app/netease_voice_common_module/src/record.c @@ -33,7 +33,9 @@ when who why #include "record.h" #include "error.h" +#if ENABLE_MODULE_XUNFEICAE #include +#endif #include #include #include @@ -56,6 +58,7 @@ when who why ** ------------------------------------------------------------------------ */ static char *out_pcm_name; +#if ENABLE_MODULE_XUNFEICAE static Proc_CAENew api_cae_new; static Proc_CAEAudioWrite api_cae_audio_write; static Proc_CAEResetEng api_cae_reset_eng; @@ -66,6 +69,7 @@ static Proc_CAEGetVersion api_cae_get_version; static Proc_CAEGetChannel api_cae_get_channel; static Proc_CAESetShowLog api_cae_set_show_log; static Proc_CAEDestroy api_cae_destroy; +#endif static off64_t fdcount = 0; static snd_output_t *sndlog; @@ -117,7 +121,7 @@ static void *QueueReadThread(void *param) { if (record->buff_size != readLen) { // printf("\nqueue_read readLen %d\n", readLen); } - //printf("\nqueue_read readLen %d\n", readLen); + printf("\nqueue_read readLen %d\n", readLen); if (record->cb) record->cb(data_buff, readLen, NETEASE_SUCCESS); @@ -511,17 +515,24 @@ static void *RecordThread(void *param) { break; case WorkMode_R311_PV1_CES: + // printf("Begin to read\n"); ret = pcm_read(record); + // printf("Read: %d\n", ret); + if (ret == record->chunk_size) { int len = 0; char *newbuf = (char *)malloc(record->chunk_bytes + 60); - if (newbuf != NULL) { CheckData(record->buffer, record->chunk_bytes, (void *)newbuf, &len); if (record->backupfilefd > 0) { +#if 0 xwrite(record->backupfilefd, newbuf, len); fdcount += len; +#else + xwrite(record->backupfilefd, record->buffer, record->chunk_bytes); + fdcount += record->chunk_bytes; +#endif } queue_write(record->queue, newbuf, len); free(newbuf);