jdk/test/javax/sound/sampled/spi/AudioFileReader/EndlessLoopHugeLengthWave.java
author serb
Mon, 31 Oct 2016 14:50:09 +0300
changeset 41905 e8e5df013c6e
parent 32873 d445b313f219
permissions -rw-r--r--
8167615: Opensource unit/regression tests for JavaSound Reviewed-by: amenkov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32873
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     1
/*
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     4
 *
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     8
 *
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    13
 * accompanied this code).
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    14
 *
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    18
 *
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    21
 * questions.
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    22
 */
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    23
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    24
import java.io.ByteArrayInputStream;
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    25
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    26
import javax.sound.sampled.AudioSystem;
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    27
import javax.sound.sampled.UnsupportedAudioFileException;
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    28
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    29
/**
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    30
 * @test
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    31
 * @bug 8135160
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    32
 */
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    33
public final class EndlessLoopHugeLengthWave {
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    34
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    35
    // some data wich can cause an endless loop in RiffReader.java
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    36
    private static byte[] headerWAV = {0x52, 0x49, 0x46, 0x46, // RIFF_MAGIC
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    37
            0x7, 0xF, 0xF, 0xF, // fileLength
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    38
            0x57, 0x41, 0x56, 0x45, //  waveMagic
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    39
            0x66, 0x6d, 0x74, 0x20, // FMT_MAGIC
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    40
            1, 2, 3, 4, // format
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    41
            3, 0,// wav_type  WAVE_FORMAT_IEEE_FLOAT
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    42
            1, 0, // channels
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    43
            1, 1, // sampleRate
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    44
            1, 0, 0, 0, // avgBytesPerSec
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    45
            0, 1, // blockAlign
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    46
            1, 0, // sampleSizeInBits
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    47
            0x64, 0x61, 0x74, 0x61, // DATA_MAGIC
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    48
    };
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    49
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    50
    public static void main(final String[] args) throws Exception {
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    51
        try {
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    52
            AudioSystem.getAudioFileFormat(new ByteArrayInputStream(headerWAV));
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    53
        } catch (final UnsupportedAudioFileException ignored) {
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    54
            // Expected
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    55
        }
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    56
    }
d445b313f219 8135160: Endless Loop in RiffReader
serb
parents:
diff changeset
    57
}