On Sat, Feb 26, 2022 at 01:14:12AM +0800, su wrote: > My application is to play a single stream with pulseaudio Asynchronous API based on "Main Loop - A minimal but fast implementation based on poll()." implementation . I am going to set up an independent thread for pulseaudio context and the related stream setup and I would like to use "Polled" model instead of "Asynchronous " model to feed the audio raw data . > > > The point is : data is transferred with pa_stream_write() at "Polled" model at the other thread. Namely , at the other thread , both pa_stream_writable_size() and pa_stream_write() will be executed from time to time . Will it work ? There is some useful information about thread safety in the docs here: https://freedesktop.org/software/pulseaudio/doxygen/threaded_mainloop.html The short answer is that you must use locks to prevent concurrent calls to the pulse APIs. It is not safe for two threads to execute calls to pa_stream_write() simultaneously. --Sean