gpt4 book ai didi

c - 使用 libpulse 播放多个流

转载 作者:太空宇宙 更新时间:2023-11-04 04:45:06 26 4
gpt4 key购买 nike

如何使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com