Android recording issue with AudioRecord
<p>I am Using the following code for recording and playing it in real time after some delay.But its repeating the same voice again and again with increasing amplitude and some crackling sound.For example if I speak "Hello" in microphone then its repeating the same "hello" voice over and over again with increasing amplitude and with some crackling background sound..I have Tried many combinations but no success</p>

<pre><code> public void run1()
  {

     android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
        final int bufferSize=AudioRecord.getMinBufferSize(freq,AudioFormat.CHANNEL_CONFIGURATION_MONO,AudioFormat.ENCODING_PCM_16BIT);

        Log.e("Error", "Read write failed"+bufferSize);
        audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, freq,
                AudioFormat.CHANNEL_CONFIGURATION_MONO,
                AudioFormat.ENCODING_PCM_16BIT,bufferSize*10);

        audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, freq,
                AudioFormat.CHANNEL_CONFIGURATION_MONO,
                AudioFormat.ENCODING_PCM_16BIT,bufferSize*10,
                AudioTrack.MODE_STREAM);



        //audioTrack.setPlaybackRate(freq);
         final byte[] buffer = new byte[bufferSize];
        audioRecord.startRecording();
        Log.i("abc", "Audio Recording started");
        audioTrack.play();
        Log.i("abc", "Audio Playing started");
        Rthread = new Thread(new Runnable() {
            public void run() {
                while (true) {
                    try {
                        audioRecord.read(buffer, 0, bufferSize);                                    
                        audioTrack.write(buffer, 0, buffer.length);

                    } catch (Throwable t) {
                        Log.e("Error", "Read write failed");
                        t.printStackTrace();
                    }
                }
            }
        });
        Rthread.start();

    }
</code></pre>

<p>Any help will be greatly appreciated</p>
