How to make audio playback start as early as possible

From Tizen Wiki
Jump to: navigation, search


This article is about how to make audio playback start as early as possible on Bay Trail platform. With these actions, the audio playback starts at about 2.05 seconds from power on.

Install alsa-lib and alsa-utils into rootfs

Download source code of alsa-lib and alsa-utils from ALSA-Projects, run command

        tar -xjf alsa-lib- 
        cd alsa-lib-
	./configure --prefix=/home/xxx/alsa_lib --disable-python --with-configdir=/usr/share/alsa
	make ; make install

	tar -xjf alsa-utils- 
        cd alsa-utils-
	./configure --prefix=/home/xxx/alsa_lib --with-alsa-inc-prefix=/home/xxx/alsa_lib/include 
		    --with-alsa-prefix=/home/xxx/alsa_lib/lib --disable-alsamixer --disable-xmlto --disable-nls
	make ; make install

to compile and install alsa-lib and alsa-utils.

Run command

        sudo cp -a   /home/xxx/alsa_lib/*    rootfs/usr/
	sudo cp -a   /usr/share/alsa/     rootfs/usr/share

to copy alsa-lib and alsa-utils to rootfs.

Write aplay.service to start audio playback

Create a unit file “aplay.service” under rootfs/usr/lib/systemd/systemand make it run as soon as systemd starts up.

	# aplay systemd service unit file

	Description=Play a wav file automotively 

	ExecStart=/usr/bin/aplay /root/test.wav


Run command :

       $ cd rootfs/usr/lib/systemd/system/local-fs.targets.wants/
       $ ln –s ../aplay.service  aplay.service

to enable aplay.service and make it run automatically at the very beginning of systemd.

Build firmware into kernel image

Enable "CONFIG_FIRMWARE_IN_KERNEL", "CONFIG_EXTRA_FIRMWARE_DIR" and "CONFIG_EXTRA_FIRMWARE" to build firmware into kernel image, for example:

       CONFIG_EXTRA_FIRMWARE_DIR="firmware"		// this means $(source_tree/firmware)

For more information about firmware build-in, please refer to Usage and Mechanism of kernel function "request firmware()".

Make related modules to be probed asynchronously

Make all the modules related to audio probe asynchronously to faster kernel start-up time. Usually, add option ".async_probe" in module's device driver, for example:

       static struct platform_driver sst_platform_driver = {
               .driver     = {
               .name       = "sst-platform",
               .owner      = THIS_MODULE,
               .async_probe = ASYNC_PROBE_LOCAL_NO_WAIT,
               .probe      = sst_platform_probe,
               .remove     = sst_platform_remove,

Delete redundant delay time in codec driver

Find out all the unnecessary "msleep()" in codec driver, delete them or change them to a shorter delay time.