[RK3288][Android6.0] 开机播放音乐流程小结

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 += \
    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" >> $LOG_FILE
//先切换到speaker
tinymix -D 0 "Playback Path" "SPK"
//然后播放
tinyplay $WAV_FILE -D 0 -d 0
wav文件播放时间可以根据开机动画来决定.

你可能感兴趣的:(子类__Audio)