Skip to content
Snippets Groups Projects
Commit b1a0be29 authored by Leo Ma's avatar Leo Ma
Browse files

Improve audio mute feature


Add an latency in PCM loop. It is trivial but it works.

Signed-off-by: default avatarLeo Ma <begeekmyfriend@gmail.com>
parent a50b40b4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -18,7 +18,6 @@ public class SrsPublisher {
private static AcousticEchoCanceler aec;
private static AutomaticGainControl agc;
private byte[] mPcmBuffer = new byte[4096];
private byte[] mMuteBuffer = new byte[11];
private Thread aworker;
private SrsCameraView mCameraView;
Loading
Loading
@@ -95,7 +94,13 @@ public class SrsPublisher {
mic.startRecording();
while (!Thread.interrupted()) {
if (sendVideoOnly) {
mEncoder.onGetPcmFrame(mMuteBuffer, mMuteBuffer.length);
mEncoder.onGetPcmFrame(mPcmBuffer, mPcmBuffer.length);
try {
// This is trivial...
Thread.sleep(20);
} catch (InterruptedException e) {
// Do nothing
}
} else {
int size = mic.read(mPcmBuffer, 0, mPcmBuffer.length);
if (size > 0) {
Loading
Loading
@@ -249,9 +254,10 @@ public class SrsPublisher {
public void setSendVideoOnly(boolean flag) {
if (mic != null) {
if (flag) {
mic.startRecording();
} else {
mic.stop();
mPcmBuffer = new byte[4096];
} else {
mic.startRecording();
}
}
sendVideoOnly = flag;
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment