问题陈述:当作为文件转储时,我没有在输出中收到整首歌曲(我无法通过插孔听到歌曲,但我可以转储文件内容)。
摘录:我是ALSA编程的新手,我有一个嵌入式电路板,命令集有限。 我已经浏览了这里的链接: 需要ALSA教程,但我无法弄清楚这个时间相关的问题。
设定:
OS: linux 4.14.70
aplay: version 1.1.4 by Jaroslav Kysela
Advanced Linux Sound Architecture Driver Version k4.14.70.
所涉及的音频盒具有单独的硬件和独立的DSP,用于独立处理
信息流:Linux - > DSP核心
输入歌曲传送到linux内核,将歌曲加载到DMA区域 - >将DMA读入DSP使用的独立DMA环形缓冲区,并将其写入I2S输出路径到文件中
我可以看到歌曲的大小是960000字节,采样率为48000,S16_LE formwat,2通道,16位位深度 - >计算如下所示 - 根据页面“ https://www.colincrawley。 com / audio-duration-calculator / “
Bit Rate: 1536 kbps
Duration:
0 Hours : 0 Minutes : 5 Seconds . 34 Milliseconds
当我放入日志时,我的DSP内核只处理大约一段时间的歌曲。 在“aplay”应用程序发送ioctl调用以关闭linux上的音频接口之前1秒。
我的问题是:
aplay如何理解时间? 在5秒的时间内,我们怎么能确定它已经运行了5秒钟。
有没有办法理解等到在发出关闭的IOCTL命令之前将整首歌曲传输到DSP内核进行处理?
有关我正在输入的输入文件的更多信息:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 24000
period_size : 6000
period_time : 125000
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 6000
period_event : 0
start_threshold : 24000
stop_threshold : 24000
silence_threshold: 0
silence_size : 0
boundary : 6755399441055744000
appl_ptr : 0
hw_ptr : 0
我很乐意提供更多信息来理解为什么aplay应用程序会提前关闭歌曲。 但请注意它是一个封闭源项目。
我使用的命令:
aplay input.wav -c 2 -r 48000 -t wav
input size: 960044 bytes (including wav header)
output size: 306 KB observed before IOCTL call to close the audio interface occurs.
For a input.wav file of 960044 file size i.e., 938 KB,
time aplay input.wav returns:
real 0m0.988s
user 0m0.012s
sys 0m0.080s
To find the duration of wav file:
fileLength/(sampleRate*channel*bits per sample/8) = 960000/((48000 * 2 * 16)/8) = 5 seconds
If I run the same song on my Ubuntu machine, it is as expected:
real 0m5.452s
user 0m0.025s
sys 0m0.029s
有关为何会发生这种情况的任何提示? 如上所示,我可以看到aplay应用程序在0.98秒内退出。 但这首歌必须播放5秒钟。