java - Android : manually streaming audio effeciently using AudioTrack and Socket -


the basic idea create application can record audio 1 device , send on wlan using sockets device play it. in nutshell lan voice chat program.

i recording live audio mic using audiorecord object , read recorded data byte array ,then write byte array tcp socket. receiving device reads byte array socket , writes buffer of audiotrack object.

its like

audio record-->byte array-->socket--->lan--->socket-->byte array-->audiotrack

the process repeated using while loops.

although audio playing there lagging between frames. i.e when hello receiver hears he--ll--o. although audio complete there lag between buffer blocks.

as far know lag due delay in lan transmission

how improve it? approach should use smooth in commercial online chat applications skype , gtalk?

sounds need longer buffer somewhere deal variance of audio transmission on lan. deal create intermediary buffer between socket byte array , audio track. buffer can x times size of buffer used in audiotrack object. this:

socket bytes -> audio buffer -> buffer fed audio track -> audio track

when audio starts recording, don't play until fills longer buffer. , after can feed blocks of size of audio track buffer audio track object.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -