2362N/A * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Java Sound audio clip; 0N/A * @author Arthur van Hoff, Kara Kytle, Jan Borgersen 0N/A * @author Florian Bomers 0N/A private static final boolean DEBUG =
false;
0N/A private static final int BUFFER_SIZE =
16384;
// number of bytes written each time to the source data line 0N/A * used for determining how many samples is the 0N/A * threshhold between playing as a Clip and streaming 0N/A * $$jb: 11.07.99: the engine has a limit of 1M 0N/A * samples to play as a Clip, so compare this number 0N/A * with the number of samples in the stream. 0N/A //private final static long CLIP_THRESHOLD = 1; 0N/A // load the stream data into memory 0N/A // not an audio file 0N/A throw new IOException(
"Unable to create AudioClip from input stream");
0N/A // hack for some applets that call the start method very rapidly... 0N/A // need to stop in case the looped status changed 0N/A // Event handlers (for debugging) 0N/A // handle MIDI track end meta events for looping 0N/A //$$fb 2001-09-26: may improve situation related to bug #4302884 0N/A // FILE LOADING METHODS 0N/A // first possibly convert this stream to PCM 0N/A // if the stream length is known, it can be efficiently loaded into memory 0N/A // otherwise we use a ByteArrayOutputStream to load it into memory 0N/A // if everything went fine, we have now the audio data in 0N/A // loadedAudio, and the byte length in loadedAudioByteLength 0N/A // arrays "only" max. 2GB 0N/A // this loop may throw an IOException // this loop may throw an IOException // METHODS FOR CREATING THE DEVICE // fail -> will try with SourceDataLine * private inner class representing a ByteArrayOutputStream * which allows retrieval of the internal array