Code example for SourceDataLine

Methods: flush

0
 
	@Override 
	public synchronized int nextSamples(byte[] buffer, int quant) {
		if (dataLine == null) return -1;
		if (buffer == null) {		// Signal is off
			dataLine.flush();
			return -1; 
		} 
		// Drop samples that don't fit the input buffer available capacity 
		int ava = inputBuffer.remaining();
		if (ava > quant)
			ava = quant;
		// else 
			// if (ava < quant) System.out.println(">>>> DROPPED: " + quant + " - " + ava + " = " + (quant - ava)); 
		inputBuffer.put(buffer, 0, ava);
 
		// System.out.println(">>>> Available: " + inputBuffer.position()); 
		return inputBuffer.position();
	} 
	 
Experience pair programming with AI  Get Codota for Java