dsp_map[]以sound-card的序号为数组索引号,数组内容为,相应声卡对应的默认pcm索引号[luther.gliethttp].
文件:sound/core/oss/pcm_oss.c
static int dsp_map[SNDRV_CARDS]; // insmod或者built-in时,该static静态量默认都将被置全0[luther.gliethttp].
module_param_array(dsp_map, int, NULL, 0444); // insmod时,指定了每个声卡的第几个stream对应的pcm,用于该声卡的默认流通道.
MODULE_PARM_DESC(dsp_map, "PCM device number assigned to 1st OSS device.");
static int snd_pcm_oss_register_minor(struct snd_pcm *pcm)
{
pcm->oss.reg = 0; // pcm->card->number为声卡号,dsp_map[pcm->card->number]为该声卡默认的pcm流通道
if (dsp_map[pcm->card->number] == (int)pcm->device) { // 查看打算注册的pcm的索引号pcm->device是否为为默认/dev/dsp对应通道
char name[128]; // snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback, capture, &pcm)
int duplex; // pcm->device = device;等于codec->pcm_devs++索引值
register_oss_dsp(pcm, 0); // 最后该pcm对应的/dev/dsp子节点号为((pcm->card->number) << 4 | pcm->device)
duplex = (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count > 0 && // 所以card0,card1间隔为16,即1<<4[luther.gliethttp].
pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count &&
!(pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX));
sprintf(name, "%s%s", pcm->name, duplex ? " (DUPLEX)" : "");
#ifdef SNDRV_OSS_INFO_DEV_AUDIO
snd_oss_info_register(SNDRV_OSS_INFO_DEV_AUDIO,
pcm->card->number,
name);
#endif
pcm->oss.reg++;
pcm->oss.reg_mask |= 1;
}
if (adsp_map[pcm->card->number] == (int)pcm->device) {
register_oss_dsp(pcm, 1);
pcm->oss.reg++;
pcm->oss.reg_mask |= 2;
}
if (pcm->oss.reg)
snd_pcm_oss_proc_init(pcm);
return 0;
}
阅读(377) | 评论(0) | 转发(0) |