move everything out of subdirectory

This commit is contained in:
Aaron Neyer
2013-12-15 14:12:57 -05:00
parent 71aacf1305
commit fed46a2a49
151 changed files with 191 additions and 2359 deletions

View File

@@ -0,0 +1,52 @@
package com.limelight.binding.audio;
import java.nio.ByteBuffer;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import com.limelight.nvstream.av.audio.AudioRenderer;
import com.limelight.nvstream.av.audio.OpusDecoder;
public class JavaxAudioRenderer implements AudioRenderer {
private SourceDataLine soundLine;
@Override
public void playDecodedAudio(short[] pcmData, int offset, int length) {
if (soundLine != null) {
byte[] pcmDataBytes = new byte[length * 2];
ByteBuffer.wrap(pcmDataBytes).asShortBuffer().put(pcmData, offset, length);
if (soundLine.available() < length) {
soundLine.write(pcmDataBytes, 0, soundLine.available());
}
else {
soundLine.write(pcmDataBytes, 0, pcmDataBytes.length);
}
}
}
@Override
public void streamClosing() {
if (soundLine != null) {
soundLine.close();
}
}
@Override
public void streamInitialized(int channelCount, int sampleRate) {
AudioFormat audioFormat = new AudioFormat(sampleRate, 16, channelCount, true, true);
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat, OpusDecoder.getMaxOutputShorts());
try {
soundLine = (SourceDataLine) AudioSystem.getLine(info);
soundLine.open(audioFormat, OpusDecoder.getMaxOutputShorts()*4*2);
soundLine.start();
} catch (LineUnavailableException e) {
soundLine = null;
}
}
}