* [rustpotterks] Remove unnecessary thread sleep call
Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
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;
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"));
}