public void run() { byte[] bytes = new byte[8192]; int nrRead; boolean terminate = false; try { while (!terminate && (nrRead = from.read(bytes)) > -1) { latestSeenTime = System.currentTimeMillis(); logger.debug("Read " + nrRead + " bytes from audio source."); if (endMarker != null) { int start = MaryUtils.indexOf(bytes, endMarker); if (start != -1) { // found the end marker! nrRead = start; // truncate terminate = true; logger.debug("Found end marker at index position " + start); } } audioDestination.write(bytes, 0, nrRead); } logger.info("Finished reading."); from.close(); } catch (IOException e) { logger.warn("Problem reading from module:", e); } }
public void run() { byte[] bytes = new byte[8192]; int nrRead; boolean terminate = false; try { while (!terminate && (nrRead = from.read(bytes)) > -1) { latestSeenTime = System.currentTimeMillis(); logger.debug("Read " + nrRead + " bytes from audio source."); if (endMarker != null) { int start = MaryUtils.indexOf(bytes, endMarker); if (start != -1) { // found the end marker! nrRead = start; // truncate terminate = true; logger.debug("Found end marker at index position " + start); } } audioDestination.write(bytes, 0, nrRead); } logger.info("Finished reading."); from.close(); } catch (IOException e) { logger.warn("Problem reading from module:", e); } }