日期:2014-05-16  浏览次数:23361 次

alsa音频驱动,overrun,underrun
telechips 8803. linux 2.6.35.7
在小系统下用arecord,aplay录放音测试,设置采样率在44100以上的单声道双声道录放都正常,但是在这个采样率一下的录音会提示overrun。调整了结构体snd_pcm_hardware的设置,有改变,但不是很清楚这个结构体的赋值是怎么计算出来的。
请问,如何调整驱动对采样率的支持?还有就是snd_pcm_hardware这个结构的怎么赋值?谢谢
当前设置如下
C/C++ code

#define __play_buf_size 4096
#define __play_buf_cnt  16

#define __cap_buf_size 4096
#define __cap_buf_cnt  16
static const struct snd_pcm_hardware tcc_pcm_hardware_play = {
    .info = (SNDRV_PCM_INFO_MMAP
             | SNDRV_PCM_INFO_MMAP_VALID
             | SNDRV_PCM_INFO_INTERLEAVED
             | SNDRV_PCM_INFO_BLOCK_TRANSFER
             | SNDRV_PCM_INFO_PAUSE
             | SNDRV_PCM_INFO_RESUME),

    .formats      = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE),
    .rates        = SNDRV_PCM_RATE_8000_96000,
    .rate_min     = 8000,
    .rate_max     = 96000, 
    .channels_min = 2,
    .channels_max = 2,                                

    .period_bytes_min = 1024,
    .period_bytes_max = __play_buf_size,
    .periods_min      = 2,
    .periods_max      = __play_buf_cnt ,
    .buffer_bytes_max = __play_buf_cnt * __play_buf_size ,
    .fifo_size = 16,  //ignored
};

static const struct snd_pcm_hardware tcc_pcm_hardware_capture = {
    .info = (SNDRV_PCM_INFO_MMAP
             | SNDRV_PCM_INFO_MMAP_VALID
             | SNDRV_PCM_INFO_INTERLEAVED
             | SNDRV_PCM_INFO_BLOCK_TRANSFER
             | SNDRV_PCM_INFO_PAUSE
             | SNDRV_PCM_INFO_RESUME),

    .formats      = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
    .rates        = SNDRV_PCM_RATE_8000_96000,
    .rate_min     = 8000,
    .rate_max     = 96000,
    .channels_min = 2,
    .channels_max = 2,                                

    .period_bytes_min = 1024,
    .period_bytes_max = __cap_buf_size ,
    .periods_min      = 2,
    .periods_max      = __cap_buf_cnt,
    .buffer_bytes_max = __cap_buf_cnt * __cap_buf_size,
    .fifo_size = 16, //ignored
};



------解决方案--------------------
问下楼主:你是soc架构的声卡还usb的声卡?
你录音是放在那个目录的?换个目录试试,最好不要放在sd卡里录音,可能有些问题,我前段时间也是这样的,我当时测试的usb声卡!
采样率的支持不是在pcm驱动里,是在codec驱动和ssi的驱动里面(soc架构是这样的。),两个采样率都是通过dai->playback.rates和dai->capture.rates。