Skip to main content

Issue with AudioRecord behaviour



I'm struggling to get things right using AudioRecord.





Basically what I'm trying to do is seldomly record from the audio on my Android device. I don't have to get a continuous stream of bytes from the audio source, but I have to feed a buffer every 5 minutes or so.





The problem is that the memory used by my program increases everytime I'm recording (I used the DDMS to investigate my memory issue). I reduced my code to the following lines to better understand the issue.







buffersizebytes = AudioRecord.getMinBufferSize(SAMPPERSEC,

channelConfiguration, audioEncoding);

tabbAudioBuffer = new byte[buffersizebytes];



setContentView(R.layout.main);



audioRecord = new AudioRecord(

android.media.MediaRecorder.AudioSource.MIC, SAMPPERSEC,

channelConfiguration, audioEncoding, buffersizebytes);



int i=1000;

while(i-->0) {

audioRecord.startRecording();

audioRecord.stop();

}



audioRecord.release();

audioRecord = null;







Please let me know if you can help me with my problem. Thanks.


Comments

Popular posts from this blog

Wildcards in a hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost . The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local , site2.local etc, and have them all resolve to localhost , while Apache serves a different site accordingly.