fix issue when capturing with pre processing

When capturing audio with AEC or NS enabled there is a risk that
audio buffers are lost. This happens if the capture is started with a particular
timing with regard to playback. A particular case if when placing an outgoing video
chat with gTalk.
The problem is with the mechanism used to pass buffers between the capture thread and
the preprocessing thread. It is possible that the preprocessing thread locks in with the
timing of the capture thread and always gets a condition where buffers are not ready in which
case it will read new data from the driver causing every other buffer to be dropped.

The fix consists in modifying the buffer sync mechanism and have the preprocessing thread
wait for a condition in case the read buffer is not available yet.

Change-Id: I8ff33f762d600d6dbe8b0dda58973e96d68d02f9
2 files changed