c - 使用 libpulse 播放多个流

标签 c audio pulseaudio

如何使用 libpulse 播放多个 audio 流。我知道可以通过对多个流求和并使用 libaudio 进行播放,但是是否可以在 lib pulse api 上编写多个流并让 PulseAudio 进行求和?

最佳答案

我通过实现这个得到了解决方案。 libpulse API

同步多个播放流

PulseAudio allows applications to fully synchronize multiple playback streams that are connected to the same output device. That means the streams will always be played back sample-by-sample synchronously. If stream operations like pa_stream_cork() are issued on one of the synchronized streams, they are simultaneously issued on the others. To synchronize a stream to another, just pass the "master" stream as last argument to pa_stream_connect_playback(). To make sure that the freshly created stream doesn't start playback right-away, make sure to pass PA_STREAM_START_CORKED and – after all streams have been created – uncork them all with a single call to pa_stream_cork() for the master stream. To make sure that a particular stream doesn't stop to play when a server side buffer underrun happens on it while the other synchronized streams continue playing and hence deviate, you need to pass a "prebuf" pa_buffer_attr of 0 when connecting it.

关于c - 使用 libpulse 播放多个流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21991912/

相关文章:

c - 二维数组作为函数参数

c - 检索当前可执行文件名称的 glibc 函数?

c - 如何在C程序中使用 'BUFSIZ'将整个文件复制或写入另一个文件?

audio - PulseAudio 未检测到 RaspBMC 上的声卡

Java 音频无法在 Linux 中播放 wav 文件

c - 使用 malloc 动态创建字符串数组

iphone - 切换 View 时如何中断for循环?

ios - OpenAL 随机停止播放某些声音,只能通过重启来修复

javascript - 如何使用 Web Audio API 移动/调制音频缓冲频率

python - 使用 Numpy/Scipy 和 PulseAudio 的音频数据 IO