该参数的正确类型是什么?

发布于 2024-09-25 07:14:45 字数 455 浏览 0 评论 0原文

这是给所有 ALSA 人的。我需要在这里进行健全性检查。我正在使用 alsa-lib api 来播放声音,我用来将数据写入驱动程序的函数是

snd_pcm_sframes_t snd_pcm_writei (snd_pcm_t* pcm,
                                  const void* buffer,
                                  snd_pcm_uframes_t size);

对于第三个参数,它应该是帧计数还是缓冲区大小(以字节为单位)?我之所以这么问,是因为我见过很多以字节为单位传递大小的示例。 文档

This one is for all you ALSA guys. I need a sanity check here. I am using the the alsa-lib api to play sounds and the function that I am using to write the data to the driver is

snd_pcm_sframes_t snd_pcm_writei (snd_pcm_t* pcm,
                                  const void* buffer,
                                  snd_pcm_uframes_t size);

For the third parameter, should it be the frame count or the size of the buffer in bytes? I'm asking because I have seen numerous examples where the size in bytes is passed in. One example is included in the documentation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手心的温暖 2024-10-02 07:14:45

根据文档,它是帧的数量,而不是字节的数量。

在示例中,您链接到的值恰好相同,因为它使用 8 位样本和一个通道,并且一个通道 8 位数据的一帧是一个字节。

According to the documentation, it's the amount of frames, not bytes.

In the example you linked to the values just happen to be the same because it's using 8-bit samples and one channel, and one frame of one channel 8-bit data is one byte.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文