2022-3-3 11:38:03
Platform: Rockchip
OS: Android 7.1.2
Kernel: 4.4
问题分析
当插上USB录音设备开机时,由于USB声卡被优先挂载,导致系统声卡不出声音,因此需要将系统声卡固定成默认播放声卡
解决方案
1、使用cat proc/asound/cards命令打印出系统声卡的名字。
2、在系统中强制使用系统声卡做为默认声卡
--- a/hardware/rockchip/audio/tinyalsa_hal/alsa_route.c
+++ b/hardware/rockchip/audio/tinyalsa_hal/alsa_route.c
@@ -58,26 +58,26 @@ struct mixer* mMixerCapture;
*/
int route_init(void)
{
- char soundCardID[20] = "";
+ char soundCardID[20] = "rockchipes8316c";
static FILE * fp;
unsigned i, config_count = sizeof(sound_card_config_list) / sizeof(struct alsa_sound_card_config);
- size_t read_size;
+ size_t read_size=15;
ALOGV("route_init()");
- fp = fopen("/proc/asound/card0/id", "rt");
- if (!fp) {
- ALOGE("Open sound card0 id error!");
- } else {
- read_size = fread(soundCardID, sizeof(char), sizeof(soundCardID), fp);
- fclose(fp);
+ //fp = fopen("/proc/asound/card0/id", "rt");
+ //if (!fp) {
+ // ALOGE("Open sound card0 id error!");
+ //} else {
+ // read_size = fread(soundCardID, sizeof(char), sizeof(soundCardID), fp);
+ // fclose(fp);
if (soundCardID[read_size - 1] == 'n') {
read_size--;
soundCardID[read_size] = '