< prev index next >
test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 92,102 ****
}
}
}
}
! public static void main(final String[] args) {
for (final FormatConversionProvider fcp : load(
FormatConversionProvider.class)) {
System.out.println("fcp = " + fcp);
for (final AudioFormat from : formats) {
for (final AudioFormat to : formats) {
--- 92,102 ----
}
}
}
}
! public static void main(final String[] args) throws IOException {
for (final FormatConversionProvider fcp : load(
FormatConversionProvider.class)) {
System.out.println("fcp = " + fcp);
for (final AudioFormat from : formats) {
for (final AudioFormat to : formats) {
*** 137,175 ****
* Verifies the frame length after the stream was saved/read to/from
* stream.
*/
private static void testAfterSaveToStream(final AudioFileWriter afw,
final AudioFileFormat.Type type,
! final AudioInputStream ais) {
try {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
afw.write(ais, type, out);
final InputStream input = new ByteArrayInputStream(
out.toByteArray());
validate(AudioSystem.getAudioInputStream(input).getFrameLength());
} catch (IllegalArgumentException | UnsupportedAudioFileException
! | IOException ignored) {
}
}
/**
* Verifies the frame length after the stream was saved/read to/from file.
*/
private static void testAfterSaveToFile(final AudioFileWriter afw,
final AudioFileFormat.Type type,
! AudioInputStream ais) {
! try {
final File temp = File.createTempFile("sound", ".tmp");
! temp.deleteOnExit();
afw.write(ais, type, temp);
ais = AudioSystem.getAudioInputStream(temp);
final long frameLength = ais.getFrameLength();
ais.close();
- Files.delete(Paths.get(temp.getAbsolutePath()));
validate(frameLength);
} catch (IllegalArgumentException | UnsupportedAudioFileException
! | IOException ignored) {
}
}
/**
* Verifies the frame length after the stream was converted to other
--- 137,177 ----
* Verifies the frame length after the stream was saved/read to/from
* stream.
*/
private static void testAfterSaveToStream(final AudioFileWriter afw,
final AudioFileFormat.Type type,
! final AudioInputStream ais)
! throws IOException {
try {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
afw.write(ais, type, out);
final InputStream input = new ByteArrayInputStream(
out.toByteArray());
validate(AudioSystem.getAudioInputStream(input).getFrameLength());
} catch (IllegalArgumentException | UnsupportedAudioFileException
! ignored) {
}
}
/**
* Verifies the frame length after the stream was saved/read to/from file.
*/
private static void testAfterSaveToFile(final AudioFileWriter afw,
final AudioFileFormat.Type type,
! AudioInputStream ais)
! throws IOException {
final File temp = File.createTempFile("sound", ".tmp");
! try {
afw.write(ais, type, temp);
ais = AudioSystem.getAudioInputStream(temp);
final long frameLength = ais.getFrameLength();
ais.close();
validate(frameLength);
} catch (IllegalArgumentException | UnsupportedAudioFileException
! ignored) {
! } finally {
! Files.delete(Paths.get(temp.getAbsolutePath()));
}
}
/**
* Verifies the frame length after the stream was converted to other
< prev index next >