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:
Branden Archer
2015-12-26 17:51:16 -05:00
parent 828e6a16f6
commit 4635a78574

View File

@@ -71,6 +71,9 @@ public class MonitorActivity extends Activity
OutputStream out = socket.getOutputStream(); OutputStream out = socket.getOutputStream();
socket.setSendBufferSize(bufferSize);
Log.d(TAG, "Socket send buffer size: " + socket.getSendBufferSize());
while (socket.isConnected() && Thread.currentThread().isInterrupted() == false) while (socket.isConnected() && Thread.currentThread().isInterrupted() == false)
{ {
int read = audioRecord.read(buffer, 0, bufferSize); int read = audioRecord.read(buffer, 0, bufferSize);