I'm using the following pseudo code to get audio using audioRecord and play it audioTrack for eg a hearing aid project.
your_audio_thread_run()
{
declare audio buffer
create AudioRecord
create AudioTrack
start both
while(1)
{
capture mic to buffer
write buffer to output track
}
}
Please correct me if I'm wrong: audioRecord and audioTrack are created on the same thread so when the audio is captured using audioRecord, your_audio_thread_run will block and will have to wait until the buffer is filled out. Am i right? In this scenario there will be delay until sound is output to audioTrack.
Should i use 2 threads, one for audioRecord and another for audioTrack?If so how?