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"
"time"
"github.com/kidoman/embd"
embd "netease_control_center/nembd"
)
type Key int

View File

@ -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))
}

View File

@ -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,11 +24,9 @@ choice
config XUNFEI_CAE_SDK
bool "Used xunfei CAE SDK"
endchoice
config NETEASE_DUILITE_SDK
bool "Used duilite CAE SDK"
default y
endchoice
choice
prompt "Selected TTS SDK"

View File

@ -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)" \

View File

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

View File

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

View File

@ -35,15 +35,22 @@ extern "C" {
//#define ENABLE_YUNXIN
#if USED_NETEASE_FMAE
#include <fmae/fmae.h>
#else
#ifdef ENABLE_MODULE_XUNFEICAE
#include "cae.h"
#include "cae_lib.h"
#include "cae_thread.h"
#include <cae/cae_errors.h>
#include <cae/cae_intf.h>
#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

View File

@ -41,10 +41,13 @@ when who why
#if USED_NETEASE_DUILITE
// speech voice cb
#include "nduilite.h"
#include <cae/cae_errors.h>
#include <duilite.h>
#endif
#if ENABLE_MODULE_XUNFEICAE
#include <cae/cae_errors.h>
#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,10 +400,12 @@ 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
#if ENABLE_MODULE_XUNFEICAE
if (NULL != caeconfig)
Netease_CAESetRealBeam(caeconfig, 0);
#endif
}

View File

@ -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;

View File

@ -33,7 +33,6 @@ when who why
#include "msc.h"
#include "nduilite.h"
#include <cae/cae_errors.h>
#include <duilite.h>
/* ------------------------------------------------------------------------
@ -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

View File

@ -33,7 +33,9 @@ when who why
#include "record.h"
#include "error.h"
#if ENABLE_MODULE_XUNFEICAE
#include <cae/cae_intf.h>
#endif
#include <pthread.h>
#include <sched.h>
#include <stdint.h>
@ -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);