From 765523be4e352b63d58e07b964a6c4bac42f2512 Mon Sep 17 00:00:00 2001 From: wangzijiao Date: Fri, 30 Nov 2018 17:45:43 +0800 Subject: [PATCH] update cc && voice to adapter for pv1 ces board --- .gitignore | 27 +++ Makefile.common.submodule | 4 +- app/InitScript/r311-pv1c/netease.init | 164 +++++++++++++++ app/InitScript/r311-pv1c/neteasebt.init | 58 ++++++ app/InitScript/r311-pv1c/neteasecc.init | 61 ++++++ app/InitScript/r311-pv1c/neteasedbus.init | 18 ++ .../r311-pv1c/neteasemanufacture_cc.init | 89 ++++++++ .../r311-pv1c/neteasemanufacture_mcu.init | 89 ++++++++ .../r311-pv1c/neteasemanufacture_rf.init | 89 ++++++++ app/InitScript/r311-pv1c/neteaseplayer.init | 151 ++++++++++++++ app/InitScript/r311-pv1c/neteasevoice.init | 65 ++++++ app/InitScript/r311-pv1c/neteasewifi.init | 58 ++++++ .../globals/baseDefines.go | 1 + .../globals/platformConfig.go | 16 +- .../interfaces/vui/icon.go | 5 +- .../src/netease_control_center/main.go | 8 + .../modules/controller/init.go | 4 +- .../modules/controller/keyInputEvent.go | 35 +++- .../modules/hardware/led_mcu/ledsControl.go | 3 + .../src/include/base.h | 3 +- app/netease_voice_common_module/src/main.c | 15 +- app/netease_voice_common_module/src/record.c | 195 ++++++++++++++++-- 22 files changed, 1119 insertions(+), 39 deletions(-) create mode 100644 .gitignore create mode 100755 app/InitScript/r311-pv1c/netease.init create mode 100755 app/InitScript/r311-pv1c/neteasebt.init create mode 100644 app/InitScript/r311-pv1c/neteasecc.init create mode 100644 app/InitScript/r311-pv1c/neteasedbus.init create mode 100644 app/InitScript/r311-pv1c/neteasemanufacture_cc.init create mode 100644 app/InitScript/r311-pv1c/neteasemanufacture_mcu.init create mode 100755 app/InitScript/r311-pv1c/neteasemanufacture_rf.init create mode 100644 app/InitScript/r311-pv1c/neteaseplayer.init create mode 100644 app/InitScript/r311-pv1c/neteasevoice.init create mode 100755 app/InitScript/r311-pv1c/neteasewifi.init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59a22ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +/include +out +.config +tmp +build +!/build +.config.old +build/libuv-v1.11.0/ +.orig +/logs +*.orig +.vscode +.idea +cmake-build-debug +build/portaudio-190600_20161030/ +build/portaudio/ +build/sqlite-autoconf-3190200/ +build/sqlite-autoconf-3190300/ +build/ca-certificates +lichee/linux-4.9/user_headers/ +.DS_Store +._.DS_Store +prebuilt/r311/mcu_ota +prebuilt/r311/fw_bcm43436b0.bin +prebuilt/r311/wl +*.code-workspace +*.si4project diff --git a/Makefile.common.submodule b/Makefile.common.submodule index 3f234de..9931e8c 100644 --- a/Makefile.common.submodule +++ b/Makefile.common.submodule @@ -19,8 +19,8 @@ ifeq ('$(CONFIG_BOARD_HARDWARE_VERSION_R311_PV1)', 'y') endif ifeq ('$(CONFIG_BOARD_HARDWARE_VERSION_R311_PV1_CES)', 'y') - HARDWARE_VERSION=r311-pv1-ces - HARDWARE_ALIAS=r311-pv1-ces + HARDWARE_VERSION=r311-pv1c + HARDWARE_ALIAS=r311-pv1c endif ifeq ('$(CONFIG_BOARD_HARDWARE_VERSION_R311_PV2)', 'y') diff --git a/app/InitScript/r311-pv1c/netease.init b/app/InitScript/r311-pv1c/netease.init new file mode 100755 index 0000000..f8c83c2 --- /dev/null +++ b/app/InitScript/r311-pv1c/netease.init @@ -0,0 +1,164 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=120 +STOP=120 +USE_PROCD=1 +DEPEND=netease_wifi_service,netease_voice_service,boot,netease_player_service + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_LE_APP=/usr/bin/app_nevsps_bt +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer +PROG_KPLAYER=/usr/bin/KPlayer +PROG_SPLAYER=/usr/bin/SPlayer + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "wzj: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +start_voice() { + echo "start voice" >> $LOG + 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 respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS + procd_close_instance +} + +start_cc() { + echo "start cc" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_CC + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS + procd_close_instance + +} + +start_player() { + echo "start player" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_PLAYER -D + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_wifi() { + echo "start wifi" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_WIFI_APP -D >> /tmp/wifilog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_ble() { + echo "start ble" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_LE_APP -D >> /tmp/blelog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_ota() { + echo "start ota" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_OTA -D >> /tmp/otalog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_alarmer() { + echo "start ota" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_ALARMER -D >> /tmp/otalog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_dlna() { + echo "start dlna" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_KPLAYER -D >> /tmp/dlnalog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_airplay() { + echo "start airplay" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_SPLAYER -D >> /tmp/airplaylog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_all() { + echo "start all" >> $LOG + $PROG_CC > /dev/null 2>&1 & + $PROG_PLAYER -D > /dev/null 2>&1 & + $PROG_VOICE -D > /dev/null 2>&1 & +} + +start_service() { +#/etc/bluetooth/btenable.sh on + init_dbus + start_dlna + start_airplay + #start_ble + start_ota + start_alarmer +} diff --git a/app/InitScript/r311-pv1c/neteasebt.init b/app/InitScript/r311-pv1c/neteasebt.init new file mode 100755 index 0000000..de6c923 --- /dev/null +++ b/app/InitScript/r311-pv1c/neteasebt.init @@ -0,0 +1,58 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=110 +STOP=110 +USE_PROCD=1 +DEPEND=boot + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_BT_APP=/usr/bin/app_nevsps_bt +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "bt_service: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +start_bt() { + echo "start bt" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_BT_APP -D >> /tmp/btlog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_service() { + init_dbus + start_bt +} diff --git a/app/InitScript/r311-pv1c/neteasecc.init b/app/InitScript/r311-pv1c/neteasecc.init new file mode 100644 index 0000000..077b920 --- /dev/null +++ b/app/InitScript/r311-pv1c/neteasecc.init @@ -0,0 +1,61 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=121 +STOP=121 +USE_PROCD=1 +DEPEND=netease_wifi_service,netease_voice_service,boot,netease_player_service,netease_service + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_LE_APP=/usr/bin/app_nevsps_bt +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer +PROG_KPLAYER=/usr/bin/KPlayer +PROG_SPLAYER=/usr/bin/SPlayer + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "wzj: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +start_cc() { + echo "start cc" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_CC + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_service() { + init_dbus + start_cc +} diff --git a/app/InitScript/r311-pv1c/neteasedbus.init b/app/InitScript/r311-pv1c/neteasedbus.init new file mode 100644 index 0000000..3269fb7 --- /dev/null +++ b/app/InitScript/r311-pv1c/neteasedbus.init @@ -0,0 +1,18 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=60 +STOP=60 +USE_PROCD=1 + +LOG=/tmp/netease.init.log +DBUS_SESSION_FILE=/tmp/dbus-session.env + +create_dbus_env() { + dbus-daemon --session --print-address >> $DBUS_SESSION_FILE & + sync +} + +start_service() { + create_dbus_env +} diff --git a/app/InitScript/r311-pv1c/neteasemanufacture_cc.init b/app/InitScript/r311-pv1c/neteasemanufacture_cc.init new file mode 100644 index 0000000..aa17ee7 --- /dev/null +++ b/app/InitScript/r311-pv1c/neteasemanufacture_cc.init @@ -0,0 +1,89 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +STOP=121 +USE_PROCD=1 + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_LE_APP=/usr/bin/app_nevsps_bt +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer +PROG_KPLAYER=/usr/bin/KPlayer +PROG_SPLAYER=/usr/bin/SPlayer + +PROG_WIRELESS_TEST=/usr/bin/wirelessTest +PROG_MCU_OTA=/usr/bin/mcu_ota + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "wzj: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +start_cc() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_CC + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} + +start_wirelessTest() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_WIRELESS_TEST + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} +start_mcu_ota() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_MCU_OTA + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} + +start_service() { + init_dbus + + start_cc +} diff --git a/app/InitScript/r311-pv1c/neteasemanufacture_mcu.init b/app/InitScript/r311-pv1c/neteasemanufacture_mcu.init new file mode 100644 index 0000000..9faaf68 --- /dev/null +++ b/app/InitScript/r311-pv1c/neteasemanufacture_mcu.init @@ -0,0 +1,89 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +STOP=121 +USE_PROCD=1 + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_LE_APP=/usr/bin/app_nevsps_bt +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer +PROG_KPLAYER=/usr/bin/KPlayer +PROG_SPLAYER=/usr/bin/SPlayer + +PROG_WIRELESS_TEST=/usr/bin/wirelessTest +PROG_MCU_OTA=/usr/bin/mcu_ota + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "wzj: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +start_cc() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_CC + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} + +start_wirelessTest() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_WIRELESS_TEST + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} +start_mcu_ota() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_MCU_OTA + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} + +start_service() { + init_dbus + + start_mcu_ota +} diff --git a/app/InitScript/r311-pv1c/neteasemanufacture_rf.init b/app/InitScript/r311-pv1c/neteasemanufacture_rf.init new file mode 100755 index 0000000..2604d95 --- /dev/null +++ b/app/InitScript/r311-pv1c/neteasemanufacture_rf.init @@ -0,0 +1,89 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +STOP=121 +USE_PROCD=1 + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_LE_APP=/usr/bin/app_nevsps_bt +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer +PROG_KPLAYER=/usr/bin/KPlayer +PROG_SPLAYER=/usr/bin/SPlayer + +PROG_WIRELESS_TEST=/usr/bin/wirelessTest +PROG_MCU_OTA=/usr/bin/mcu_ota + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "wzj: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +start_cc() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_CC + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} + +start_wirelessTest() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_WIRELESS_TEST + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} +start_mcu_ota() { + echo "start cc manufacture mode" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_MCU_OTA + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS ccmode=manufacture GOROOT=$GOROOT + procd_close_instance + +} + +start_service() { + init_dbus + + start_wirelessTest +} diff --git a/app/InitScript/r311-pv1c/neteaseplayer.init b/app/InitScript/r311-pv1c/neteaseplayer.init new file mode 100644 index 0000000..7b9cddf --- /dev/null +++ b/app/InitScript/r311-pv1c/neteaseplayer.init @@ -0,0 +1,151 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=110 +STOP=110 +USE_PROCD=1 +DEPEND=netease_voice_service,boot + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_LE_APP=/usr/bin/app_nevsps +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer +PROG_KPLAYER=/usr/bin/KPlayer + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "wzj: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +enable_soundcard() { + echo "set r311 audio pass through" + amixer cset numid=20 1 + amixer cset numid=46 1 + amixer cset numid=50 1 + echo 4 > /sys/netease/cpld_control/cpld_init + adau1761 2 0 + adau1761 0 8 +} + +start_voice() { + echo "start voice" >> $LOG + 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 respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS + procd_close_instance +} + +start_cc() { + echo "start cc" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_CC + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS + procd_close_instance + +} + +start_player() { + echo "start player" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_PLAYER -D + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_wifi() { + echo "start wifi" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_WIFI_APP -D >> /tmp/wifilog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_ble() { + echo "start ble" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_LE_APP -D >> /tmp/blelog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_ota() { + echo "start ota" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_OTA -D >> /tmp/otalog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_alarmer() { + echo "start ota" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_ALARMER -D >> /tmp/otalog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_dlna() { + echo "start dlna" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_KPLAYER -D >> /tmp/dlnalog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_service() { + enable_soundcard + init_dbus + start_player +} diff --git a/app/InitScript/r311-pv1c/neteasevoice.init b/app/InitScript/r311-pv1c/neteasevoice.init new file mode 100644 index 0000000..2cd37b2 --- /dev/null +++ b/app/InitScript/r311-pv1c/neteasevoice.init @@ -0,0 +1,65 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=109 +STOP=109 +USE_PROCD=1 +DEPEND=boot + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_LE_APP=/usr/bin/app_nevsps +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer +PROG_KPLAYER=/usr/bin/KPlayer + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "netease_voice: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +start_voice() { + echo "start voice" >> $LOG + echo $DBUS_SESSION_BUS_ADDRESS >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_VOICE --work-mode=1 + 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 + procd_close_instance +} + +start_adc() { + echo 1 > /sys/netease/cpld_control/cpld_init +} + +start_service() { + init_dbus + start_adc + start_voice +} diff --git a/app/InitScript/r311-pv1c/neteasewifi.init b/app/InitScript/r311-pv1c/neteasewifi.init new file mode 100755 index 0000000..ea9f359 --- /dev/null +++ b/app/InitScript/r311-pv1c/neteasewifi.init @@ -0,0 +1,58 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=110 +STOP=110 +USE_PROCD=1 +DEPEND=boot + +PROG_VOICE=/bin/netease_voice +PROG_CC=/usr/sbin/netease_control_center +PROG_PLAYER=/usr/bin/ihwplayer +PROG_LE_APP=/usr/bin/app_nevsps +PROG_WIFI_APP=/bin/app_wifi_manager +PROG_OTA=/usr/bin/ota +PROG_ALARMER=/usr/bin/alarmer + +OOM_ADJ=2 +LOG=/tmp/netease.init.log +GOROOT=/usr/share/golang/ + +init_dbus() { + echo "init dbus" >> $LOG +if [ -x /tmp/dbus_env.sh ] +then + DBUS_DAEMON_ON=`ps | grep "dbus-daemon --fork" | grep -v grep | wc -l` + if [ "$DBUS_DAEMON_ON" == "1" ] + then + source /tmp/dbus_env.sh + else + echo "-----------------" >> /mnt/UDISK/reboot.log + date -R >> /mnt/UDISK/reboot.log + reboot -f + fi +else + export $(dbus-launch) + echo "export DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" > /tmp/dbus_env.sh + echo "export DBUS_SESSION_BUS_PID=\"$DBUS_SESSION_BUS_PID\"" >> /tmp/dbus_env.sh + chmod +x /tmp/dbus_env.sh +fi + +echo "wifi_service: DBUS_SESSION_BUS_ADDRESS=\"$DBUS_SESSION_BUS_ADDRESS\"" >> $LOG +} + +start_wifi() { + echo "start wifi" >> $LOG + procd_open_instance + procd_set_param oom_adj $OOM_ADJ + procd_set_param command $PROG_WIFI_APP -D >> /tmp/wifilog + procd_set_param respawn + procd_append_param limits core=unlimited + procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS GOROOT=$GOROOT + procd_close_instance +} + +start_service() { + init_dbus + start_wifi +} diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/baseDefines.go b/app/netease_control_center_common_module/src/netease_control_center/globals/baseDefines.go index 0fb5433..fd4c480 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/baseDefines.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/baseDefines.go @@ -40,6 +40,7 @@ var ( GitTag *string StartTime time.Time Hv *string + ActualHv *string ) const ( 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 b7ae065..d3d3ec1 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 @@ -3,14 +3,18 @@ package globals import "netease_control_center/interfaces/log" type PlatformConfig struct { + IconSwitch bool + TopLight bool MicAdc bool + LedMcuInit bool InputKeyPath string } var ( platformConfigs = map[string]PlatformConfig{ - "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"}, + "default": PlatformConfig{MicAdc:false, LedMcuInit:true,IconSwitch:true, TopLight:true, InputKeyPath:"/dev/input/event2"}, + "EVT":PlatformConfig{MicAdc:true,LedMcuInit:true,IconSwitch:true, TopLight:true, InputKeyPath:"/dev/input/event2"}, + "r311-pv1":PlatformConfig{MicAdc:false, LedMcuInit:true, IconSwitch:true, TopLight:true, InputKeyPath:"/dev/input/event1"}, + "r311-pv1c":PlatformConfig{MicAdc:true, LedMcuInit:false, IconSwitch:false, TopLight:false, InputKeyPath:"/dev/input/event1"}, } curPlatformConfig *PlatformConfig ) @@ -20,16 +24,16 @@ func GetCurPlatformConfig() PlatformConfig { return *curPlatformConfig } - if Hv == nil { + if ActualHv == nil { log.Println(log.ErrorLog, "Can not get the right platform, hv is nil!") return platformConfigs["default"] } - queryString := *Hv + queryString := *ActualHv if queryString == "DVT" { queryString = "EVT" } - if tmp,ok := platformConfigs[*Hv]; ok { + if tmp,ok := platformConfigs[*ActualHv]; ok { curPlatformConfig = &tmp return tmp } else { diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/icon.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/icon.go index b6fccf3..6c9fd04 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/icon.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/icon.go @@ -3,6 +3,7 @@ package vui import ( "netease_control_center/interfaces/vui/cvui" "time" + "netease_control_center/globals" ) type IconLedDesc struct { @@ -17,7 +18,9 @@ func (this *IconLedDesc) GetPath() string { return cvui.GetSkinRes(this.Name) } func (this IconLedDesc) Show() { - ShowIcon(this) + if globals.GetCurPlatformConfig().IconSwitch == true { + ShowIcon(this) + } } func (this IconLedDesc) Clear() { diff --git a/app/netease_control_center_common_module/src/netease_control_center/main.go b/app/netease_control_center_common_module/src/netease_control_center/main.go index 406686a..b42e2cf 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/main.go +++ b/app/netease_control_center_common_module/src/netease_control_center/main.go @@ -15,6 +15,7 @@ var ( BuildVersion string Tag string Hv string + ActualHv string ) func main() { @@ -29,6 +30,13 @@ func main() { globals.BuildDate = BuildDate globals.GitTag = &Tag globals.Hv = &Hv + ActualHv = Hv + globals.ActualHv = &ActualHv + + if Hv == "r311-pv1c" { + Hv = "EVT" + globals.BuildVersion = "1.1.19" + } log.Println(log.DebugLog, "BuildVersion: ", globals.BuildVersion) log.Println(log.DebugLog, "BuildTime: ", globals.BuildDate) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/init.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/init.go index 7fa778e..25bd7eb 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/init.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/init.go @@ -319,7 +319,9 @@ func StartBoardRoutine() { <-playstopch } - led_mcu.McuResetInitStatus() + if GetCurPlatformConfig().LedMcuInit == true { + led_mcu.McuResetInitStatus() + } if NewBoard == false { StartBackground_wificheck() 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 eec843f..9b6b376 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 @@ -216,9 +216,40 @@ func KeyResponse(keycode int, pressedTimes uint8, longpress bool, insistTime tim } else { switch pressedTimes { case 1: - VboxTagTestSongSimilar() + if globals.CurBootState == globals.BootStage_WIFIPARING || globals.CurBootState == globals.BootStage_BACKUPSYSTEM_WIFIPARING { + schedule.SendSCmd(schedule.SCMD_SuperTask_System_WifiModeChange_AP_BT) + eventPoint.EpRecord("H411", map[string]interface{}{"pressedTimes": pressedTimes, "pressedtime": insistTime.Nanoseconds() / 1e6, "net": true, "status": "ap/ble wifi paring", "longpress": longpress}) + } else { + if schedule.CheckTaskActive(schedule.TaskLevel_SystemService) == false { + log.Println(log.ErrorLog, "come into mic control!!!") + player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Scaozuofankui001.GetPath()) + if globals.IsMicClose == true { + //globals.CurVboxVolSt.MuteMic = false + + SetMicClose(false, globals.WhoCLoseMic_User, true) + time.Sleep(100 * time.Millisecond) + player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Mic_Open.GetPath()) + } else { + //globals.CurVboxVolSt.MuteMic = true + + SetMicClose(true, globals.WhoCLoseMic_User, true) + if GetCurVoiceStatus() != globals.VoiceStatus_IDLE { + VoiceEndSession() + UpdateVoiceStatus(globals.VoiceStatus_IDLE) + } + time.Sleep(100 * time.Millisecond) + player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Mic_Close.GetPath()) + } + eventPoint.EpRecord("H111", map[string]interface{}{"pressedtime": insistTime.Nanoseconds() / 1e6, "status": globals.IsMicClose, "net": false}) + } else { + log.Println(log.DebugLog, "Currently s task run, ignore mic disable command!") + eventPoint.EpRecord("H411", map[string]interface{}{"pressedTimes": pressedTimes, "status": "do nothing", "pressedtime": insistTime.Nanoseconds() / 1e6, "net": (globals.CurBootState == globals.BootStage_WIFIPARING), "longpress": longpress}) + } + } + schedule.SendSCmd(schedule.SCMD_KeyInterrupt) + //VboxTagTestSongSimilar() case 2: - VboxCardTestTag() + //VboxCardTestTag() //CopyLogfiles() //schedule.PlayNoticeAsync(globals.AdSrcType_TTS, "日志已保存", globals.CONST_AUDIO_ID, false, nil, nil) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/led_mcu/ledsControl.go b/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/led_mcu/ledsControl.go index ed5f573..0d298c3 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/led_mcu/ledsControl.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/led_mcu/ledsControl.go @@ -161,6 +161,9 @@ func ShowLastDirectLed() { ShowDirectLed(LastDirectLed) } func DirectLedControl(EffectId GUIDE_EFFECT_ID, Action GUIDE_ACTION, StartLampNum uint8, data []byte) { + if globals.GetCurPlatformConfig().TopLight == false { + return + } if GUIDE_EFFECT_ID_NONE == EffectId { return } diff --git a/app/netease_voice_common_module/src/include/base.h b/app/netease_voice_common_module/src/include/base.h index 7376ac3..6cec44d 100644 --- a/app/netease_voice_common_module/src/include/base.h +++ b/app/netease_voice_common_module/src/include/base.h @@ -59,7 +59,8 @@ typedef enum { } VoiceSessionStatus; typedef enum { - WorkMode_R311_PV1 = 0 + WorkMode_R311_PV1 = 0, + WorkMode_R311_PV1_CES = 1, } WorkMode; void setVss(VoiceSessionStatus st); diff --git a/app/netease_voice_common_module/src/main.c b/app/netease_voice_common_module/src/main.c index f45e7b1..7788357 100644 --- a/app/netease_voice_common_module/src/main.c +++ b/app/netease_voice_common_module/src/main.c @@ -226,6 +226,7 @@ static char *g_pQuickWkKey[] = { int Duilite_doa_cb(void *userdata, int type, char *msg, int len) { json_t *tmp; json_t *js; + n_toast("Doa cb:%s, wakeup by: %s\n", msg, getVoiceWakeupword()); if (NULL == msg || len <= 0) { return 0; @@ -537,7 +538,7 @@ static void usage() { "-l, --list-devices list all soundcards and digital audio " "devices\n" "-L, --list-pcms list device names\n" - "-w, --work-mode=# work mode: 0: r311_pv1\n" + "-w, --work-mode=# work mode: 0: r311_pv1(dmic) 1:r311_pv1_ces(nmic)\n" "-f, --list-format list all format in alsa\n" "-r, --just-record Only record voice to file\n" "-t, --type=# sample format (case insensitive): raw,wav\n" @@ -649,13 +650,15 @@ void main(int argc, char **argv) { printf("Will record final data to file:%s\n", finalfile); } - recordconfig.audio_cb = NULL; + //recordconfig.audio_cb = NULL; Neteasae_record_start(&recordconfig); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); signal(SIGABRT, signal_handler); + Netease_nduilite_init(Duilite_wakeup_cb, Duilite_doa_cb, + Duilite_beforming_cb, Duilite_vad_cb); while (1) usleep(1000000); } @@ -686,14 +689,6 @@ void main(int argc, char **argv) { } #endif -#if 0 - if (access(TEST_SERVER_CFG_FILE, F_OK) == 0) { - g_bIsUsedTestServer = 1; - } else { - g_bIsUsedTestServer = 0; - } -#endif - #if USED_NETEASE_FMAE ret = Netease_audiobypass_init(&audiobypassconfig, NULL, AUDIO_BYPASS_CHANNEL_MSC_IAT); diff --git a/app/netease_voice_common_module/src/record.c b/app/netease_voice_common_module/src/record.c index 6d8ae5d..12fca7f 100644 --- a/app/netease_voice_common_module/src/record.c +++ b/app/netease_voice_common_module/src/record.c @@ -110,15 +110,18 @@ static void *QueueReadThread(void *param) { char *data_buff = NULL; readLen = queue_read(record->queue, &data_buff); if (0 == readLen) { - // printf("queue_read readLen = 0\n"); + printf("queue_read readLen = 0\n"); // usleep(16000); continue; } if (record->buff_size != 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); + free(data_buff); } printf("QueueReadThread end, running:%d \n", record->runing); @@ -185,23 +188,63 @@ static void do_test_position(RecordData *record) { } } +static void prg_exit(int code, RecordData *record) { + n_toast("Do exit!!\n"); + exit(code); +} + +/* I/O error handler */ +static void xrun(RecordData *record) { + snd_pcm_status_t *status; + int res; + + snd_pcm_status_alloca(&status); + if ((res = snd_pcm_status(record->handle, status)) < 0) { + n_toast("status error: %s", snd_strerror(res)); + prg_exit(EXIT_FAILURE, record); + } + if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { + fprintf(stderr, ("Status:\n")); + snd_pcm_status_dump(status, sndlog); + + if ((res = snd_pcm_prepare(record->handle)) < 0) { + n_toast("xrun: prepare error: %s", snd_strerror(res)); + prg_exit(EXIT_FAILURE, record); + } + return; /* ok, data should be accepted again */ + } else if (snd_pcm_status_get_state(status) == SND_PCM_STATE_DRAINING) { + fprintf(stderr, ("Status(DRAINING):\n")); + snd_pcm_status_dump(status, sndlog); + fprintf(stderr, + ("capture stream format change? attempting recover...\n")); + if ((res = snd_pcm_prepare(record->handle)) < 0) { + n_toast("xrun(DRAINING): prepare error: %s", snd_strerror(res)); + prg_exit(EXIT_FAILURE, record); + } + return; + } + fprintf(stderr, ("Status(R/W):\n")); + snd_pcm_status_dump(status, sndlog); + n_toast("read/write error, state = %s", + snd_pcm_state_name(snd_pcm_status_get_state(status))); + prg_exit(EXIT_FAILURE, record); +} + static ssize_t pcm_read(RecordData *record) { ssize_t r; size_t result = 0; size_t rcount = record->chunk_size; size_t count = rcount; char *data = record->buffer; - while (count > 0 && !!record->runing) { r = snd_pcm_readi(record->handle, data, count); if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) { + fprintf(stderr, "read data == EAGAIN\n"); n_debug("read data == EAGAIN\n"); snd_pcm_wait(record->handle, 50); } else if (r == -EPIPE) { /* EPIPE means overrun */ - fprintf(stderr, "overrun occurred/n"); - LOG_EX(LOG_Error, "ALSA Read Data = -EPIPE\n"); - snd_pcm_prepare(record->handle); + xrun(record); continue; } else if (r < 0) { fprintf(stderr, "error from read: %s/n", snd_strerror(r)); @@ -312,6 +355,66 @@ static void begin_wave(RecordData *record, int fd, size_t cnt) { } } +// voice binary data convert by HongChuanRong +static void CheckData(const void *dataIn, int lenIn, void *dataOut, + int *lenOut) { +#define DATA_CHAN_NUM (12) + static short ckDataBuf[DATA_CHAN_NUM]; + static int ckDataPos = 0; + static int chanOneFoundFlag = 0; + if (lenIn % sizeof(int) != 0) { + fprintf(stderr, "fatal error!\n"); + return; + } + const int totalCountsIn = lenIn / sizeof(int); + const int *pDataIn = (const int *)dataIn; + short *pDataOut = (short *)dataOut; + int countsOut = 0; + + if (!chanOneFoundFlag) { + // we have to find chan one first (Peng) + for (auto k = 0; k < totalCountsIn; ++k) { + const int chanId = (pDataIn[k] >> 8) & 0x0f; + if (chanId == 1) { + // chan one found + chanOneFoundFlag = 1; + CheckData(pDataIn + k, (totalCountsIn - k) * sizeof(int), + dataOut, lenOut); + return; + } + } + return; + } + for (auto k = 0; k < totalCountsIn; ++k) { + const int chanId = (pDataIn[k] >> 8) & 0x0f; + + if (chanId == (ckDataPos + 1)) { + ckDataBuf[ckDataPos++] = (short)(pDataIn[k] >> 16); + } else { + fprintf(stderr, "expecting chan: %d, input chan: %d\n", + ckDataPos + 1, chanId); + ckDataPos = 0; + } + + if (ckDataPos == DATA_CHAN_NUM) { + short finalOut[8]; + finalOut[0] = ckDataBuf[8 - 1]; + finalOut[1] = ckDataBuf[2 - 1]; + finalOut[2] = ckDataBuf[7 - 1]; + finalOut[3] = ckDataBuf[1 - 1]; + finalOut[4] = ckDataBuf[9 - 1]; + finalOut[5] = ckDataBuf[3 - 1]; + finalOut[6] = ckDataBuf[4 - 1]; + finalOut[7] = ckDataBuf[10 - 1]; + + memcpy(pDataOut + countsOut, finalOut, sizeof(finalOut)); + countsOut += 8; + ckDataPos = 0; + } + } + (*lenOut) = countsOut * sizeof(short); +} + static void *RecordThread(void *param) { RecordData *record = (RecordData *)param; int ret = 0; @@ -334,8 +437,10 @@ static void *RecordThread(void *param) { if (record->finalfilefd > 0 && record->pcm_cfg->backupfile_waveformat > 0) { begin_wave(record, record->backupfilefd, (size_t)max_file_size); } + n_toast("Running:%d, work mode:%d\n", record->runing, getWorkMode()); while (!!record->runing) { - if (getWorkMode() == WorkMode_R311_PV1) { + switch (getWorkMode()) { + case WorkMode_R311_PV1: if (pcm_read(record->pcm_cfg->adc) == record->pcm_cfg->adc->chunk_size) { if (pcm_read(record) == record->chunk_size) { @@ -362,8 +467,11 @@ static void *RecordThread(void *param) { // printf("copy to 0x%p, size:%d\n", (record->buffer + // i * record->bits_per_frame / 8 + - // 6 * record->significant_bits_per_sample / - // 8), 2 * record->significant_bits_per_sample / 8); + // 6 * record->significant_bits_per_sample + // / + // 8), 2 * + // record->significant_bits_per_sample + // / 8); memcpy( (void *)(record->buffer + i * record->bits_per_frame / 8 + @@ -399,9 +507,41 @@ static void *RecordThread(void *param) { pcm_read(record); printf("Read adc codec error!\n"); } - } else { - printf("Unknow work mode!\n"); - exit(0); + + break; + + case WorkMode_R311_PV1_CES: + ret = pcm_read(record); + 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) { + xwrite(record->backupfilefd, newbuf, len); + fdcount += len; + } + queue_write(record->queue, newbuf, len); + free(newbuf); + } + + // if (record->backupfilefd > 0) { + // xwrite(record->backupfilefd, record->buffer, + // record->chunk_bytes); + // fdcount += record->chunk_bytes; + // } + // queue_write(record->queue, record->buffer, + // record->chunk_bytes); + } else { + fprintf(stderr, "short read, read %d frames/n", ret); + LOG_EX(LOG_Error, "ALSA Short Read, Read %d Frames: %d\n", ret); + } + break; + + default: + n_error("Unknow mode!\n"); } } @@ -473,6 +613,26 @@ int Neteasae_record_start(struct pcm_config *pcm_cfg) { break; + case WorkMode_R311_PV1_CES: + pcm_cfg->device_name = "hw:1,0"; + pcm_cfg->channels = 2; + pcm_cfg->rate = 96000; + pcm_cfg->period_size = 1535; + pcm_cfg->format = "S32_LE"; + + printf("Begin to init R311 pv1 ces i2s0!"); + init_params(pcm_cfg, 1); + + pthread_attr_init(&thread_attr); + pthread_attr_setschedpolicy(&thread_attr, SCHED_RR); + thread_param.sched_priority = sched_get_priority_max(SCHED_RR); + pthread_attr_setschedparam(&thread_attr, &thread_param); + + pthread_create(&pcm_cfg->recordata->tid_pcm_read, &thread_attr, + RecordThread, (void *)pcm_cfg->recordata); + pthread_create(&pcm_cfg->recordata->tid_queue_read, NULL, + QueueReadThread, (void *)pcm_cfg->recordata); + break; default: printf("Unknow mode!\n"); exit(0); @@ -501,6 +661,7 @@ static int init_params(struct pcm_config *pcm_cfg, int init_queue) { record->pcm_cfg = pcm_cfg; record->cb = pcm_cfg->audio_cb; + n_toast("r_cb:%p, pcm_cb:%p\n", record->cb, pcm_cfg->audio_cb); //设置录音参数参数 rc = snd_pcm_open(&record->handle, pcm_cfg->device_name, SND_PCM_STREAM_CAPTURE, 0); @@ -603,14 +764,15 @@ static int init_params(struct pcm_config *pcm_cfg, int init_queue) { } if (init_queue > 0) { - record->queue_buff = (char *)malloc( - sizeof(audio_queue_t) + record->chunk_bytes * QUEUE_BUFF_MULTIPLE + 1); + record->queue_buff = + (char *)malloc(sizeof(audio_queue_t) + + record->chunk_bytes * QUEUE_BUFF_MULTIPLE + 1); if (NULL == record->queue_buff) { ret = NETEASE_ERROR_OUT_OF_MEMORY; goto error; } - record->queue = queue_init(record->queue_buff, - record->chunk_bytes * QUEUE_BUFF_MULTIPLE + 1); + record->queue = queue_init( + record->queue_buff, record->chunk_bytes * QUEUE_BUFF_MULTIPLE + 1); } else { record->queue_buff = NULL; record->queue = NULL; @@ -620,7 +782,8 @@ static int init_params(struct pcm_config *pcm_cfg, int init_queue) { snd_pcm_sw_params_set_avail_min(record->handle, swparams, record->chunk_size); snd_pcm_sw_params_set_start_threshold(record->handle, swparams, 1); - snd_pcm_sw_params_set_stop_threshold(record->handle, swparams, 8000); + snd_pcm_sw_params_set_stop_threshold(record->handle, swparams, + record->buff_size); if (snd_pcm_sw_params(record->handle, swparams) < 0) { n_error("unable to install sw params:");