Path: blob/master/test/jdk/javax/sound/sampled/spi/AudioFileReader/Aiff12bit.java
40527 views
/*1* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.ByteArrayInputStream;24import java.io.InputStream;2526import javax.sound.sampled.AudioFileFormat;27import javax.sound.sampled.AudioSystem;2829/**30* @test31* @bug 489593432* @summary AudioInputStream.getFrameLength returns wrong value for 12-bit AIFF33* file34*/35public class Aiff12bit {3637public static void test(byte[] file) throws Exception {38InputStream inputStream = new ByteArrayInputStream(file);39AudioFileFormat aff = AudioSystem.getAudioFileFormat(inputStream);4041if (aff.getFormat().getSampleSizeInBits() != 12) {42throw new Exception("Wrong sample size. test FAILED");43}44if (aff.getFormat().getFrameSize() != 2) {45throw new Exception("Wrong frame size. test FAILED");46}47if (aff.getFrameLength() != 100) {48throw new Exception("Wrong file length. test FAILED");49}50}5152public static void main(String[] args) throws Exception {53test(AIFF_12BIT);5455System.out.println("Test passed.");56}5758public static byte[] AIFF_12BIT = {5970, 79, 82, 77, 0, 0, 0, -10, 65, 73, 70, 70, 67, 79, 77, 77,600, 0, 0, 18, 0, 1, 0, 0, 0, 100, 0, 12, 64, 8, -6, 0,610, 0, 0, 0, 0, 0, 83, 83, 78, 68, 0, 0, 0, -48, 0, 0,620, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 32, 0, 48, 0, 64,630, 80, 0, 96, 0, 112, 0, -128, 0, -112, 0, -96, 0, -80, 0, -64,640, -48, 0, -32, 0, -16, 1, 0, 1, 16, 1, 32, 1, 48, 1, 64,651, 80, 1, 96, 1, 112, 1, -128, 1, -112, 1, -96, 1, -80, 1, -64,661, -48, 1, -32, 1, -16, 2, 0, 2, 16, 2, 32, 2, 48, 2, 64,672, 80, 2, 96, 2, 112, 2, -128, 2, -112, 2, -96, 2, -80, 2, -64,682, -48, 2, -32, 2, -16, 3, 0, 3, 16, 3, 32, 3, 48, 3, 64,693, 80, 3, 96, 3, 112, 3, -128, 3, -112, 3, -96, 3, -80, 3, -64,703, -48, 3, -32, 3, -16, 4, 0, 4, 16, 4, 32, 4, 48, 4, 64,714, 80, 4, 96, 4, 112, 4, -128, 4, -112, 4, -96, 4, -80, 4, -64,724, -48, 4, -32, 4, -16, 5, 0, 5, 16, 5, 32, 5, 48, 5, 64,735, 80, 5, 96, 5, 112, 5, -128, 5, -112, 5, -96, 5, -80, 5, -64,745, -48, 5, -32, 5, -16, 6, 0, 6, 16, 6, 32, 6, 48,75};7677}787980