Stop thread properly and close utterance.

This commit is contained in:
Gregory John Casamento 2020-02-08 06:22:14 -05:00
parent 07bf3d32e4
commit f05702d450
2 changed files with 7 additions and 3 deletions

View file

@ -149,9 +149,9 @@ static const arg_t cont_args_def[] = {
}
utt_started = NO;
NSLog(@"Ready....");
NSLog(@"Ready.... <%@, %d>", _listeningThread, [_listeningThread isCancelled]);
while([_listeningThread isCancelled] == NO)
while([_listeningThread isCancelled] == NO && _listeningThread != nil)
{
if ((k = ad_read(ad, adbuf, 2048)) < 0)
{
@ -193,6 +193,9 @@ static const arg_t cont_args_def[] = {
}
[NSThread sleepForTimeInterval: 0.01];
}
// Close everything...
ps_end_utt(ps);
ad_close(ad);
}
@ -202,6 +205,7 @@ static const arg_t cont_args_def[] = {
[[NSThread alloc] initWithTarget: self
selector: @selector(recognize)
object: nil];
[_listeningThread setName: @"Speech Recognition Loop"];
NSLog(@"Thread info for speech reconigtion server %@", _listeningThread);
[_listeningThread start];
}