diff --git a/server/src/main/java/com/genymobile/scrcpy/AudioCapture.java b/server/src/main/java/com/genymobile/scrcpy/AudioCapture.java index 9228e3d7..6bb3ce23 100644 --- a/server/src/main/java/com/genymobile/scrcpy/AudioCapture.java +++ b/server/src/main/java/com/genymobile/scrcpy/AudioCapture.java @@ -111,7 +111,7 @@ public final class AudioCapture { @TargetApi(Build.VERSION_CODES.N) public int read(ByteBuffer directBuffer, int size, MediaCodec.BufferInfo outBufferInfo) { int r = recorder.read(directBuffer, size); - if (r < 0) { + if (r <= 0) { return r; } diff --git a/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java b/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java index 24d685c5..d3459831 100644 --- a/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java @@ -92,7 +92,7 @@ public final class AudioEncoder implements AsyncProcessor { InputTask task = inputTasks.take(); ByteBuffer buffer = mediaCodec.getInputBuffer(task.index); int r = capture.read(buffer, READ_SIZE, bufferInfo); - if (r < 0) { + if (r <= 0) { throw new IOException("Could not read audio: " + r); }