This commit is contained in:
Alejandro Murillo 2016-08-22 08:27:10 -07:00
commit 46babcb5b7
421 changed files with 13800 additions and 8886 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -26,6 +26,7 @@
package apple.security;
import java.security.*;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
* The Apple Security Provider.
@ -74,7 +75,7 @@ public final class AppleProvider extends Provider {
public AppleProvider() {
/* We are the Apple provider */
super("Apple", 9.0d, info);
super("Apple", PROVIDER_VER, info);
final Provider p = this;
AccessController.doPrivileged(new PrivilegedAction<Void>() {

View File

@ -108,6 +108,11 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
}
try {
this.prf = Mac.getInstance(prfAlgo);
// SunPKCS11 requires a non-empty PBE password
if (passwdBytes.length == 0 &&
this.prf.getProvider().getName().startsWith("SunPKCS11")) {
this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
}
} catch (NoSuchAlgorithmException nsae) {
// not gonna happen; re-throw just in case
InvalidKeySpecException ike = new InvalidKeySpecException();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -28,6 +28,7 @@ package com.sun.crypto.provider;
import java.security.AccessController;
import java.security.Provider;
import java.security.SecureRandom;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
@ -104,7 +105,7 @@ public final class SunJCE extends Provider {
public SunJCE() {
/* We are the "SunJCE" provider */
super("SunJCE", 9.0d, info);
super("SunJCE", PROVIDER_VER, info);
final String BLOCK_MODES = "ECB|CBC|PCBC|CTR|CTS|CFB|OFB" +
"|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64" +

View File

@ -38,6 +38,32 @@ import java.util.HashSet;
*/
class GenerateJLIClassesHelper {
static byte[] generateBasicFormsClassBytes(String className) {
ArrayList<LambdaForm> forms = new ArrayList<>();
ArrayList<String> names = new ArrayList<>();
HashSet<String> dedupSet = new HashSet<>();
for (LambdaForm.BasicType type : LambdaForm.BasicType.values()) {
LambdaForm zero = LambdaForm.zeroForm(type);
String name = zero.kind.defaultLambdaName
+ "_" + zero.returnType().basicTypeChar();
if (dedupSet.add(name)) {
names.add(name);
forms.add(zero);
}
LambdaForm identity = LambdaForm.identityForm(type);
name = identity.kind.defaultLambdaName
+ "_" + identity.returnType().basicTypeChar();
if (dedupSet.add(name)) {
names.add(name);
forms.add(identity);
}
}
return generateCodeBytesForLFs(className,
names.toArray(new String[0]),
forms.toArray(new LambdaForm[0]));
}
static byte[] generateDirectMethodHandleHolderClassBytes(String className,
MethodType[] methodTypes, int[] types) {
LambdaForm[] forms = new LambdaForm[methodTypes.length];

View File

@ -624,6 +624,11 @@ class InvokerBytecodeGenerator {
return resolveFrom(name, invokerType, DelegatingMethodHandle.Holder.class);
}
case DELEGATE: return resolveFrom(name, invokerType, DelegatingMethodHandle.Holder.class);
case ZERO: // fall-through
case IDENTITY: {
name = name + "_" + form.returnType().basicTypeChar();
return resolveFrom(name, invokerType, LambdaForm.Holder.class);
}
case DIRECT_INVOKE_INTERFACE: // fall-through
case DIRECT_INVOKE_SPECIAL: // fall-through
case DIRECT_INVOKE_STATIC: // fall-through

View File

@ -270,6 +270,8 @@ class LambdaForm {
enum Kind {
GENERIC(""),
ZERO("zero"),
IDENTITY("identity"),
BOUND_REINVOKER("BMH.reinvoke"),
REINVOKER("MH.reinvoke"),
DELEGATE("MH.delegate"),
@ -1848,7 +1850,7 @@ class LambdaForm {
// bootstrap dependency on this method in case we're interpreting LFs
if (isVoid) {
Name[] idNames = new Name[] { argument(0, L_TYPE) };
idForm = new LambdaForm(idMem.getName(), 1, idNames, VOID_RESULT);
idForm = new LambdaForm(idMem.getName(), 1, idNames, VOID_RESULT, Kind.IDENTITY);
idForm.compileToBytecode();
idFun = new NamedFunction(idMem, SimpleMethodHandle.make(idMem.getInvocationType(), idForm));
@ -1856,15 +1858,17 @@ class LambdaForm {
zeFun = idFun;
} else {
Name[] idNames = new Name[] { argument(0, L_TYPE), argument(1, type) };
idForm = new LambdaForm(idMem.getName(), 2, idNames, 1);
idForm = new LambdaForm(idMem.getName(), 2, idNames, 1, Kind.IDENTITY);
idForm.compileToBytecode();
idFun = new NamedFunction(idMem, SimpleMethodHandle.make(idMem.getInvocationType(), idForm));
idFun = new NamedFunction(idMem, MethodHandleImpl.makeIntrinsic(
idMem.getInvocationType(), idForm, MethodHandleImpl.Intrinsic.IDENTITY));
Object zeValue = Wrapper.forBasicType(btChar).zero();
Name[] zeNames = new Name[] { argument(0, L_TYPE), new Name(idFun, zeValue) };
zeForm = new LambdaForm(zeMem.getName(), 1, zeNames, 1);
zeForm = new LambdaForm(zeMem.getName(), 1, zeNames, 1, Kind.ZERO);
zeForm.compileToBytecode();
zeFun = new NamedFunction(zeMem, SimpleMethodHandle.make(zeMem.getInvocationType(), zeForm));
zeFun = new NamedFunction(zeMem, MethodHandleImpl.makeIntrinsic(
zeMem.getInvocationType(), zeForm, MethodHandleImpl.Intrinsic.ZERO));
}
LF_zero[ord] = zeForm;
@ -1921,8 +1925,17 @@ class LambdaForm {
if (USE_PREDEFINED_INTERPRET_METHODS)
computeInitialPreparedForms();
NamedFunction.initializeInvokers();
// The Holder class will contain pre-generated forms resolved
// using MemberName.getFactory(). However, that doesn't initialize the
// class, which subtly breaks inlining etc. By forcing
// initialization of the Holder class we avoid these issues.
UNSAFE.ensureClassInitialized(Holder.class);
}
/* Placeholder class for zero and identity forms generated ahead of time */
final class Holder {}
// The following hack is necessary in order to suppress TRACE_INTERPRETER
// during execution of the static initializes of this class.
// Turning on TRACE_INTERPRETER too early will cause

View File

@ -1739,6 +1739,12 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
return GenerateJLIClassesHelper
.generateConcreteBMHClassBytes(types);
}
@Override
public byte[] generateBasicFormsClassBytes(final String className) {
return GenerateJLIClassesHelper
.generateBasicFormsClassBytes(className);
}
});
}
@ -1934,7 +1940,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
* @return whether the counter has reached the limit.
*/
static boolean countedLoopPredicate(int counter, int limit) {
return counter <= limit;
return counter < limit;
}
/**

View File

@ -4583,7 +4583,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* // assume MH_decrement is a handle to x-1 of type int
* MethodHandle[]
* indexVar = {start, MH_increment}, // i = start; i = i+1
* loopLimit = {end, null, MH_lessThan, returnVar }, // i<end
* loopLimit = {end, null,
* filterArgument(MH_lessThan, 0, MH_decrement), returnVar}, // i-1<end
* bodyClause = {init,
* filterArgument(dropArguments(body, 1, int.class), 0, MH_decrement}; // v = body(i-1, v)
* return loop(indexVar, loopLimit, bodyClause);
@ -4619,12 +4620,12 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
MethodHandle actualBody = body == null ? dropArguments(defaultResultHandle, 0, int.class) : body;
MethodHandle returnVar = dropArguments(defaultResultHandle, 0, int.class, int.class);
MethodHandle actualEnd = end == null ? constant(int.class, 0) : end;
MethodHandle decr = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_decrementCounter);
MethodHandle[] indexVar = {start, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopStep)};
MethodHandle[] loopLimit = {actualEnd, null,
MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopPred), returnVar};
MethodHandle[] bodyClause = {actualInit,
filterArgument(dropArguments(actualBody, 1, int.class), 0,
MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_decrementCounter))};
filterArgument(MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopPred), 0, decr),
returnVar};
MethodHandle[] bodyClause = {actualInit, filterArgument(dropArguments(actualBody, 1, int.class), 0, decr)};
return loop(indexVar, loopLimit, bodyClause);
}

View File

@ -29,11 +29,9 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -49,6 +47,7 @@ import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import jdk.internal.loader.ClassLoaderValue;
import sun.reflect.misc.ReflectUtil;
import sun.security.action.GetPropertyAction;
import sun.security.util.SecurityConstants;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -50,9 +50,24 @@ public abstract class AuthProvider extends Provider {
* @param name the provider name.
* @param version the provider version number.
* @param info a description of the provider and its services.
* @deprecated use {@link #AuthProvider(String, String, String)} instead.
*/
@Deprecated(since="9")
protected AuthProvider(String name, double version, String info) {
super(name, version, info);
super(name, Double.toString(version), info);
}
/**
* Constructs a provider with the specified name, version string,
* and information.
*
* @param name the provider name.
* @param versionStr the provider version string.
* @param info a description of the provider and its services.
* @since 9
*/
protected AuthProvider(String name, String versionStr, String info) {
super(name, versionStr, info);
}
/**

View File

@ -67,14 +67,14 @@ import java.util.function.Function;
* <tr><td>{@code Provider.id name}</td>
* <td>{@code String.valueOf(provider.getName())}</td>
* <tr><td>{@code Provider.id version}</td>
* <td>{@code String.valueOf(provider.getVersion())}</td>
* <td>{@code String.valueOf(provider.getVersionStr())}</td>
* <tr><td>{@code Provider.id info}</td>
<td>{@code String.valueOf(provider.getInfo())}</td>
* <tr><td>{@code Provider.id className}</td>
* <td>{@code provider.getClass().getName()}</td>
* </table>
*
* <p>Each provider has a name and a version number. A provider normally
* <p>Each provider has a name and a version string. A provider normally
* identifies itself with a file named {@code java.security.Provider}
* in the resource directory {@code META-INF/services}.
* Security providers are looked up via the {@link ServiceLoader} mechanism
@ -102,11 +102,10 @@ import java.util.function.Function;
public abstract class Provider extends Properties {
// Declare serialVersionUID to be compatible with JDK1.1
static final long serialVersionUID = -4298000515446427739L;
private static final long serialVersionUID = -4298000515446427739L;
private static final sun.security.util.Debug debug =
sun.security.util.Debug.getInstance
("provider", "Provider");
sun.security.util.Debug.getInstance("provider", "Provider");
/**
* The provider name.
@ -129,6 +128,12 @@ public abstract class Provider extends Properties {
*/
private double version;
/**
* The provider version string.
*
* @serial
*/
private String versionStr;
private transient Set<Map.Entry<Object,Object>> entrySet = null;
private transient int entrySetCallCount = 0;
@ -174,19 +179,83 @@ public abstract class Provider extends Properties {
}
}
private static double parseVersionStr(String s) {
try {
int firstDotIdx = s.indexOf('.');
int nextDotIdx = s.indexOf('.', firstDotIdx + 1);
if (nextDotIdx != -1) {
s = s.substring(0, nextDotIdx);
}
int endIdx = s.indexOf('-');
if (endIdx > 0) {
s = s.substring(0, endIdx);
}
endIdx = s.indexOf('+');
if (endIdx > 0) {
s = s.substring(0, endIdx);
}
return Double.parseDouble(s);
} catch (NullPointerException | NumberFormatException e) {
return 0d;
}
}
/**
* Constructs a provider with the specified name, version number,
* and information.
* and information. Calling this constructor is equivalent to call the
* {@link #Provider(String, String, String)} with {@code name}
* name, {@code Double.toString(version)}, and {@code info}.
*
* @param name the provider name.
*
* @param version the provider version number.
*
* @param info a description of the provider and its services.
*
* @deprecated use {@link #Provider(String, String, String)} instead.
*/
@Deprecated(since="9")
protected Provider(String name, double version, String info) {
this.name = name;
this.version = version;
this.versionStr = Double.toString(version);
this.info = info;
putId();
initialized = true;
}
/**
* Constructs a provider with the specified name, version string,
* and information.
*
* <p>The version string contains a version number optionally followed
* by other information separated by one of the characters of '+', '-'.
*
* The format for the version number is:
*
* <blockquote><pre>
* ^[0-9]+(\.[0-9]+)*
* </pre></blockquote>
*
* <p>In order to return the version number in a double, when there are
* more than two components (separated by '.' as defined above), only
* the first two components are retained. The resulting string is then
* passed to {@link Double#valueOf(String)} to generate version number,
* i.e. {@link #getVersion}.
* <p>If the conversion failed, value 0 will be used.
*
* @param name the provider name.
*
* @param versionStr the provider version string.
*
* @param info a description of the provider and its services.
*
* @since 9
*/
protected Provider(String name, String versionStr, String info) {
this.name = name;
this.versionStr = versionStr;
this.version = parseVersionStr(versionStr);
this.info = info;
putId();
initialized = true;
@ -250,11 +319,25 @@ public abstract class Provider extends Properties {
* Returns the version number for this provider.
*
* @return the version number for this provider.
*
* @deprecated use {@link #getVersionStr} instead.
*/
@Deprecated(since="9")
public double getVersion() {
return version;
}
/**
* Returns the version string for this provider.
*
* @return the version string for this provider.
*
* @since 9
*/
public String getVersionStr() {
return versionStr;
}
/**
* Returns a human-readable description of the provider and its
* services. This may return an HTML page, with relevant links.
@ -266,14 +349,14 @@ public abstract class Provider extends Properties {
}
/**
* Returns a string with the name and the version number
* Returns a string with the name and the version string
* of this provider.
*
* @return the string with the name and the version number
* @return the string with the name and the version string
* for this provider.
*/
public String toString() {
return name + " version " + version;
return name + " version " + versionStr;
}
/*
@ -787,11 +870,21 @@ public abstract class Provider extends Properties {
private void putId() {
// note: name and info may be null
super.put("Provider.id name", String.valueOf(name));
super.put("Provider.id version", String.valueOf(version));
super.put("Provider.id version", String.valueOf(versionStr));
super.put("Provider.id info", String.valueOf(info));
super.put("Provider.id className", this.getClass().getName());
}
/**
* Reads the {@code ObjectInputStream} for the default serializable fields.
* If the serialized field {@code versionStr} is found in the STREAM FIELDS,
* its String value will be used to populate both the version string and
* version number. If {@code versionStr} is not found, but {@code version}
* is, then its double value will be used to populate both fields.
*
* @param in the {@code ObjectInputStream} to read
* @serial
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
Map<Object,Object> copy = new HashMap<>();
@ -800,6 +893,13 @@ public abstract class Provider extends Properties {
}
defaults = null;
in.defaultReadObject();
if (this.versionStr == null) {
// set versionStr based on version when not found in serialized bytes
this.versionStr = Double.toString(this.version);
} else {
// otherwise, set version based on versionStr
this.version = parseVersionStr(this.versionStr);
}
implClear();
initialized = true;
putAll(copy);
@ -1913,7 +2013,5 @@ public abstract class Provider extends Properties {
return provider.getName() + ": " + type + "." + algorithm
+ " -> " + className + aString + attrs + "\r\n";
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
@ -952,6 +952,9 @@ public class Date
* without affecting its internal state.
*/
static final long getMillisOf(Date date) {
if (date.getClass() != Date.class) {
return date.getTime();
}
if (date.cdate == null || date.cdate.isNormalized()) {
return date.fastTime;
}

View File

@ -295,7 +295,13 @@ public final class Collectors {
public static <T>
Collector<T, ?, Set<T>> toSet() {
return new CollectorImpl<>((Supplier<Set<T>>) HashSet::new, Set::add,
(left, right) -> { left.addAll(right); return left; },
(left, right) -> {
if (left.size() < right.size()) {
right.addAll(left); return right;
} else {
left.addAll(right); return left;
}
},
CH_UNORDERED_ID);
}

View File

@ -53,6 +53,7 @@ var FileSystems = Java.type("java.nio.file.FileSystems");
var Files = Java.type("java.nio.file.Files");
var System = Java.type("java.lang.System");
var URI = Java.type("java.net.URI");
var Collections = Java.type("java.util.Collections");
// JavaFX classes used
var StackPane = Java.type("javafx.scene.layout.StackPane");
@ -100,7 +101,7 @@ function getJrtFileSystem() {
print("did you miss specifying jrt-fs.jar with -cp option?");
usage();
}
return FileSystems.newFileSystem(uri, null, cls.classLoader);
return FileSystems.newFileSystem(uri, Collections.emptyMap(), cls.classLoader);
}
}

View File

@ -34,7 +34,6 @@
* but also compiled and delivered as part of the jrtfs.jar to support access
* to the jimage file provided by the shipped JDK by tools running on JDK 8.
*/
*/
// classes used
var Files = Java.type("java.nio.file.Files");

View File

@ -21,12 +21,12 @@
* questions.
*/
package java.lang.reflect;
package jdk.internal.loader;
import jdk.internal.loader.BootLoader;
import jdk.internal.misc.JavaLangAccess;
import jdk.internal.misc.SharedSecrets;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.Iterator;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@ -40,7 +40,7 @@ import java.util.function.Supplier;
* @param <CLV> the type of concrete ClassLoaderValue (this type)
* @param <V> the type of values associated with ClassLoaderValue
*/
abstract class AbstractClassLoaderValue<CLV extends AbstractClassLoaderValue<CLV, V>, V> {
public abstract class AbstractClassLoaderValue<CLV extends AbstractClassLoaderValue<CLV, V>, V> {
/**
* Sole constructor.
@ -377,7 +377,7 @@ abstract class AbstractClassLoaderValue<CLV extends AbstractClassLoaderValue<CLV
* @param <K> the type of {@link #key()} component contained in the
* sub-ClassLoaderValue.
*/
final class Sub<K> extends AbstractClassLoaderValue<Sub<K>, V> {
public final class Sub<K> extends AbstractClassLoaderValue<Sub<K>, V> {
private final K key;

View File

@ -21,7 +21,7 @@
* questions.
*/
package java.lang.reflect;
package jdk.internal.loader;
import java.util.Objects;
import java.util.function.BiFunction;
@ -74,7 +74,7 @@ import java.util.function.BiFunction;
* @author Peter Levart
* @since 9
*/
final class ClassLoaderValue<V>
public final class ClassLoaderValue<V>
extends AbstractClassLoaderValue<ClassLoaderValue<V>, V> {
/**

View File

@ -72,4 +72,10 @@ public interface JavaLangInvokeAccess {
*/
Map.Entry<String, byte[]> generateConcreteBMHClassBytes(
final String types);
/**
* Returns a {@code byte[]} containing the bytecode for a class implementing
* the zero and identity forms of all {@code LambdaForm.BasicType}s.
*/
byte[] generateBasicFormsClassBytes(final String className);
}

View File

@ -76,7 +76,7 @@ public final class ProviderList {
// dummy provider object to use during initialization
// used to avoid explicit null checks in various places
private static final Provider EMPTY_PROVIDER =
new Provider("##Empty##", 1.0d, "initialization in progress") {
new Provider("##Empty##", "1.0", "initialization in progress") {
private static final long serialVersionUID = 1151354171352296389L;
// override getService() to return null slightly faster
public Service getService(String type, String algorithm) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -28,6 +28,7 @@ package sun.security.provider;
import java.security.*;
import static sun.security.provider.ByteArrayAccess.*;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
* The MD4 class is used to compute an MD4 message digest over a given
@ -65,7 +66,8 @@ public final class MD4 extends DigestBase {
private static final Provider md4Provider;
static {
md4Provider = new Provider("MD4Provider", 9.0d, "MD4 MessageDigest") {
md4Provider = new Provider("MD4Provider", PROVIDER_VER,
"MD4 MessageDigest") {
private static final long serialVersionUID = -8850464997518327965L;
};
AccessController.doPrivileged(new PrivilegedAction<Void>() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -29,6 +29,8 @@ import java.util.*;
import java.security.*;
import sun.security.action.PutAllAction;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
* The SUN Security Provider.
@ -47,7 +49,7 @@ public final class Sun extends Provider {
public Sun() {
/* We are the SUN provider */
super("SUN", 9.0d, INFO);
super("SUN", PROVIDER_VER, INFO);
// if there is no security manager installed, put directly into
// the provider. Otherwise, create a temporary map and use a

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -31,6 +31,8 @@ import java.security.*;
import sun.security.action.PutAllAction;
import sun.security.rsa.SunRsaSignEntries;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
* Provider used for verification of signed JAR files *if* the Sun and
@ -61,7 +63,7 @@ public final class VerificationProvider extends Provider {
}
public VerificationProvider() {
super("SunJarVerification", 9.0d, "Jar Verification Provider");
super("SunJarVerification", PROVIDER_VER, "Jar Verification Provider");
// register all algorithms normally registered by the Sun and SunRsaSign
// providers, but only if they are missing
if (ACTIVE == false) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -30,6 +30,7 @@ import java.util.*;
import java.security.*;
import sun.security.action.PutAllAction;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
* Provider class for the RSA signature provider. Supports RSA keyfactory,
@ -43,7 +44,7 @@ public final class SunRsaSign extends Provider {
private static final long serialVersionUID = 866040293550393045L;
public SunRsaSign() {
super("SunRsaSign", 9.0d, "Sun RSA signature provider");
super("SunRsaSign", PROVIDER_VER, "Sun RSA signature provider");
// if there is no security manager installed, put directly into
// the provider. Otherwise, create a temporary map and use a

View File

@ -44,6 +44,7 @@ import sun.security.jca.ProviderList;
import sun.security.util.ECUtil;
import static sun.security.ssl.SunJSSE.cryptoProvider;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
* This class contains a few static methods for interaction with the JCA/JCE
@ -90,7 +91,7 @@ final class JsseJce {
private static final long serialVersionUID = -3284138292032213752L;
SunCertificates(final Provider p) {
super("SunCertificates", 9.0d, "SunJSSE internal");
super("SunCertificates", PROVIDER_VER, "SunJSSE internal");
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {

View File

@ -27,6 +27,7 @@
package sun.security.ssl;
import java.security.*;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
* The JSSE provider.
@ -104,7 +105,7 @@ public abstract class SunJSSE extends java.security.Provider {
// standard constructor
protected SunJSSE() {
super("SunJSSE", 9.0d, info);
super("SunJSSE", PROVIDER_VER, info);
subclassCheck();
if (Boolean.TRUE.equals(fips)) {
throw new ProviderException
@ -132,7 +133,7 @@ public abstract class SunJSSE extends java.security.Provider {
private SunJSSE(java.security.Provider cryptoProvider,
String providerName) {
super("SunJSSE", 9.0d, fipsInfo + providerName + ")");
super("SunJSSE", PROVIDER_VER, fipsInfo + providerName + ")");
subclassCheck();
if (cryptoProvider == null) {
// Calling Security.getProvider() will cause other providers to be

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -33,6 +33,7 @@ import java.security.Permission;
import java.security.BasicPermission;
import java.security.SecurityPermission;
import java.security.AllPermission;
import sun.security.action.GetPropertyAction;
/**
* Permission constants and string constants used to create permissions
@ -145,4 +146,7 @@ public final class SecurityConstants {
// java.lang.SecurityManager
public static final SocketPermission LOCAL_LISTEN_PERMISSION =
new SocketPermission("localhost:0", SOCKET_LISTEN_ACTION);
public static final String PROVIDER_VER =
GetPropertyAction.privilegedGetProperty("java.specification.version");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
@ -143,8 +143,8 @@ public abstract class LocaleProviderAdapter {
defaultLocaleProviderAdapter = Type.CLDR;
if (!typeList.isEmpty()) {
// bona fide preference exists
if (!typeList.contains(Type.CLDR)) {
// Append FALLBACK as the last resort.
if (!(typeList.contains(Type.CLDR) || (typeList.contains(Type.JRE)))) {
// Append FALLBACK as the last resort when no ResourceBundleBasedAdapter is available.
typeList.add(Type.FALLBACK);
defaultLocaleProviderAdapter = Type.FALLBACK;
}

View File

@ -124,7 +124,9 @@ public class AquaProgressBarUI extends ProgressBarUI implements ChangeListener,
if (!progressBar.isIndeterminate()) return;
stopAnimationTimer();
// start the animation thread
startAnimationTimer();
if (progressBar.isDisplayable()) {
startAnimationTimer();
}
}
if ("JProgressBar.style".equals(prop)) {
@ -141,7 +143,9 @@ public class AquaProgressBarUI extends ProgressBarUI implements ChangeListener,
public void ancestorAdded(final AncestorEvent e) {
if (!progressBar.isIndeterminate()) return;
startAnimationTimer();
if (progressBar.isDisplayable()) {
startAnimationTimer();
}
}
public void ancestorMoved(final AncestorEvent e) { }

View File

@ -807,6 +807,18 @@ AWT_ASSERT_APPKIT_THREAD;
- (void)sendEvent:(NSEvent *)event {
if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) {
// Move parent windows to front and make sure that a child window is displayed
// in front of its nearest parent.
if (self.ownerWindow != nil) {
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
if (platformWindow != NULL) {
static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V");
JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings);
(*env)->DeleteLocalRef(env, platformWindow);
}
}
[self orderChildWindows:YES];
NSPoint p = [NSEvent mouseLocation];
NSRect frame = [self.nsWindow frame];
@ -1159,6 +1171,16 @@ JNF_COCOA_ENTER(env);
NSWindow *nsWindow = OBJC(windowPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[nsWindow orderBack:nil];
// Order parent windows
AWTWindow *awtWindow = (AWTWindow*)[nsWindow delegate];
while (awtWindow.ownerWindow != nil) {
awtWindow = awtWindow.ownerWindow;
if ([AWTWindow isJavaPlatformWindowVisible:awtWindow.nsWindow]) {
[awtWindow.nsWindow orderBack:nil];
}
}
// Order child windows
[(AWTWindow*)[nsWindow delegate] orderChildWindows:NO];
}];
JNF_COCOA_EXIT(env);

View File

@ -47,7 +47,7 @@ public abstract class TIFFColorConverter {
* @throws NullPointerException if {@code result} is
* {@code null}.
* @throws ArrayIndexOutOfBoundsException if
* {@code result.length&nbsp;&lt;&nbsp;3}.
* {@code result.length < 3}.
*/
public abstract void fromRGB(float r, float g, float b, float[] result);
@ -63,7 +63,7 @@ public abstract class TIFFColorConverter {
* @throws NullPointerException if {@code rgb} is
* {@code null}.
* @throws ArrayIndexOutOfBoundsException if
* {@code rgb.length&nbsp;&lt;&nbsp;3}.
* {@code rgb.length < 3}.
*/
public abstract void toRGB(float x0, float x1, float x2, float[] rgb);
}

View File

@ -353,7 +353,7 @@ public abstract class TIFFDecompressor {
* <p> The pixels in the source region to be copied are
* those with X coordinates of the form {@code activeSrcMinX +
* k*subsampleX}, where {@code k} is an integer such
* that {@code 0 &le; k &lt; dstWidth}.
* that {@code 0 <= k < dstWidth}.
*/
protected int activeSrcMinX;
@ -365,7 +365,7 @@ public abstract class TIFFDecompressor {
* <p> The pixels in the source region to be copied are
* those with Y coordinates of the form {@code activeSrcMinY +
* k*subsampleY}, where {@code k} is an integer such
* that {@code 0 &le; k &lt; dstHeight}.
* that {@code 0 <= k < dstHeight}.
*/
protected int activeSrcMinY;

View File

@ -49,6 +49,45 @@ public class TIFFIFD extends TIFFDirectory {
private long stripOrTileOffsetsPosition = -1;
private long lastPosition = -1;
/**
* Converts a {@code TIFFDirectory} to a {@code TIFFIFD}.
*/
public static TIFFIFD getDirectoryAsIFD(TIFFDirectory dir) {
if(dir instanceof TIFFIFD) {
return (TIFFIFD)dir;
}
TIFFIFD ifd = new TIFFIFD(Arrays.asList(dir.getTagSets()),
dir.getParentTag());
TIFFField[] fields = dir.getTIFFFields();
int numFields = fields.length;
for(int i = 0; i < numFields; i++) {
TIFFField f = fields[i];
TIFFTag tag = f.getTag();
if(tag.isIFDPointer()) {
TIFFDirectory subDir = null;
if (f.hasDirectory()) {
subDir = f.getDirectory();
} else if (f.getData() instanceof TIFFDirectory) {
subDir = (TIFFDirectory)f.getData();
}
if (subDir != null) {
TIFFDirectory subIFD = getDirectoryAsIFD(subDir);
f = new TIFFField(tag, f.getType(), (long)f.getCount(),
subIFD);
} else {
f = null;
}
}
if (f != null) {
ifd.addTIFFField(f);
}
}
return ifd;
}
public static TIFFTag getTag(int tagNumber, List<TIFFTagSet> tagSets) {
Iterator<TIFFTagSet> iter = tagSets.iterator();
while (iter.hasNext()) {
@ -704,7 +743,7 @@ public class TIFFIFD extends TIFFDirectory {
pos = nextSpace;
if (tag.isIFDPointer() && f.hasDirectory()) {
TIFFIFD subIFD = (TIFFIFD)f.getDirectory();
TIFFIFD subIFD = getDirectoryAsIFD(f.getDirectory());
subIFD.writeToStream(stream);
nextSpace = subIFD.lastPosition;
} else {

View File

@ -132,7 +132,7 @@ public class TIFFImageMetadata extends IIOMetadata {
if (tag == null) {
node = f.getAsNativeNode();
} else if (tag.isIFDPointer() && f.hasDirectory()) {
TIFFIFD subIFD = (TIFFIFD)f.getDirectory();
TIFFIFD subIFD = TIFFIFD.getDirectoryAsIFD(f.getDirectory());
// Recurse
node = getIFDAsTree(subIFD, tag.getName(), tag.getNumber());
@ -1465,8 +1465,14 @@ public class TIFFImageMetadata extends IIOMetadata {
String className = st.nextToken();
Object o = null;
Class<?> setClass = null;
try {
Class<?> setClass = Class.forName(className);
ClassLoader cl = TIFFImageMetadata.class.getClassLoader();
setClass = Class.forName(className, false, cl);
if (!TIFFTagSet.class.isAssignableFrom(setClass)) {
fatal(node, "TagSets in IFD must be subset of"
+ " TIFFTagSet class");
}
Method getInstanceMethod =
setClass.getMethod("getInstance", (Class[])null);
o = getInstanceMethod.invoke(null, (Object[])null);

View File

@ -35,6 +35,7 @@ import java.awt.image.ComponentColorModel;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.awt.image.SampleModel;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteOrder;
import java.util.ArrayList;
@ -189,8 +190,8 @@ public class TIFFImageReader extends ImageReader {
// Seek to start of first IFD
long offset = stream.readUnsignedInt();
imageStartPosition.add(Long.valueOf(offset));
stream.seek(offset);
imageStartPosition.add(Long.valueOf(offset));
} catch (IOException e) {
throw new IIOException("I/O error reading header!", e);
}
@ -201,10 +202,10 @@ public class TIFFImageReader extends ImageReader {
private int locateImage(int imageIndex) throws IIOException {
readHeader();
try {
// Find closest known index
int index = Math.min(imageIndex, imageStartPosition.size() - 1);
// Find closest known index
int index = Math.min(imageIndex, imageStartPosition.size() - 1);
try {
// Seek to that position
Long l = imageStartPosition.get(index);
stream.seek(l.longValue());
@ -212,6 +213,11 @@ public class TIFFImageReader extends ImageReader {
// Skip IFDs until at desired index or last image found
while (index < imageIndex) {
int count = stream.readUnsignedShort();
// If zero-entry IFD, decrement the index and exit the loop
if (count == 0) {
imageIndex = index > 0 ? index - 1 : 0;
break;
}
stream.skipBytes(12 * count);
long offset = stream.readUnsignedInt();
@ -219,12 +225,17 @@ public class TIFFImageReader extends ImageReader {
return index;
}
imageStartPosition.add(Long.valueOf(offset));
stream.seek(offset);
imageStartPosition.add(Long.valueOf(offset));
++index;
}
} catch (IOException e) {
throw new IIOException("Couldn't seek!", e);
} catch (EOFException eofe) {
forwardWarningMessage("Ignored " + eofe);
// Ran off the end of stream: decrement index
imageIndex = index > 0 ? index - 1 : 0;
} catch (IOException ioe) {
throw new IIOException("Couldn't seek!", ioe);
}
if (currIndex != imageIndex) {

View File

@ -1478,7 +1478,7 @@ public class TIFFImageWriter extends ImageWriter {
(ExifParentTIFFTagSet.TAG_EXIF_IFD_POINTER);
if(f != null && f.hasDirectory()) {
// Retrieve the Exif IFD.
exifIFD = (TIFFIFD)f.getDirectory();
exifIFD = TIFFIFD.getDirectoryAsIFD(f.getDirectory());
} else if(isPrimaryIFD) {
// Create the Exif IFD.
List<TIFFTagSet> exifTagSets = new ArrayList<TIFFTagSet>(1);
@ -3622,6 +3622,8 @@ public class TIFFImageWriter extends ImageWriter {
streamMetadata = null;
imageMetadata = null;
isRescaling = false;
isWritingSequence = false;
isWritingEmpty = false;
isInsertingEmpty = false;

View File

@ -49,7 +49,8 @@ public abstract class TIFFMetadataFormat implements IIOMetadataFormat {
}
try {
ResourceBundle bundle =
ResourceBundle.getBundle(resourceBaseName, locale);
ResourceBundle.getBundle(resourceBaseName, locale,
this.getClass().getModule());
return bundle.getString(key);
} catch (MissingResourceException e) {
return null;

View File

@ -657,7 +657,6 @@ class XPStyle {
protected void paintToImage(Component c, Image image, Graphics g,
int w, int h, Object[] args) {
boolean accEnabled = false;
Skin skin = (Skin)args[0];
Part part = skin.part;
State state = (State)args[1];
@ -668,6 +667,8 @@ class XPStyle {
c = skin.component;
}
BufferedImage bi = (BufferedImage)image;
w = bi.getWidth();
h = bi.getHeight();
WritableRaster raster = bi.getRaster();
DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();

View File

@ -32,7 +32,6 @@ import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineUnavailableException;
/**
* AbstractDataLine
*
@ -147,36 +146,35 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
}
}
public final void open(AudioFormat format) throws LineUnavailableException {
open(format, AudioSystem.NOT_SPECIFIED);
}
/**
* This implementation always returns 0.
*/
@Override
public int available() {
return 0;
}
/**
* This implementation does nothing.
*/
@Override
public void drain() {
if (Printer.trace) Printer.trace("AbstractDataLine: drain");
}
/**
* This implementation does nothing.
*/
@Override
public void flush() {
if (Printer.trace) Printer.trace("AbstractDataLine: flush");
}
@Override
public final void start() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized(mixer) {
@ -200,7 +198,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< "+getClass().getName()+".start() - AbstractDataLine");
}
@Override
public final void stop() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
@ -245,15 +243,17 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
// in MixerSourceLine and MixerClip, and I want to touch as little
// code as possible to change isStarted() back to isRunning().
@Override
public final boolean isRunning() {
return started;
}
@Override
public final boolean isActive() {
return active;
}
@Override
public final long getMicrosecondPosition() {
long microseconds = getLongFramePosition();
@ -263,12 +263,12 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
return microseconds;
}
@Override
public final AudioFormat getFormat() {
return format;
}
@Override
public final int getBufferSize() {
return bufferSize;
}
@ -283,11 +283,11 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
/**
* This implementation returns AudioSystem.NOT_SPECIFIED.
*/
@Override
public final float getLevel() {
return (float)AudioSystem.NOT_SPECIFIED;
}
// HELPER METHODS
/**
@ -317,19 +317,12 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
synchronized (this) {
//if (Printer.debug) Printer.debug(" AbstractDataLine: setActive: this.active: " + this.active);
//if (Printer.debug) Printer.debug(" active: " + active);
if (this.active != active) {
this.active = active;
//sendEvents = true;
}
}
//if (Printer.debug) Printer.debug(" this.active: " + this.active);
//if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents);
// $$kk: 11.19.99: take ACTIVE / INACTIVE / EOM events out;
// putting them in is technically an API change.
// do not generate ACTIVE / INACTIVE events for now
@ -356,18 +349,12 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
synchronized (this) {
//if (Printer.debug) Printer.debug(" AbstractDataLine: setStarted: this.started: " + this.started);
//if (Printer.debug) Printer.debug(" started: " + started);
if (this.started != started) {
this.started = started;
sendEvents = true;
}
}
//if (Printer.debug) Printer.debug(" this.started: " + this.started);
//if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents);
if (sendEvents) {
if (started) {
@ -379,7 +366,6 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< AbstractDataLine: setStarted completed");
}
/**
* This method generates a STOP event and sets the started state to false.
* It is here for historic reasons when an EOM event existed.
@ -393,9 +379,6 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< AbstractDataLine: setEOM() completed");
}
// OVERRIDES OF ABSTRACT LINE METHODS
/**
@ -404,6 +387,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
* line is open, this should return quietly because the values
* requested will match the current ones.
*/
@Override
public final void open() throws LineUnavailableException {
if (Printer.trace) Printer.trace("> "+getClass().getName()+".open() - AbstractDataLine");
@ -413,11 +397,11 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< "+getClass().getName()+".open() - AbstractDataLine");
}
/**
* This should also stop the line. The closed line should not be running or active.
* After we close the line, we reset the format and buffer size to the defaults.
*/
@Override
public final void close() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized (mixer) {
@ -445,12 +429,6 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< "+getClass().getName()+".close() - in AbstractDataLine");
}
// IMPLEMENTATIONS OF ABSTRACT LINE ABSTRACE METHODS
// ABSTRACT METHODS
abstract void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException;
abstract void implClose();

View File

@ -36,7 +36,6 @@ import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineUnavailableException;
/**
* AbstractLine
*
@ -72,19 +71,19 @@ abstract class AbstractLine implements Line {
this.controls = controls;
}
// LINE METHODS
@Override
public final Line.Info getLineInfo() {
return info;
}
@Override
public final boolean isOpen() {
return open;
}
@Override
public final void addLineListener(LineListener listener) {
synchronized(listeners) {
if ( ! (listeners.contains(listener)) ) {
@ -93,22 +92,22 @@ abstract class AbstractLine implements Line {
}
}
/**
* Removes an audio listener.
* @param listener listener to remove
*/
@Override
public final void removeLineListener(LineListener listener) {
listeners.removeElement(listener);
}
/**
* Obtains the set of controls supported by the
* line. If no controls are supported, returns an
* array of length 0.
* @return control set
*/
@Override
public final Control[] getControls() {
Control[] returnedArray = new Control[controls.length];
@ -119,7 +118,7 @@ abstract class AbstractLine implements Line {
return returnedArray;
}
@Override
public final boolean isControlSupported(Control.Type controlType) {
// protect against a NullPointerException
if (controlType == null) {
@ -135,7 +134,7 @@ abstract class AbstractLine implements Line {
return false;
}
@Override
public final Control getControl(Control.Type controlType) {
// protect against a NullPointerException
if (controlType != null) {
@ -150,10 +149,8 @@ abstract class AbstractLine implements Line {
throw new IllegalArgumentException("Unsupported control type: " + controlType);
}
// HELPER METHODS
/**
* This method sets the open state and generates
* events if it changes.
@ -182,7 +179,6 @@ abstract class AbstractLine implements Line {
if (Printer.trace) Printer.trace("< "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open);
}
/**
* Send line events.
*/
@ -190,7 +186,6 @@ abstract class AbstractLine implements Line {
getEventDispatcher().sendAudioEvents(event, listeners);
}
/**
* This is an error in the API: getFramePosition
* should return a long value. At CD quality,
@ -200,7 +195,6 @@ abstract class AbstractLine implements Line {
return (int) getLongFramePosition();
}
/**
* Return the frame position in a long value
* This implementation returns AudioSystem.NOT_SPECIFIED.
@ -209,7 +203,6 @@ abstract class AbstractLine implements Line {
return AudioSystem.NOT_SPECIFIED;
}
// $$kk: 06.03.99: returns the mixer used in construction.
// this is a hold-over from when there was a public method like
// this on line and should be fixed!!
@ -232,8 +225,8 @@ abstract class AbstractLine implements Line {
}
}
// ABSTRACT METHODS
@Override
public abstract void open() throws LineUnavailableException;
@Override
public abstract void close();
}

View File

@ -26,10 +26,17 @@
package com.sun.media.sound;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.util.List;
import javax.sound.midi.*;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiDeviceReceiver;
import javax.sound.midi.MidiDeviceTransmitter;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.Transmitter;
/**
@ -43,11 +50,8 @@ import javax.sound.midi.*;
*/
abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice {
// STATIC VARIABLES
private static final boolean TRACE_TRANSMITTER = false;
// INSTANCE VARIABLES
private ArrayList<Receiver> receiverList;
private TransmitterList transmitterList;
@ -62,7 +66,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
private final MidiDevice.Info info;
// DEVICE STATE
private volatile boolean open;
@ -73,15 +76,10 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
private List<Object> openKeepingObjects;
/**
* This is the device handle returned from native code
* This is the device handle returned from native code.
*/
protected volatile long id;
// CONSTRUCTOR
/**
* Constructs an AbstractMidiDevice with the specified info object.
* @param info the description of the device
@ -99,9 +97,9 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if(Printer.trace) Printer.trace("<< AbstractMidiDevice CONSTRUCTOR completed");
}
// MIDI DEVICE METHODS
@Override
public final MidiDevice.Info getDeviceInfo() {
return info;
}
@ -111,6 +109,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
* opened the device implicitly from closing it. The only way to close the device after
* this call is a call to close().
*/
@Override
public final void open() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: open()");
synchronized(this) {
@ -120,8 +119,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: open() completed");
}
/** Open the device implicitly.
* This method is intended to be used by AbstractReceiver
* and BasicTransmitter. Actually, it is called by getReceiverReferenceCounting() and
@ -146,7 +143,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: openInternal() completed");
}
private void doOpen() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: doOpen()");
synchronized(this) {
@ -158,7 +154,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: doOpen() completed");
}
@Override
public final void close() {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: close()");
synchronized (this) {
@ -168,7 +164,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: close() completed");
}
/** Close the device for an object that implicitely opened it.
* This method is intended to be used by Transmitter.close() and Receiver.close().
* Those methods should pass this for the object parameter. Since Transmitters or Receivers
@ -196,7 +191,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: closeInternal() completed");
}
public final void doClose() {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: doClose()");
synchronized(this) {
@ -208,12 +202,11 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: doClose() completed");
}
@Override
public final boolean isOpen() {
return open;
}
protected void implClose() {
synchronized (traRecLock) {
if (receiverList != null) {
@ -230,21 +223,21 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
/**
* This implementation always returns -1.
* Devices that actually provide this should over-ride
* this method.
*/
@Override
public long getMicrosecondPosition() {
return -1;
}
/** Return the maximum number of Receivers supported by this device.
Depending on the return value of hasReceivers(), this method returns either 0 or -1.
Subclasses should rather override hasReceivers() than override this method.
*/
@Override
public final int getMaxReceivers() {
if (hasReceivers()) {
return -1;
@ -253,11 +246,11 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
/** Return the maximum number of Transmitters supported by this device.
Depending on the return value of hasTransmitters(), this method returns either 0 or -1.
Subclasses should override hasTransmitters().
*/
@Override
public final int getMaxTransmitters() {
if (hasTransmitters()) {
return -1;
@ -266,7 +259,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
/** Retrieve a Receiver for this device.
This method returns the value returned by createReceiver(), if it doesn't throw
an exception. Subclasses should rather override createReceiver() than override
@ -274,6 +266,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
If createReceiver returns a Receiver, it is added to the internal list
of Receivers (see getReceiversList)
*/
@Override
public final Receiver getReceiver() throws MidiUnavailableException {
Receiver receiver;
synchronized (traRecLock) {
@ -283,7 +276,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return receiver;
}
@Override
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Receiver> getReceivers() {
List<Receiver> recs;
@ -298,12 +291,12 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return recs;
}
/**
* This implementation uses createTransmitter, which may throw an exception.
* If a transmitter is returned in createTransmitter, it is added to the internal
* TransmitterList
*/
@Override
public final Transmitter getTransmitter() throws MidiUnavailableException {
Transmitter transmitter;
synchronized (traRecLock) {
@ -313,7 +306,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return transmitter;
}
@Override
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Transmitter> getTransmitters() {
List<Transmitter> tras;
@ -328,19 +321,16 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return tras;
}
// HELPER METHODS
final long getId() {
return id;
}
// REFERENCE COUNTING
/** Retrieve a Receiver and open the device implicitly.
This method is called by MidiSystem.getReceiver().
*/
@Override
public final Receiver getReceiverReferenceCounting()
throws MidiUnavailableException {
/* Keep this order of commands! If getReceiver() throws an exception,
@ -354,10 +344,10 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return receiver;
}
/** Retrieve a Transmitter and open the device implicitly.
This method is called by MidiSystem.getTransmitter().
*/
@Override
public final Transmitter getTransmitterReferenceCounting()
throws MidiUnavailableException {
/* Keep this order of commands! If getTransmitter() throws an exception,
@ -371,7 +361,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return transmitter;
}
/** Return the list of objects that have opened the device implicitely.
*/
private synchronized List<Object> getOpenKeepingObjects() {
@ -381,23 +370,19 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return openKeepingObjects;
}
// RECEIVER HANDLING METHODS
/** Return the internal list of Receivers, possibly creating it first.
*/
private List<Receiver> getReceiverList() {
synchronized (traRecLock) {
if (receiverList == null) {
receiverList = new ArrayList<Receiver>();
receiverList = new ArrayList<>();
}
}
return receiverList;
}
/** Returns if this device supports Receivers.
Subclasses that use Receivers should override this method to
return true. They also should override createReceiver().
@ -408,7 +393,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return false;
}
/** Create a Receiver object.
throwing an exception here means that Receivers aren't enabled.
Subclasses that use Receivers should override this method with
@ -420,8 +404,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
throw new MidiUnavailableException("MIDI IN receiver not available");
}
// TRANSMITTER HANDLING
/** Return the internal list of Transmitters, possibly creating it first.
@ -435,7 +417,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return transmitterList;
}
/** Returns if this device supports Transmitters.
Subclasses that use Transmitters should override this method to
return true. They also should override createTransmitter().
@ -446,7 +427,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return false;
}
/** Create a Transmitter object.
throwing an exception here means that Transmitters aren't enabled.
Subclasses that use Transmitters should override this method with
@ -458,20 +438,16 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
throw new MidiUnavailableException("MIDI OUT transmitter not available");
}
// ABSTRACT METHODS
protected abstract void implOpen() throws MidiUnavailableException;
/**
* close this device if discarded by the garbage collector
* close this device if discarded by the garbage collector.
*/
@Override
protected final void finalize() {
close();
}
// INNER CLASSES
/** Base class for Receivers.
Subclasses that use Receivers must use this base class, since it
contains magic necessary to manage implicit closing the device.
@ -550,6 +526,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
this.tlist = tlist;
}
@Override
public final void setReceiver(Receiver receiver) {
if (tlist != null && this.receiver != receiver) {
if (Printer.debug) Printer.debug("Transmitter "+toString()+": set receiver "+receiver);
@ -558,16 +535,17 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
@Override
public final Receiver getReceiver() {
return receiver;
}
/** Close the Transmitter.
* Here, the call to the magic method closeInternal() takes place.
* Therefore, subclasses that override this method must call
* 'super.close()'.
*/
@Override
public final void close() {
AbstractMidiDevice.this.closeInternal(this);
if (tlist != null) {
@ -577,19 +555,19 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
@Override
public final MidiDevice getMidiDevice() {
return AbstractMidiDevice.this;
}
} // class BasicTransmitter
/**
* a class to manage a list of transmitters
* a class to manage a list of transmitters.
*/
final class TransmitterList {
private final ArrayList<Transmitter> transmitters = new ArrayList<Transmitter>();
private final ArrayList<Transmitter> transmitters = new ArrayList<>();
private MidiOutDevice.MidiOutReceiver midiOutReceiver;
// how many transmitters must be present for optimized
@ -712,9 +690,8 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
/**
* Send this message to all transmitters
* Send this message to all transmitters.
*/
void sendMessage(MidiMessage message, long timeStamp) {
if (message instanceof FastShortMessage) {
@ -746,8 +723,5 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
}
} // TransmitterList
}

View File

@ -52,7 +52,6 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider {
// also for memory's sake, do not initialize the arrays here
}
final synchronized void readDeviceInfos() {
Info[] infos = getInfoCache();
MidiDevice[] devices = getDeviceCache();
@ -148,10 +147,6 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider {
throw MidiUtils.unsupportedDevice(info);
}
// INNER CLASSES
/**
* Info class for MidiDevices. Adds an index value for
* making native references to a particular device.
@ -182,9 +177,6 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider {
} // class Info
// ABSTRACT METHODS
abstract int getNumDevices();
abstract MidiDevice[] getDeviceCache();
abstract void setDeviceCache(MidiDevice[] devices);

View File

@ -28,9 +28,9 @@ package com.sun.media.sound;
import java.util.Vector;
import javax.sound.sampled.Control;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
/**
* Abstract Mixer. Implements Mixer (with abstract methods) and specifies
@ -76,29 +76,18 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
*/
private boolean manuallyOpened = false;
/**
* Supported formats for the mixer.
*/
//$$fb DELETE
//protected Vector formats = new Vector();
// STATE VARIABLES
/**
* Source lines (ports) currently open
* Source lines (ports) currently open.
*/
private final Vector<Line> sourceLines = new Vector<>();
/**
* Target lines currently open.
*/
private final Vector<Line> targetLines = new Vector<>();
/**
* Constructs a new AbstractMixer.
* @param mixer the mixer with which this line is associated
@ -124,30 +113,28 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
this.targetLineInfo = targetLineInfo;
}
// MIXER METHODS
@Override
public final Mixer.Info getMixerInfo() {
return mixerInfo;
}
@Override
public final Line.Info[] getSourceLineInfo() {
Line.Info[] localArray = new Line.Info[sourceLineInfo.length];
System.arraycopy(sourceLineInfo, 0, localArray, 0, sourceLineInfo.length);
return localArray;
}
@Override
public final Line.Info[] getTargetLineInfo() {
Line.Info[] localArray = new Line.Info[targetLineInfo.length];
System.arraycopy(targetLineInfo, 0, localArray, 0, targetLineInfo.length);
return localArray;
}
@Override
public final Line.Info[] getSourceLineInfo(Line.Info info) {
int i;
@ -168,7 +155,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return returnedArray;
}
@Override
public final Line.Info[] getTargetLineInfo(Line.Info info) {
int i;
@ -189,7 +176,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return returnedArray;
}
@Override
public final boolean isLineSupported(Line.Info info) {
int i;
@ -211,9 +198,10 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return false;
}
@Override
public abstract Line getLine(Line.Info info) throws LineUnavailableException;
@Override
public abstract int getMaxLines(Line.Info info);
protected abstract void implOpen() throws LineUnavailableException;
@ -221,7 +209,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
protected abstract void implStop();
protected abstract void implClose();
@Override
public final Line[] getSourceLines() {
Line[] localLines;
@ -238,7 +226,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return localLines;
}
@Override
public final Line[] getTargetLines() {
Line[] localLines;
@ -255,37 +243,37 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return localLines;
}
/**
* Default implementation always throws an exception.
*/
@Override
public final void synchronize(Line[] lines, boolean maintainSync) {
throw new IllegalArgumentException("Synchronization not supported by this mixer.");
}
/**
* Default implementation always throws an exception.
*/
@Override
public final void unsynchronize(Line[] lines) {
throw new IllegalArgumentException("Synchronization not supported by this mixer.");
}
/**
* Default implementation always returns false.
*/
@Override
public final boolean isSynchronizationSupported(Line[] lines,
boolean maintainSync) {
return false;
}
// OVERRIDES OF ABSTRACT DATA LINE METHODS
/**
* This implementation tries to open the mixer with its current format and buffer size settings.
*/
@Override
public final synchronized void open() throws LineUnavailableException {
open(true);
}
@ -307,10 +295,8 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: open() succeeded");
}
// METHOD FOR INTERNAL IMPLEMENTATION USE
/**
* The default implementation of this method just determines whether
* this line is a source or target line, calls open(no-arg) on the
@ -357,7 +343,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: open(" + line + ") completed");
}
/**
* Removes this line from the list of open source lines and
* open target lines, if it exists in either.
@ -388,10 +373,10 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: close(" + line + ") succeeded");
}
/**
* Close all lines and then close this mixer.
*/
@Override
public final synchronized void close() {
if (Printer.trace) Printer.trace(">> AbstractMixer: close()");
if (isOpen()) {
@ -439,7 +424,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: start(" + line + ") succeeded");
}
/**
* Stops the mixer if this was the last running line.
*/
@ -492,8 +476,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: stop(" + line + ") succeeded");
}
/**
* Determines whether this is a source line for this mixer.
* Right now this just checks whether it's supported, but should
@ -510,7 +492,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return false;
}
/**
* Determines whether this is a target line for this mixer.
* Right now this just checks whether it's supported, but should
@ -527,7 +508,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return false;
}
/**
* Returns the first complete Line.Info object it finds that
* matches the one specified, or null if no matching Line.Info
@ -551,8 +531,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return targetLineInfo[i];
}
}
return null;
}
}

View File

@ -87,5 +87,4 @@ final class AiffFileFormat extends StandardFileFormat {
int getSsndChunkOffset() {
return getHeaderSize()-16;
}
}

View File

@ -29,7 +29,6 @@ import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;

View File

@ -33,7 +33,6 @@ import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
/**
* A-law encodes linear data, and decodes a-law data to linear data.
*
@ -52,7 +51,7 @@ public final class AlawCodec extends SunCodec {
0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
/**
* Initializes the decode tables
* Initializes the decode tables.
*/
static {
for (int i=0;i<256;i++) {
@ -83,10 +82,7 @@ public final class AlawCodec extends SunCodec {
super(alawEncodings, alawEncodings);
}
// NEW CODE
/**
*/
@Override
public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat){
if( sourceFormat.getEncoding().equals( AudioFormat.Encoding.PCM_SIGNED )) {
@ -117,8 +113,7 @@ public final class AlawCodec extends SunCodec {
}
}
/**
*/
@Override
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
Objects.requireNonNull(sourceFormat);
if( (targetEncoding.equals( AudioFormat.Encoding.PCM_SIGNED ) && sourceFormat.getEncoding().equals( AudioFormat.Encoding.ALAW)) ||
@ -129,8 +124,7 @@ public final class AlawCodec extends SunCodec {
}
}
/**
*/
@Override
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream){
AudioFormat sourceFormat = sourceStream.getFormat();
AudioFormat.Encoding sourceEncoding = sourceFormat.getEncoding();
@ -169,9 +163,7 @@ public final class AlawCodec extends SunCodec {
return getConvertedStream(targetFormat, sourceStream);
}
/**
* use old code...
*/
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
throw new IllegalArgumentException("Unsupported conversion: "
@ -180,10 +172,6 @@ public final class AlawCodec extends SunCodec {
return getConvertedStream( targetFormat, sourceStream );
}
// OLD CODE
/**
* Opens the codec with the specified parameters.
* @param stream stream from which data to be processed should be read
@ -192,7 +180,6 @@ public final class AlawCodec extends SunCodec {
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
/* public AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) { */
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
AudioInputStream cs = null;
@ -201,7 +188,7 @@ public final class AlawCodec extends SunCodec {
if( inputFormat.matches(outputFormat) ) {
cs = stream;
} else {
cs = (AudioInputStream) (new AlawCodecStream(stream, outputFormat));
cs = new AlawCodecStream(stream, outputFormat);
}
return cs;
@ -214,7 +201,6 @@ public final class AlawCodec extends SunCodec {
* returns an array of length 0.
* @return array of supported output formats.
*/
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
@ -343,18 +329,20 @@ public final class AlawCodec extends SunCodec {
* Note that this won't actually read anything; must read in
* two-byte units.
*/
@Override
public int read() throws IOException {
byte[] b = new byte[1];
return read(b, 0, b.length);
}
@Override
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
// don't read fractional frames

View File

@ -45,6 +45,7 @@ import javax.sound.sampled.UnsupportedAudioFileException;
*/
public final class AudioFileSoundbankReader extends SoundbankReader {
@Override
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
try {
@ -59,6 +60,7 @@ public final class AudioFileSoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException {
stream.mark(512);
@ -108,6 +110,7 @@ public final class AudioFileSoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException {
try {

View File

@ -89,8 +89,9 @@ public abstract class AudioFloatConverter {
mask = (byte) 0xFF;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
byte[] ret = converter.toByteArray(in_buff, in_offset, in_len,
out_buff, out_offset);
@ -102,8 +103,9 @@ public abstract class AudioFloatConverter {
return ret;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
if (mask_buffer == null || mask_buffer.length < in_buff.length)
mask_buffer = new byte[in_buff.length];
System.arraycopy(in_buff, 0, mask_buffer, 0, in_buff.length);
@ -132,8 +134,9 @@ public abstract class AudioFloatConverter {
double[] double_buff = null;
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int in_len = out_len * 8;
if (bytebuffer == null || bytebuffer.capacity() < in_len) {
bytebuffer = ByteBuffer.allocate(in_len).order(
@ -154,8 +157,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int out_len = in_len * 8;
if (bytebuffer == null || bytebuffer.capacity() < out_len) {
bytebuffer = ByteBuffer.allocate(out_len).order(
@ -184,8 +188,9 @@ public abstract class AudioFloatConverter {
double[] double_buff = null;
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int in_len = out_len * 8;
if (bytebuffer == null || bytebuffer.capacity() < in_len) {
bytebuffer = ByteBuffer.allocate(in_len).order(
@ -206,8 +211,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int out_len = in_len * 8;
if (bytebuffer == null || bytebuffer.capacity() < out_len) {
bytebuffer = ByteBuffer.allocate(out_len).order(
@ -240,8 +246,9 @@ public abstract class AudioFloatConverter {
FloatBuffer floatbuffer = null;
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int in_len = out_len * 4;
if (bytebuffer == null || bytebuffer.capacity() < in_len) {
bytebuffer = ByteBuffer.allocate(in_len).order(
@ -255,8 +262,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int out_len = in_len * 4;
if (bytebuffer == null || bytebuffer.capacity() < out_len) {
bytebuffer = ByteBuffer.allocate(out_len).order(
@ -277,8 +285,9 @@ public abstract class AudioFloatConverter {
FloatBuffer floatbuffer = null;
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int in_len = out_len * 4;
if (bytebuffer == null || bytebuffer.capacity() < in_len) {
bytebuffer = ByteBuffer.allocate(in_len).order(
@ -292,8 +301,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int out_len = in_len * 4;
if (bytebuffer == null || bytebuffer.capacity() < out_len) {
bytebuffer = ByteBuffer.allocate(out_len).order(
@ -316,8 +326,9 @@ public abstract class AudioFloatConverter {
// PCM 8 bit, signed
private static class AudioFloatConversion8S extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -327,8 +338,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -341,8 +353,9 @@ public abstract class AudioFloatConverter {
// PCM 8 bit, unsigned
private static class AudioFloatConversion8U extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -352,8 +365,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -372,8 +386,9 @@ public abstract class AudioFloatConverter {
// PCM 16 bit, signed, little-endian
private static class AudioFloatConversion16SL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int len = out_offset + out_len;
for (int ox = out_offset; ox < len; ox++) {
@ -383,8 +398,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ox = out_offset;
int len = in_offset + in_len;
for (int ix = in_offset; ix < len; ix++) {
@ -399,8 +415,9 @@ public abstract class AudioFloatConverter {
// PCM 16 bit, signed, big-endian
private static class AudioFloatConversion16SB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -410,8 +427,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -426,8 +444,9 @@ public abstract class AudioFloatConverter {
// PCM 16 bit, unsigned, little-endian
private static class AudioFloatConversion16UL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -438,8 +457,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -454,8 +474,9 @@ public abstract class AudioFloatConverter {
// PCM 16 bit, unsigned, big-endian
private static class AudioFloatConversion16UB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -466,8 +487,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -488,8 +510,9 @@ public abstract class AudioFloatConverter {
// PCM 24 bit, signed, little-endian
private static class AudioFloatConversion24SL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -502,8 +525,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -521,8 +545,9 @@ public abstract class AudioFloatConverter {
// PCM 24 bit, signed, big-endian
private static class AudioFloatConversion24SB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -535,8 +560,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -554,8 +580,9 @@ public abstract class AudioFloatConverter {
// PCM 24 bit, unsigned, little-endian
private static class AudioFloatConversion24UL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -567,8 +594,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -585,8 +613,9 @@ public abstract class AudioFloatConverter {
// PCM 24 bit, unsigned, big-endian
private static class AudioFloatConversion24UB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -598,8 +627,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -622,8 +652,9 @@ public abstract class AudioFloatConverter {
// PCM 32 bit, signed, little-endian
private static class AudioFloatConversion32SL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -635,8 +666,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -652,8 +684,9 @@ public abstract class AudioFloatConverter {
// PCM 32 bit, signed, big-endian
private static class AudioFloatConversion32SB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -665,8 +698,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -682,8 +716,9 @@ public abstract class AudioFloatConverter {
// PCM 32 bit, unsigned, little-endian
private static class AudioFloatConversion32UL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -696,8 +731,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -715,8 +751,9 @@ public abstract class AudioFloatConverter {
// PCM 32 bit, unsigned, big-endian
private static class AudioFloatConversion32UB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -729,8 +766,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -760,8 +798,9 @@ public abstract class AudioFloatConverter {
this.xbytes = xbytes;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -774,8 +813,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -801,8 +841,9 @@ public abstract class AudioFloatConverter {
this.xbytes = xbytes;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -816,8 +857,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -843,8 +885,9 @@ public abstract class AudioFloatConverter {
this.xbytes = xbytes;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -858,8 +901,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -886,8 +930,9 @@ public abstract class AudioFloatConverter {
this.xbytes = xbytes;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -901,8 +946,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {

View File

@ -32,9 +32,9 @@ import java.util.Arrays;
import java.util.Objects;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.spi.FormatConversionProvider;
/**
@ -63,6 +63,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
fsize = ((targetFormat.getSampleSizeInBits() + 7) / 8);
}
@Override
public int read() throws IOException {
byte[] b = new byte[1];
int ret = read(b);
@ -71,6 +72,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return b[0] & 0xFF;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int flen = len / fsize;
@ -83,6 +85,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return ret * fsize;
}
@Override
public int available() throws IOException {
int ret = stream.available();
if (ret < 0)
@ -90,22 +93,27 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return ret * fsize;
}
@Override
public void close() throws IOException {
stream.close();
}
@Override
public synchronized void mark(int readlimit) {
stream.mark(readlimit * fsize);
}
@Override
public boolean markSupported() {
return stream.markSupported();
}
@Override
public synchronized void reset() throws IOException {
stream.reset();
}
@Override
public long skip(long n) throws IOException {
long ret = stream.skip(n / fsize);
if (ret < 0)
@ -141,30 +149,37 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
.isBigEndian());
}
@Override
public int available() throws IOException {
return (ais.available() / sourceChannels) * targetChannels;
}
@Override
public void close() throws IOException {
ais.close();
}
@Override
public AudioFormat getFormat() {
return targetFormat;
}
@Override
public long getFrameLength() {
return ais.getFrameLength();
}
@Override
public void mark(int readlimit) {
ais.mark((readlimit / targetChannels) * sourceChannels);
}
@Override
public boolean markSupported() {
return ais.markSupported();
}
@Override
public int read(float[] b, int off, int len) throws IOException {
int len2 = (len / targetChannels) * sourceChannels;
if (conversion_buffer == null || conversion_buffer.length < len2)
@ -212,10 +227,12 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return (ret / sourceChannels) * targetChannels;
}
@Override
public void reset() throws IOException {
ais.reset();
}
@Override
public long skip(long len) throws IOException {
long ret = ais.skip((len / targetChannels) * sourceChannels);
if (ret < 0)
@ -305,22 +322,27 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
ibuffer_len = buffer_len;
}
@Override
public int available() throws IOException {
return 0;
}
@Override
public void close() throws IOException {
ais.close();
}
@Override
public AudioFormat getFormat() {
return targetFormat;
}
@Override
public long getFrameLength() {
return AudioSystem.NOT_SPECIFIED; // ais.getFrameLength();
}
@Override
public void mark(int readlimit) {
ais.mark((int) (readlimit * pitch[0]));
mark_ibuffer_index = ibuffer_index;
@ -337,6 +359,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
}
}
@Override
public boolean markSupported() {
return ais.markSupported();
}
@ -381,6 +404,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
}
@Override
public int read(float[] b, int off, int len) throws IOException {
if (cbuffer == null || cbuffer[0].length < len / nrofchannels) {
@ -431,6 +455,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return len - remain * nrofchannels;
}
@Override
public void reset() throws IOException {
ais.reset();
if (mark_ibuffer == null)
@ -447,6 +472,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
}
@Override
public long skip(long len) throws IOException {
if (len < 0)
return 0;
@ -474,8 +500,9 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT};
@Override
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
AudioInputStream sourceStream) {
AudioInputStream sourceStream) {
if (!isConversionSupported(targetEncoding, sourceStream.getFormat())) {
throw new IllegalArgumentException(
"Unsupported conversion: " + sourceStream.getFormat()
@ -496,8 +523,9 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return getAudioInputStream(targetFormat, sourceStream);
}
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat,
AudioInputStream sourceStream) {
AudioInputStream sourceStream) {
if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
throw new IllegalArgumentException("Unsupported conversion: "
+ sourceStream.getFormat().toString() + " to "
@ -526,16 +554,19 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
.getFrameLength());
}
@Override
public Encoding[] getSourceEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}
@Override
public Encoding[] getTargetEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}
@Override
public Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new Encoding[0];
@ -543,14 +574,15 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
Encoding.PCM_FLOAT };
}
@Override
public AudioFormat[] getTargetFormats(Encoding targetEncoding,
AudioFormat sourceFormat) {
AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new AudioFormat[0];
int channels = sourceFormat.getChannels();
ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>();
ArrayList<AudioFormat> formats = new ArrayList<>();
if (targetEncoding.equals(Encoding.PCM_SIGNED))
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
@ -598,8 +630,9 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return formats.toArray(new AudioFormat[formats.size()]);
}
@Override
public boolean isConversionSupported(AudioFormat targetFormat,
AudioFormat sourceFormat) {
AudioFormat sourceFormat) {
Objects.requireNonNull(targetFormat);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return false;
@ -612,8 +645,9 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return true;
}
@Override
public boolean isConversionSupported(Encoding targetEncoding,
AudioFormat sourceFormat) {
AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return false;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.ByteArrayInputStream;
@ -66,14 +67,17 @@ public abstract class AudioFloatInputStream {
}
@Override
public AudioFormat getFormat() {
return format;
}
@Override
public long getFrameLength() {
return buffer_len;// / format.getFrameSize();
}
@Override
public int read(float[] b, int off, int len) throws IOException {
if (b == null)
throw new NullPointerException();
@ -91,6 +95,7 @@ public abstract class AudioFloatInputStream {
return len;
}
@Override
public long skip(long len) throws IOException {
if (pos >= buffer_len)
return -1;
@ -102,21 +107,26 @@ public abstract class AudioFloatInputStream {
return len;
}
@Override
public int available() throws IOException {
return buffer_len - pos;
}
@Override
public void close() throws IOException {
}
@Override
public void mark(int readlimit) {
markpos = pos;
}
@Override
public boolean markSupported() {
return true;
}
@Override
public void reset() throws IOException {
pos = markpos;
}
@ -163,14 +173,17 @@ public abstract class AudioFloatInputStream {
this.stream = stream;
}
@Override
public AudioFormat getFormat() {
return stream.getFormat();
}
@Override
public long getFrameLength() {
return stream.getFrameLength();
}
@Override
public int read(float[] b, int off, int len) throws IOException {
int b_len = len * framesize_pc;
if (buffer == null || buffer.length < b_len)
@ -182,6 +195,7 @@ public abstract class AudioFloatInputStream {
return ret / framesize_pc;
}
@Override
public long skip(long len) throws IOException {
long b_len = len * framesize_pc;
long ret = stream.skip(b_len);
@ -190,22 +204,27 @@ public abstract class AudioFloatInputStream {
return ret / framesize_pc;
}
@Override
public int available() throws IOException {
return stream.available() / framesize_pc;
}
@Override
public void close() throws IOException {
stream.close();
}
@Override
public void mark(int readlimit) {
stream.mark(readlimit * framesize_pc);
}
@Override
public boolean markSupported() {
return stream.markSupported();
}
@Override
public void reset() throws IOException {
stream.reset();
}

View File

@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Map;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;
import javax.sound.sampled.AudioFormat;
@ -53,7 +55,7 @@ public interface AudioSynthesizer extends Synthesizer {
* @return current audio data format
* @see AudioFormat
*/
public AudioFormat getFormat();
AudioFormat getFormat();
/**
* Gets information about the possible properties for the synthesizer.
@ -63,8 +65,7 @@ public interface AudioSynthesizer extends Synthesizer {
* describing possible properties. This array may be an empty array if
* no properties are required.
*/
public AudioSynthesizerPropertyInfo[] getPropertyInfo(
Map<String, Object> info);
AudioSynthesizerPropertyInfo[] getPropertyInfo(Map<String, Object> info);
/**
* Opens the synthesizer and starts rendering audio into
@ -93,7 +94,7 @@ public interface AudioSynthesizer extends Synthesizer {
* @see #close
* @see #isOpen
*/
public void open(SourceDataLine line, Map<String, Object> info)
void open(SourceDataLine line, Map<String, Object> info)
throws MidiUnavailableException;
/**
@ -123,6 +124,7 @@ public interface AudioSynthesizer extends Synthesizer {
* @see #close
* @see #isOpen
*/
public AudioInputStream openStream(AudioFormat targetFormat,
Map<String, Object> info) throws MidiUnavailableException;
AudioInputStream openStream(AudioFormat targetFormat,
Map<String, Object> info)
throws MidiUnavailableException;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -28,7 +28,7 @@ package com.sun.media.sound;
import javax.sound.sampled.Clip;
/**
* Interface for Clip objects that close themselves automatically
* Interface for Clip objects that close themselves automatically.
*
* @author Florian Bomers
*/

View File

@ -41,6 +41,5 @@ public interface AutoConnectSequencer {
* needs to re-connect itself to a suitable
* device in open().
*/
public void setAutoConnect(Receiver autoConnectReceiver);
void setAutoConnect(Receiver autoConnectReceiver);
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -47,8 +48,8 @@ public final class DLSInstrument extends ModelInstrument {
boolean druminstrument = false;
byte[] guid = null;
DLSInfo info = new DLSInfo();
List<DLSRegion> regions = new ArrayList<DLSRegion>();
List<DLSModulator> modulators = new ArrayList<DLSModulator>();
List<DLSRegion> regions = new ArrayList<>();
List<DLSModulator> modulators = new ArrayList<>();
public DLSInstrument() {
super(null, null, null, null);
@ -62,6 +63,7 @@ public final class DLSInstrument extends ModelInstrument {
return info;
}
@Override
public String getName() {
return info.name;
}
@ -70,6 +72,7 @@ public final class DLSInstrument extends ModelInstrument {
info.name = name;
}
@Override
public ModelPatch getPatch() {
return new ModelPatch(bank, preset, druminstrument);
}
@ -86,6 +89,7 @@ public final class DLSInstrument extends ModelInstrument {
}
}
@Override
public Object getData() {
return null;
}
@ -98,6 +102,7 @@ public final class DLSInstrument extends ModelInstrument {
return modulators;
}
@Override
public String toString() {
if (druminstrument)
return "Drumkit: " + info.name
@ -362,17 +367,17 @@ public final class DLSInstrument extends ModelInstrument {
return null;
}
@Override
public ModelPerformer[] getPerformers() {
List<ModelPerformer> performers = new ArrayList<ModelPerformer>();
List<ModelPerformer> performers = new ArrayList<>();
Map<String, DLSModulator> modmap = new HashMap<String, DLSModulator>();
Map<String, DLSModulator> modmap = new HashMap<>();
for (DLSModulator mod: getModulators()) {
modmap.put(mod.getSource() + "x" + mod.getControl() + "=" +
mod.getDestination(), mod);
}
Map<String, DLSModulator> insmodmap =
new HashMap<String, DLSModulator>();
Map<String, DLSModulator> insmodmap = new HashMap<>();
for (DLSRegion zone: regions) {
ModelPerformer performer = new ModelPerformer();

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -39,7 +40,7 @@ import java.util.List;
public final class DLSRegion {
public static final int OPTION_SELFNONEXCLUSIVE = 0x0001;
List<DLSModulator> modulators = new ArrayList<DLSModulator>();
List<DLSModulator> modulators = new ArrayList<>();
int keyfrom;
int keyto;
int velfrom;

View File

@ -22,10 +22,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.InputStream;
import java.util.Arrays;
import javax.sound.midi.Soundbank;
import javax.sound.midi.SoundbankResource;
import javax.sound.sampled.AudioFormat;
@ -60,6 +62,7 @@ public final class DLSSample extends SoundbankResource {
return info;
}
@Override
public Object getData() {
AudioFormat format = getFormat();
@ -93,6 +96,7 @@ public final class DLSSample extends SoundbankResource {
this.data = new ModelByteBuffer(data, offset, length);
}
@Override
public String getName() {
return info.name;
}
@ -109,6 +113,7 @@ public final class DLSSample extends SoundbankResource {
this.sampleoptions = sampleOptions;
}
@Override
public String toString() {
return "Sample: " + info.name;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -40,7 +41,7 @@ public final class DLSSampleOptions {
short finetune;
int attenuation;
long options;
List<DLSSampleLoop> loops = new ArrayList<DLSSampleLoop>();
List<DLSSampleLoop> loops = new ArrayList<>();
public int getAttenuation() {
return attenuation;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.File;
@ -42,9 +43,9 @@ import javax.sound.midi.Patch;
import javax.sound.midi.Soundbank;
import javax.sound.midi.SoundbankResource;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat.Encoding;
/**
* A DLS Level 1 and Level 2 soundbank reader (from files/url/streams).
@ -100,10 +101,12 @@ public final class DLSSoundbank implements Soundbank {
return d;
}
@Override
public int hashCode() {
return (int)i1;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof DLSID)) {
return false;
@ -176,8 +179,8 @@ public final class DLSSoundbank implements Soundbank {
private final DLSInfo info = new DLSInfo();
private final List<DLSInstrument> instruments = new ArrayList<DLSInstrument>();
private final List<DLSSample> samples = new ArrayList<DLSSample>();
private final List<DLSInstrument> instruments = new ArrayList<>();
private final List<DLSSample> samples = new ArrayList<>();
private boolean largeFormat = false;
private File sampleFile;
@ -300,7 +303,7 @@ public final class DLSSoundbank implements Soundbank {
DLSID uuid;
long x;
long y;
Stack<Long> stack = new Stack<Long>();
Stack<Long> stack = new Stack<>();
while (riff.available() != 0) {
int opcode = riff.readUnsignedShort();
@ -482,7 +485,7 @@ public final class DLSSoundbank implements Soundbank {
}
}
if (chunk.getType().equals("lart")) {
List<DLSModulator> modlist = new ArrayList<DLSModulator>();
List<DLSModulator> modlist = new ArrayList<>();
while (chunk.hasNextChunk()) {
RIFFReader subchunk = chunk.nextChunk();
if (chunk.getFormat().equals("cdl ")) {
@ -498,7 +501,7 @@ public final class DLSSoundbank implements Soundbank {
}
if (chunk.getType().equals("lar2")) {
// support for DLS level 2 ART
List<DLSModulator> modlist = new ArrayList<DLSModulator>();
List<DLSModulator> modlist = new ArrayList<>();
while (chunk.hasNextChunk()) {
RIFFReader subchunk = chunk.nextChunk();
if (chunk.getFormat().equals("cdl ")) {
@ -582,7 +585,7 @@ public final class DLSSoundbank implements Soundbank {
}
}
private Map<DLSRegion, Long> temp_rgnassign = new HashMap<DLSRegion, Long>();
private Map<DLSRegion, Long> temp_rgnassign = new HashMap<>();
private boolean readRgnChunk(DLSRegion split, RIFFReader riff)
throws IOException {
@ -591,7 +594,7 @@ public final class DLSSoundbank implements Soundbank {
String format = chunk.getFormat();
if (format.equals("LIST")) {
if (chunk.getType().equals("lart")) {
List<DLSModulator> modlist = new ArrayList<DLSModulator>();
List<DLSModulator> modlist = new ArrayList<>();
while (chunk.hasNextChunk()) {
RIFFReader subchunk = chunk.nextChunk();
if (chunk.getFormat().equals("cdl ")) {
@ -607,7 +610,7 @@ public final class DLSSoundbank implements Soundbank {
}
if (chunk.getType().equals("lar2")) {
// support for DLS level 2 ART
List<DLSModulator> modlist = new ArrayList<DLSModulator>();
List<DLSModulator> modlist = new ArrayList<>();
while (chunk.hasNextChunk()) {
RIFFReader subchunk = chunk.nextChunk();
if (chunk.getFormat().equals("cdl ")) {
@ -902,7 +905,7 @@ public final class DLSSoundbank implements Soundbank {
RIFFWriter wvpl = writer.writeList("wvpl");
long off = wvpl.getFilePointer();
List<Long> offsettable = new ArrayList<Long>();
List<Long> offsettable = new ArrayList<>();
for (DLSSample sample : samples) {
offsettable.add(Long.valueOf(wvpl.getFilePointer() - off));
writeSample(wvpl.writeList("wave"), sample);
@ -1179,18 +1182,22 @@ public final class DLSSoundbank implements Soundbank {
return info;
}
@Override
public String getName() {
return info.name;
}
@Override
public String getVersion() {
return major + "." + minor;
}
@Override
public String getVendor() {
return info.engineers;
}
@Override
public String getDescription() {
return info.comments;
}
@ -1207,6 +1214,7 @@ public final class DLSSoundbank implements Soundbank {
info.comments = s;
}
@Override
public SoundbankResource[] getResources() {
SoundbankResource[] resources = new SoundbankResource[samples.size()];
int j = 0;
@ -1215,6 +1223,7 @@ public final class DLSSoundbank implements Soundbank {
return resources;
}
@Override
public DLSInstrument[] getInstruments() {
DLSInstrument[] inslist_array =
instruments.toArray(new DLSInstrument[instruments.size()]);
@ -1226,6 +1235,7 @@ public final class DLSSoundbank implements Soundbank {
return samples.toArray(new DLSSample[samples.size()]);
}
@Override
public Instrument getInstrument(Patch patch) {
int program = patch.getProgram();
int bank = patch.getBank();
@ -1256,9 +1266,9 @@ public final class DLSSoundbank implements Soundbank {
public void removeResource(SoundbankResource resource) {
if (resource instanceof DLSInstrument)
instruments.remove((DLSInstrument) resource);
instruments.remove(resource);
if (resource instanceof DLSSample)
samples.remove((DLSSample) resource);
samples.remove(resource);
}
public void addInstrument(DLSInstrument resource) {

View File

@ -29,6 +29,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Soundbank;
import javax.sound.midi.spi.SoundbankReader;
@ -41,6 +42,7 @@ import javax.sound.midi.spi.SoundbankReader;
*/
public final class DLSSoundbankReader extends SoundbankReader {
@Override
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
try {
@ -52,6 +54,7 @@ public final class DLSSoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException {
try {
@ -63,6 +66,7 @@ public final class DLSSoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException {
try {

View File

@ -27,7 +27,9 @@ package com.sun.media.sound;
import java.util.Arrays;
import javax.sound.sampled.*;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.SourceDataLine;
/**
* Class to write an AudioInputStream to a SourceDataLine.
@ -125,7 +127,6 @@ public final class DataPusher implements Runnable {
if (DEBUG || Printer.debug) Printer.debug("< DataPusher.start(loop="+loop+")");
}
public synchronized void stop() {
if (DEBUG || Printer.debug) Printer.debug("> DataPusher.stop()");
if (threadState == STATE_STOPPING
@ -161,6 +162,7 @@ public final class DataPusher implements Runnable {
/**
* Write data to the source data line.
*/
@Override
public void run() {
byte[] buffer = null;
boolean useStream = (ais != null);
@ -242,5 +244,4 @@ public final class DataPusher implements Runnable {
}
if (DEBUG || Printer.debug)Printer.debug("DataPusher:end of thread");
}
} // class DataPusher

View File

@ -29,35 +29,35 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Vector;
import javax.sound.sampled.*;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.Clip;
import javax.sound.sampled.Control;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.TargetDataLine;
// IDEA:
// Use java.util.concurrent.Semaphore,
// java.util.concurrent.locks.ReentrantLock and other new classes/methods
// to improve this class's thread safety.
/**
* A Mixer which provides direct access to audio devices
* A Mixer which provides direct access to audio devices.
*
* @author Florian Bomers
*/
final class DirectAudioDevice extends AbstractMixer {
// CONSTANTS
private static final int CLIP_BUFFER_TIME = 1000; // in milliseconds
private static final int DEFAULT_LINE_BUFFER_TIME = 500; // in milliseconds
// INSTANCE VARIABLES
/** number of opened lines */
private int deviceCountOpened = 0;
/** number of started lines */
private int deviceCountStarted = 0;
// CONSTRUCTOR
DirectAudioDevice(DirectAudioDeviceProvider.DirectAudioDeviceInfo portMixerInfo) {
// pass in Line.Info, mixer, controls
super(portMixerInfo, // Mixer.Info
@ -168,6 +168,7 @@ final class DirectAudioDevice extends AbstractMixer {
// ABSTRACT MIXER: ABSTRACT METHOD IMPLEMENTATIONS
@Override
public Line getLine(Line.Info info) throws LineUnavailableException {
Line.Info fullInfo = getLineInfo(info);
if (fullInfo == null) {
@ -216,7 +217,7 @@ final class DirectAudioDevice extends AbstractMixer {
throw new IllegalArgumentException("Line unsupported: " + info);
}
@Override
public int getMaxLines(Line.Info info) {
Line.Info fullInfo = getLineInfo(info);
@ -233,26 +234,26 @@ final class DirectAudioDevice extends AbstractMixer {
return 0;
}
@Override
protected void implOpen() throws LineUnavailableException {
if (Printer.trace) Printer.trace("DirectAudioDevice: implOpen - void method");
}
@Override
protected void implClose() {
if (Printer.trace) Printer.trace("DirectAudioDevice: implClose - void method");
}
@Override
protected void implStart() {
if (Printer.trace) Printer.trace("DirectAudioDevice: implStart - void method");
}
@Override
protected void implStop() {
if (Printer.trace) Printer.trace("DirectAudioDevice: implStop - void method");
}
// IMPLEMENTATION HELPERS
int getMixerIndex() {
return ((DirectAudioDeviceProvider.DirectAudioDeviceInfo) getMixerInfo()).getIndex();
}
@ -319,12 +320,6 @@ final class DirectAudioDevice extends AbstractMixer {
return null;
}
// INNER CLASSES
/**
* Private inner class for the DataLine.Info objects
* adds a little magic for the isFormatSupported so
@ -367,7 +362,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
/**
* Private inner class as base class for direct lines
* Private inner class as base class for direct lines.
*/
private static class DirectDL extends AbstractDataLine implements EventDispatcher.LineMonitor {
protected final int mixerIndex;
@ -397,7 +392,6 @@ final class DirectAudioDevice extends AbstractMixer {
// Guards all native calls.
protected final Object lockNative = new Object();
// CONSTRUCTOR
protected DirectDL(DataLine.Info info,
DirectAudioDevice mixer,
AudioFormat format,
@ -414,11 +408,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
// ABSTRACT METHOD IMPLEMENTATIONS
// ABSTRACT LINE / DATALINE
@Override
void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException {
if (Printer.trace) Printer.trace(">> DirectDL: implOpen("+format+", "+bufferSize+" bytes)");
@ -538,7 +528,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectDL: implOpen() succeeded");
}
@Override
void implStart() {
if (Printer.trace) Printer.trace(" >> DirectDL: implStart()");
@ -570,6 +560,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectDL: implStart() succeeded");
}
@Override
void implStop() {
if (Printer.trace) Printer.trace(">> DirectDL: implStop()");
@ -600,6 +591,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace(" << DirectDL: implStop() succeeded");
}
@Override
void implClose() {
if (Printer.trace) Printer.trace(">> DirectDL: implClose()");
@ -625,8 +617,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectDL: implClose() succeeded");
}
// METHOD OVERRIDES
@Override
public int available() {
if (id == 0) {
return 0;
@ -638,7 +629,7 @@ final class DirectAudioDevice extends AbstractMixer {
return a;
}
@Override
public void drain() {
noService = true;
// additional safeguard against draining forever
@ -681,6 +672,7 @@ final class DirectAudioDevice extends AbstractMixer {
noService = false;
}
@Override
public void flush() {
if (id != 0) {
// first stop ongoing read/write method
@ -699,6 +691,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
// replacement for getFramePosition (see AbstractDataLine)
@Override
public long getLongFramePosition() {
long pos;
synchronized (lockNative) {
@ -713,7 +706,6 @@ final class DirectAudioDevice extends AbstractMixer {
return (pos / getFormat().getFrameSize());
}
/*
* write() belongs into SourceDataLine and Clip,
* so define it here and make it accessible by
@ -786,6 +778,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
// called from event dispatcher for lines that need servicing
@Override
public void checkLine() {
synchronized (lockNative) {
if (monitoring
@ -826,7 +819,6 @@ final class DirectAudioDevice extends AbstractMixer {
}
}
/////////////////// CONTROLS /////////////////////////////
protected final class Gain extends FloatControl {
@ -844,6 +836,7 @@ final class DirectAudioDevice extends AbstractMixer {
"dB", "Minimum", "", "Maximum");
}
@Override
public void setValue(float newValue) {
// adjust value within range ?? spec says IllegalArgumentException
//newValue = Math.min(newValue, getMaximum());
@ -861,13 +854,13 @@ final class DirectAudioDevice extends AbstractMixer {
}
} // class Gain
private final class Mute extends BooleanControl {
private Mute() {
super(BooleanControl.Type.MUTE, false, "True", "False");
}
@Override
public void setValue(boolean newValue) {
super.setValue(newValue);
calcVolume();
@ -881,6 +874,7 @@ final class DirectAudioDevice extends AbstractMixer {
"", "Left", "Center", "Right");
}
@Override
public void setValue(float newValue) {
setValueImpl(newValue);
panControl.setValueImpl(newValue);
@ -900,6 +894,7 @@ final class DirectAudioDevice extends AbstractMixer {
"", "Left", "Center", "Right");
}
@Override
public void setValue(float newValue) {
setValueImpl(newValue);
balanceControl.setValueImpl(newValue);
@ -909,19 +904,14 @@ final class DirectAudioDevice extends AbstractMixer {
super.setValue(newValue);
}
} // class Pan
} // class DirectDL
/**
* Private inner class representing a SourceDataLine
* Private inner class representing a SourceDataLine.
*/
private static final class DirectSDL extends DirectDL
implements SourceDataLine {
// CONSTRUCTOR
private DirectSDL(DataLine.Info info,
AudioFormat format,
int bufferSize,
@ -933,12 +923,11 @@ final class DirectAudioDevice extends AbstractMixer {
}
/**
* Private inner class representing a TargetDataLine
* Private inner class representing a TargetDataLine.
*/
private static final class DirectTDL extends DirectDL
implements TargetDataLine {
// CONSTRUCTOR
private DirectTDL(DataLine.Info info,
AudioFormat format,
int bufferSize,
@ -947,8 +936,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("DirectTDL CONSTRUCTOR: completed");
}
// METHOD OVERRIDES
@Override
public int read(byte[] b, int off, int len) {
flushing = false;
if (len == 0) {
@ -1030,7 +1018,6 @@ final class DirectAudioDevice extends AbstractMixer {
// auto closing clip support
private boolean autoclosing = false;
// CONSTRUCTOR
private DirectClip(DataLine.Info info,
AudioFormat format,
int bufferSize,
@ -1041,6 +1028,7 @@ final class DirectAudioDevice extends AbstractMixer {
// CLIP METHODS
@Override
public void open(AudioFormat format, byte[] data, int offset, int bufferSize)
throws LineUnavailableException {
@ -1111,7 +1099,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("< DirectClip.open completed");
}
@Override
public void open(AudioInputStream stream) throws LineUnavailableException, IOException {
// $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
@ -1178,17 +1166,17 @@ final class DirectAudioDevice extends AbstractMixer {
} // synchronized
}
@Override
public int getFrameLength() {
return m_lengthInFrames;
}
@Override
public long getMicrosecondLength() {
return Toolkit.frames2micros(getFormat(), getFrameLength());
}
@Override
public void setFramePosition(int frames) {
if (Printer.trace) Printer.trace("> DirectClip: setFramePosition: " + frames);
@ -1229,6 +1217,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
// replacement for getFramePosition (see AbstractDataLine)
@Override
public long getLongFramePosition() {
/* $$fb
* this would be intuitive, but the definition of getFramePosition
@ -1243,7 +1232,7 @@ final class DirectAudioDevice extends AbstractMixer {
return super.getLongFramePosition();
}
@Override
public synchronized void setMicrosecondPosition(long microseconds) {
if (Printer.trace) Printer.trace("> DirectClip: setMicrosecondPosition: " + microseconds);
@ -1253,6 +1242,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("< DirectClip: setMicrosecondPosition succeeded");
}
@Override
public void setLoopPoints(int start, int end) {
if (Printer.trace) Printer.trace("> DirectClip: setLoopPoints: start: " + start + " end: " + end);
@ -1283,7 +1273,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("< DirectClip: setLoopPoints completed");
}
@Override
public void loop(int count) {
// note: when count reaches 0, it means that the entire clip
// will be played, i.e. it will play past the loop end point
@ -1291,10 +1281,7 @@ final class DirectAudioDevice extends AbstractMixer {
start();
}
// ABSTRACT METHOD IMPLEMENTATIONS
// ABSTRACT LINE
@Override
void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException {
// only if audioData wasn't set in a calling open(format, byte[], frameSize)
// this call is allowed.
@ -1304,6 +1291,7 @@ final class DirectAudioDevice extends AbstractMixer {
super.implOpen(format, bufferSize);
}
@Override
void implClose() {
if (Printer.trace) Printer.trace(">> DirectClip: implClose()");
@ -1333,13 +1321,14 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectClip: implClose() succeeded");
}
@Override
void implStart() {
if (Printer.trace) Printer.trace("> DirectClip: implStart()");
super.implStart();
if (Printer.trace) Printer.trace("< DirectClip: implStart() succeeded");
}
@Override
void implStop() {
if (Printer.trace) Printer.trace(">> DirectClip: implStop()");
@ -1351,8 +1340,8 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectClip: implStop() succeeded");
}
// main playback loop
@Override
public void run() {
if (Printer.trace) Printer.trace(">>> DirectClip: run() threadID="+Thread.currentThread().getId());
while (thread != null) {
@ -1418,10 +1407,12 @@ final class DirectAudioDevice extends AbstractMixer {
MixerClip. They should be moved to a base class, together
with the instance variable 'autoclosing'. */
@Override
public boolean isAutoClosing() {
return autoclosing;
}
@Override
public void setAutoClosing(boolean value) {
if (value != autoclosing) {
if (isOpen()) {
@ -1435,6 +1426,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
}
@Override
protected boolean requiresServicing() {
// no need for servicing for Clips
return false;
@ -1488,5 +1480,4 @@ final class DirectAudioDevice extends AbstractMixer {
private static native boolean nRequiresServicing(long id, boolean isSource);
// called in irregular intervals
private static native void nService(long id, boolean isSource);
}

View File

@ -28,7 +28,6 @@ package com.sun.media.sound;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.spi.MixerProvider;
/**
* DirectAudioDevice provider.
*
@ -36,8 +35,6 @@ import javax.sound.sampled.spi.MixerProvider;
*/
public final class DirectAudioDeviceProvider extends MixerProvider {
// STATIC VARIABLES
/**
* Set of info objects for all port input devices on the system.
*/
@ -48,18 +45,11 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
*/
private static DirectAudioDevice[] devices;
// STATIC
static {
// initialize
Platform.initialize();
}
// CONSTRUCTOR
/**
* Required public no-arg constructor.
*/
@ -92,6 +82,7 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
}
}
@Override
public Mixer.Info[] getMixerInfo() {
synchronized (DirectAudioDeviceProvider.class) {
Mixer.Info[] localArray = new Mixer.Info[infos.length];
@ -100,7 +91,7 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
}
}
@Override
public Mixer getMixer(Mixer.Info info) {
synchronized (DirectAudioDeviceProvider.class) {
// if the default device is asked, we provide the mixer
@ -125,7 +116,6 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
String.format("Mixer %s not supported by this provider", info));
}
private static Mixer getDevice(DirectAudioDeviceInfo info) {
int index = info.getIndex();
if (devices[index] == null) {
@ -134,9 +124,6 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
return devices[index];
}
// INNER CLASSES
/**
* Info class for DirectAudioDevices. Adds an index value and a string for
* making native references to a particular device.
@ -171,7 +158,6 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
}
} // class DirectAudioDeviceInfo
// NATIVE METHODS
private static native int nGetNumDevices();
// index: [0..nGetNumDevices()-1]
private static native DirectAudioDeviceInfo nNewDirectAudioDeviceInfo(int deviceIndex);

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Random;

View File

@ -35,8 +35,6 @@ import javax.sound.midi.ShortMessage;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
/**
* EventDispatcher. Used by various classes in the Java Sound implementation
* to send events.
@ -49,39 +47,35 @@ final class EventDispatcher implements Runnable {
/**
* time of inactivity until the auto closing clips
* are closed
* are closed.
*/
private static final int AUTO_CLOSE_TIME = 5000;
/**
* List of events
* List of events.
*/
private final ArrayList<EventInfo> eventQueue = new ArrayList<>();
/**
* Thread object for this EventDispatcher instance
* Thread object for this EventDispatcher instance.
*/
private Thread thread = null;
/*
* support for auto-closing Clips
*/
private final ArrayList<ClipInfo> autoClosingClips = new ArrayList<ClipInfo>();
private final ArrayList<ClipInfo> autoClosingClips = new ArrayList<>();
/*
* support for monitoring data lines
*/
private final ArrayList<LineMonitor> lineMonitors = new ArrayList<LineMonitor>();
private final ArrayList<LineMonitor> lineMonitors = new ArrayList<>();
/**
* Approximate interval between calls to LineMonitor.checkLine
*/
static final int LINE_MONITOR_TIME = 400;
/**
* This start() method starts an event thread if one is not already active.
*/
@ -96,7 +90,6 @@ final class EventDispatcher implements Runnable {
}
}
/**
* Invoked when there is at least one event in the queue.
* Implement this as a callback to process one event.
@ -153,7 +146,6 @@ final class EventDispatcher implements Runnable {
Printer.err("Unknown event type: " + eventInfo.getEvent());
}
/**
* Wait until there is something in the event queue to process. Then
* dispatch the event to the listeners.The entire method does not
@ -202,7 +194,6 @@ final class EventDispatcher implements Runnable {
}
}
/**
* Queue the given event in the event queue.
*/
@ -211,10 +202,10 @@ final class EventDispatcher implements Runnable {
notifyAll();
}
/**
* A loop to dispatch events.
*/
@Override
public void run() {
while (true) {
@ -226,7 +217,6 @@ final class EventDispatcher implements Runnable {
}
}
/**
* Send audio and MIDI events.
*/
@ -243,7 +233,6 @@ final class EventDispatcher implements Runnable {
postEvent(eventInfo);
}
/*
* go through the list of registered auto-closing
* Clip instances and close them, if appropriate
@ -291,7 +280,7 @@ final class EventDispatcher implements Runnable {
}
/**
* called from auto-closing clips when one of their open() method is called
* called from auto-closing clips when one of their open() method is called.
*/
void autoClosingClipOpened(AutoClosingClip clip) {
if (Printer.debug)Printer.debug("> EventDispatcher.autoClosingClipOpened ");
@ -316,7 +305,7 @@ final class EventDispatcher implements Runnable {
}
/**
* called from auto-closing clips when their closed() method is called
* called from auto-closing clips when their closed() method is called.
*/
void autoClosingClipClosed(AutoClosingClip clip) {
// nothing to do -- is removed from arraylist above
@ -340,9 +329,8 @@ final class EventDispatcher implements Runnable {
if (Printer.debug)Printer.debug("< EventDispatcher.monitorLines("+lineMonitors.size()+" monitors)");
}
/**
* Add this LineMonitor instance to the list of monitors
* Add this LineMonitor instance to the list of monitors.
*/
void addLineMonitor(LineMonitor lm) {
if (Printer.trace)Printer.trace("> EventDispatcher.addLineMonitor("+lm+")");
@ -362,7 +350,7 @@ final class EventDispatcher implements Runnable {
}
/**
* Remove this LineMonitor instance from the list of monitors
* Remove this LineMonitor instance from the list of monitors.
*/
void removeLineMonitor(LineMonitor lm) {
if (Printer.trace)Printer.trace("> EventDispatcher.removeLineMonitor("+lm+")");
@ -377,8 +365,6 @@ final class EventDispatcher implements Runnable {
if (Printer.debug)Printer.debug("< EventDispatcher.removeLineMonitor finished -- now ("+lineMonitors.size()+" monitors)");
}
// /////////////////////////////////// INNER CLASSES ////////////////////////////////////////// //
/**
* Container for an event and a set of listeners to deliver it to.
*/
@ -413,7 +399,7 @@ final class EventDispatcher implements Runnable {
/**
* Container for a clip with its expiration time
* Container for a clip with its expiration time.
*/
private class ClipInfo {
@ -421,7 +407,7 @@ final class EventDispatcher implements Runnable {
private final long expiration;
/**
* Create a new instance of this clip Info class
* Create a new instance of this clip Info class.
*/
ClipInfo(AutoClosingClip clip) {
this.clip = clip;
@ -440,13 +426,13 @@ final class EventDispatcher implements Runnable {
/**
* Interface that a class that wants to get regular
* line monitor events implements
* line monitor events implements.
*/
interface LineMonitor {
/**
* Called by event dispatcher in regular intervals
* Called by event dispatcher in regular intervals.
*/
public void checkLine();
void checkLine();
}
} // class EventDispatcher

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -588,7 +589,6 @@ public final class FFT {
i += jmax << 1;
}
}
// Perform Factor-4 Decomposition with 3 * complex operators and 8 +/-
@ -682,7 +682,6 @@ public final class FFT {
i += jmax << 1;
}
}
private void bitreversal(double[] data) {
@ -743,6 +742,5 @@ public final class FFT {
data[n] = data[m];
data[m] = tempi;
}
}
}

View File

@ -25,10 +25,11 @@
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.ShortMessage;
/**
* an optimized ShortMessage that does not need an array
* an optimized ShortMessage that does not need an array.
*
* @author Florian Bomers
*/
@ -51,6 +52,7 @@ final class FastShortMessage extends ShortMessage {
return packedMsg;
}
@Override
public byte[] getMessage() {
int length = 0;
try {
@ -73,6 +75,7 @@ final class FastShortMessage extends ShortMessage {
return returnedArray;
}
@Override
public int getLength() {
try {
return getDataLength(packedMsg & 0xFF) + 1;
@ -82,6 +85,7 @@ final class FastShortMessage extends ShortMessage {
return 0;
}
@Override
public void setMessage(int status) throws InvalidMidiDataException {
// check for valid values
int dataLength = getDataLength(status); // can throw InvalidMidiDataException
@ -91,35 +95,39 @@ final class FastShortMessage extends ShortMessage {
packedMsg = (packedMsg & 0xFFFF00) | (status & 0xFF);
}
@Override
public void setMessage(int status, int data1, int data2) throws InvalidMidiDataException {
getDataLength(status); // can throw InvalidMidiDataException
packedMsg = (status & 0xFF) | ((data1 & 0xFF) << 8) | ((data2 & 0xFF) << 16);
}
@Override
public void setMessage(int command, int channel, int data1, int data2) throws InvalidMidiDataException {
getDataLength(command); // can throw InvalidMidiDataException
packedMsg = (command & 0xF0) | (channel & 0x0F) | ((data1 & 0xFF) << 8) | ((data2 & 0xFF) << 16);
}
@Override
public int getChannel() {
return packedMsg & 0x0F;
}
@Override
public int getCommand() {
return packedMsg & 0xF0;
}
@Override
public int getData1() {
return (packedMsg & 0xFF00) >> 8;
}
@Override
public int getData2() {
return (packedMsg & 0xFF0000) >> 16;
}
@Override
public int getStatus() {
return packedMsg & 0xFF;
}
@ -129,6 +137,7 @@ final class FastShortMessage extends ShortMessage {
* as this object.
* @return a clone of this instance.
*/
@Override
public Object clone() {
try {
return new FastShortMessage(packedMsg);

View File

@ -25,10 +25,11 @@
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.SysexMessage;
/**
* optimized FastSysexMessage that doesn't copy the array upon instantiation
* optimized FastSysexMessage that doesn't copy the array upon instantiation.
*
* @author Florian Bomers
*/
@ -51,6 +52,7 @@ final class FastSysexMessage extends SysexMessage {
// overwrite this method so that the original data array,
// which is shared among all transmitters, cannot be modified
@Override
public void setMessage(byte[] data, int length) throws InvalidMidiDataException {
if ((data.length == 0) || (((data[0] & 0xFF) != 0xF0) && ((data[0] & 0xFF) != 0xF7))) {
super.setMessage(data, data.length); // will throw Exception

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.IOException;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -69,11 +69,12 @@ public final class JARSoundbankReader extends SoundbankReader {
return ok;
}
@Override
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
if (!isZIP(url))
return null;
ArrayList<Soundbank> soundbanks = new ArrayList<Soundbank>();
ArrayList<Soundbank> soundbanks = new ArrayList<>();
URLClassLoader ucl = URLClassLoader.newInstance(new URL[]{url});
InputStream stream = ucl.getResourceAsStream(
"META-INF/services/javax.sound.midi.Soundbank");
@ -114,12 +115,14 @@ public final class JARSoundbankReader extends SoundbankReader {
return sbk;
}
@Override
public Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException {
Objects.requireNonNull(stream);
return null;
}
@Override
public Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException {
return getSoundbank(file.toURI().toURL());

View File

@ -136,7 +136,6 @@ public final class JDK13Services {
return value;
}
/** Obtain the instance name part of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
@ -158,7 +157,6 @@ public final class JDK13Services {
return value;
}
/** Obtain the value of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
@ -190,7 +188,6 @@ public final class JDK13Services {
return value;
}
/** Obtain a properties bundle containing property values from the
properties file. If the properties file could not be loaded,
the properties bundle is empty.

View File

@ -26,19 +26,17 @@
package com.sun.media.sound;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.sound.sampled.AudioPermission;
/** Managing security in the Java Sound implementation.
@ -64,7 +62,6 @@ final class JSSecurityManager {
return (System.getSecurityManager() != null);
}
static void checkRecordPermission() throws SecurityException {
if(Printer.trace) Printer.trace("JSSecurityManager.checkRecordPermission()");
SecurityManager sm = System.getSecurityManager();
@ -90,6 +87,7 @@ final class JSSecurityManager {
try {
// invoke the privileged action using 1.2 security
PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
@Override
public Void run() {
loadPropertiesImpl(properties, filename);
return null;
@ -108,7 +106,6 @@ final class JSSecurityManager {
}
}
private static void loadPropertiesImpl(Properties properties,
String filename) {
if(Printer.trace)Printer.trace(">> JSSecurityManager: loadPropertiesImpl()");
@ -176,6 +173,7 @@ final class JSSecurityManager {
// the iterator's hasNext() method looks through classpath for
// the provider class names, so it requires read permissions
PrivilegedAction<Boolean> hasNextAction = new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
return ps.hasNext();
}

View File

@ -25,30 +25,29 @@
package com.sun.media.sound;
import java.io.IOException;
import java.io.InputStream;
import java.applet.AudioClip;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.applet.AudioClip;
import java.io.IOException;
import java.io.InputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiFileFormat;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaEventListener;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiFileFormat;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.MetaEventListener;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
/**
* Java Sound audio clip;
@ -56,7 +55,6 @@ import javax.sound.midi.MetaEventListener;
* @author Arthur van Hoff, Kara Kytle, Jan Borgersen
* @author Florian Bomers
*/
public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
private static final boolean DEBUG = false;
@ -126,12 +124,12 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
}
@Override
public synchronized void play() {
startImpl(false);
}
@Override
public synchronized void loop() {
startImpl(true);
}
@ -205,6 +203,7 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
}
@Override
public synchronized void stop() {
if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip->stop()");
@ -248,13 +247,15 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
// Event handlers (for debugging)
@Override
public synchronized void update(LineEvent event) {
if (DEBUG || Printer.debug) Printer.debug("line event received: "+event);
}
// handle MIDI track end meta events for looping
public synchronized void meta( MetaMessage message ) {
@Override
public synchronized void meta(MetaMessage message) {
if (DEBUG || Printer.debug)Printer.debug("META EVENT RECEIVED!!!!! ");
@ -269,12 +270,12 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
}
@Override
public String toString() {
return getClass().toString();
}
@Override
protected void finalize() {
if (clip != null) {
@ -326,8 +327,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
return true;
}
private void readStream(AudioInputStream as, long byteLen) throws IOException {
// arrays "only" max. 2GB
int intLen;
@ -371,7 +370,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
loadedAudioByteLength = totalBytesRead;
}
// METHODS FOR CREATING THE DEVICE
private boolean createClip() {
@ -464,7 +462,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
return true;
}
/*
* private inner class representing a ByteArrayOutputStream
* which allows retrieval of the internal array
@ -479,5 +476,4 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
} // class DirectBAOS
}

View File

@ -22,10 +22,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiDeviceReceiver;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.Receiver;
/**
* Helper class which allows to convert {@code Receiver}
@ -55,15 +58,18 @@ public final class MidiDeviceReceiverEnvelope implements MidiDeviceReceiver {
}
// Receiver implementation
@Override
public void close() {
receiver.close();
}
@Override
public void send(MidiMessage message, long timeStamp) {
receiver.send(message, timeStamp);
}
// MidiDeviceReceiver implementation
@Override
public MidiDevice getMidiDevice() {
return device;
}

View File

@ -22,10 +22,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiDeviceTransmitter;
import javax.sound.midi.Receiver;
import javax.sound.midi.Transmitter;
/**
* Helper class which allows to convert {@code Transmitter}
@ -55,20 +58,23 @@ public final class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitte
}
// Transmitter implementation
@Override
public void setReceiver(Receiver receiver) {
transmitter.setReceiver(receiver);
}
@Override
public Receiver getReceiver() {
return transmitter.getReceiver();
}
@Override
public void close() {
transmitter.close();
}
// MidiDeviceReceiver implementation
@Override
public MidiDevice getMidiDevice() {
return device;
}

View File

@ -25,9 +25,8 @@
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Transmitter;
/**
* MidiInDevice class representing functionality of MidiIn devices.
@ -40,18 +39,14 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
private volatile Thread midiInThread;
// CONSTRUCTOR
MidiInDevice(AbstractMidiDeviceProvider.Info info) {
super(info);
if(Printer.trace) Printer.trace("MidiInDevice CONSTRUCTOR");
}
// IMPLEMENTATION OF ABSTRACT MIDI DEVICE METHODS
// $$kk: 06.24.99: i have this both opening and starting the midi in device.
// may want to separate these??
@Override
protected synchronized void implOpen() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> MidiInDevice: implOpen()");
@ -75,9 +70,9 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
if (Printer.trace) Printer.trace("< MidiInDevice: implOpen() completed");
}
// $$kk: 06.24.99: i have this both stopping and closing the midi in device.
// may want to separate these??
@Override
protected synchronized void implClose() {
if (Printer.trace) Printer.trace("> MidiInDevice: implClose()");
long oldId = id;
@ -98,7 +93,7 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
if (Printer.trace) Printer.trace("< MidiInDevice: implClose() completed");
}
@Override
public long getMicrosecondPosition() {
long timestamp = -1;
if (isOpen()) {
@ -107,22 +102,21 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
return timestamp;
}
// OVERRIDES OF ABSTRACT MIDI DEVICE METHODS
@Override
protected boolean hasTransmitters() {
return true;
}
@Override
protected Transmitter createTransmitter() {
return new MidiInTransmitter();
}
/**
* An own class to distinguish the class name from
* the transmitter of other devices
* the transmitter of other devices.
*/
private final class MidiInTransmitter extends BasicTransmitter {
private MidiInTransmitter() {
@ -130,8 +124,7 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
}
}
// RUNNABLE METHOD
@Override
public void run() {
// while the device is started, keep trying to get messages.
// this thread returns from native code whenever stop() or close() is called
@ -149,9 +142,6 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
midiInThread = null;
}
// CALLBACKS FROM NATIVE
/**
* Callback from native code when a short MIDI event is received from hardware.
* @param packedMsg: status | data1 << 8 | data2 << 8
@ -179,8 +169,6 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
getTransmitterList().sendMessage(data, timeStamp);
}
// NATIVE METHODS
private native long nOpen(int index) throws MidiUnavailableException;
private native void nClose(long id);
@ -190,6 +178,4 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
// go into native code and get messages. May be blocking
private native void nGetMessages(long id);
}

View File

@ -27,7 +27,6 @@ package com.sun.media.sound;
import javax.sound.midi.MidiDevice;
/**
* MIDI input device provider.
*
@ -44,16 +43,12 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
private static final boolean enabled;
// STATIC
static {
// initialize
Platform.initialize();
enabled = Platform.isMidiIOEnabled();
}
// CONSTRUCTOR
/**
* Required public no-arg constructor.
*/
@ -63,6 +58,7 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
// implementation of abstract methods in AbstractMidiDeviceProvider
@Override
AbstractMidiDeviceProvider.Info createInfo(int index) {
if (!enabled) {
return null;
@ -70,6 +66,7 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
return new MidiInDeviceInfo(index, MidiInDeviceProvider.class);
}
@Override
MidiDevice createDevice(AbstractMidiDeviceProvider.Info info) {
if (enabled && (info instanceof MidiInDeviceInfo)) {
return new MidiInDevice(info);
@ -77,6 +74,7 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
return null;
}
@Override
int getNumDevices() {
if (!enabled) {
if (Printer.debug)Printer.debug("MidiInDevice not enabled, returning 0 devices");
@ -87,14 +85,15 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
return numDevices;
}
@Override
MidiDevice[] getDeviceCache() { return devices; }
@Override
void setDeviceCache(MidiDevice[] devices) { MidiInDeviceProvider.devices = devices; }
@Override
Info[] getInfoCache() { return infos; }
@Override
void setInfoCache(Info[] infos) { MidiInDeviceProvider.infos = infos; }
// INNER CLASSES
/**
* Info class for MidiInDevices. Adds the
* provider's Class to keep the provider class from being
@ -115,9 +114,6 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
} // class MidiInDeviceInfo
// NATIVE METHODS
private static native int nGetNumDevices();
private static native String nGetName(int index);
private static native String nGetVendor(int index);

View File

@ -25,9 +25,10 @@
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.ShortMessage;
/**
* MidiOutDevice class representing functionality of MidiOut devices.
@ -38,16 +39,12 @@ import javax.sound.midi.*;
*/
final class MidiOutDevice extends AbstractMidiDevice {
// CONSTRUCTOR
MidiOutDevice(AbstractMidiDeviceProvider.Info info) {
super(info);
if(Printer.trace) Printer.trace("MidiOutDevice CONSTRUCTOR");
}
// IMPLEMENTATION OF ABSTRACT MIDI DEVICE METHODS
@Override
protected synchronized void implOpen() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> MidiOutDevice: implOpen()");
int index = ((AbstractMidiDeviceProvider.Info)getDeviceInfo()).getIndex();
@ -58,7 +55,7 @@ final class MidiOutDevice extends AbstractMidiDevice {
if (Printer.trace) Printer.trace("< MidiOutDevice: implOpen(): completed.");
}
@Override
protected synchronized void implClose() {
if (Printer.trace) Printer.trace("> MidiOutDevice: implClose()");
// prevent further action
@ -72,7 +69,7 @@ final class MidiOutDevice extends AbstractMidiDevice {
if (Printer.trace) Printer.trace("< MidiOutDevice: implClose(): completed");
}
@Override
public long getMicrosecondPosition() {
long timestamp = -1;
if (isOpen()) {
@ -81,28 +78,23 @@ final class MidiOutDevice extends AbstractMidiDevice {
return timestamp;
}
// OVERRIDES OF ABSTRACT MIDI DEVICE METHODS
/** Returns if this device supports Receivers.
This implementation always returns true.
@return true, if the device supports Receivers, false otherwise.
*/
@Override
protected boolean hasReceivers() {
return true;
}
@Override
protected Receiver createReceiver() {
return new MidiOutReceiver();
}
// INNER CLASSES
final class MidiOutReceiver extends AbstractReceiver {
@Override
void implSend(final MidiMessage message, final long timeStamp) {
final int length = message.getLength();
final int status = message.getStatus();
@ -159,13 +151,8 @@ final class MidiOutDevice extends AbstractMidiDevice {
nSendShortMessage(id, packedMsg, timeStamp);
}
}
} // class MidiOutReceiver
// NATIVE METHODS
private native long nOpen(int index) throws MidiUnavailableException;
private native void nClose(long id);

View File

@ -27,7 +27,6 @@ package com.sun.media.sound;
import javax.sound.midi.MidiDevice;
/**
* MIDI output device provider.
*
@ -44,16 +43,12 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
private static final boolean enabled;
// STATIC
static {
// initialize
Platform.initialize();
enabled = Platform.isMidiIOEnabled();
}
// CONSTRUCTOR
/**
* Required public no-arg constructor.
*/
@ -61,8 +56,7 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
if (Printer.trace) Printer.trace("MidiOutDeviceProvider: constructor");
}
// implementation of abstract methods in AbstractMidiDeviceProvider
@Override
AbstractMidiDeviceProvider.Info createInfo(int index) {
if (!enabled) {
return null;
@ -70,6 +64,7 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
return new MidiOutDeviceInfo(index, MidiOutDeviceProvider.class);
}
@Override
MidiDevice createDevice(AbstractMidiDeviceProvider.Info info) {
if (enabled && (info instanceof MidiOutDeviceInfo)) {
return new MidiOutDevice(info);
@ -77,6 +72,7 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
return null;
}
@Override
int getNumDevices() {
if (!enabled) {
if (Printer.debug)Printer.debug("MidiOutDevice not enabled, returning 0 devices");
@ -85,14 +81,15 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
return nGetNumDevices();
}
@Override
MidiDevice[] getDeviceCache() { return devices; }
@Override
void setDeviceCache(MidiDevice[] devices) { MidiOutDeviceProvider.devices = devices; }
@Override
Info[] getInfoCache() { return infos; }
@Override
void setInfoCache(Info[] infos) { MidiOutDeviceProvider.infos = infos; }
// INNER CLASSES
/**
* Info class for MidiOutDevices. Adds the
* provider's Class to keep the provider class from being
@ -113,9 +110,6 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
} // class MidiOutDeviceInfo
// NATIVE METHODS
private static native int nGetNumDevices();
private static native String nGetName(int index);
private static native String nGetVendor(int index);

View File

@ -77,7 +77,6 @@ public final class MidiUtils {
return ((msg[1] & 0xFF) == META_END_OF_TRACK_TYPE) && (msg[2] == 0);
}
/** return if the given message is a meta tempo message */
public static boolean isMetaTempo(MidiMessage midiMsg) {
// first check if it is a META message at all
@ -91,7 +90,6 @@ public final class MidiUtils {
return ((msg[1] & 0xFF) == META_TEMPO_TYPE) && (msg[2] == 3);
}
/** parses this message for a META tempo message and returns
* the tempo in MPQ, or -1 if this isn't a tempo message
*/
@ -111,7 +109,6 @@ public final class MidiUtils {
return tempo;
}
/**
* converts<br>
* 1 - MPQ-Tempo to BPM tempo<br>
@ -124,7 +121,6 @@ public final class MidiUtils {
return ((double) 60000000l) / tempo;
}
/**
* convert tick to microsecond with given tempo.
* Does not take tempo changes into account.
@ -145,7 +141,6 @@ public final class MidiUtils {
return (long) ((((double)us) * resolution) / tempoMPQ);
}
/**
* Given a tick, convert to microsecond
* @param cache tempo info and current tempo
@ -246,7 +241,6 @@ public final class MidiUtils {
return tick;
}
/**
* Binary search for the event indexes of the track
*
@ -283,7 +277,6 @@ public final class MidiUtils {
return ret;
}
public static final class TempoCache {
long[] ticks;
int[] tempos; // in MPQ
@ -310,7 +303,6 @@ public final class MidiUtils {
refresh(seq);
}
public synchronized void refresh(Sequence seq) {
ArrayList<MidiEvent> list = new ArrayList<>();
Track[] tracks = seq.getTracks();
@ -373,6 +365,5 @@ public final class MidiUtils {
}
return tempos[tempos.length - 1];
}
}
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -32,95 +33,123 @@ package com.sun.media.sound;
*/
public abstract class ModelAbstractChannelMixer implements ModelChannelMixer {
@Override
public abstract boolean process(float[][] buffer, int offset, int len);
@Override
public abstract void stop();
@Override
public void allNotesOff() {
}
@Override
public void allSoundOff() {
}
@Override
public void controlChange(int controller, int value) {
}
@Override
public int getChannelPressure() {
return 0;
}
@Override
public int getController(int controller) {
return 0;
}
@Override
public boolean getMono() {
return false;
}
@Override
public boolean getMute() {
return false;
}
@Override
public boolean getOmni() {
return false;
}
@Override
public int getPitchBend() {
return 0;
}
@Override
public int getPolyPressure(int noteNumber) {
return 0;
}
@Override
public int getProgram() {
return 0;
}
@Override
public boolean getSolo() {
return false;
}
@Override
public boolean localControl(boolean on) {
return false;
}
@Override
public void noteOff(int noteNumber) {
}
@Override
public void noteOff(int noteNumber, int velocity) {
}
@Override
public void noteOn(int noteNumber, int velocity) {
}
@Override
public void programChange(int program) {
}
@Override
public void programChange(int bank, int program) {
}
@Override
public void resetAllControllers() {
}
@Override
public void setChannelPressure(int pressure) {
}
@Override
public void setMono(boolean on) {
}
@Override
public void setMute(boolean mute) {
}
@Override
public void setOmni(boolean on) {
}
@Override
public void setPitchBend(int bend) {
}
@Override
public void setPolyPressure(int noteNumber, int pressure) {
}
@Override
public void setSolo(boolean soloState) {
}
}

View File

@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.IOException;
import javax.sound.midi.Instrument;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.Patch;
@ -51,15 +53,18 @@ public abstract class ModelAbstractOscillator
public void init() {
}
@Override
public void close() throws IOException {
}
@Override
public void noteOff(int velocity) {
on = false;
}
@Override
public void noteOn(MidiChannel channel, VoiceStatus voice, int noteNumber,
int velocity) {
int velocity) {
this.channel = channel;
this.voice = voice;
this.noteNumber = noteNumber;
@ -67,6 +72,7 @@ public abstract class ModelAbstractOscillator
on = true;
}
@Override
public int read(float[][] buffer, int offset, int len) throws IOException {
return -1;
}
@ -91,6 +97,7 @@ public abstract class ModelAbstractOscillator
return on;
}
@Override
public void setPitch(float pitch) {
this.pitch = pitch;
}
@ -107,14 +114,17 @@ public abstract class ModelAbstractOscillator
return samplerate;
}
@Override
public float getAttenuation() {
return 0;
}
@Override
public int getChannels() {
return 1;
}
@Override
public String getName() {
return getClass().getName();
}
@ -123,6 +133,7 @@ public abstract class ModelAbstractOscillator
return new Patch(0, 0);
}
@Override
public ModelOscillatorStream open(float samplerate) {
ModelAbstractOscillator oscs;
try {
@ -162,10 +173,12 @@ public abstract class ModelAbstractOscillator
return sbk;
}
@Override
public String getDescription() {
return getName();
}
@Override
public Instrument getInstrument(Patch patch) {
Instrument ins = getInstrument();
Patch p = ins.getPatch();
@ -182,18 +195,22 @@ public abstract class ModelAbstractOscillator
return ins;
}
@Override
public Instrument[] getInstruments() {
return new Instrument[]{getInstrument()};
}
@Override
public SoundbankResource[] getResources() {
return new SoundbankResource[0];
}
@Override
public String getVendor() {
return null;
}
@Override
public String getVersion() {
return null;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.ByteArrayInputStream;
@ -60,12 +61,14 @@ public final class ModelByteBuffer {
left = capacity();
}
@Override
public int available() throws IOException {
if (left > Integer.MAX_VALUE)
return Integer.MAX_VALUE;
return (int)left;
}
@Override
public synchronized void mark(int readlimit) {
try {
mark = raf.getFilePointer();
@ -75,15 +78,18 @@ public final class ModelByteBuffer {
}
}
@Override
public boolean markSupported() {
return true;
}
@Override
public synchronized void reset() throws IOException {
raf.seek(mark);
left = markleft;
}
@Override
public long skip(long n) throws IOException {
if( n < 0)
return 0;
@ -95,6 +101,7 @@ public final class ModelByteBuffer {
return n;
}
@Override
public int read(byte b[], int off, int len) throws IOException {
if (len > left)
len = (int)left;
@ -107,6 +114,7 @@ public final class ModelByteBuffer {
return len;
}
@Override
public int read(byte[] b) throws IOException {
int len = b.length;
if (len > left)
@ -120,6 +128,7 @@ public final class ModelByteBuffer {
return len;
}
@Override
public int read() throws IOException {
if (left == 0)
return -1;
@ -130,6 +139,7 @@ public final class ModelByteBuffer {
return b;
}
@Override
public void close() throws IOException {
raf.close();
}

View File

@ -22,14 +22,16 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.IOException;
import java.io.InputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat.Encoding;
/**
* Wavetable oscillator for pre-loaded data.
@ -52,6 +54,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
bigendian = format.isBigEndian();
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int avail = available();
if (avail <= 0)
@ -82,6 +85,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
return len;
}
@Override
public long skip(long n) throws IOException {
int avail = available();
if (avail <= 0)
@ -93,10 +97,12 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
return super.skip(n);
}
@Override
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
@Override
public int read() throws IOException {
byte[] b = new byte[1];
int ret = read(b, 0, 1);
@ -105,19 +111,23 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
return 0 & 0xFF;
}
@Override
public boolean markSupported() {
return true;
}
@Override
public int available() throws IOException {
return (int)buffer.capacity() + (int)buffer8.capacity() - pos - pos2;
}
@Override
public synchronized void mark(int readlimit) {
markpos = pos;
markpos2 = pos2;
}
@Override
public synchronized void reset() throws IOException {
pos = markpos;
pos2 = markpos2;
@ -189,6 +199,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
return format;
}
@Override
public AudioFloatInputStream openStream() {
if (buffer == null)
return null;
@ -230,16 +241,19 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
(int)buffer.arrayOffset(), (int)buffer.capacity());
}
@Override
public int getChannels() {
return getFormat().getChannels();
}
@Override
public ModelOscillatorStream open(float samplerate) {
// ModelWavetableOscillator doesn't support ModelOscillatorStream
return null;
}
// attenuation is in cB
@Override
public float getAttenuation() {
return attenuation;
}
@ -248,6 +262,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
this.attenuation = attenuation;
}
@Override
public float getLoopLength() {
return loopLength;
}
@ -256,6 +271,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
this.loopLength = loopLength;
}
@Override
public float getLoopStart() {
return loopStart;
}
@ -268,10 +284,12 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
this.loopType = loopType;
}
@Override
public int getLoopType() {
return loopType;
}
@Override
public float getPitchcorrection() {
return pitchcorrection;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.MidiChannel;
@ -42,9 +43,9 @@ import javax.sound.midi.MidiChannel;
public interface ModelChannelMixer extends MidiChannel {
// Used to process input audio from voices mix.
public boolean process(float[][] buffer, int offset, int len);
boolean process(float[][] buffer, int offset, int len);
// Is used to trigger that this mixer is not be used
// and it should fade out.
public void stop();
void stop();
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Arrays;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -32,5 +33,5 @@ package com.sun.media.sound;
*/
public interface ModelDirectedPlayer {
public void play(int performerIndex, ModelConnectionBlock[] connectionBlocks);
void play(int performerIndex, ModelConnectionBlock[] connectionBlocks);
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -38,9 +39,9 @@ package com.sun.media.sound;
*/
public interface ModelDirector {
public void noteOn(int noteNumber, int velocity);
void noteOn(int noteNumber, int velocity);
public void noteOff(int noteNumber, int velocity);
void noteOff(int noteNumber, int velocity);
public void close();
void close();
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -134,6 +135,7 @@ public final class ModelIdentifier {
this.variable = variable;
}
@Override
public int hashCode() {
int hashcode = instance;
if(object != null) hashcode |= object.hashCode();
@ -141,6 +143,7 @@ public final class ModelIdentifier {
return hashcode;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ModelIdentifier))
return false;
@ -159,6 +162,7 @@ public final class ModelIdentifier {
return true;
}
@Override
public String toString() {
if (variable == null) {
return object + "[" + instance + "]";

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.Instrument;

View File

@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Comparator;
import javax.sound.midi.Instrument;
import javax.sound.midi.Patch;
@ -36,6 +38,7 @@ import javax.sound.midi.Patch;
*/
public final class ModelInstrumentComparator implements Comparator<Instrument> {
@Override
public int compare(Instrument arg0, Instrument arg1) {
Patch p0 = arg0.getPatch();
Patch p1 = arg1.getPatch();

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.MidiChannel;
@ -42,21 +43,25 @@ public final class ModelMappedInstrument extends ModelInstrument {
this.ins = ins;
}
@Override
public Object getData() {
return ins.getData();
}
@Override
public ModelPerformer[] getPerformers() {
return ins.getPerformers();
}
@Override
public ModelDirector getDirector(ModelPerformer[] performers,
MidiChannel channel, ModelDirectedPlayer player) {
MidiChannel channel, ModelDirectedPlayer player) {
return ins.getDirector(performers, channel, player);
}
@Override
public ModelChannelMixer getChannelMixer(MidiChannel channel,
AudioFormat format) {
AudioFormat format) {
return ins.getChannelMixer(channel, format);
}
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -32,13 +33,13 @@ package com.sun.media.sound;
*/
public interface ModelOscillator {
public int getChannels();
int getChannels();
/**
* Attenuation is in cB.
* @return
*/
public float getAttenuation();
float getAttenuation();
public ModelOscillatorStream open(float samplerate);
ModelOscillatorStream open(float samplerate);
}

View File

@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.IOException;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.VoiceStatus;
@ -35,14 +37,14 @@ import javax.sound.midi.VoiceStatus;
*/
public interface ModelOscillatorStream {
public void setPitch(float pitch); // Pitch is in cents!
void setPitch(float pitch); // Pitch is in cents!
public void noteOn(MidiChannel channel, VoiceStatus voice, int noteNumber,
int velocity);
void noteOn(MidiChannel channel, VoiceStatus voice, int noteNumber,
int velocity);
public void noteOff(int velocity);
void noteOff(int velocity);
public int read(float[][] buffer, int offset, int len) throws IOException;
int read(float[][] buffer, int offset, int len) throws IOException;
public void close() throws IOException;
void close() throws IOException;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.Patch;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -35,9 +36,9 @@ import java.util.List;
*/
public final class ModelPerformer {
private final List<ModelOscillator> oscillators = new ArrayList<ModelOscillator>();
private List<ModelConnectionBlock> connectionBlocks
= new ArrayList<ModelConnectionBlock>();
private final List<ModelOscillator> oscillators = new ArrayList<>();
private List<ModelConnectionBlock> connectionBlocks = new ArrayList<>();
private int keyFrom = 0;
private int keyTo = 127;
private int velFrom = 0;

Some files were not shown because too many files have changed in this diff Show More