Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
cfc7f025
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看板
提交
cfc7f025
编写于
10月 24, 2013
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8026163: Enhance media provisioning
Reviewed-by: art, skoivu
上级
83ec931c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
51 addition
and
80 deletion
+51
-80
src/share/classes/com/sun/media/sound/JDK13Services.java
src/share/classes/com/sun/media/sound/JDK13Services.java
+49
-78
src/share/classes/com/sun/media/sound/JSSecurityManager.java
src/share/classes/com/sun/media/sound/JSSecurityManager.java
+2
-2
未找到文件。
src/share/classes/com/sun/media/sound/JDK13Services.java
浏览文件 @
cfc7f025
...
...
@@ -25,27 +25,33 @@
package
com.sun.media.sound
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
javax.sound.midi.Receiver
;
import
javax.sound.midi.Sequencer
;
import
javax.sound.midi.Synthesizer
;
import
javax.sound.midi.Transmitter
;
import
javax.sound.midi.spi.MidiDeviceProvider
;
import
javax.sound.midi.spi.MidiFileReader
;
import
javax.sound.midi.spi.MidiFileWriter
;
import
javax.sound.midi.spi.SoundbankReader
;
import
javax.sound.sampled.Clip
;
import
javax.sound.sampled.Port
;
import
javax.sound.sampled.SourceDataLine
;
import
javax.sound.sampled.TargetDataLine
;
import
javax.sound.sampled.spi.AudioFileReader
;
import
javax.sound.sampled.spi.AudioFileWriter
;
import
javax.sound.sampled.spi.FormatConversionProvider
;
import
javax.sound.sampled.spi.MixerProvider
;
/**
* JDK13Services uses the Service class in JDK 1.3
* to discover a list of service providers installed
* in the system.
*
* JDK13Services uses the Service class in JDK 1.3 to discover a list of service
* providers installed in the system.
* <p>
* This class is public because it is called from javax.sound.midi.MidiSystem
* and javax.sound.sampled.AudioSystem. The alternative would be to make
* JSSecurityManager public, which is considered worse.
...
...
@@ -54,80 +60,55 @@ import javax.sound.sampled.TargetDataLine;
*/
public
final
class
JDK13Services
{
/** The default for the length of the period to hold the cache.
This value is given in milliseconds. It is equivalent to
1 minute.
*/
private
static
final
long
DEFAULT_CACHING_PERIOD
=
60000
;
/** Filename of the properties file for default provider properties.
This file is searched in the subdirectory "lib" of the JRE directory
(this behaviour is hardcoded).
/**
* Filename of the properties file for default provider properties. This
* file is searched in the subdirectory "lib" of the JRE directory (this
* behaviour is hardcoded).
*/
private
static
final
String
PROPERTIES_FILENAME
=
"sound.properties"
;
/** Cache for the providers.
Class objects of the provider type (MixerProvider, MidiDeviceProvider
...) are used as keys. The values are instances of ProviderCache.
*/
private
static
final
Map
providersCacheMap
=
new
HashMap
();
/** The length of the period to hold the cache.
This value is given in milliseconds.
*/
private
static
long
cachingPeriod
=
DEFAULT_CACHING_PERIOD
;
/** Properties loaded from the properties file for default provider
properties.
/**
* Properties loaded from the properties file for default provider
* properties.
*/
private
static
Properties
properties
;
/*
* Private, no-args constructor to ensure against instantiation.
/**
* Private, no-args constructor to ensure against instantiation.
*/
private
JDK13Services
()
{
}
/** Set the period provider lists are cached.
This method is only intended for testing.
*/
public
static
void
setCachingPeriod
(
int
seconds
)
{
cachingPeriod
=
seconds
*
1000L
;
}
/** Obtains a List containing installed instances of the
providers for the requested service.
The List of providers is cached for the period of time given by
{@link #cachingPeriod cachingPeriod}. During this period, the same
List instance is returned for the same type of provider. After this
period, a new instance is constructed and returned. The returned
List is immutable.
@param serviceClass The type of providers requested. This should be one
of AudioFileReader.class, AudioFileWriter.class,
FormatConversionProvider.class, MixerProvider.class,
MidiDeviceProvider.class, MidiFileReader.class, MidiFileWriter.class or
SoundbankReader.class.
@return A List of providers of the requested type. This List is
immutable.
/**
* Obtains a List containing installed instances of the providers for the
* requested service. The returned List is immutable.
*
* @param serviceClass The type of providers requested. This should be one
* of AudioFileReader.class, AudioFileWriter.class,
* FormatConversionProvider.class, MixerProvider.class,
* MidiDeviceProvider.class, MidiFileReader.class,
* MidiFileWriter.class or SoundbankReader.class.
*
* @return A List of providers of the requested type. This List is
* immutable.
*/
public
static
synchronized
List
getProviders
(
Class
serviceClass
)
{
ProviderCache
cache
=
(
ProviderCache
)
providersCacheMap
.
get
(
serviceClass
);
if
(
cache
==
null
)
{
cache
=
new
ProviderCache
();
providersCacheMap
.
put
(
serviceClass
,
cache
);
}
if
(
cache
.
providers
==
null
||
System
.
currentTimeMillis
()
>
cache
.
lastUpdate
+
cachingPeriod
)
{
cache
.
providers
=
Collections
.
unmodifiableList
(
JSSecurityManager
.
getProviders
(
serviceClass
));
cache
.
lastUpdate
=
System
.
currentTimeMillis
();
public
static
List
<?>
getProviders
(
final
Class
<?>
serviceClass
)
{
final
List
<?>
providers
;
if
(!
MixerProvider
.
class
.
equals
(
serviceClass
)
&&
!
FormatConversionProvider
.
class
.
equals
(
serviceClass
)
&&
!
AudioFileReader
.
class
.
equals
(
serviceClass
)
&&
!
AudioFileWriter
.
class
.
equals
(
serviceClass
)
&&
!
MidiDeviceProvider
.
class
.
equals
(
serviceClass
)
&&
!
SoundbankReader
.
class
.
equals
(
serviceClass
)
&&
!
MidiFileWriter
.
class
.
equals
(
serviceClass
)
&&
!
MidiFileReader
.
class
.
equals
(
serviceClass
))
{
providers
=
new
ArrayList
<>(
0
);
}
else
{
providers
=
JSSecurityManager
.
getProviders
(
serviceClass
);
}
return
cache
.
providers
;
return
Collections
.
unmodifiableList
(
providers
)
;
}
/** Obtain the provider class name part of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
...
...
@@ -219,14 +200,4 @@ public final class JDK13Services {
}
return
properties
;
}
// INNER CLASSES
private
static
class
ProviderCache
{
// System time of the last update in milliseconds.
public
long
lastUpdate
;
// The providers.
public
List
providers
;
}
}
src/share/classes/com/sun/media/sound/JSSecurityManager.java
浏览文件 @
cfc7f025
...
...
@@ -185,8 +185,8 @@ final class JSSecurityManager {
return
thread
;
}
static
<
T
>
List
<
T
>
getProviders
(
final
Class
<
T
>
providerClass
)
{
List
<
T
>
p
=
new
ArrayList
<>();
static
synchronized
<
T
>
List
<
T
>
getProviders
(
final
Class
<
T
>
providerClass
)
{
List
<
T
>
p
=
new
ArrayList
<>(
7
);
// ServiceLoader creates "lazy" iterator instance, but it ensures that
// next/hasNext run with permissions that are restricted by whatever
// creates the ServiceLoader instance, so it requires to be called from
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录