Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
f31c3029
E
engine
项目概览
liujiuri
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f31c3029
编写于
12月 14, 2015
作者:
J
Jason Simmons
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2163 from jason-simmons/sound_pool_2
In SoundPool, have the client provide stream IDs
上级
e5c866cd
d9b4f66d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
13 deletion
+56
-13
sky/services/media/media.mojom
sky/services/media/media.mojom
+12
-4
sky/services/media/src/org/domokit/media/SoundPoolImpl.java
sky/services/media/src/org/domokit/media/SoundPoolImpl.java
+44
-9
未找到文件。
sky/services/media/media.mojom
浏览文件 @
f31c3029
...
...
@@ -16,14 +16,22 @@ interface MediaPlayer {
[ServiceName="media::SoundPool"]
interface SoundPool {
Load(handle<data_pipe_consumer> data_source) => (bool success, int32 sound_id);
Play(int32 sound_id, float left_volume, float right_volume, bool loop, float rate) =>
(bool success, int32 stream_id);
// Load a sound from a Mojo pipe.
Load(handle<data_pipe_consumer> data_source) =>
(bool success, int32 sound_id);
// Play a sound. The stream ID is supplied by the caller and can be used in
// other APIs to control this playback.
Play(int32 sound_id, int32 stream_id, array<float> channel_volumes, bool loop,
float rate) => (bool success);
// Stop playing a sound. After this call the stream ID is no longer valid.
Stop(int32 stream_id);
Pause(int32 stream_id);
Resume(int32 stream_id);
SetRate(int32 stream_id, float rate);
SetVolume(int32 stream_id,
float left_volume, float right_volume
);
SetVolume(int32 stream_id,
array<float> channel_volumes
);
PauseAll();
ResumeAll();
...
...
sky/services/media/src/org/domokit/media/SoundPoolImpl.java
浏览文件 @
f31c3029
...
...
@@ -32,12 +32,16 @@ public class SoundPoolImpl implements SoundPool, android.media.SoundPool.OnLoadC
private
final
ArrayList
<
File
>
mTempFiles
;
private
final
HashMap
<
Integer
,
LoadResponse
>
mPendingLoads
;
// Maps stream IDs provided by the client to stream IDs assigned by the Android SoundPool.
private
final
HashMap
<
Integer
,
Integer
>
mStreamIdMap
;
public
SoundPoolImpl
(
Core
core
,
Context
context
,
Executor
executor
,
int
maxStreams
)
{
mCore
=
core
;
mContext
=
context
;
mExecutor
=
executor
;
mTempFiles
=
new
ArrayList
<
File
>();
mPendingLoads
=
new
HashMap
<
Integer
,
LoadResponse
>();
mStreamIdMap
=
new
HashMap
<
Integer
,
Integer
>();
android
.
media
.
SoundPool
.
Builder
builder
=
new
android
.
media
.
SoundPool
.
Builder
();
builder
.
setMaxStreams
(
maxStreams
);
...
...
@@ -98,35 +102,66 @@ public class SoundPoolImpl implements SoundPool, android.media.SoundPool.OnLoadC
}
@Override
public
void
play
(
int
soundId
,
float
leftVolume
,
float
rightVolume
,
boolean
loop
,
float
rate
,
public
void
play
(
int
soundId
,
int
streamId
,
float
[]
channelVolumes
,
boolean
loop
,
float
rate
,
PlayResponse
callback
)
{
int
streamId
=
mSoundPool
.
play
(
soundId
,
leftVolume
,
rightVolume
,
0
,
loop
?
-
1
:
0
,
rate
);
callback
.
call
(
streamId
!=
0
,
streamId
);
if
(
channelVolumes
.
length
!=
2
)
{
Log
.
e
(
TAG
,
"setVolume: channelVolumes must be of length 2"
);
callback
.
call
(
false
);
return
;
}
int
poolStreamId
=
mSoundPool
.
play
(
soundId
,
channelVolumes
[
0
],
channelVolumes
[
1
],
0
,
loop
?
-
1
:
0
,
rate
);
if
(
poolStreamId
!=
0
)
{
mStreamIdMap
.
put
(
streamId
,
poolStreamId
);
callback
.
call
(
true
);
}
else
{
callback
.
call
(
false
);
}
}
@Override
public
void
stop
(
int
streamId
)
{
mSoundPool
.
stop
(
streamId
);
Integer
poolStreamId
=
mStreamIdMap
.
remove
(
streamId
);
if
(
poolStreamId
!=
null
)
{
mSoundPool
.
stop
(
poolStreamId
);
}
}
@Override
public
void
pause
(
int
streamId
)
{
mSoundPool
.
pause
(
streamId
);
Integer
poolStreamId
=
mStreamIdMap
.
get
(
streamId
);
if
(
poolStreamId
!=
null
)
{
mSoundPool
.
pause
(
poolStreamId
);
}
}
@Override
public
void
resume
(
int
streamId
)
{
mSoundPool
.
resume
(
streamId
);
Integer
poolStreamId
=
mStreamIdMap
.
get
(
streamId
);
if
(
poolStreamId
!=
null
)
{
mSoundPool
.
resume
(
poolStreamId
);
}
}
@Override
public
void
setRate
(
int
streamId
,
float
rate
)
{
mSoundPool
.
setRate
(
streamId
,
rate
);
Integer
poolStreamId
=
mStreamIdMap
.
get
(
streamId
);
if
(
poolStreamId
!=
null
)
{
mSoundPool
.
setRate
(
poolStreamId
,
rate
);
}
}
@Override
public
void
setVolume
(
int
streamId
,
float
leftVolume
,
float
rightVolume
)
{
mSoundPool
.
setVolume
(
streamId
,
leftVolume
,
rightVolume
);
public
void
setVolume
(
int
streamId
,
float
[]
channelVolumes
)
{
if
(
channelVolumes
.
length
!=
2
)
{
Log
.
e
(
TAG
,
"setVolume: channelVolumes must be of length 2"
);
return
;
}
Integer
poolStreamId
=
mStreamIdMap
.
get
(
streamId
);
if
(
poolStreamId
!=
null
)
{
mSoundPool
.
setVolume
(
poolStreamId
,
channelVolumes
[
0
],
channelVolumes
[
1
]);
}
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录