1
votes

I created and Audio Track and Audio Recorder object and tried to get the microphone sound back to the speaker.

To do that I created a task that "read" the Audio data from the Audio Record task and "Write it back" to the Audio track. It seems to be working fine. However playing with this application trying some data manipulation I learned that this task that copy the Audio Track data and write is back is practically do nothing - I deleted it and stayed only with the two lines:

    audioRecord.startRecording();
    audioTrack.play();

No read or writes - the application continue to work - i.e. mic data echoed to the speaker! In practice all read and write operations I was trying to performs seems to be ignored!

Some other unexpected behaviour:

I tried to stop this process buy calling AudioTrack.stop() or AudioTrack.pause() - nothing happens, the only way to stop the audio was by calling AudioRecord.stop(), However after stooping the AudioRecord I could find no way to restart it.

Does anyone else experienced this as well? Does anyone have a solution? Can anyone explain this strange behavior of the Android AudioTrack and AudioRecord?

1

1 Answers

2
votes

These 3 lines should work for you when you want to stop audioTrack

audioTrack.flush();
audioTrack.stop();
audioTrack.release();