< prev index next >

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

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.media.sound;
  27 
  28 import sun.misc.ManagedLocalsThread;
  29 
  30 import java.io.BufferedInputStream;
  31 import java.io.File;
  32 import java.io.FileInputStream;
  33 import java.io.FileNotFoundException;
  34 import java.io.FileOutputStream;
  35 import java.io.IOException;
  36 import java.io.InputStream;
  37 import java.io.OutputStream;
  38 import java.lang.ref.WeakReference;
  39 import java.security.AccessController;
  40 import java.security.PrivilegedAction;
  41 import java.util.ArrayList;
  42 import java.util.Arrays;
  43 import java.util.HashMap;
  44 import java.util.List;
  45 import java.util.Map;
  46 import java.util.Properties;
  47 import java.util.StringTokenizer;
  48 import java.util.prefs.BackingStoreException;
  49 import java.util.prefs.Preferences;


 124                      {
 125                          SoftAudioPusher _pusher = pusher;
 126                          AudioInputStream _jitter_stream = jitter_stream;
 127                          SourceDataLine _sourceDataLine = sourceDataLine;
 128                          public void run()
 129                          {
 130                              _pusher.stop();
 131                              if(_jitter_stream != null)
 132                                 try {
 133                                     _jitter_stream.close();
 134                                 } catch (IOException e) {
 135                                     e.printStackTrace();
 136                                 }
 137                              if(_sourceDataLine != null)
 138                                  _sourceDataLine.close();
 139                          }
 140                      };
 141                      pusher = null;
 142                      jitter_stream = null;
 143                      sourceDataLine = null;
 144                      new ManagedLocalsThread(runnable).start();
 145                  }
 146                  return len;
 147              }
 148         }
 149 
 150         public WeakAudioStream(AudioInputStream stream) {
 151             this.stream = stream;
 152             weak_stream_link = new WeakReference<AudioInputStream>(stream);
 153             converter = AudioFloatConverter.getConverter(stream.getFormat());
 154             samplesize = stream.getFormat().getFrameSize() / stream.getFormat().getChannels();
 155             framesize = stream.getFormat().getFrameSize();
 156         }
 157 
 158         public AudioInputStream getAudioInputStream()
 159         {
 160             return new AudioInputStream(this, stream.getFormat(), AudioSystem.NOT_SPECIFIED);
 161         }
 162 
 163         public void close() throws IOException
 164         {




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.media.sound;
  27 


  28 import java.io.BufferedInputStream;
  29 import java.io.File;
  30 import java.io.FileInputStream;
  31 import java.io.FileNotFoundException;
  32 import java.io.FileOutputStream;
  33 import java.io.IOException;
  34 import java.io.InputStream;
  35 import java.io.OutputStream;
  36 import java.lang.ref.WeakReference;
  37 import java.security.AccessController;
  38 import java.security.PrivilegedAction;
  39 import java.util.ArrayList;
  40 import java.util.Arrays;
  41 import java.util.HashMap;
  42 import java.util.List;
  43 import java.util.Map;
  44 import java.util.Properties;
  45 import java.util.StringTokenizer;
  46 import java.util.prefs.BackingStoreException;
  47 import java.util.prefs.Preferences;


 122                      {
 123                          SoftAudioPusher _pusher = pusher;
 124                          AudioInputStream _jitter_stream = jitter_stream;
 125                          SourceDataLine _sourceDataLine = sourceDataLine;
 126                          public void run()
 127                          {
 128                              _pusher.stop();
 129                              if(_jitter_stream != null)
 130                                 try {
 131                                     _jitter_stream.close();
 132                                 } catch (IOException e) {
 133                                     e.printStackTrace();
 134                                 }
 135                              if(_sourceDataLine != null)
 136                                  _sourceDataLine.close();
 137                          }
 138                      };
 139                      pusher = null;
 140                      jitter_stream = null;
 141                      sourceDataLine = null;
 142                      new Thread(null, runnable, "Synthesizer",0,false).start();
 143                  }
 144                  return len;
 145              }
 146         }
 147 
 148         public WeakAudioStream(AudioInputStream stream) {
 149             this.stream = stream;
 150             weak_stream_link = new WeakReference<AudioInputStream>(stream);
 151             converter = AudioFloatConverter.getConverter(stream.getFormat());
 152             samplesize = stream.getFormat().getFrameSize() / stream.getFormat().getChannels();
 153             framesize = stream.getFormat().getFrameSize();
 154         }
 155 
 156         public AudioInputStream getAudioInputStream()
 157         {
 158             return new AudioInputStream(this, stream.getFormat(), AudioSystem.NOT_SPECIFIED);
 159         }
 160 
 161         public void close() throws IOException
 162         {


< prev index next >