/** * Incrementally processes new input from {@code inputBuffer} while in {@link #STATE_SILENT}, * updating the state if needed. */ private void processSilence(ByteBuffer inputBuffer) { int limit = inputBuffer.limit(); int noisyPosition = findNoisePosition(inputBuffer); inputBuffer.limit(noisyPosition); skippedFrames += inputBuffer.remaining() / bytesPerFrame; updatePaddingBuffer(inputBuffer, paddingBuffer, paddingSize); if (noisyPosition < limit) { // Output the padding, which may include previous input as well as new input, then transition // back to the noisy state. output(paddingBuffer, paddingSize); state = STATE_NOISY; // Restore the limit. inputBuffer.limit(limit); } }
skippedFrames += (maybeSilenceBufferSize - paddingSize) / bytesPerFrame; updatePaddingBuffer(inputBuffer, maybeSilenceBuffer, maybeSilenceBufferSize); maybeSilenceBufferSize = 0; state = STATE_SILENT;