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

Improve audio mute feature


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

Signed-off-by: default avatarLeo Ma <begeekmyfriend@gmail.com>
parent 6f1386f3
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -17,7 +17,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
@@ -94,7 +93,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
@@ -248,9 +253,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