+ /** A buffered output stream to ensure correct writing to the source data line. */
+ private OutputStream sourceDataLineOutputStream = new IntegralWriteOutputStream(new OutputStream() {
+
+ @Override
+ public void write(int b) throws IOException {
+ }
+
+ @Override
+ public void write(byte[] b) throws IOException {
+ write(b, 0, b.length);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ if (sourceDataLine != null) {
+ sourceDataLine.write(b, off, len);
+ }
+ }
+ }, 1024);
+
+ /**
+ * Creates a new audio sink.
+ *
+ * @param eventBus
+ * The event bus
+ */
+ public AudioSink(EventBus eventBus) {
+ this.eventBus = eventBus;
+ volumeFader = new Fader("Volume") {