【发布时间】:2014-07-09 18:06:29
【问题描述】:
我已将IMX 板背靠背连接到电脑。
我在板上运行一个二进制文件,它每 5.7 毫秒发送 1024 个字节的音频帧。
pc接收帧并使用
printf("snd_pcm_avail %d \n",snd_pcm_avail (FMWK.FMWK_Handler.playback_handle));
err = snd_pcm_writei(FMWK.FMWK_Handler.playback_handle, OutputPointer, PERIOD_BYTES);
播放时,每 6 秒我就会损坏管道
播放成功时的日志
snd_pcm_avail 32
snd_pcm_avail 17
snd_pcm_avail 81
snd_pcm_avail 25
snd_pcm_avail 89
snd_pcm_avail 32
snd_pcm_avail 17
snd_pcm_avail 81
snd_pcm_avail 32
snd_pcm_avail 17
snd_pcm_avail 81
snd_pcm_avail 25
snd_pcm_avail 89
snd_pcm_avail 32
snd_pcm_avail 17
snd_pcm_avail 81
大约减少了 56 当 5 秒后使用率增加并且缓冲区溢出 buffer_size=256 的配置限制
日志:
snd_pcm_avail 89
snd_pcm_avail 112
snd_pcm_avail 96
snd_pcm_avail 120
snd_pcm_avail 104
snd_pcm_avail 129
snd_pcm_avail 153
snd_pcm_avail 137
snd_pcm_avail 160
snd_pcm_avail 184
snd_pcm_avail 168
snd_pcm_avail 193
snd_pcm_avail 176
snd_pcm_avail 201
snd_pcm_avail 224
snd_pcm_avail 209
snd_pcm_avail 232
snd_pcm_avail 217
snd_pcm_avail 240
snd_pcm_avail -32
(AVB Info) 12:26:11 PM.606306 (Slave) ==> Broken pipe
snd_pcm_avail 256
snd_pcm_avail 48
我将 period_size 设置为 128
我不确定我是否在 snd_pcm 的初始配置中遗漏了什么?是44.1khz音频。
【问题讨论】:
-
这些音频帧从何而来?您如何测量 5.7 毫秒?
-
我们在发送端实现了一个定时器,它每 5.7ms 发送 1024 个字节。
-
@user3659653:您不得使用系统计时器(使用 ALSA)来确定何时发送下一帧。是的,理智的事情是期待,这是可行的。但不幸的是,进程调度程序的粒度本身是毫秒级的,因此您无法将时间精确到 +/-0.1 毫秒。它更像是您可以有效获得的 +/-2ms 精度。此外,DAC 时钟和您的系统定时器时钟不会同步运行(这是 PC 架构的一个巨大设计愚蠢,可以通过外围互连标准的下一个修订版轻松消除),因此您必须只依赖在 DAC 采样时钟上。
-
Datenwolf 感谢您的回复。我如何从 DAC 导出时序,因为在用户空间中没有要读取的抽象或接口。如何获得用户空间的编解码器时钟,是否有任何提供此 ADC/DAC 时钟的 alsa 接口?
-
如何回复发送方和接收方的 DAC 时钟?..有什么方法可以获取 DAC/ADC 的时序?
标签: buffer playback pcm alsa overrun