alsa_aplay 出现 Warning: rate is not accurate

来源:互联网 发布:刘备是汉室宗亲吗 知乎 编辑:程序博客网 时间:2024/05/01 07:26

           最近项目中需要添加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;elsesnprintf(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)。



0 0
原创粉丝点击