IT. Expert System.

Java Standard Edition (SE)

AudioSystem.java


< Contents

Appendix 1: Code Overview: AudioSystem.java

For the benefit of service providers and API implementers, a brief overview of the Java Sound source code is provided.

javax.sound.sampled.AudioSystem is the entry point to JavaSound for obtaining resources; i.e., mixers, lines, etc. And each method of AudioSystem involves getting the providers of some service—MixerProvider[], FormatConversionProvider[], AudioFileReader[], or AudioFileWriter[]. Then the method goes on to obtain some specific information or perform some task. There is much similarity in how these methods work. Let us take a look at how getMixerInfo() works.

The following is a sequence diagram of getMixerInfo() in AudioSystem.java:

sequence diagram of getmixerinfo() in audiosystem.java

getMixerInfo() in AudioSystem first calls getMixerProviders(), a private static method of AudioSystem. The first thing that getMixerProviders() does is attempt to load sun.misc.Service. If an exception is thrown, it means that a pre-1.3 JRE is in use and there is no service provider lookup mechanism present. If an exception is thrown, then sun.media.sound.DefaultServices is used to obtain service providers (not depicted in above diagram). If the 1.3 mechanims is present, then getJDK13Serives() is called (shown above) with "javax.sound.sampled.spi.MixerProvider" as the argument.

getJDK13Services() is another private static method of AudioSystem. It attempts to the load the class for "com.sun.media.sound.JDK13Services", and if it succeeds it set Class jdk13Services equal to it. A bit of trickery is then performed by using Class.getMethod() to get the getProviders() method of jdk13Services, which is returned as object Method m. The method is then invoked, which has the effect of invoking getProviders("javax.sound.sampled.spi.MixerProvider") on JDK13Services. This in turn uses the providers() method of sun.misc.Service to return a vector of mixer providers, MixerProvider[]. The getMixerInfo() method of MixerProvider is then called on each element of the vector to return info (Mixer.info) for all mixers of all mixer providers.

Other services are handled in a similar way. For instance, getTargetEncodings() calls getFormatConversionProviders(), getAudioFileFormat() calls getAudioFileReaders(), etc., which are similarly structured to getMixerProviders().

 



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 382 / 158726433. Delta: 0.03074 с