【问题标题】:aplay quits before entire song is readaplay 在读完整首歌曲之前退出
【发布时间】:2019-09-26 01:16:45
【问题描述】:

问题说明:当转储为文件时,我没有在输出中收到整首歌曲(我无法通过插孔听到歌曲,但我可以转储文件内容)。

摘录:我是 ALSA 编程的新手,我有一块嵌入式板,命令集有限。我已经浏览了这里的链接:ALSA tutorial required,但我无法弄清楚这个与时间相关的问题。

设置:

OS: linux 4.14.70
aplay: version 1.1.4 by Jaroslav Kysela <perex@perex.cz>
Advanced Linux Sound Architecture Driver Version k4.14.70.

涉及的音频盒具有单独的硬件和单独的 DSP,用于独立处理

信息流:Linux -> DSP 内核

输入歌曲与linux内核通信,将歌曲加载到DMA区域 -> 将DMA读取到DSP使用的单独DMA环形缓冲区并将其写入I2S输出路径到文件中

我可以看到歌曲的大小是 960000 字节,采样率为 48000,S16_LE 格式,2 通道,16 位位深度 -> 计算如下 - 根据页面“https://www.colincrawley.com/audio-duration-calculator/

Bit Rate: 1536 kbps
Duration: 
0 Hours : 0 Minutes : 5 Seconds . 34 Milliseconds

当我输入日志时,我的 DSP 核心仅处理歌曲大约 10 分钟。在“aplay”应用程序发送 ioctl 调用以关闭 linux 上的音频接口之前 1 秒。

我的问题是:

  1. aplay 如何理解时间? 5秒时间,我们怎么能确定它已经运行了5秒呢。
  2. 有没有办法理解等到整首歌曲传输到 DSP 内核处理后再发出关闭 IOCTL 命令?

关于我输入的输入文件的更多信息:

  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 秒。

【问题讨论】:

  • 不清楚你在做什么但是如果你的代码正在执行 aplay 并且 aplay 子进程似乎退出得太早了我的猜测是它已经正确呈现了它的输入音频文件并发送了它的输出音频到已经缓冲它的系统...替代方法是消除使用 aplay 并编写自己的音频渲染
  • 我正在测试整个音频硬件,在播放音频输入并检查其保真度的过程中,我看到 aplay 应用程序在整个音频转储到输出路径之前就退出了,这让我很困惑问题出在哪里。

标签: linux audio playback alsa libalsa


【解决方案1】:

自定义音频硬件似乎存在问题,导致处理歌曲的时间延迟。现在似乎已修复。基本上,声音硬件必须至少根据 AXI 协议在读取字节时提供足够的延迟。但在这种情况下,情况并非如此。现在解决了。感谢关注

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多