Skip to content

Commit

Permalink
RecorderThread: Make AudioRecord internal buffer less excessively large
Browse files Browse the repository at this point in the history
When the call ends, everything still remaining in AudioRecord's internal
buffer is lost because there's no way to read the remaining bytes after
recording is stopped. With 20x the buffer size on eg. a device with a
1920 byte minimum buffer size and a sample rate of 8000 Hz, this may
cause 1.6 seconds of audio at the end of the call to be lost.

This commit should not have a negative effect since the large buffer
size was meant to address buffer overruns and the root cause of that
problem was addressed in #72.

Signed-off-by: Andrew Gunnerson <[email protected]>
  • Loading branch information
chenxiaolong committed Jun 6, 2022
1 parent 7c89e39 commit a73659d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/chiller3/bcr/RecorderThread.kt
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ class RecorderThread(
CHANNEL_CONFIG,
ENCODING,
// On some devices, MediaCodec occasionally has sudden spikes in processing time, so use
// a large internal buffer to reduce the chance of overrun on the recording side.
minBufSize * 20,
// a larger internal buffer to reduce the chance of overrun on the recording side.
minBufSize * 6,
)
val initialBufSize = audioRecord.bufferSizeInFrames *
audioRecord.format.frameSizeInBytesCompat
Expand Down

0 comments on commit a73659d

Please sign in to comment.