How to port new audio codec into Android
来源:互联网 发布:音乐截取软件手机 编辑:程序博客网 时间:2024/05/21 10:43
How to port new audio codec into Android
1.Prepare the codec driver
The codec driver is under alsa-driver, the code is in kernel_imx/sound. For each codec driver , it includes three part: codec driver, machine driver and platform driver.
a.Codec driver
It is put in sound/soc/codecs/. If you do not find the codec driver you need, please ask the codec vendor to supply.
b.Platform driver
it is in sound/soc/fsl/. Platform driver is for the interface and dma operation in the soc. We already have these drivers, like imx-ssi.c, imx-pcm-dma-mx2.c.
c.Machine driver
It is in sound/soc/fsl/. This driver is the only one that user need to write. Which is the connection of Codec driver and platform driver. Please refer imx-wm8962.c
2. Test the codec driver
If you use the alsa-lib, Use the alsa-player, alsa-recorder, alsa-mixer to verify the codec driver, to found the issues.
If you use tinyalsa interface, please use tinycap, tinyplay, tinymix to test.
3. Add the codec in the Audio HAL
We use the tinyalsa as the default interface which is supplied by Google. The audio HAL for android is in hardware/imx/alsa/. It is easy to add new codec in this hal.
a. Add a new configure file for the codec. Like config_wm8962.h, config_hdmi.h. Use SPDIF codec as example.
static struct audio_card spdif_card = {
.name = "imx-spdif",
.driver_name = "imx-spdif", //driver_name, which is used to scan the supported sound card.
.supported_devices = AUDIO_DEVICE_OUT_AUX_DIGITAL | AUDIO_DEVICE_IN_AUX_DIGITAL, //which devices is supported by the card.
.defaults = NULL, // mixer control for different route
.bt_output = NULL,
.speaker_output = NULL,
.hs_output = NULL,
.earpiece_output = NULL,
.vx_hs_mic_input = NULL,
.mm_main_mic_input = NULL,
.vx_main_mic_input = NULL,
.mm_hs_mic_input = NULL,
.vx_bt_mic_input = NULL,
.mm_bt_mic_input = NULL,
.card = 0, // which will be set by the HAL.
.out_rate = 0, //which will be set by the HAL
.in_rate = 0, //which will be set by the HAL.
};
b. Add the configure file in the tinyalsa_hal.c.
diff --git a/alsa/tinyalsa_hal.c b/alsa/tinyalsa_hal.c
index 8cc37a4..22148d7 100644
--- a/alsa/tinyalsa_hal.c
+++ b/alsa/tinyalsa_hal.c
@@ -44,6 +44,7 @@
#include "config_hdmi.h"
#include "config_usbaudio.h"
#include "config_nullcard.h"
+#include "config_spdif.h"
/* ALSA ports for IMX */
@@ -85,7 +86,7 @@
#define PRODUCT_DEVICE_PROPERTY "ro.product.device"
#define PRODUCT_NAME_PROPERTY "ro.product.name"
#define PRODUCT_DEVICE_IMX "imx"
-#define SUPPORT_CARD_NUM 5
+#define SUPPORT_CARD_NUM 6
/*"null_card" must be in the end of this array*/
struct audio_card *audio_card_list[SUPPORT_CARD_NUM] = {
@@ -93,6 +94,7 @@ struct audio_card *audio_card_list[SUPPORT_CARD_NUM] = {
&wm8962_card,
&hdmi_card,
&usbaudio_card,
+ &spdif_card, //please add the card before the null_card.
&null_card,
};
c. Finished. Compile the file and test.
阅读全文
0 0
- How to port new audio codec into Android
- How to port native (C/C++) library into android.
- How to port native (C/C++) library into android.
- FFMPEG -- How to add one new CODEC
- How to port lighttpd to Android
- How to port pcre 8.33 to Android
- How to use Android HW Video Codec
- How to use Android HW Video Codec
- How to intergrate a new library into OpenCore
- How to intergrate a new library into OpenCore
- How to add a new package into BuildRoot
- How to install Android plugin into NetBeans
- How to add SMSC feature into Android
- How to add project into Android BSP
- Android audio codec power consumption
- how to use HW accelerated video codec on android
- How to new an emulator for Android?
- How to use an ActiveX script task to import data into a new Excel file
- 给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方
- KPI之痛:有哪些奇葩的技术人员考核方式?
- elasticsearch 东八区问题
- Android Xml文件操作
- java字符串除法
- How to port new audio codec into Android
- [C++ 从入门到放弃-06]C++STL之multimap多重映照容器
- PAT甲级 1007. Maximum Subsequence Sum (25)
- 关于Toast的一些常见操作
- 正则表达式基础
- 获取任意小数点位的百分比表示
- oracle的nvl和nvl2函数
- 16s rDNA数据分析经验总结
- POJ 1005 & ZOJ 1049 & UVA 2363