aispeech-2mic-32bit: add wait_device_mode_timeout_ms when vad resume

Change-Id: I3fb05ecea55db55a099255fbe26951dffe56f0ae
Signed-off-by: Nyx Zheng <zyh@rock-chips.com>
This commit is contained in:
Nyx Zheng
2018-07-25 11:13:45 +08:00
parent aa5d1f1528
commit 4ada407f21

View File

@ -609,12 +609,11 @@ bool sleep_check(void) {
return false;
}
int wait_device_mode_timeout_ms(int microseconds)
void wait_device_mode_timeout_ms(int microseconds)
{
struct timeval tv;
long long absmsec;
struct timespec abstime;
int ret;
gettimeofday(&tv, NULL);
absmsec = tv.tv_sec * 1000ll + tv.tv_usec / 1000ll;
@ -625,14 +624,12 @@ int wait_device_mode_timeout_ms(int microseconds)
printf("#### public sleep mode ####");
pthread_mutex_lock(&mylock);
ret = pthread_cond_timedwait(&mycond, &mylock, &abstime);
pthread_cond_timedwait(&mycond, &mylock, &abstime);
pthread_mutex_unlock(&mylock);
printf("#### return sleep mode succeed ####");
return ret;
}
void *vad_detect_func(void* arg) {
int ret = 0;
clean_silence_frame();
while(true) {
if (sleep_check()) {
@ -641,13 +638,10 @@ void *vad_detect_func(void* arg) {
wait_device_mode_timeout_ms(30);
printf("pause >>>>\n");
clean_silence_frame();
m_vad_wakeup_time = 0;
do_system_sleep();
printf("resume >>>>\n");
do {
dds_client_publish(dc, DDS_CLIENT_USER_DEVICE_MODE, "{\"mode\":\"normal\"}");
ret = wait_device_mode_timeout_ms(300);
} while(ret!=0);
wait_device_mode_timeout_ms(30);
}
usleep(1000*1000);
}