Fix audio capture buffer handling on Android.
Fix audio capture buffer handling on Android.

The buffer handling in OpenSL is:
1. enqueue the buffers;
2. wait for a callback;
3. inside the callback, read out the PCM data of current buffer and enqueue one buffer (it's the same buffer in this case).
4. go to step 2.

Current implementation has several problems:
a. When buffer #1 (not buffer #0) is read first time, it doesn't have PCM data recorded by the device. 
b. There are 2 buffer worth of time delay.
c. There are racing condtion since both OpenSL and AudioInputController hold the same buffer.

BUG=243506
R=xians@chromium.org

Review URL: https://codereview.chromium.org/15941002

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@202581 0039d316-1c4b-4281-b951-d872f2087c98

Chilledheart/chromium,patrickm/chromium.src,PeterWangIntel/chromium-crosswalk,jaruba/chromium.src,markYoungH/chromium.src,axinging/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,hgl888/chromium-crosswalk,chuan9/chromium-crosswalk,ltilve/chromium,hgl888/chromium-crosswalk-efl,M4sse/chromium.src,fujunwei/chromium-crosswalk,hujiajie/pa-chromium,hgl888/chromium-crosswalk,pozdnyakov/chromium-crosswalk,Jonekee/chromium.src,Just-D/chromium-1,anirudhSK/chromium,krieger-od/nwjs_chromium.src,M4sse/chromium.src,TheTypoMaster/chromium-crosswalk,anirudhSK/chromium,hgl888/chromium-crosswalk,M4sse/chromium.src,Just-D/chromium-1,mohamed--abdel-maksoud/chromium.src,Pluto-tv/chromium-crosswalk,dednal/chromium.src,M4sse/chromium.src,dednal/chromium.src,crosswalk-project/chromium-crosswalk-efl,krieger-od/nwjs_chromium.src,Just-D/chromium-1,Chilledheart/chromium,Chilledheart/chromium,krieger-od/nwjs_chromium.src,dednal/chromium.src,pozdnyakov/chromium-crosswalk,axinging/chromium-crosswalk,ondra-novak/chromium.src,Chilledheart/chromium,crosswalk-project/chromium-crosswalk-efl,ChromiumWebApps/chromium,axinging/chromium-crosswalk,anirudhSK/chromium,TheTypoMaster/chromium-crosswalk,M4sse/chromium.src,hgl888/chromium-crosswalk,Pluto-tv/chromium-crosswalk,dushu1203/chromium.src,littlstar/chromium.src,Fireblend/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,Jonekee/chromium.src,mogoweb/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,Just-D/chromium-1,pozdnyakov/chromium-crosswalk,hujiajie/pa-chromium,hujiajie/pa-chromium,PeterWangIntel/chromium-crosswalk,patrickm/chromium.src,ondra-novak/chromium.src,patrickm/chromium.src,dednal/chromium.src,mohamed--abdel-maksoud/chromium.src,axinging/chromium-crosswalk,dushu1203/chromium.src,Chilledheart/chromium,dednal/chromium.src,hgl888/chromium-crosswalk-efl,littlstar/chromium.src,anirudhSK/chromium,Fireblend/chromium-crosswalk,jaruba/chromium.src,mogoweb/chromium-crosswalk,M4sse/chromium.src,Chilledheart/chromium,ChromiumWebApps/chromium,Chilledheart/chromium,hgl888/chromium-crosswalk-efl,krieger-od/nwjs_chromium.src,chuan9/chromium-crosswalk,hgl888/chromium-crosswalk,patrickm/chromium.src,krieger-od/nwjs_chromium.src,mogoweb/chromium-crosswalk,Jonekee/chromium.src,axinging/chromium-crosswalk,ondra-novak/chromium.src,markYoungH/chromium.src,ChromiumWebApps/chromium,ondra-novak/chromium.src,chuan9/chromium-crosswalk,ltilve/chromium,krieger-od/nwjs_chromium.src,fujunwei/chromium-crosswalk,hujiajie/pa-chromium,dednal/chromium.src,mogoweb/chromium-crosswalk,bright-sparks/chromium-spacewalk,patrickm/chromium.src,mogoweb/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,ChromiumWebApps/chromium,Just-D/chromium-1,hujiajie/pa-chromium,bright-sparks/chromium-spacewalk,Pluto-tv/chromium-crosswalk,ltilve/chromium,Chilledheart/chromium,patrickm/chromium.src,bright-sparks/chromium-spacewalk,krieger-od/nwjs_chromium.src,chuan9/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,markYoungH/chromium.src,Pluto-tv/chromium-crosswalk,hgl888/chromium-crosswalk-efl,Pluto-tv/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,axinging/chromium-crosswalk,dushu1203/chromium.src,ondra-novak/chromium.src,anirudhSK/chromium,patrickm/chromium.src,Chilledheart/chromium,pozdnyakov/chromium-crosswalk,patrickm/chromium.src,dushu1203/chromium.src,mogoweb/chromium-crosswalk,hujiajie/pa-chromium,bright-sparks/chromium-spacewalk,Jonekee/chromium.src,dushu1203/chromium.src,dushu1203/chromium.src,chuan9/chromium-crosswalk,ChromiumWebApps/chromium,crosswalk-project/chromium-crosswalk-efl,dednal/chromium.src,mohamed--abdel-maksoud/chromium.src,ondra-novak/chromium.src,TheTypoMaster/chromium-crosswalk,M4sse/chromium.src,krieger-od/nwjs_chromium.src,dednal/chromium.src,pozdnyakov/chromium-crosswalk,jaruba/chromium.src,ltilve/chromium,Jonekee/chromium.src,ChromiumWebApps/chromium,markYoungH/chromium.src,PeterWangIntel/chromium-crosswalk,chuan9/chromium-crosswalk,Jonekee/chromium.src,jaruba/chromium.src,jaruba/chromium.src,ltilve/chromium,Just-D/chromium-1,dednal/chromium.src,fujunwei/chromium-crosswalk,dednal/chromium.src,hujiajie/pa-chromium,ltilve/chromium,Fireblend/chromium-crosswalk,fujunwei/chromium-crosswalk,ChromiumWebApps/chromium,Pluto-tv/chromium-crosswalk,krieger-od/nwjs_chromium.src,hgl888/chromium-crosswalk-efl,dushu1203/chromium.src,M4sse/chromium.src,fujunwei/chromium-crosswalk,Just-D/chromium-1,littlstar/chromium.src,dushu1203/chromium.src,littlstar/chromium.src,pozdnyakov/chromium-crosswalk,Fireblend/chromium-crosswalk,markYoungH/chromium.src,hgl888/chromium-crosswalk,Just-D/chromium-1,jaruba/chromium.src,TheTypoMaster/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,markYoungH/chromium.src,PeterWangIntel/chromium-crosswalk,ChromiumWebApps/chromium,crosswalk-project/chromium-crosswalk-efl,Pluto-tv/chromium-crosswalk,dushu1203/chromium.src,Fireblend/chromium-crosswalk,Jonekee/chromium.src,chuan9/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,crosswalk-project/chromium-crosswalk-efl,markYoungH/chromium.src,pozdnyakov/chromium-crosswalk,axinging/chromium-crosswalk,Jonekee/chromium.src,jaruba/chromium.src,hgl888/chromium-crosswalk-efl,pozdnyakov/chromium-crosswalk,anirudhSK/chromium,hgl888/chromium-crosswalk-efl,chuan9/chromium-crosswalk,anirudhSK/chromium,hgl888/chromium-crosswalk-efl,mohamed--abdel-maksoud/chromium.src,Fireblend/chromium-crosswalk,hgl888/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,jaruba/chromium.src,PeterWangIntel/chromium-crosswalk,fujunwei/chromium-crosswalk,ltilve/chromium,anirudhSK/chromium,jaruba/chromium.src,littlstar/chromium.src,mogoweb/chromium-crosswalk,bright-sparks/chromium-spacewalk,Jonekee/chromium.src,ltilve/chromium,ltilve/chromium,pozdnyakov/chromium-crosswalk,ChromiumWebApps/chromium,bright-sparks/chromium-spacewalk,mogoweb/chromium-crosswalk,Fireblend/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,markYoungH/chromium.src,Fireblend/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,ondra-novak/chromium.src,Pluto-tv/chromium-crosswalk,dushu1203/chromium.src,fujunwei/chromium-crosswalk,ChromiumWebApps/chromium,M4sse/chromium.src,dushu1203/chromium.src,mogoweb/chromium-crosswalk,jaruba/chromium.src,axinging/chromium-crosswalk,anirudhSK/chromium,fujunwei/chromium-crosswalk,chuan9/chromium-crosswalk,markYoungH/chromium.src,PeterWangIntel/chromium-crosswalk,hgl888/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,Fireblend/chromium-crosswalk,axinging/chromium-crosswalk,markYoungH/chromium.src,bright-sparks/chromium-spacewalk,hujiajie/pa-chromium,crosswalk-project/chromium-crosswalk-efl,Jonekee/chromium.src,patrickm/chromium.src,littlstar/chromium.src,fujunwei/chromium-crosswalk,hgl888/chromium-crosswalk-efl,Just-D/chromium-1,anirudhSK/chromium,hgl888/chromium-crosswalk,anirudhSK/chromium,axinging/chromium-crosswalk,krieger-od/nwjs_chromium.src,bright-sparks/chromium-spacewalk,hujiajie/pa-chromium,Jonekee/chromium.src,TheTypoMaster/chromium-crosswalk,pozdnyakov/chromium-crosswalk,jaruba/chromium.src,littlstar/chromium.src,ChromiumWebApps/chromium,crosswalk-project/chromium-crosswalk-efl,axinging/chromium-crosswalk,hujiajie/pa-chromium,M4sse/chromium.src,ChromiumWebApps/chromium,littlstar/chromium.src,anirudhSK/chromium,hujiajie/pa-chromium,ondra-novak/chromium.src,ondra-novak/chromium.src,markYoungH/chromium.src,mohamed--abdel-maksoud/chromium.src,pozdnyakov/chromium-crosswalk,dednal/chromium.src,mogoweb/chromium-crosswalk,hgl888/chromium-crosswalk-efl,PeterWangIntel/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,bright-sparks/chromium-spacewalk,mohamed--abdel-maksoud/chromium.src,krieger-od/nwjs_chromium.src,M4sse/chromium.src,Pluto-tv/chromium-crosswalk