static int snd_pcm_hw_rule_format(struct snd_pcm_hw_params *params,
struct snd_pcm_hw_rule *rule)
{
unsigned int k;
struct snd_interval *i = hw_param_interval(params, rule->deps[0]);
struct snd_mask m;
struct snd_mask *mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
snd_mask_any(&m); // m->bits[]全部置1
for (k = 0; k <= SNDRV_PCM_FORMAT_LAST; ++k) {
int bits;
if (! snd_mask_test(mask, k)) // params下第k个SNDRV_PCM_HW_PARAM_FORMAT
continue; // 如果没有设置,那么continue,下面只关心有效的params
bits = snd_pcm_format_physical_width(k); // 取出第k项对应的物理位宽
if (bits <= 0)
continue; /* ignore invalid formats */
if ((unsigned)bits < i->min || (unsigned)bits > i->max)
snd_mask_reset(&m, k); // 将[i->min,i->max]之间的bit保留,小于min或者大于max的所有bit清0
}
return snd_mask_refine(mask, &m); // mask->bits[] &= m->bits[]进行交集计算,进一步约束mask->bits[]
}
阅读(1604) | 评论(0) | 转发(0) |