update cc && voice to adapter for pv1 ces board

This commit is contained in:
wangzijiao 2018-11-30 17:45:43 +08:00
parent d5be49e88c
commit 765523be4e
22 changed files with 1119 additions and 39 deletions

27
.gitignore vendored Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,6 +40,7 @@ var (
GitTag *string
StartTime time.Time
Hv *string
ActualHv *string
)
const (

View File

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

View File

@ -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() {
if globals.GetCurPlatformConfig().IconSwitch == true {
ShowIcon(this)
}
}
func (this IconLedDesc) Clear() {

View File

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

View File

@ -319,7 +319,9 @@ func StartBoardRoutine() {
<-playstopch
}
if GetCurPlatformConfig().LedMcuInit == true {
led_mcu.McuResetInitStatus()
}
if NewBoard == false {
StartBackground_wificheck()

View File

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

View File

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

View File

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

View File

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

View File

@ -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");
}
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 {
printf("Unknow work mode!\n");
exit(0);
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:");