版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kris_fei/article/details/70208202 </div>
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-f57960eb32.css">
<div class="htmledit_views" id="content_views">
Platform: ROCKCHIP
OS: Android 6.0
Kernel: 3.10.92
main -> bootanimation_main.cpp
new BootAnimation -> Bootanimation.cpp
BootAnimation::threadLoop ->
BootAnimation::playMusic ->
property_set(“ctl.start”, “startup_rington”); -> //音频文件存在才会调用.
音频文件路径:
/system/media/audio/startup.wav
init进程去启startup_rington service, service的定义如下
rk3288/device/rockchip/common/init.rk30board.rc
//默认禁止,参数表示音频文件隔多久之后开始播放,见后面脚本文件.
service startup_rington /system/bin/tinyplaywav /system/media/audio/startup.wav 3
class core
user system
group graphics audio system
disabled
oneshot
编译生成:
rk3288/device/rockchip/common/device.mk
PRODUCT_COPY_FILES += <br>
device/rockchip/common/tinyplaywav:system/bin/tinyplaywav
tinyplaywav其实是个脚本
rk3288/device/rockchip/common/tinyplaywav
[kris@:~/rk3288/device/rockchip/common]$ cat tinyplaywav
#!/system/bin/sh
#LOG_FILE=/data/tinyplaywave.log
# check input
if [ $# -lt 1 ] ; then
#echo “[tinyplaywav] not wav file to play!!” >> $LOG_FILE
exit 1
fi
//wav文件:/system/media/audio/startup.wav
# set parameter
WAV_FILE=$1
//休眠3秒后播放
if [ $# -eq 2 ] ; then
# sleep some time
#echo “[tinyplaywav] sleep $2 s” >> $LOG_FILE
sleep $2
fi
//最终调用的是tinyalsa工具
# play wav file
#echo “[tinyplaywav] start play, wav file is: $WAV_FILE” >>
L
O
G
F
I
L
E
<
/
s
p
a
n
>
/
/
先
切
换
到
s
p
e
a
k
e
r
t
i
n
y
m
i
x
−
D
0
<
s
p
a
n
c
l
a
s
s
=
"
h
l
j
s
−
s
t
r
i
n
g
"
>
"
P
l
a
y
b
a
c
k
P
a
t
h
"
<
/
s
p
a
n
>
<
s
p
a
n
c
l
a
s
s
=
"
h
l
j
s
−
s
t
r
i
n
g
"
>
"
S
P
K
"
<
/
s
p
a
n
>
/
/
然
后
播
放
t
i
n
y
p
l
a
y
<
s
p
a
n
c
l
a
s
s
=
"
h
l
j
s
−
v
a
r
i
a
b
l
e
"
>
LOG_FILE</span> //先切换到speaker tinymix -D 0 <span class="hljs-string">"Playback Path"</span> <span class="hljs-string">"SPK"</span> //然后播放 tinyplay <span class="hljs-variable">
LOGFILE</span>//先切换到speakertinymix−D0<spanclass="hljs−string">"PlaybackPath"</span><spanclass="hljs−string">"SPK"</span>//然后播放tinyplay<spanclass="hljs−variable">WAV_FILE -D 0 -d 0wav文件播放时间可以根据开机动画来决定.