< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java

Print this page

        

@@ -23,42 +23,40 @@
  * questions.
  */
 
 package com.sun.media.sound;
 
-import java.io.IOException;
-import java.io.InputStream;
+import java.applet.AudioClip;
 import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
-import java.applet.AudioClip;
+import java.io.IOException;
+import java.io.InputStream;
 
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MetaEventListener;
+import javax.sound.midi.MetaMessage;
+import javax.sound.midi.MidiFileFormat;
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Sequence;
+import javax.sound.midi.Sequencer;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
 import javax.sound.sampled.AudioSystem;
 import javax.sound.sampled.Clip;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.DataLine;
-import javax.sound.sampled.SourceDataLine;
 import javax.sound.sampled.LineEvent;
 import javax.sound.sampled.LineListener;
+import javax.sound.sampled.SourceDataLine;
 import javax.sound.sampled.UnsupportedAudioFileException;
 
-import javax.sound.midi.MidiSystem;
-import javax.sound.midi.MidiFileFormat;
-import javax.sound.midi.MetaMessage;
-import javax.sound.midi.Sequence;
-import javax.sound.midi.Sequencer;
-import javax.sound.midi.InvalidMidiDataException;
-import javax.sound.midi.MidiUnavailableException;
-import javax.sound.midi.MetaEventListener;
-
 /**
  * Java Sound audio clip;
  *
  * @author Arthur van Hoff, Kara Kytle, Jan Borgersen
  * @author Florian Bomers
  */
-
 public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
 
     private static final boolean DEBUG = false;
     private static final int BUFFER_SIZE = 16384; // number of bytes written each time to the source data line
 

@@ -124,16 +122,16 @@
         if (!success) {
             throw new IOException("Unable to create AudioClip from input stream");
         }
     }
 
-
+    @Override
     public synchronized void play() {
         startImpl(false);
     }
 
-
+    @Override
     public synchronized void loop() {
         startImpl(true);
     }
 
     private synchronized void startImpl(boolean loop) {

@@ -203,10 +201,11 @@
         } catch (Exception e) {
             if (DEBUG || Printer.err)e.printStackTrace();
         }
     }
 
+    @Override
     public synchronized void stop() {
 
         if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip->stop()");
         lastPlayCall = 0;
 

@@ -246,17 +245,19 @@
         }
     }
 
     // Event handlers (for debugging)
 
+    @Override
     public synchronized void update(LineEvent event) {
         if (DEBUG || Printer.debug) Printer.debug("line event received: "+event);
     }
 
     // handle MIDI track end meta events for looping
 
-    public synchronized void meta( MetaMessage message ) {
+    @Override
+    public synchronized void meta(MetaMessage message) {
 
         if (DEBUG || Printer.debug)Printer.debug("META EVENT RECEIVED!!!!! ");
 
         if( message.getType() == 47 ) {
             if (sequencerloop){

@@ -267,16 +268,16 @@
                 stop();
             }
         }
     }
 
-
+    @Override
     public String toString() {
         return getClass().toString();
     }
 
-
+    @Override
     protected void finalize() {
 
         if (clip != null) {
             if (DEBUG || Printer.trace)Printer.trace("JavaSoundAudioClip.finalize: clip.close()");
             clip.close();

@@ -324,12 +325,10 @@
         // if everything went fine, we have now the audio data in
         // loadedAudio, and the byte length in loadedAudioByteLength
         return true;
     }
 
-
-
     private void readStream(AudioInputStream as, long byteLen) throws IOException {
         // arrays "only" max. 2GB
         int intLen;
         if (byteLen > 2147483647) {
             intLen = 2147483647;

@@ -369,11 +368,10 @@
         }
         loadedAudio = baos.getInternalBuffer();
         loadedAudioByteLength = totalBytesRead;
     }
 
-
     // METHODS FOR CREATING THE DEVICE
 
     private boolean createClip() {
 
         if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createClip()");

@@ -462,11 +460,10 @@
 
         if (DEBUG || Printer.debug)Printer.debug("Created Sequencer.");
         return true;
     }
 
-
     /*
      * private inner class representing a ByteArrayOutputStream
      * which allows retrieval of the internal array
      */
     private static class DirectBAOS extends ByteArrayOutputStream {

@@ -477,7 +474,6 @@
         public byte[] getInternalBuffer() {
             return buf;
         }
 
     } // class DirectBAOS
-
 }
< prev index next >