home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / sun / audio / AudioDevice$DataPusher.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.1 KB  |  98 lines

  1. package sun.audio;
  2.  
  3. import java.io.IOException;
  4. import javax.sound.sampled.AudioInputStream;
  5. import javax.sound.sampled.SourceDataLine;
  6.  
  7. class AudioDevice$DataPusher implements Runnable {
  8.    SourceDataLine target;
  9.    // $FF: renamed from: is javax.sound.sampled.AudioInputStream
  10.    AudioInputStream field_0;
  11.    Thread pushThread;
  12.    boolean stopping;
  13.    boolean stopped;
  14.    // $FF: synthetic field
  15.    private final AudioDevice this$0;
  16.  
  17.    AudioDevice$DataPusher(AudioDevice var1, SourceDataLine var2, AudioInputStream var3) {
  18.       this.this$0 = var1;
  19.       this.pushThread = null;
  20.       this.target = var2;
  21.       this.field_0 = var3;
  22.    }
  23.  
  24.    public void start() {
  25.       if (this.pushThread != null) {
  26.          if (AudioDevice.access$000(this.this$0)) {
  27.             System.out.println("Thread is not null");
  28.          }
  29.  
  30.       } else {
  31.          if (AudioDevice.access$000(this.this$0)) {
  32.             System.out.println("Starting push");
  33.          }
  34.  
  35.          this.stopping = false;
  36.          this.stopped = false;
  37.          this.pushThread = new Thread(this);
  38.          this.pushThread.start();
  39.       }
  40.    }
  41.  
  42.    public void stop() {
  43.       if (this.pushThread != null) {
  44.          if (AudioDevice.access$000(this.this$0)) {
  45.             System.out.println("Stopping push");
  46.          }
  47.  
  48.          this.stopping = true;
  49.  
  50.          while(!this.stopped) {
  51.             try {
  52.                Thread.sleep(10L);
  53.             } catch (InterruptedException var2) {
  54.             }
  55.          }
  56.  
  57.          this.pushThread = null;
  58.       }
  59.    }
  60.  
  61.    public void run() {
  62.       byte[] var1 = new byte[this.target.getBufferSize() / 2];
  63.       int var2 = this.target.getFormat().getFrameSize();
  64.  
  65.       while(!this.stopping) {
  66.          try {
  67.             int var3 = this.field_0.read(var1);
  68.             if (var3 == -1) {
  69.                if (AudioDevice.access$000(this.this$0)) {
  70.                   System.out.println("\n\nFOUND END OF STREAM\n\n");
  71.                }
  72.  
  73.                this.target.drain();
  74.                this.target.stop();
  75.                break;
  76.             }
  77.  
  78.             if (AudioDevice.access$000(this.this$0)) {
  79.                System.out.println("> WRITING " + var3 + " BYTES\n");
  80.             }
  81.  
  82.             for(int var4 = var3; var4 > 0; var4 -= this.target.write(var1, 0, var3)) {
  83.             }
  84.  
  85.             if (AudioDevice.access$000(this.this$0)) {
  86.                System.out.println("< WROTE " + var3 + " BYTES\n");
  87.             }
  88.          } catch (IOException var5) {
  89.             break;
  90.          }
  91.       }
  92.  
  93.       this.target.flush();
  94.       this.target.stop();
  95.       this.stopped = true;
  96.    }
  97. }
  98.