hardware/rockchip/audio/tinyalsa_hal/audio.hw.c
/*
* get sound card infor by parser node: /proc/asound/cards
* the sound card number is not always the same value
*/
static void read_out_sound_card(struct stream_out *out)
{
struct audio_device *device = NULL;
int card = 0;
char str[32];
char id[20];
size_t len;
FILE* file = NULL;
if((out == NULL) || (out->dev == NULL)) {
return ;
}
device = out->dev;
set_default_dev_info(device->dev_out, SND_OUT_SOUND_CARD_UNKNOWN, 0);
for (card = 0; card < SNDRV_CARDS; card++) {
sprintf(str, "proc/asound/card%d/id", card); // 这里会打印当前已经就绪的audio设备
if (access(str, 0)) {
ALOGD("No exist %s, break and finish parsing", str);
break;
}
file = fopen(str, "r");
if (!file) {
ALOGD("Could reading %s property", str);
continue;
}
len = fread(id, sizeof(char), sizeof(id)/sizeof(char), file);
fclose(file);
if (len == 0 || len > sizeof(id)/sizeof(char))
continue;
if (id[len - 1] == '\n') {
len--;
id[len] = '\0';
}
ALOGD("card%d id:%s", card, id);
get_specified_out_dev(&device->dev_out[SND_OUT_SOUND_CARD_SPEAKER], card, id, SPEAKER_OUT_NAME);
get_specified_out_dev(&device->dev_out[SND_OUT_SOUND_CARD_HDMI], card, id, HDMI_OUT_NAME);
get_specified_out_dev(&device->dev_out[SND_OUT_SOUND_CARD_SPDIF], card, id, SPDIF_OUT_NAME);
get_specified_out_dev(&device->dev_out[SND_OUT_SOUND_CARD_BT], card, id, BT_OUT_NAME);
}
dumpdev_info("out", device->dev_out, SND_OUT_SOUND_CARD_MAX);
return ;
}
如何接入蓝牙的PCM功能
最新推荐文章于 2024-04-17 16:27:45 发布