real time audio recording and sending
<p>I'm trying to capture audio from a microphone and no matter what buffer 
size (<code>bufferSizeInBytes</code>) I set at construct time of <code>AudioRecord</code>, when 
I do a <code>AudioRecord.read</code> I always get <code>8192</code> bytes of audio data (128 
ms). I would like the <code>AudioRecord.read</code> be able to read <code>40ms</code> of data 
(<code>2560 bytes</code>). The only working sample code that I can find is Sipdroid 
(<a href="http://code.google.com/p/sipdroid/source/browse/trunk/src/org/sipdroid/media/RtpStreamSender.java%29" rel="nofollow"><code>RtpStreamSender.java</code></a>) which I haven't tried.
 Here's the relevant piece of my code: </p>

<pre><code>public void run()
{ 
running = true; 
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URG ENT_AUDIO); 
try { 
     frameSize = AudioRecord.getMinBufferSize(samplingRate, 
              AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); 
     Log.i(TAG, "trying to capture " + String.format("%d", frameSize) + " bytes"); 
     record = new AudioRecord(MediaRecorder.AudioSource.MIC, samplingRate, 
    AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, frameSize);
     record.startRecording(); 
     byte[] buffer = new byte[frameSize]; 
     while (running)
     { 
        record.read(buffer, 0, frameSize); 
        Log.i(TAG, "Captured " + String.format("%d", frameSize) + " bytes of audio"); 
     } 
     record.stop(); 
     record.release(); 
 } catch (Throwable t) { 
 Log.e(TAG, "Failed to capture audio"); 
   } 
 }
</code></pre>

<p>My questions/comments are: </p>

<ol>
<li>Is this a limitation of AudioRecord class and/or the particular 
device ? </li>
<li>I don't see a method to query the supported sampling rate (steps of 
bufferSizeInBytes) a given device can do. It would be nice if there's 
one. </li>
<li>Can we use AudioRecord.OnRecordPositionUpdateListener and how?</li>
<li>In above code encoding pcm in 8 bit is not working. why?
if anyone tried sipdroid code, help me.
Thanks in advance, </li>
</ol>
