Code example for SourceDataLine

Methods: sleepavailablewrite

0
		return ava;
	} 
 
	private void refresh() { 
		if (dataLine == null) return;
		int ava = dataLine.available();		// this is a little expensive... :-(
		 
		// System.out.println(">> Out: " + (OUTPUT_BUFFER_SIZE - ava) + "\tIn: " + inputBuffer.position()); 
		 
		if (ava == 0) {
			// System.out.println("+ OutputBuffer FULL, InputBuffer: " + inputBuffer.position()); 
			if (OUTPUT_BUFFER_FULL_SLEEP_TIME > 0 && FPS < 0)
				try { Thread.sleep(OUTPUT_BUFFER_FULL_SLEEP_TIME, 0); } catch (InterruptedException e) { }
			return; 
		} 
		int data = getFromInputBuffer(tempBuffer, ava);
		if (data == 0) {
			// System.out.println("- InputBuffer EMPTY, OutputBuffer: " + (OUTPUT_BUFFER_SIZE - ava)); 
			if (NO_DATA_SLEEP_TIME > 0 && FPS < 0)
				try { Thread.sleep(NO_DATA_SLEEP_TIME, 0); } catch (InterruptedException e) { }
			return; 
		} 
 
		dataLine.write(tempBuffer, 0, data);
		if (FPS < 0)
			try { Thread.sleep(OUTPUT_BUFFER_FULL_SLEEP_TIME, 0); } catch (InterruptedException e) { }
	} 
 
 
	public Clock clock;
	private AudioSignal signal;