2713N/A/*
2713N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2713N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2713N/A *
2713N/A * This code is free software; you can redistribute it and/or modify it
2713N/A * under the terms of the GNU General Public License version 2 only, as
2713N/A * published by the Free Software Foundation. Oracle designates this
2713N/A * particular file as subject to the "Classpath" exception as provided
2713N/A * by Oracle in the LICENSE file that accompanied this code.
2713N/A *
2713N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2713N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2713N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2713N/A * version 2 for more details (a copy is included in the LICENSE file that
2713N/A * accompanied this code).
2713N/A *
2713N/A * You should have received a copy of the GNU General Public License version
2713N/A * 2 along with this work; if not, write to the Free Software Foundation,
2713N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2713N/A *
2713N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2713N/A * or visit www.oracle.com if you need additional information or have any
2713N/A * questions.
2713N/A */
2713N/A
2713N/A/* @test
2713N/A @summary Test skip method returned from AudioFloatFormatConverter.getAudioInputStream */
2713N/A
2713N/Aimport java.io.ByteArrayInputStream;
2713N/A
2713N/Aimport javax.sound.sampled.AudioFormat;
2713N/Aimport javax.sound.sampled.AudioInputStream;
2713N/A
2713N/Aimport com.sun.media.sound.AudioFloatFormatConverter;
2713N/A
2713N/Apublic class SkipTest {
2713N/A
2713N/A public static void main(String[] args) throws Exception {
2713N/A AudioFloatFormatConverter converter = new AudioFloatFormatConverter();
2713N/A byte[] data = { 10, 20, 30, 40, 30, 20, 10 };
2713N/A AudioFormat format = new AudioFormat(8000, 8, 1, true, false);
2713N/A AudioFormat format2 = new AudioFormat(16000, 8, 1, true, false);
2713N/A AudioInputStream ais = new AudioInputStream(new ByteArrayInputStream(
2713N/A data), format, data.length);
2713N/A AudioInputStream ais2 = converter.getAudioInputStream(format2, ais);
2713N/A byte[] data2 = new byte[30];
2713N/A int ret = ais2.read(data2, 0, data2.length);
2713N/A ais.reset();
2713N/A AudioInputStream ais3 = converter.getAudioInputStream(format2, ais);
2713N/A byte[] data3 = new byte[100];
2713N/A ais3.skip(7);
2713N/A int ret2 = ais3.read(data3, 7, data3.length);
2713N/A if (ret2 != ret - 7)
2713N/A throw new Exception("Skip doesn't work correctly (" + ret2 + " != "
2713N/A + (ret - 7) + ")");
2713N/A for (int i = 7; i < ret2 + 7; i++) {
2713N/A if (data3[i] != data2[i])
2713N/A throw new Exception("Skip doesn't work correctly (" + data3[i]
2713N/A + " != " + data2[i] + ")");
2713N/A }
2713N/A }
2713N/A
2713N/A}