add key platform config && voice init script

This commit is contained in:
wangzijiao 2018-09-14 15:30:22 +08:00
parent d27d8a5821
commit 84da3dc26a
4 changed files with 30 additions and 33 deletions

View File

@ -47,7 +47,7 @@ start_voice() {
echo $DBUS_SESSION_BUS_ADDRESS >> $LOG echo $DBUS_SESSION_BUS_ADDRESS >> $LOG
procd_open_instance procd_open_instance
procd_set_param oom_adj $OOM_ADJ 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_set_param respawn
procd_append_param limits core=unlimited procd_append_param limits core=unlimited
procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS --work-mode=0 procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS --work-mode=0

View File

@ -2,12 +2,13 @@ package globals
type PlatformConfig struct { type PlatformConfig struct {
MicAdc bool MicAdc bool
InputKeyPath string
} }
var ( var (
platformConfigs = map[string]PlatformConfig{ platformConfigs = map[string]PlatformConfig{
"default": PlatformConfig{MicAdc:false}, "default": PlatformConfig{MicAdc:false, InputKeyPath:"/dev/input/event2"},
"EVT":PlatformConfig{MicAdc:true}, "EVT":PlatformConfig{MicAdc:true, InputKeyPath:"/dev/input/event2"},
"r311-pv1":PlatformConfig{MicAdc:false}, "r311-pv1":PlatformConfig{MicAdc:false, InputKeyPath:"/dev/input/event1"},
} }
curPlatformConfig *PlatformConfig curPlatformConfig *PlatformConfig
) )

View File

@ -265,7 +265,7 @@ func TriggerKey(keycode int, isPress bool) {
} }
func KeyApp() error { func KeyApp() error {
dev, err := evdev.Open(devpath) dev, err := evdev.Open(globals.GetCurPlatformConfig().InputKeyPath)
if err != nil { if err != nil {
return err return err
} }

View File

@ -84,20 +84,19 @@ struct pcm_config recordconfig = {0};
struct audio_bypass *audiobypassconfig = NULL; struct audio_bypass *audiobypassconfig = NULL;
static char been_wakedup = 0; static char been_wakedup = 0;
static long parse_long(const char *str, int *err) static long parse_long(const char *str, int *err) {
{ long val;
long val; char *endptr;
char *endptr;
errno = 0; errno = 0;
val = strtol(str, &endptr, 0); val = strtol(str, &endptr, 0);
if (errno != 0 || *endptr != '\0') if (errno != 0 || *endptr != '\0')
*err = -1; *err = -1;
else else
*err = 0; *err = 0;
return val; return val;
} }
static void debug_waste_time(char *where, unsigned long long *tm) { 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, sprintf(tmp, "{\"angle\":%d,\"score\":%d,\"beam\":%d,\"power\":%f}", 1,
1, 1, 1.2); 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, Netease_Dbus_Send_CMD(MODULE_VOICEENGINE, MODULE_CONTROLLER,
CMD_MSC_MSG_CONTROLLER_WAKEUP, tmp, strlen(tmp)); CMD_MSC_MSG_CONTROLLER_WAKEUP, tmp, strlen(tmp));
} }
static char* g_pQuickWkKey[] = static char *g_pQuickWkKey[] = {
{ "xia yi shou",
"xia yi shou", "da sheng yi dian",
"da sheng yi dian", "xiao sheng yi dian",
"xiao sheng yi dian",
}; };
int Duilite_doa_cb(void *userdata, int type, char *msg, int len) { int Duilite_doa_cb(void *userdata, int type, char *msg, int len) {
json_t *tmp; json_t *tmp;
json_t *js; json_t *js;
@ -546,13 +544,10 @@ static void usage() {
"--rawfile=# record raw data to filepath\n" "--rawfile=# record raw data to filepath\n"
"--finalfile=# record duilite output to filepath\n"); "--finalfile=# record duilite output to filepath\n");
} }
enum { enum { OPT_RAW_FILE = 1, OPT_FINAL_FILE };
OPT_RAW_FILE = 1,
OPT_FINAL_FILE
};
void main(int argc, char **argv) { 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 *rawfile = "/dev/null";
char *finalfile = "/dev/null"; char *finalfile = "/dev/null";
static const char short_options[] = "hlt:w:Lfr"; 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, while ((c = getopt_long(argc, argv, short_options, long_options,
&option_index)) != -1) { &option_index)) != -1) {
switch (c) { switch (c) {
case 'h': case 'h':
usage(); usage();
@ -633,10 +628,6 @@ void main(int argc, char **argv) {
} }
} }
printf("parse arg end!\n"); printf("parse arg end!\n");
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGABRT, signal_handler);
// Base module init // Base module init
BaseInit(); BaseInit();
@ -660,6 +651,11 @@ void main(int argc, char **argv) {
recordconfig.audio_cb = NULL; recordconfig.audio_cb = NULL;
Neteasae_record_start(&recordconfig); Neteasae_record_start(&recordconfig);
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGABRT, signal_handler);
while (1) while (1)
usleep(1000000); usleep(1000000);
} }