alsa_aplay 出现 Warning: rate is not accurate

           最近项目中需要添加88.2k rate的驱动支持。之前加过192k的HDMI trueHD支持,因此想88.2k应该是支持的,于是用cooledit 做了一个88.2k rate的wav文件,在串口中用alsa_aplay播放测试。

          alsa_aplay  -D hw:0,1 -t wav -c 2 -r 88200 -f S16_LE /storage/sdcard0/1k_10db_88k_60s.wav

         出现如下提示:

         Signed 16 bit Little Endian, Rate 88200 Hz, Stereo,

        Warning: rate is not accurate (requested = 88200Hz, got = 96000Hz)
         please, try the plug plugin

         搜索了一下打印的地方代码。

         external/alsa-utils/aplay/aplay.c

        

static void set_params(void)
{
	snd_pcm_hw_params_t *params;
	snd_pcm_sw_params_t *swparams;
	snd_pcm_uframes_t buffer_size;
	int err;
	size_t n;
	unsigned int rate;
	snd_pcm_uframes_t start_threshold, stop_threshold;
	snd_pcm_hw_params_alloca(¶ms);
	snd_pcm_sw_params_alloca(&swparams);
	err = snd_pcm_hw_params_any(handle, params);
	if (err < 0) {
		error(_("Broken configuration for this PCM: no configurations available"));
		prg_exit(EXIT_FAILURE);
	}
 
         ...........................
	
         rate = hwparams.rate;
	err = snd_pcm_hw_params_set_rate_near(handle, params, &hwparams.rate, 0);
	assert(err >= 0);
	if ((float)rate * 1.05 < hwparams.rate || (float)rate * 0.95 > hwparams.rate) {
		if (!quiet_mode) {
			char plugex[64];
			const char *pcmname = snd_pcm_name(handle);
			<span style="color:#ff0000;">fprintf(stderr, _("Warning: rate is not accurate (requested = %iHz, got = %iHz)\n"), rate, hwparams.rate);
</span>			if (! pcmname || strchr(snd_pcm_name(handle), ':'))
				*plugex = 0;
			else
				snprintf(plugex, sizeof(plugex), "(-Dplug:%s)",
					 snd_pcm_name(handle));
			fprintf(stderr, _("         please, try the plug plugin %s\n"),
				plugex);
		}
	}
	rate = hwparams.rate;

 

从打印来看,rate = 88.2k, alsa_aplay传递过来的参数,hwparams.rate=96k是从底层snd_pcm_hw_params获得的参数。


因此,可以判断是底层kernel的参数没有加88.2k的支持,检查后果然发现对应的dai没有加这个rate的支持。

static struct snd_soc_dai_driver xxx_dai[] = {
	{
		.name = "xxx-dai",
		.playback = {
			.stream_name = "S/PDIF Playback",
			.channels_min = 1,
			.channels_max = 8,
			.rates = (
					SNDRV_PCM_RATE_32000 |
					SNDRV_PCM_RATE_44100 |
					SNDRV_PCM_RATE_48000 |
					<span style="color:#ff6666;"><strong>SNDRV_PCM_RATE_88200 |</strong></span>
					SNDRV_PCM_RATE_96000  |
					SNDRV_PCM_RATE_176400 |
					SNDRV_PCM_RATE_192000),
			.formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)。



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值