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