[pulseaudio-discuss] Playback and Recording isn't working simultaneously

Sayem Ahmed sayem64 at gmail.com
Sun Nov 27 22:54:59 PST 2011

Hi All,

I have created two C++ classes (Recorder, Player) for recording and 
playback. They have a common base class which takes care of creating the 
mainloop, mainloop API and context. Each of these two classes run in 
separate threads (Qt thread). The Recorder captures data from the stream 
and writes it into a common buffer. The Player loops through the buffer 
and writes any available data into the output device.

The problem is that this program shows inconsistent behaviour. Sometimes 
it works (I can hear what what I am saying in the microphone), but most 
of the times it doesn't work at all. The player callback (the one that I 
set up using ****_set_write_callback) executes one time at the beginning 
of the execution. After that it doesn't execute anymore (I've tested it 
with debug messages). It doesn't reports any overflow/underflow 
conditions either. The recorder is working as far as I've checked 
(written the captured data into a file and played it using aplay). I 
don't know what's the problem here. Is it because I've created two 
mainloops in a single application or there are some other reasons?

Here are my codes -

     1. Common base class for recorder and player: 
     2. Recorder Class: http://pastebin.com/r6hWCpG6
     3. Player Class: http://pastebin.com/DDg5B1R1
     4. Code that initiates/stops recording/playback: 

Thank you in advance.

Sayem Ahmed

More information about the pulseaudio-discuss mailing list