Skip to content

Commit d34fb60

Browse files
committed
8000走默认的缓冲区大小
1 parent f4e6cce commit d34fb60

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

sdk/video-link-android/src/main/java/com/tencent/iot/video/link/util/audio/AudioRecordUtil.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,10 @@ private void init(int sampleRate, int channel, int bitDepth) {
200200
this.encodeBit = 8;
201201
}
202202
Log.e(TAG, "recordMinBufferSize is: "+ recordMinBufferSize);
203-
recordMinBufferSize = (sampleRate*this.channelCount*this.encodeBit/8)/1000*20; //20ms数据长度
204-
Log.e(TAG, "20ms recordMinBufferSize is: "+ recordMinBufferSize);
203+
if (sampleRate != 8000) {
204+
recordMinBufferSize = (sampleRate * this.channelCount * this.encodeBit / 8) / 1000 * 20; //20ms数据长度
205+
Log.e(TAG, "20ms recordMinBufferSize is: " + recordMinBufferSize);
206+
}
205207
Log.e(TAG, "AudioRecordUtil init Pitch is: "+ pitch);
206208
GvoiceJNIBridge.init(context);
207209
}
@@ -456,17 +458,7 @@ public void run() {
456458
if (buffer != null && pcmEncoder != null) {
457459
byte [] playerPcmBytes = onReadPlayerPlayPcm(buffer.length);
458460
if (playerPcmBytes != null && playerPcmBytes.length > 0) {
459-
byte[] expandBuffer = buffer;
460-
if (buffer.length < AEC_PCM_MIN_FRAME_SIZE) {
461-
expandBuffer = new byte[AEC_PCM_MIN_FRAME_SIZE];
462-
System.arraycopy(buffer, 0, expandBuffer, 0, buffer.length);
463-
}
464-
byte[] expandPlayerPcmBytes = playerPcmBytes;
465-
if (playerPcmBytes.length < AEC_PCM_MIN_FRAME_SIZE) {
466-
expandPlayerPcmBytes = new byte[AEC_PCM_MIN_FRAME_SIZE];
467-
System.arraycopy(playerPcmBytes, 0, expandPlayerPcmBytes, 0, playerPcmBytes.length);
468-
}
469-
byte[] aecPcmBytes = GvoiceJNIBridge.cancellation(expandBuffer, expandPlayerPcmBytes);
461+
byte[] aecPcmBytes = GvoiceJNIBridge.cancellation(buffer, playerPcmBytes);
470462
if (isRecord) {
471463
writePcmBytesToFile(buffer, playerPcmBytes, aecPcmBytes);
472464
}

0 commit comments

Comments
 (0)