[rustpotterks] Remove unnecessary thread sleep call (#14664)

* [rustpotterks] Remove unnecessary thread sleep call

Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
This commit is contained in:
GiviMAD 2023-03-25 00:20:34 +01:00 committed by GitHub
parent b9751dced3
commit c30893281c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,12 +191,11 @@ public class RustpotterKSService implements KSService {
while (!aborted.get()) {
try {
numBytesRead = audioStream.read(audioBuffer, bufferSize - remaining, remaining);
if (aborted.get()) {
if (aborted.get() || numBytesRead == -1) {
break;
}
if (numBytesRead != remaining) {
remaining = remaining - numBytesRead;
Thread.sleep(100);
continue;
}
remaining = bufferSize;
@ -217,7 +216,7 @@ public class RustpotterKSService implements KSService {
detection.delete();
ksListener.ksEventReceived(new KSpottedEvent());
}
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
String errorMessage = e.getMessage();
ksListener.ksEventReceived(new KSErrorEvent(errorMessage != null ? errorMessage : "Unexpected error"));
}