home *** CD-ROM | disk | FTP | other *** search
- package sun.audio;
-
- import java.io.IOException;
- import javax.sound.sampled.AudioInputStream;
- import javax.sound.sampled.SourceDataLine;
-
- class AudioDevice$DataPusher implements Runnable {
- SourceDataLine target;
- // $FF: renamed from: is javax.sound.sampled.AudioInputStream
- AudioInputStream field_0;
- Thread pushThread;
- boolean stopping;
- boolean stopped;
- // $FF: synthetic field
- private final AudioDevice this$0;
-
- AudioDevice$DataPusher(AudioDevice var1, SourceDataLine var2, AudioInputStream var3) {
- this.this$0 = var1;
- this.pushThread = null;
- this.target = var2;
- this.field_0 = var3;
- }
-
- public void start() {
- if (this.pushThread != null) {
- if (AudioDevice.access$000(this.this$0)) {
- System.out.println("Thread is not null");
- }
-
- } else {
- if (AudioDevice.access$000(this.this$0)) {
- System.out.println("Starting push");
- }
-
- this.stopping = false;
- this.stopped = false;
- this.pushThread = new Thread(this);
- this.pushThread.start();
- }
- }
-
- public void stop() {
- if (this.pushThread != null) {
- if (AudioDevice.access$000(this.this$0)) {
- System.out.println("Stopping push");
- }
-
- this.stopping = true;
-
- while(!this.stopped) {
- try {
- Thread.sleep(10L);
- } catch (InterruptedException var2) {
- }
- }
-
- this.pushThread = null;
- }
- }
-
- public void run() {
- byte[] var1 = new byte[this.target.getBufferSize() / 2];
- int var2 = this.target.getFormat().getFrameSize();
-
- while(!this.stopping) {
- try {
- int var3 = this.field_0.read(var1);
- if (var3 == -1) {
- if (AudioDevice.access$000(this.this$0)) {
- System.out.println("\n\nFOUND END OF STREAM\n\n");
- }
-
- this.target.drain();
- this.target.stop();
- break;
- }
-
- if (AudioDevice.access$000(this.this$0)) {
- System.out.println("> WRITING " + var3 + " BYTES\n");
- }
-
- for(int var4 = var3; var4 > 0; var4 -= this.target.write(var1, 0, var3)) {
- }
-
- if (AudioDevice.access$000(this.this$0)) {
- System.out.println("< WROTE " + var3 + " BYTES\n");
- }
- } catch (IOException var5) {
- break;
- }
- }
-
- this.target.flush();
- this.target.stop();
- this.stopped = true;
- }
- }
-