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

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?