From 84da3dc26ad038cc7328f735c707309e0b983222 Mon Sep 17 00:00:00 2001 From: wangzijiao Date: Fri, 14 Sep 2018 15:30:22 +0800 Subject: [PATCH] add key platform config && voice init script --- app/InitScript/r311-pv1/neteasevoice.init | 2 +- .../globals/platformConfig.go | 7 +-- .../modules/controller/keyInputEvent.go | 2 +- app/netease_voice_common_module/src/main.c | 52 +++++++++---------- 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/app/InitScript/r311-pv1/neteasevoice.init b/app/InitScript/r311-pv1/neteasevoice.init index 7b9a0e5..e1f8479 100644 --- a/app/InitScript/r311-pv1/neteasevoice.init +++ b/app/InitScript/r311-pv1/neteasevoice.init @@ -47,7 +47,7 @@ start_voice() { echo $DBUS_SESSION_BUS_ADDRESS >> $LOG procd_open_instance procd_set_param oom_adj $OOM_ADJ - procd_set_param command $PROG_VOICE -D >> /tmp/voicelog 2>&1 + procd_set_param command $PROG_VOICE --work-mode=0 procd_set_param respawn procd_append_param limits core=unlimited procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS --work-mode=0 diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/platformConfig.go b/app/netease_control_center_common_module/src/netease_control_center/globals/platformConfig.go index b9a764a..3890420 100644 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/platformConfig.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/platformConfig.go @@ -2,12 +2,13 @@ package globals type PlatformConfig struct { MicAdc bool + InputKeyPath string } var ( platformConfigs = map[string]PlatformConfig{ - "default": PlatformConfig{MicAdc:false}, - "EVT":PlatformConfig{MicAdc:true}, - "r311-pv1":PlatformConfig{MicAdc:false}, + "default": PlatformConfig{MicAdc:false, InputKeyPath:"/dev/input/event2"}, + "EVT":PlatformConfig{MicAdc:true, InputKeyPath:"/dev/input/event2"}, + "r311-pv1":PlatformConfig{MicAdc:false, InputKeyPath:"/dev/input/event1"}, } curPlatformConfig *PlatformConfig ) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/keyInputEvent.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/keyInputEvent.go index 9a36e01..95e9d3a 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/keyInputEvent.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/keyInputEvent.go @@ -265,7 +265,7 @@ func TriggerKey(keycode int, isPress bool) { } func KeyApp() error { - dev, err := evdev.Open(devpath) + dev, err := evdev.Open(globals.GetCurPlatformConfig().InputKeyPath) if err != nil { return err } diff --git a/app/netease_voice_common_module/src/main.c b/app/netease_voice_common_module/src/main.c index 857d404..f45e7b1 100644 --- a/app/netease_voice_common_module/src/main.c +++ b/app/netease_voice_common_module/src/main.c @@ -84,20 +84,19 @@ struct pcm_config recordconfig = {0}; struct audio_bypass *audiobypassconfig = NULL; static char been_wakedup = 0; -static long parse_long(const char *str, int *err) -{ - long val; - char *endptr; +static long parse_long(const char *str, int *err) { + long val; + char *endptr; - errno = 0; - val = strtol(str, &endptr, 0); + errno = 0; + val = strtol(str, &endptr, 0); - if (errno != 0 || *endptr != '\0') - *err = -1; - else - *err = 0; + if (errno != 0 || *endptr != '\0') + *err = -1; + else + *err = 0; - return val; + return val; } static void debug_waste_time(char *where, unsigned long long *tm) { @@ -213,18 +212,17 @@ int Duilite_wakeup_cb(void *userdata, int type, char *msg, int len) { sprintf(tmp, "{\"angle\":%d,\"score\":%d,\"beam\":%d,\"power\":%f}", 1, 1, 1, 1.2); } - n_toast("Send to cc:%s\n", tmp); + n_toast("Send to cc:%s\n", tmp); Netease_Dbus_Send_CMD(MODULE_VOICEENGINE, MODULE_CONTROLLER, CMD_MSC_MSG_CONTROLLER_WAKEUP, tmp, strlen(tmp)); } -static char* g_pQuickWkKey[] = -{ - "xia yi shou", - "da sheng yi dian", - "xiao sheng yi dian", +static char *g_pQuickWkKey[] = { + "xia yi shou", + "da sheng yi dian", + "xiao sheng yi dian", }; - + int Duilite_doa_cb(void *userdata, int type, char *msg, int len) { json_t *tmp; json_t *js; @@ -546,13 +544,10 @@ static void usage() { "--rawfile=# record raw data to filepath\n" "--finalfile=# record duilite output to filepath\n"); } -enum { - OPT_RAW_FILE = 1, - OPT_FINAL_FILE -}; +enum { OPT_RAW_FILE = 1, OPT_FINAL_FILE }; void main(int argc, char **argv) { - int ret, c, option_index, err,tmp; + int ret, c, option_index, err, tmp; char *rawfile = "/dev/null"; char *finalfile = "/dev/null"; static const char short_options[] = "hlt:w:Lfr"; @@ -579,7 +574,7 @@ void main(int argc, char **argv) { } while ((c = getopt_long(argc, argv, short_options, long_options, - &option_index)) != -1) { + &option_index)) != -1) { switch (c) { case 'h': usage(); @@ -633,10 +628,6 @@ void main(int argc, char **argv) { } } printf("parse arg end!\n"); - - signal(SIGINT, signal_handler); - signal(SIGTERM, signal_handler); - signal(SIGABRT, signal_handler); // Base module init BaseInit(); @@ -660,6 +651,11 @@ void main(int argc, char **argv) { recordconfig.audio_cb = NULL; Neteasae_record_start(&recordconfig); + + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + signal(SIGABRT, signal_handler); + while (1) usleep(1000000); }