/**
* The default implementation of this method just determines whether
* this line is a source or target line, calls open(no-arg) on the
* mixer, and adds the line to the appropriate vector.
* The mixer may be opened at a format different than the line's
* format if it is a DataLine.
*/
final synchronized void open(Line line) throws LineUnavailableException {
if (Printer.trace) Printer.trace(">> AbstractMixer: open(line = " + line + ")");
// $$kk: 06.11.99: ignore ourselves for now
if (this.equals(line)) {
if (Printer.trace) Printer.trace("<< AbstractMixer: open(" + line + ") nothing done");
return;
}
// source line?
if (isSourceLine(line.getLineInfo())) {
if (! sourceLines.contains(line) ) {
// call the no-arg open method for the mixer; it should open at its
// default format if it is not open yet
open(false);
// we opened successfully! add the line to the list
sourceLines.addElement(line);
}
} else {
// target line?
if(isTargetLine(line.getLineInfo())) {
if (! targetLines.contains(line) ) {
// call the no-arg open method for the mixer; it should open at its
// default format if it is not open yet
open(false);
// we opened successfully! add the line to the list
targetLines.addElement(line);
}
} else {
if (Printer.err) Printer.err("Unknown line received for AbstractMixer.open(Line): " + line);
}
}
if (Printer.trace) Printer.trace("<< AbstractMixer: open(" + line + ") completed");
}
java类javax.sound.sampled.Line的实例源码
AbstractMixer.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
AbstractMixer.java 文件源码
项目:OpenJSharp
阅读 24
收藏 0
点赞 0
评论 0
/**
* Determines whether this is a source line for this mixer.
* Right now this just checks whether it's supported, but should
* check whether it actually belongs to this mixer....
*/
final boolean isSourceLine(Line.Info info) {
for (int i = 0; i < sourceLineInfo.length; i++) {
if (info.matches(sourceLineInfo[i])) {
return true;
}
}
return false;
}
AbstractLine.java 文件源码
项目:jdk8u-jdk
阅读 22
收藏 0
点赞 0
评论 0
/**
* Constructs a new AbstractLine.
* @param mixer the mixer with which this line is associated
* @param controls set of supported controls
*/
protected AbstractLine(Line.Info info, AbstractMixer mixer, Control[] controls) {
if (controls == null) {
controls = new Control[0];
}
this.info = info;
this.mixer = mixer;
this.controls = controls;
}
SoftMixingMixer.java 文件源码
项目:jdk8u-jdk
阅读 20
收藏 0
点赞 0
评论 0
public int getMaxLines(Line.Info info) {
if (info.getLineClass() == SourceDataLine.class)
return AudioSystem.NOT_SPECIFIED;
if (info.getLineClass() == Clip.class)
return AudioSystem.NOT_SPECIFIED;
return 0;
}
SoftMixingMixer.java 文件源码
项目:jdk8u-jdk
阅读 24
收藏 0
点赞 0
评论 0
public javax.sound.sampled.Line.Info[] getSourceLineInfo(
javax.sound.sampled.Line.Info info) {
int i;
ArrayList<javax.sound.sampled.Line.Info> infos = new ArrayList<javax.sound.sampled.Line.Info>();
for (i = 0; i < sourceLineInfo.length; i++) {
if (info.matches(sourceLineInfo[i])) {
infos.add(sourceLineInfo[i]);
}
}
return infos.toArray(new Line.Info[infos.size()]);
}
AbstractMixer.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
/**
* Determines whether this is a source line for this mixer.
* Right now this just checks whether it's supported, but should
* check whether it actually belongs to this mixer....
*/
final boolean isSourceLine(Line.Info info) {
for (int i = 0; i < sourceLineInfo.length; i++) {
if (info.matches(sourceLineInfo[i])) {
return true;
}
}
return false;
}
UnexpectedIAE.java 文件源码
项目:openjdk-jdk10
阅读 18
收藏 0
点赞 0
评论 0
public static void main(String argv[]) throws Exception {
boolean success = true;
Mixer.Info [] infos = AudioSystem.getMixerInfo();
for (int i=0; i<infos.length; i++) {
Mixer mixer = AudioSystem.getMixer(infos[i]);
System.out.println("Mixer is: " + mixer);
Line.Info [] target_line_infos = mixer.getTargetLineInfo();
for (int j = 0; j < target_line_infos.length; j++) {
try {
System.out.println("Trying to get:" + target_line_infos[j]);
mixer.getLine(target_line_infos[j]);
} catch (IllegalArgumentException iae) {
System.out.println("Unexpected IllegalArgumentException raised:");
iae.printStackTrace();
success = false;
} catch (LineUnavailableException lue) {
System.out.println("Unexpected LineUnavailableException raised:");
lue.printStackTrace();
success = false;
}
}
}
if (success) {
System.out.println("Test passed");
} else {
throw new Exception("Test FAILED");
}
}
SoftMixingMixer.java 文件源码
项目:jdk8u-jdk
阅读 24
收藏 0
点赞 0
评论 0
public boolean isLineSupported(javax.sound.sampled.Line.Info info) {
if (info != null) {
for (int i = 0; i < sourceLineInfo.length; i++) {
if (info.matches(sourceLineInfo[i])) {
return true;
}
}
}
return false;
}
FrameSizeTest.java 文件源码
项目:openjdk-jdk10
阅读 19
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws Exception {
boolean res=true;
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
for (int i = 0; i < mixerInfo.length; i++) {
Mixer mixer = AudioSystem.getMixer(mixerInfo[i]);
System.out.println(mixer);
Line.Info[] lineinfo = mixer.getSourceLineInfo();
for (int j = 0; j < lineinfo.length; j++) {
System.out.println(" " + lineinfo[j]);
try {
AudioFormat[] formats = ((DataLine.Info)lineinfo[j]).getFormats();
for (int k = 0; k < formats.length; k++) {
if ( (formats[k].getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)
|| formats[k].getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED))
&& (formats[k].getFrameSize() != AudioSystem.NOT_SPECIFIED)
&& ((formats[k].getSampleSizeInBits() == 16) || (formats[k].getSampleSizeInBits() == 8))
&& ((((formats[k].getSampleSizeInBits() + 7) / 8) * formats[k].getChannels()) != formats[k].getFrameSize())) {
System.out.println(" # " + formats[k] + ", getFrameSize() wrongly returns"+ formats[k].getFrameSize());
res=false;
}
}
} catch (ClassCastException e) {
}
}
}
if (res) {
System.out.println("Test passed");
} else {
System.out.println("Test failed");
throw new Exception("Test failed");
}
}
GetLine.java 文件源码
项目:openjdk-jdk10
阅读 19
收藏 0
点赞 0
评论 0
public static int run(String argv[], java.io.PrintStream out) {
String testCaseID = "LineListener2001";
log.println("===== " + testCaseID + " =====");
boolean failed = false;
Line l = null;
// get the default SourceDataLine
DataLine.Info s_info = new DataLine.Info(SourceDataLine.class, null);
Line.Info infos[] = AudioSystem.getSourceLineInfo( s_info );
if( infos.length < 1 ) {
log.println("Line.Info array == 0");
return STATUS_PASSED;
}
try {
l = AudioSystem.getLine(infos[0]);
} catch(SecurityException lue) {
log.println("SecurityException");
return STATUS_PASSED;
} catch (LineUnavailableException e1) {
log.println("LUE");
return STATUS_PASSED;
} catch (IllegalArgumentException iae) {
log.println("IllegalArgumentException should not be thrown "
+ "for supported line");
iae.printStackTrace(log);
return STATUS_FAILED;
}
out.println("Passed.");
return STATUS_PASSED;
}