【发布时间】:2009-12-01 17:13:43
【问题描述】:
在 linux 中这段代码不起作用:我添加了两行
// Added two lines.
DataLine.Info info = new DataLine.Info( SourceDataLine.class, audioFormat );
SourceDataLine dataLine = (SourceDataLine) AudioSystem.getLine( info );
// Adjust the volume on the output line.
if( dataLine.isControlSupported( FloatControl.Type.MASTER_GAIN)) {
// If inside this if, the Master_Gain must be supported. Yes?
FloatControl volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN);
// This line throws an exception. "Master_Gain not supported"
volume.setValue( 100.0F );
}
这正常吗?我该怎么做才能解决这个问题?
在 Windows 中它可以工作。
谢谢,马丁。
【问题讨论】:
-
这似乎是您正在使用的“dataLine”实现的问题。数据线的类型是什么?我希望 getControl() 仅在 isControlSupported 返回 false 时抛出此异常...
-
有可能你的dataLine不是windows和linux中同类型的dataline。通过调试此代码,您可以在 Linux 和 Windows 中调查 dataLine 的类型(它是 SourceDataLine 的子类型)。
-
是的,是同一种线。