MarkSupported.java revision 2362
342N/A/*
844N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
342N/A *
342N/A * This code is free software; you can redistribute it and/or modify it
342N/A * under the terms of the GNU General Public License version 2 only, as
342N/A * published by the Free Software Foundation. Oracle designates this
342N/A * particular file as subject to the "Classpath" exception as provided
342N/A * by Oracle in the LICENSE file that accompanied this code.
342N/A *
342N/A * This code is distributed in the hope that it will be useful, but WITHOUT
342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
342N/A * version 2 for more details (a copy is included in the LICENSE file that
342N/A * accompanied this code).
342N/A *
342N/A * You should have received a copy of the GNU General Public License version
342N/A * 2 along with this work; if not, write to the Free Software Foundation,
342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
342N/A *
342N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
342N/A * or visit www.oracle.com if you need additional information or have any
342N/A * questions.
342N/A */
342N/A
342N/A/* @test
342N/A @summary Test AudioFloatInputStream markSupported method */
342N/A
342N/Aimport java.io.*;
342N/A
342N/Aimport javax.sound.sampled.*;
342N/A
441N/Aimport com.sun.media.sound.*;
342N/A
342N/Apublic class MarkSupported {
342N/A
342N/A static float[] test_float_array;
342N/A static byte[] test_byte_array;
342N/A static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
342N/A
342N/A static AudioFloatInputStream getStream1()
342N/A {
342N/A return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length);
342N/A }
441N/A
441N/A static AudioFloatInputStream getStream2()
342N/A {
342N/A AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024);
342N/A return AudioFloatInputStream.getInputStream(strm);
342N/A }
342N/A
342N/A static void setUp() throws Exception {
342N/A test_float_array = new float[1024];
342N/A test_byte_array = new byte[1024*format.getFrameSize()];
342N/A for (int i = 0; i < 1024; i++) {
342N/A double ii = i / 1024.0;
342N/A ii = ii * ii;
342N/A test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI);
342N/A test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
342N/A test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
342N/A test_float_array[i] *= 0.3;
342N/A }
342N/A AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array);
342N/A }
342N/A
342N/A public static void main(String[] args) throws Exception {
1111N/A setUp();
342N/A if(!getStream1().markSupported())
342N/A throw new RuntimeException("Mark not supported.");
342N/A if(!getStream2().markSupported())
342N/A throw new RuntimeException("Mark not supported.");
342N/A }
342N/A
342N/A}
342N/A