Set the TCP send buffer size to avoid buffering audio
If the send buffer size is large and the receiver is unable to keep up, then audio samples will collect on the monitor and lag will accumulate. As only the most recent sample is important, reduce the send buffer size to the minimum AudioRecord buffer size.
This commit is contained in:
@@ -71,6 +71,9 @@ public class MonitorActivity extends Activity
|
||||
|
||||
OutputStream out = socket.getOutputStream();
|
||||
|
||||
socket.setSendBufferSize(bufferSize);
|
||||
Log.d(TAG, "Socket send buffer size: " + socket.getSendBufferSize());
|
||||
|
||||
while (socket.isConnected() && Thread.currentThread().isInterrupted() == false)
|
||||
{
|
||||
int read = audioRecord.read(buffer, 0, bufferSize);
|
||||
|
||||
Reference in New Issue
Block a user