Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
40ec59e8
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
40ec59e8
编写于
9月 14, 2010
作者:
A
amenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6944033: RFE: add PCM_FLOAT support
Reviewed-by: dav
上级
e3d87e52
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
126 addition
and
35 deletion
+126
-35
src/share/classes/com/sun/media/sound/AudioFloatConverter.java
...hare/classes/com/sun/media/sound/AudioFloatConverter.java
+2
-4
src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
...lasses/com/sun/media/sound/AudioFloatFormatConverter.java
+11
-11
src/share/classes/com/sun/media/sound/DLSSoundbank.java
src/share/classes/com/sun/media/sound/DLSSoundbank.java
+3
-3
src/share/classes/com/sun/media/sound/SoftMixingMixer.java
src/share/classes/com/sun/media/sound/SoftMixingMixer.java
+5
-5
src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
...classes/com/sun/media/sound/WaveExtensibleFileReader.java
+2
-2
src/share/classes/com/sun/media/sound/WaveFloatFileReader.java
...hare/classes/com/sun/media/sound/WaveFloatFileReader.java
+3
-2
src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java
...hare/classes/com/sun/media/sound/WaveFloatFileWriter.java
+4
-5
src/share/classes/javax/sound/sampled/AudioFormat.java
src/share/classes/javax/sound/sampled/AudioFormat.java
+10
-3
test/javax/sound/sampled/AudioFormat/PCM_FLOAT_support.java
test/javax/sound/sampled/AudioFormat/PCM_FLOAT_support.java
+86
-0
未找到文件。
src/share/classes/com/sun/media/sound/AudioFloatConverter.java
浏览文件 @
40ec59e8
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,
2010,
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
...
...
@@ -40,8 +40,6 @@ import javax.sound.sampled.AudioFormat.Encoding;
*/
public
abstract
class
AudioFloatConverter
{
public
static
final
Encoding
PCM_FLOAT
=
new
Encoding
(
"PCM_FLOAT"
);
/***************************************************************************
*
* LSB Filter, used filter least significant byte in samples arrays.
...
...
@@ -982,7 +980,7 @@ public abstract class AudioFloatConverter {
format
.
getSampleSizeInBits
()
+
7
)
/
8
)
-
4
);
}
}
}
else
if
(
format
.
getEncoding
().
equals
(
PCM_FLOAT
))
{
}
else
if
(
format
.
getEncoding
().
equals
(
Encoding
.
PCM_FLOAT
))
{
if
(
format
.
getSampleSizeInBits
()
==
32
)
{
if
(
format
.
isBigEndian
())
conv
=
new
AudioFloatConversion32B
();
...
...
src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
浏览文件 @
40ec59e8
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008,
2010,
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
...
...
@@ -469,7 +469,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
}
private
Encoding
[]
formats
=
{
Encoding
.
PCM_SIGNED
,
Encoding
.
PCM_UNSIGNED
,
AudioFloatConverter
.
PCM_FLOAT
};
Encoding
.
PCM_FLOAT
};
public
AudioInputStream
getAudioInputStream
(
Encoding
targetEncoding
,
AudioInputStream
sourceStream
)
{
...
...
@@ -481,7 +481,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
float
samplerate
=
format
.
getSampleRate
();
int
bits
=
format
.
getSampleSizeInBits
();
boolean
bigendian
=
format
.
isBigEndian
();
if
(
targetEncoding
.
equals
(
AudioFloatConverter
.
PCM_FLOAT
))
if
(
targetEncoding
.
equals
(
Encoding
.
PCM_FLOAT
))
bits
=
32
;
AudioFormat
targetFormat
=
new
AudioFormat
(
encoding
,
samplerate
,
bits
,
channels
,
channels
*
bits
/
8
,
samplerate
,
bigendian
);
...
...
@@ -520,19 +520,19 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
public
Encoding
[]
getSourceEncodings
()
{
return
new
Encoding
[]
{
Encoding
.
PCM_SIGNED
,
Encoding
.
PCM_UNSIGNED
,
AudioFloatConverter
.
PCM_FLOAT
};
Encoding
.
PCM_FLOAT
};
}
public
Encoding
[]
getTargetEncodings
()
{
return
new
Encoding
[]
{
Encoding
.
PCM_SIGNED
,
Encoding
.
PCM_UNSIGNED
,
AudioFloatConverter
.
PCM_FLOAT
};
Encoding
.
PCM_FLOAT
};
}
public
Encoding
[]
getTargetEncodings
(
AudioFormat
sourceFormat
)
{
if
(
AudioFloatConverter
.
getConverter
(
sourceFormat
)
==
null
)
return
new
Encoding
[
0
];
return
new
Encoding
[]
{
Encoding
.
PCM_SIGNED
,
Encoding
.
PCM_UNSIGNED
,
AudioFloatConverter
.
PCM_FLOAT
};
Encoding
.
PCM_FLOAT
};
}
public
AudioFormat
[]
getTargetFormats
(
Encoding
targetEncoding
,
...
...
@@ -571,17 +571,17 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
}
}
if
(
targetEncoding
.
equals
(
AudioFloatConverter
.
PCM_FLOAT
))
{
formats
.
add
(
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
if
(
targetEncoding
.
equals
(
Encoding
.
PCM_FLOAT
))
{
formats
.
add
(
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
AudioSystem
.
NOT_SPECIFIED
,
32
,
channels
,
channels
*
4
,
AudioSystem
.
NOT_SPECIFIED
,
false
));
formats
.
add
(
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
formats
.
add
(
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
AudioSystem
.
NOT_SPECIFIED
,
32
,
channels
,
channels
*
4
,
AudioSystem
.
NOT_SPECIFIED
,
true
));
formats
.
add
(
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
formats
.
add
(
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
AudioSystem
.
NOT_SPECIFIED
,
64
,
channels
,
channels
*
8
,
AudioSystem
.
NOT_SPECIFIED
,
false
));
formats
.
add
(
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
formats
.
add
(
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
AudioSystem
.
NOT_SPECIFIED
,
64
,
channels
,
channels
*
8
,
AudioSystem
.
NOT_SPECIFIED
,
true
));
}
...
...
src/share/classes/com/sun/media/sound/DLSSoundbank.java
浏览文件 @
40ec59e8
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,
2010,
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
...
...
@@ -781,7 +781,7 @@ public class DLSSoundbank implements Soundbank {
}
if
(
sampleformat
==
3
)
{
audioformat
=
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
samplerate
,
bits
,
Encoding
.
PCM_FLOAT
,
samplerate
,
bits
,
channels
,
framesize
,
samplerate
,
false
);
}
...
...
@@ -965,7 +965,7 @@ public class DLSSoundbank implements Soundbank {
sampleformat
=
1
;
else
if
(
audioformat
.
getEncoding
().
equals
(
Encoding
.
PCM_SIGNED
))
sampleformat
=
1
;
else
if
(
audioformat
.
getEncoding
().
equals
(
AudioFloatConverter
.
PCM_FLOAT
))
else
if
(
audioformat
.
getEncoding
().
equals
(
Encoding
.
PCM_FLOAT
))
sampleformat
=
3
;
fmt_chunk
.
writeUnsignedShort
(
sampleformat
);
...
...
src/share/classes/com/sun/media/sound/SoftMixingMixer.java
浏览文件 @
40ec59e8
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008,
2010,
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
...
...
@@ -118,16 +118,16 @@ public class SoftMixingMixer implements Mixer {
AudioSystem
.
NOT_SPECIFIED
,
bits
,
channels
,
channels
*
bits
/
8
,
AudioSystem
.
NOT_SPECIFIED
,
true
));
}
formats
.
add
(
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
formats
.
add
(
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
AudioSystem
.
NOT_SPECIFIED
,
32
,
channels
,
channels
*
4
,
AudioSystem
.
NOT_SPECIFIED
,
false
));
formats
.
add
(
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
formats
.
add
(
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
AudioSystem
.
NOT_SPECIFIED
,
32
,
channels
,
channels
*
4
,
AudioSystem
.
NOT_SPECIFIED
,
true
));
formats
.
add
(
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
formats
.
add
(
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
AudioSystem
.
NOT_SPECIFIED
,
64
,
channels
,
channels
*
8
,
AudioSystem
.
NOT_SPECIFIED
,
false
));
formats
.
add
(
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
formats
.
add
(
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
AudioSystem
.
NOT_SPECIFIED
,
64
,
channels
,
channels
*
8
,
AudioSystem
.
NOT_SPECIFIED
,
true
));
}
...
...
src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
浏览文件 @
40ec59e8
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,
2010,
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
...
...
@@ -271,7 +271,7 @@ public class WaveExtensibleFileReader extends AudioFileReader {
bits
,
channels
,
framesize
,
samplerate
,
false
,
p
);
}
}
else
if
(
subFormat
.
equals
(
SUBTYPE_IEEE_FLOAT
))
{
audioformat
=
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
audioformat
=
new
AudioFormat
(
Encoding
.
PCM_FLOAT
,
samplerate
,
bits
,
channels
,
framesize
,
samplerate
,
false
,
p
);
}
else
throw
new
UnsupportedAudioFileException
();
...
...
src/share/classes/com/sun/media/sound/WaveFloatFileReader.java
浏览文件 @
40ec59e8
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,
2010,
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.net.URL;
import
javax.sound.sampled.AudioFileFormat
;
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.UnsupportedAudioFileException
;
...
...
@@ -102,7 +103,7 @@ public class WaveFloatFileReader extends AudioFileReader {
throw
new
UnsupportedAudioFileException
();
AudioFormat
audioformat
=
new
AudioFormat
(
AudioFloatConverter
.
PCM_FLOAT
,
samplerate
,
bits
,
channels
,
Encoding
.
PCM_FLOAT
,
samplerate
,
bits
,
channels
,
framesize
,
samplerate
,
false
);
AudioFileFormat
fileformat
=
new
AudioFileFormat
(
AudioFileFormat
.
Type
.
WAVE
,
audioformat
,
...
...
src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java
浏览文件 @
40ec59e8
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008,
2010,
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.io.OutputStream;
import
javax.sound.sampled.AudioFileFormat
;
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.AudioFileFormat.Type
;
...
...
@@ -48,8 +49,7 @@ public class WaveFloatFileWriter extends AudioFileWriter {
public
Type
[]
getAudioFileTypes
(
AudioInputStream
stream
)
{
if
(!
stream
.
getFormat
().
getEncoding
().
equals
(
AudioFloatConverter
.
PCM_FLOAT
))
if
(!
stream
.
getFormat
().
getEncoding
().
equals
(
Encoding
.
PCM_FLOAT
))
return
new
Type
[
0
];
return
new
Type
[]
{
Type
.
WAVE
};
}
...
...
@@ -58,8 +58,7 @@ public class WaveFloatFileWriter extends AudioFileWriter {
if
(!
Type
.
WAVE
.
equals
(
type
))
throw
new
IllegalArgumentException
(
"File type "
+
type
+
" not supported."
);
if
(!
stream
.
getFormat
().
getEncoding
().
equals
(
AudioFloatConverter
.
PCM_FLOAT
))
if
(!
stream
.
getFormat
().
getEncoding
().
equals
(
Encoding
.
PCM_FLOAT
))
throw
new
IllegalArgumentException
(
"File format "
+
stream
.
getFormat
()
+
" not supported."
);
}
...
...
src/share/classes/javax/sound/sampled/AudioFormat.java
浏览文件 @
40ec59e8
/*
* Copyright (c) 1999, 20
07
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 20
10
, 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
...
...
@@ -552,14 +552,14 @@ public class AudioFormat {
* which is simply a linear (proportional) representation of the sound
* waveform. With PCM, the number stored in each sample is proportional
* to the instantaneous amplitude of the sound pressure at that point in
* time. The numbers
are frequently signed or unsigned integer
s.
* time. The numbers
may be signed or unsigned integers or float
s.
* Besides PCM, other encodings include mu-law and a-law, which are nonlinear
* mappings of the sound amplitude that are often used for recording speech.
* <p>
* You can use a predefined encoding by referring to one of the static
* objects created by this class, such as PCM_SIGNED or
* PCM_UNSIGNED. Service providers can create new encodings, such as
* compressed audio formats
or floating-point PCM samples
, and make
* compressed audio formats, and make
* these available through the <code>{@link AudioSystem}</code> class.
* <p>
* The <code>Encoding</code> class is static, so that all
...
...
@@ -589,6 +589,13 @@ public class AudioFormat {
*/
public
static
final
Encoding
PCM_UNSIGNED
=
new
Encoding
(
"PCM_UNSIGNED"
);
/**
* Specifies floating-point PCM data.
*
* @since 1.7
*/
public
static
final
Encoding
PCM_FLOAT
=
new
Encoding
(
"PCM_FLOAT"
);
/**
* Specifies u-law encoded data.
*/
...
...
test/javax/sound/sampled/AudioFormat/PCM_FLOAT_support.java
0 → 100644
浏览文件 @
40ec59e8
/*
* Copyright (c) 2010, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6944033
* @summary Tests that PCM_FLOAT encoding is supported
* @compile -source 1.7 PCM_FLOAT_support.java
* @run main PCM_FLOAT_support
* @author Alex Menkov
*
*/
import
javax.sound.sampled.AudioFormat.Encoding
;
import
javax.sound.sampled.AudioSystem
;
public
class
PCM_FLOAT_support
{
static
Encoding
pcmFloatEnc
;
static
boolean
testFailed
=
false
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// 1st checks Encoding.PCM_FLOAT is available
pcmFloatEnc
=
Encoding
.
PCM_FLOAT
;
Encoding
[]
encodings
=
AudioSystem
.
getTargetEncodings
(
pcmFloatEnc
);
out
(
"conversion from PCM_FLOAT to "
+
encodings
.
length
+
" encodings:"
);
for
(
Encoding
e:
encodings
)
{
out
(
" - "
+
e
);
}
if
(
encodings
.
length
==
0
)
{
testFailed
=
true
;
}
test
(
Encoding
.
PCM_SIGNED
);
test
(
Encoding
.
PCM_UNSIGNED
);
if
(
testFailed
)
{
throw
new
Exception
(
"test failed"
);
}
out
(
"test passed."
);
}
static
void
out
(
String
s
)
{
System
.
out
.
println
(
s
);
}
static
boolean
test
(
Encoding
enc
)
{
out
(
"conversion "
+
enc
+
" -> PCM_FLOAT:"
);
Encoding
[]
encodings
=
AudioSystem
.
getTargetEncodings
(
enc
);
for
(
Encoding
e:
encodings
)
{
if
(
e
.
equals
(
pcmFloatEnc
))
{
out
(
" - OK"
);
return
true
;
}
}
out
(
" - FAILED (not supported)"
);
testFailed
=
true
;
return
false
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录