Skip to content
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, 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
Expand Down Expand Up @@ -31,6 +31,7 @@
import java.awt.image.SampleModel;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
Expand Down Expand Up @@ -270,10 +271,10 @@ public String[] getPropertyNames(String prefix) {

prefix = prefix.toLowerCase();

Vector<String> names = new Vector<String>();
ArrayList<String> names = new ArrayList<String>();
for (int i = 0; i < propertyNames.length; i++) {
if (propertyNames[i].startsWith(prefix)) {
names.addElement(propertyNames[i]);
names.add(propertyNames[i]);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, 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
Expand All @@ -25,6 +25,7 @@

package com.sun.media.sound;

import java.util.ArrayList;
import java.util.Vector;

import javax.sound.sampled.Control;
Expand Down Expand Up @@ -138,18 +139,18 @@ public final Line.Info[] getTargetLineInfo() {
public final Line.Info[] getSourceLineInfo(Line.Info info) {

int i;
Vector<Line.Info> vec = new Vector<>();
ArrayList<Line.Info> vec = new ArrayList<>();

for (i = 0; i < sourceLineInfo.length; i++) {

if (info.matches(sourceLineInfo[i])) {
vec.addElement(sourceLineInfo[i]);
vec.add(sourceLineInfo[i]);
}
}

Line.Info[] returnedArray = new Line.Info[vec.size()];
for (i = 0; i < returnedArray.length; i++) {
returnedArray[i] = vec.elementAt(i);
returnedArray[i] = vec.get(i);
}

return returnedArray;
Expand All @@ -159,18 +160,18 @@ public final Line.Info[] getSourceLineInfo(Line.Info info) {
public final Line.Info[] getTargetLineInfo(Line.Info info) {

int i;
Vector<Line.Info> vec = new Vector<>();
ArrayList<Line.Info> vec = new ArrayList<>();

for (i = 0; i < targetLineInfo.length; i++) {

if (info.matches(targetLineInfo[i])) {
vec.addElement(targetLineInfo[i]);
vec.add(targetLineInfo[i]);
}
}

Line.Info[] returnedArray = new Line.Info[vec.size()];
for (i = 0; i < returnedArray.length; i++) {
returnedArray[i] = vec.elementAt(i);
returnedArray[i] = vec.get(i);
}

return returnedArray;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, 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
Expand All @@ -26,8 +26,8 @@
package com.sun.media.sound;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Vector;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
Expand Down Expand Up @@ -206,7 +206,7 @@ private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInput
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {


Vector<AudioFormat> formats = new Vector<>();
ArrayList<AudioFormat> formats = new ArrayList<>();
AudioFormat format;

if (inputFormat.getSampleSizeInBits() == 16
Expand All @@ -216,7 +216,7 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getChannels(),
inputFormat.getChannels(),
inputFormat.getSampleRate(), false);
formats.addElement(format);
formats.add(format);
}
if (inputFormat.getSampleSizeInBits() == 8
&& AudioFormat.Encoding.ALAW.equals(inputFormat.getEncoding())) {
Expand All @@ -225,18 +225,18 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getChannels(),
inputFormat.getChannels() * 2,
inputFormat.getSampleRate(), false);
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
inputFormat.getSampleRate(), 16,
inputFormat.getChannels(),
inputFormat.getChannels() * 2,
inputFormat.getSampleRate(), true);
formats.addElement(format);
formats.add(format);
}

AudioFormat[] formatArray = new AudioFormat[formats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = formats.elementAt(i);
formatArray[i] = formats.get(i);
}
return formatArray;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, 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
Expand All @@ -26,8 +26,8 @@
package com.sun.media.sound;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Vector;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
Expand Down Expand Up @@ -87,17 +87,17 @@ public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, Audio
// filter out targetEncoding from the old getOutputFormats( sourceFormat ) method

AudioFormat[] formats = getOutputFormats( sourceFormat );
Vector<AudioFormat> newFormats = new Vector<>();
ArrayList<AudioFormat> newFormats = new ArrayList<>();
for(int i=0; i<formats.length; i++ ) {
if( formats[i].getEncoding().equals( targetEncoding ) ) {
newFormats.addElement( formats[i] );
newFormats.add( formats[i] );
}
}

AudioFormat[] formatArray = new AudioFormat[newFormats.size()];

for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = newFormats.elementAt(i);
formatArray[i] = newFormats.get(i);
}

return formatArray;
Expand Down Expand Up @@ -167,7 +167,7 @@ private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInput
*/
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {

Vector<AudioFormat> formats = new Vector<>();
ArrayList<AudioFormat> formats = new ArrayList<>();
AudioFormat format;

int sampleSize = inputFormat.getSampleSizeInBits();
Expand All @@ -184,7 +184,7 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
false );
formats.addElement(format);
formats.add(format);
}

if ( AudioFormat.Encoding.PCM_UNSIGNED.equals(inputFormat.getEncoding()) ) {
Expand All @@ -196,7 +196,7 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
false );
formats.addElement(format);
formats.add(format);
}

} else if ( sampleSize==16 ) {
Expand All @@ -210,23 +210,23 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
true );
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
inputFormat.getSampleRate(),
inputFormat.getSampleSizeInBits(),
inputFormat.getChannels(),
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
false );
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_UNSIGNED,
inputFormat.getSampleRate(),
inputFormat.getSampleSizeInBits(),
inputFormat.getChannels(),
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
false );
formats.addElement(format);
formats.add(format);
}

if ( AudioFormat.Encoding.PCM_UNSIGNED.equals(inputFormat.getEncoding()) && isBigEndian ) {
Expand All @@ -238,23 +238,23 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
true );
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_UNSIGNED,
inputFormat.getSampleRate(),
inputFormat.getSampleSizeInBits(),
inputFormat.getChannels(),
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
false );
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
inputFormat.getSampleRate(),
inputFormat.getSampleSizeInBits(),
inputFormat.getChannels(),
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
false );
formats.addElement(format);
formats.add(format);
}

if ( AudioFormat.Encoding.PCM_SIGNED.equals(inputFormat.getEncoding()) && !isBigEndian ) {
Expand All @@ -266,23 +266,23 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
false );
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
inputFormat.getSampleRate(),
inputFormat.getSampleSizeInBits(),
inputFormat.getChannels(),
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
true );
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_UNSIGNED,
inputFormat.getSampleRate(),
inputFormat.getSampleSizeInBits(),
inputFormat.getChannels(),
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
true );
formats.addElement(format);
formats.add(format);
}

if ( AudioFormat.Encoding.PCM_UNSIGNED.equals(inputFormat.getEncoding()) && !isBigEndian ) {
Expand All @@ -294,35 +294,30 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
false );
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_UNSIGNED,
inputFormat.getSampleRate(),
inputFormat.getSampleSizeInBits(),
inputFormat.getChannels(),
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
true );
formats.addElement(format);
formats.add(format);
format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
inputFormat.getSampleRate(),
inputFormat.getSampleSizeInBits(),
inputFormat.getChannels(),
inputFormat.getFrameSize(),
inputFormat.getFrameRate(),
true );
formats.addElement(format);
formats.add(format);
}
}
AudioFormat[] formatArray;
AudioFormat[] formatArray = new AudioFormat[formats.size()];

synchronized(formats) {

formatArray = new AudioFormat[formats.size()];

for (int i = 0; i < formatArray.length; i++) {
for (int i = 0; i < formatArray.length; i++) {

formatArray[i] = formats.elementAt(i);
}
formatArray[i] = formats.get(i);
}

return formatArray;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, 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
Expand All @@ -26,8 +26,8 @@
package com.sun.media.sound;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Vector;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
Expand Down Expand Up @@ -193,7 +193,7 @@ private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInput
*/
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {

Vector<AudioFormat> formats = new Vector<>();
ArrayList<AudioFormat> formats = new ArrayList<>();
AudioFormat format;

if ((inputFormat.getSampleSizeInBits() == 16)
Expand All @@ -205,7 +205,7 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getChannels(),
inputFormat.getSampleRate(),
false );
formats.addElement(format);
formats.add(format);
}
if (inputFormat.getSampleSizeInBits() == 8
&& AudioFormat.Encoding.ULAW.equals(inputFormat.getEncoding())) {
Expand All @@ -214,19 +214,19 @@ private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
inputFormat.getChannels(),
inputFormat.getChannels() * 2,
inputFormat.getSampleRate(), false);
formats.addElement(format);
formats.add(format);

format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
inputFormat.getSampleRate(), 16,
inputFormat.getChannels(),
inputFormat.getChannels() * 2,
inputFormat.getSampleRate(), true);
formats.addElement(format);
formats.add(format);
}

AudioFormat[] formatArray = new AudioFormat[formats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = formats.elementAt(i);
formatArray[i] = formats.get(i);
}
return formatArray;
}
Expand Down
Loading