Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
78958667
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
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看板
提交
78958667
编写于
9月 14, 2010
作者:
A
amenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
Reviewed-by: denis
上级
e417482c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
127 addition
and
23 deletion
+127
-23
src/share/classes/javax/sound/sampled/AudioFormat.java
src/share/classes/javax/sound/sampled/AudioFormat.java
+25
-23
test/javax/sound/sampled/AudioFormat/Matches_NOT_SPECIFIED.java
...avax/sound/sampled/AudioFormat/Matches_NOT_SPECIFIED.java
+102
-0
未找到文件。
src/share/classes/javax/sound/sampled/AudioFormat.java
浏览文件 @
78958667
...
@@ -431,34 +431,36 @@ public class AudioFormat {
...
@@ -431,34 +431,36 @@ public class AudioFormat {
/**
/**
* Indicates whether this format matches the one specified.
To match,
* Indicates whether this format matches the one specified.
*
two formats must have the same encoding, the same number of channels
,
*
To match, two formats must have the same encoding
,
* and
the same number of bits per sample and bytes per frame.
* and
consistent values of the number of channels, sample rate, sample size,
*
The two formats must also have the same sample rate,
*
frame rate, and frame size.
*
unless the specified format has the sample rate value <code>AudioSystem.NOT_SPECIFIED</code>,
*
The values of the property are consistent if they are equal
*
which any sample rate will match. The frame rates must
*
or the specified format has the property value
*
similarly be equal, unless the specified format has the frame rate
*
{@code AudioSystem.NOT_SPECIFIED}.
*
value <code>AudioSystem.NOT_SPECIFIED</code>. The byte order (big-endian or little-endian)
*
The byte order (big-endian or little-endian) must be the same
*
must match
if the sample size is greater than one byte.
* if the sample size is greater than one byte.
*
*
* @param format format to test for match
* @param format format to test for match
* @return <code>true</code> if this format matches the one specified,
* @return {@code true} if this format matches the one specified,
* <code>false</code> otherwise.
* {@code false} otherwise.
*/
/*
* $$kk: 04.20.99: i changed the semantics of this.
*/
*/
public
boolean
matches
(
AudioFormat
format
)
{
public
boolean
matches
(
AudioFormat
format
)
{
if
(
format
.
getEncoding
().
equals
(
getEncoding
())
if
(
format
.
getEncoding
().
equals
(
getEncoding
())
&&
&&
(
format
.
getChannels
()
==
AudioSystem
.
NOT_SPECIFIED
(
(
format
.
getSampleRate
()
==
(
float
)
AudioSystem
.
NOT_SPECIFIED
)
||
(
format
.
getSampleRate
()
==
getSampleRate
())
)
&&
||
format
.
getChannels
()
==
getChannels
())
(
format
.
getSampleSizeInBits
()
==
getSampleSizeInBits
())
&&
&&
(
format
.
getSampleRate
()
==
(
float
)
AudioSystem
.
NOT_SPECIFIED
(
format
.
getChannels
()
==
getChannels
()
&&
||
format
.
getSampleRate
()
==
getSampleRate
())
(
format
.
getFrameSize
()
==
getFrameSize
())
&&
&&
(
format
.
getSampleSizeInBits
()
==
AudioSystem
.
NOT_SPECIFIED
(
(
format
.
getFrameRate
()
==
(
float
)
AudioSystem
.
NOT_SPECIFIED
)
||
(
format
.
getFrameRate
()
==
getFrameRate
())
)
&&
||
format
.
getSampleSizeInBits
()
==
getSampleSizeInBits
())
(
(
format
.
getSampleSizeInBits
()
<=
8
)
||
(
format
.
isBigEndian
()
==
isBigEndian
())
)
)
)
&&
(
format
.
getFrameRate
()
==
(
float
)
AudioSystem
.
NOT_SPECIFIED
||
format
.
getFrameRate
()
==
getFrameRate
())
&&
(
format
.
getFrameSize
()
==
AudioSystem
.
NOT_SPECIFIED
||
format
.
getFrameSize
()
==
getFrameSize
())
&&
(
getSampleSizeInBits
()
<=
8
||
format
.
isBigEndian
()
==
isBigEndian
()))
{
return
true
;
return
true
;
}
return
false
;
return
false
;
}
}
...
...
test/javax/sound/sampled/AudioFormat/Matches_NOT_SPECIFIED.java
0 → 100644
浏览文件 @
78958667
/*
* 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 4937708
* @summary Tests that AudioFormat.matches handle NOT_SPECIFIED value in all fields
* @run main Matches_NOT_SPECIFIED
* @author Alex Menkov
*
*/
import
javax.sound.sampled.AudioFormat
;
import
javax.sound.sampled.AudioFormat.Encoding
;
import
javax.sound.sampled.AudioSystem
;
public
class
Matches_NOT_SPECIFIED
{
static
boolean
success
=
true
;
static
AudioFormat
f1
;
static
AudioFormat
f2
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
AudioFormat
f3
;
f1
=
new
AudioFormat
(
44100
,
16
,
2
,
true
,
false
);
f2
=
new
AudioFormat
(
Encoding
.
PCM_SIGNED
,
AudioSystem
.
NOT_SPECIFIED
,
AudioSystem
.
NOT_SPECIFIED
,
AudioSystem
.
NOT_SPECIFIED
,
AudioSystem
.
NOT_SPECIFIED
,
AudioSystem
.
NOT_SPECIFIED
,
false
);
test
(
true
);
// f1 = new AudioFormat(44100, 8, 16, true, false);
f2
=
new
AudioFormat
(
Encoding
.
PCM_SIGNED
,
AudioSystem
.
NOT_SPECIFIED
,
AudioSystem
.
NOT_SPECIFIED
,
AudioSystem
.
NOT_SPECIFIED
,
AudioSystem
.
NOT_SPECIFIED
,
AudioSystem
.
NOT_SPECIFIED
,
true
);
test
(
false
);
f1
=
new
AudioFormat
(
44100
,
8
,
8
,
true
,
false
);
test
(
true
);
if
(
success
)
{
out
(
"The test PASSED."
);
}
else
{
out
(
"The test FAILED."
);
throw
new
Exception
(
"The test FAILED"
);
}
}
static
void
test
(
boolean
shouldMatch
)
{
out
(
"testing:"
);
out
(
" - "
+
f1
.
toString
());
out
(
" - "
+
f2
.
toString
());
if
(
f1
.
matches
(
f2
))
{
if
(
shouldMatch
)
{
out
(
" (OK) MATCHES"
);
}
else
{
out
(
" (ERROR) MATCHES"
);
success
=
false
;
}
}
else
{
if
(
shouldMatch
)
{
out
(
" (ERROR) DOESNT MATCH!"
);
success
=
false
;
}
else
{
out
(
" (OK) DOESNT MATCH!"
);
}
}
}
static
void
out
(
String
s
)
{
System
.
out
.
println
(
s
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录