add enable_xunfei_case config to netease voice && fix cc compile error for new tina code

This commit is contained in:
wangzijiao 2018-12-25 19:33:29 +08:00
parent 5974f3a363
commit d7b4254835
13 changed files with 63 additions and 26 deletions

View File

@ -6,7 +6,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/kidoman/embd" embd "netease_control_center/nembd"
) )
type Key int type Key int

View File

@ -1,9 +1,9 @@
// Package servo allows control of servos using a PWM controller. // Package servo allows control of servos using a PWM controller.
package servo package servo
import "netease_control_center/nembd/util"
import ( import (
"github.com/golang/glog"
"github.com/kidoman/embd/util"
"netease_control_center/interfaces/log" "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)) 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) log.Printf(log.DebugLog, "servo: given angle %v calculated %v us\n", angle, us)
return s.PWM.SetMicroseconds(int(us)) return s.PWM.SetMicroseconds(int(us))
} }

View File

@ -16,7 +16,7 @@ endchoice
choice choice
prompt "Selected CAE SDK" prompt "Selected CAE SDK"
default XUNFEI_CAE_SDK default NETEASE_DUILITE_SDK
config NETEASE_CAE_SDK config NETEASE_CAE_SDK
bool "Used netease CAE SDK" bool "Used netease CAE SDK"
@ -24,12 +24,10 @@ choice
config XUNFEI_CAE_SDK config XUNFEI_CAE_SDK
bool "Used xunfei CAE SDK" bool "Used xunfei CAE SDK"
config NETEASE_DUILITE_SDK
bool "Used duilite CAE SDK"
endchoice endchoice
config NETEASE_DUILITE_SDK
bool "Used duilite CAE SDK"
default y
choice choice
prompt "Selected TTS SDK" prompt "Selected TTS SDK"
default XUNFEI_TTS_SDK default XUNFEI_TTS_SDK

View File

@ -31,6 +31,7 @@ define Package/$(PKG_NAME)
ifeq ('$(CONFIG_XUNFEI_CAE_SDK)', 'y') ifeq ('$(CONFIG_XUNFEI_CAE_SDK)', 'y')
DEPENDS+= +libcae DEPENDS+= +libcae
TARGET_CFLAGS+= -DENABLE_MODULE_XUNFEICAE=1
endif endif
ifeq ('$(CONFIG_NETEASE_MSC_SDK)', 'y') ifeq ('$(CONFIG_NETEASE_MSC_SDK)', 'y')
@ -43,6 +44,7 @@ define Package/$(PKG_NAME)
ifeq ('$(CONFIG_NETEASE_DUILITE_SDK)', 'y') ifeq ('$(CONFIG_NETEASE_DUILITE_SDK)', 'y')
DEPENDS+= +libduilite DEPENDS+= +libduilite
TARGET_CFLAGS+= -DENABLE_MODULE_DUILITE=1
endif endif
ifeq ('$(CONFIG_USED_DC_SDK)', 'y') ifeq ('$(CONFIG_USED_DC_SDK)', 'y')
@ -93,6 +95,7 @@ define Build/Configure
endef endef
define Build/Compile define Build/Compile
$(info TARGET_CFLAGS=$(TARGET_CFLAGS))
$(MAKE) -C $(PKG_BUILD_DIR)/src \ $(MAKE) -C $(PKG_BUILD_DIR)/src \
ARCH="$(TARGET_ARCH)" \ ARCH="$(TARGET_ARCH)" \
AR="$(TARGET_AR)" \ AR="$(TARGET_AR)" \

View File

@ -20,6 +20,8 @@ when who why
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
** Includes ** Includes
** ------------------------------------------------------------------------ */ ** ------------------------------------------------------------------------ */
#ifdef ENABLE_MODULE_XUNFEICAE
#include "cae_lib.h" #include "cae_lib.h"
#include "error.h" #include "error.h"
#include <assert.h> #include <assert.h>
@ -216,3 +218,5 @@ int Netease_CAESetShowLog(int show_log) {
CAESetShowLog(show_log); CAESetShowLog(show_log);
#endif #endif
} }
#endif

View File

@ -112,6 +112,7 @@ int queue_full(audio_queue_t *queue) {
int queue_write(audio_queue_t *queue, char data[], int dataLen) { int queue_write(audio_queue_t *queue, char data[], int dataLen) {
if (queue == NULL || data == NULL || dataLen <= 0) { if (queue == NULL || data == NULL || dataLen <= 0) {
printf("Input is null, return! datalen:%d\n", dataLen);
return false; return false;
} }
pthread_mutex_lock(&(queue->mutex)); 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; queue->rear = (queue->rear + dataLen) % queue->capacity;
pthread_mutex_unlock(&(queue->mutex)); pthread_mutex_unlock(&(queue->mutex));
native_event_set(queue->sync_event); native_event_set(queue->sync_event);
// printf("queue_write end \n"); //printf("queue_write end queue:0x%p\n", queue);
return true; return true;
} }
@ -153,7 +154,7 @@ int queue_read(audio_queue_t *queue, char **data) {
if (queue == NULL || data == NULL) { if (queue == NULL || data == NULL) {
return 0; 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); native_event_wait(queue->sync_event, 0x7fffffff);
pthread_mutex_lock(&(queue->mutex)); pthread_mutex_lock(&(queue->mutex));
queueBase = (char *)(queue + 1); queueBase = (char *)(queue + 1);
@ -163,7 +164,7 @@ int queue_read(audio_queue_t *queue, char **data) {
temp_buff = (char *)malloc(queueLen); temp_buff = (char *)malloc(queueLen);
if (NULL == temp_buff) { 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)); pthread_mutex_unlock(&(queue->mutex));
return 0; return 0;
} }

View File

@ -19,8 +19,9 @@ when who why
#ifndef __CAE_H__ #ifndef __CAE_H__
#define __CAE_H__ #define __CAE_H__
#if ENABLE_MODULE_XUNFEICAE
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* C++ */ #endif /* C++ */
@ -46,4 +47,5 @@ int Netease_CAESetShowLog(int show_log);
} /* extern "C" */ } /* extern "C" */
#endif /* C++ */ #endif /* C++ */
#endif /* ENABLE_MODULE_XUNFEICAE */
#endif /* __CAE_H__ */ #endif /* __CAE_H__ */

View File

@ -35,15 +35,22 @@ extern "C" {
//#define ENABLE_YUNXIN //#define ENABLE_YUNXIN
#if USED_NETEASE_FMAE #if USED_NETEASE_FMAE
#include <fmae/fmae.h> #include <fmae/fmae.h>
#else #else
#ifdef ENABLE_MODULE_XUNFEICAE
#include "cae.h" #include "cae.h"
#include "cae_lib.h"
#include "cae_thread.h"
#include <cae/cae_errors.h> #include <cae/cae_errors.h>
#include <cae/cae_intf.h> #include <cae/cae_intf.h>
#endif #endif
#endif
#include "cae_lib.h"
#include "cae_thread.h"
struct IAT_HD; struct IAT_HD;
typedef enum { typedef enum {
@ -90,8 +97,12 @@ struct IAT_HD {
void Netease_IAT_DeInit(); void Netease_IAT_DeInit();
int Netease_IAT_Init(); int Netease_IAT_Init();
void Netease_IAT_write(const void *audiobuf, int audiolen); void Netease_IAT_write(const void *audiobuf, int audiolen);
#if ENABLE_MODULE_XUNFEICAE
int Netease_MSP_Init(CAEDATA **cdata); int Netease_MSP_Init(CAEDATA **cdata);
int Netease_MSP_Deinit(); int Netease_MSP_Deinit();
#endif
void Netease_IAT_checkflag(int angle); void Netease_IAT_checkflag(int angle);
// 1: fail, 0: success // 1: fail, 0: success

View File

@ -41,10 +41,13 @@ when who why
#if USED_NETEASE_DUILITE #if USED_NETEASE_DUILITE
// speech voice cb // speech voice cb
#include "nduilite.h" #include "nduilite.h"
#include <cae/cae_errors.h>
#include <duilite.h> #include <duilite.h>
#endif #endif
#if ENABLE_MODULE_XUNFEICAE
#include <cae/cae_errors.h>
#endif
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
** Macros ** Macros
** ------------------------------------------------------------------------ */ ** ------------------------------------------------------------------------ */
@ -76,7 +79,7 @@ typedef struct _FMAEUserData {
} FMAEUserData; } FMAEUserData;
FMAE_HANDLE g_hFMAE; FMAE_HANDLE g_hFMAE;
const char *g_fmaeCfgPath = "/usr/share/fmae_res/config.ini"; const char *g_fmaeCfgPath = "/usr/share/fmae_res/config.ini";
#else #elif ENABLE_MODULE_XUNFEICAE
CAEDATA *caeconfig = NULL; CAEDATA *caeconfig = NULL;
#endif #endif
@ -316,6 +319,7 @@ static void record_audio_cb(const void *audio, unsigned int audio_len,
if (caeconfig != NULL && caeconfig->cae != NULL) { if (caeconfig != NULL && caeconfig->cae != NULL) {
// n_debug("write audio to cae !\n"); // n_debug("write audio to cae !\n");
#endif #endif
#if USED_NETEASE_DC #if USED_NETEASE_DC
// unsigned char* pBuf = (unsigned char*)audio; // unsigned char* pBuf = (unsigned char*)audio;
#if 1 #if 1
@ -350,11 +354,11 @@ static void record_audio_cb(const void *audio, unsigned int audio_len,
debug_waste_time("__cacheCAEAudio", &cachetime); debug_waste_time("__cacheCAEAudio", &cachetime);
#endif #endif
#if USED_NETEASE_FMAE #if USED_NETEASE_FMAE && ENABLE_MODULE_XUNFEICAE
ret = FMAEAudioWrite(g_hFMAE, audio, audio_len); ret = FMAEAudioWrite(g_hFMAE, audio, audio_len);
// printf("write %d at %p ret = %d\n", audio_len, audio, ret); // 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); Netease_CAEAudioWrite(caeconfig, audio, audio_len);
#endif #endif
// n_debug("write finish!\n"); // 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: case CMD_CC_MSC_BEGIN_SESSION:
n_toast("Recv cc create session command! msg:%s\n", pMsg->pMsg); 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 // todo do not waked up, do wake here
n_toast("has not waked up!todo waked up!"); 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 #endif
} }
js = json_loadb(pMsg->pMsg, pMsg->msgSize, 0, NULL); js = json_loadb(pMsg->pMsg, pMsg->msgSize, 0, NULL);

View File

@ -75,7 +75,10 @@ when who why
* Global Variable Definitions * Global Variable Definitions
* *
* ------------------------------------------------------------------------ */ * ------------------------------------------------------------------------ */
#if ENABLE_MODULE_XUNFEICAE
CAEDATA **cae; CAEDATA **cae;
#endif
struct IAT_HD *iathd; struct IAT_HD *iathd;
static char isBeginSession = 0; static char isBeginSession = 0;
static int audiostate = MSP_AUDIO_SAMPLE_CONTINUE; static int audiostate = MSP_AUDIO_SAMPLE_CONTINUE;

View File

@ -33,7 +33,6 @@ when who why
#include "msc.h" #include "msc.h"
#include "nduilite.h" #include "nduilite.h"
#include <cae/cae_errors.h>
#include <duilite.h> #include <duilite.h>
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
@ -395,7 +394,7 @@ void Netease_nduilite_writeaudio(const void *audioData,
return; 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); ret = duilite_fespa_feed(fespa, audioData, audio_len);
#if 0 #if 0

View File

@ -33,7 +33,9 @@ when who why
#include "record.h" #include "record.h"
#include "error.h" #include "error.h"
#if ENABLE_MODULE_XUNFEICAE
#include <cae/cae_intf.h> #include <cae/cae_intf.h>
#endif
#include <pthread.h> #include <pthread.h>
#include <sched.h> #include <sched.h>
#include <stdint.h> #include <stdint.h>
@ -56,6 +58,7 @@ when who why
** ------------------------------------------------------------------------ */ ** ------------------------------------------------------------------------ */
static char *out_pcm_name; static char *out_pcm_name;
#if ENABLE_MODULE_XUNFEICAE
static Proc_CAENew api_cae_new; static Proc_CAENew api_cae_new;
static Proc_CAEAudioWrite api_cae_audio_write; static Proc_CAEAudioWrite api_cae_audio_write;
static Proc_CAEResetEng api_cae_reset_eng; 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_CAEGetChannel api_cae_get_channel;
static Proc_CAESetShowLog api_cae_set_show_log; static Proc_CAESetShowLog api_cae_set_show_log;
static Proc_CAEDestroy api_cae_destroy; static Proc_CAEDestroy api_cae_destroy;
#endif
static off64_t fdcount = 0; static off64_t fdcount = 0;
static snd_output_t *sndlog; static snd_output_t *sndlog;
@ -117,7 +121,7 @@ static void *QueueReadThread(void *param) {
if (record->buff_size != readLen) { 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); printf("\nqueue_read readLen %d\n", readLen);
if (record->cb) if (record->cb)
record->cb(data_buff, readLen, NETEASE_SUCCESS); record->cb(data_buff, readLen, NETEASE_SUCCESS);
@ -511,17 +515,24 @@ static void *RecordThread(void *param) {
break; break;
case WorkMode_R311_PV1_CES: case WorkMode_R311_PV1_CES:
// printf("Begin to read\n");
ret = pcm_read(record); ret = pcm_read(record);
// printf("Read: %d\n", ret);
if (ret == record->chunk_size) { if (ret == record->chunk_size) {
int len = 0; int len = 0;
char *newbuf = (char *)malloc(record->chunk_bytes + 60); char *newbuf = (char *)malloc(record->chunk_bytes + 60);
if (newbuf != NULL) { if (newbuf != NULL) {
CheckData(record->buffer, record->chunk_bytes, CheckData(record->buffer, record->chunk_bytes,
(void *)newbuf, &len); (void *)newbuf, &len);
if (record->backupfilefd > 0) { if (record->backupfilefd > 0) {
#if 0
xwrite(record->backupfilefd, newbuf, len); xwrite(record->backupfilefd, newbuf, len);
fdcount += len; fdcount += len;
#else
xwrite(record->backupfilefd, record->buffer, record->chunk_bytes);
fdcount += record->chunk_bytes;
#endif
} }
queue_write(record->queue, newbuf, len); queue_write(record->queue, newbuf, len);
free(newbuf); free(newbuf);