On Mon, 2011-04-04 at 00:27 -0700, sohail abbasi wrote: > Hi , everyone > > I am new to audio programing(as well pulseaudio). I have to add > pulseaudio support in an application already working with ALSA and > OSS. the designe of my application is such that I have to read 320 > samples in read function each time. stream attributes are 16bit , > 16khz , and 2 channels. So I need to read 1280 bytes in > pa_stream_peek. > > But I am unable to read 320 samples each time. some time more , some > time less ,and some time 0. How can I set buffer attributes to force > pa_stream_read to read 320 samples each time. Hmm... The documentation for the fragsize field of pa_buffer_attr seems to imply that the fragment size is always a constant, which according to your experience is not true. That's the only parameter for controlling the fragment sizes when recording, so there's probably no way you can make Pulseaudio give you constant size fragments. You probably can and have to do some buffering in the pulseaudio support component for the application you're working on. So when you get a fragment from pulseaudio, you copy the data to an internal buffer and give data to the application only if there's at least 1280 bytes available, and of course exactly 1280 bytes at a time - any leftovers will be saved until the next fragment arrives. -- Tanu