Merge "Revert "RTP: integrate the echo canceller from speex."" into gingerbread
This commit is contained in:
@@ -32,11 +32,10 @@ LOCAL_SHARED_LIBRARIES := \
|
|||||||
libutils \
|
libutils \
|
||||||
libmedia
|
libmedia
|
||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := libspeex
|
LOCAL_STATIC_LIBRARIES :=
|
||||||
|
|
||||||
LOCAL_C_INCLUDES += \
|
LOCAL_C_INCLUDES += \
|
||||||
$(JNI_H_INCLUDE) \
|
$(JNI_H_INCLUDE)
|
||||||
external/speex/include
|
|
||||||
|
|
||||||
LOCAL_CFLAGS += -fvisibility=hidden
|
LOCAL_CFLAGS += -fvisibility=hidden
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,6 @@
|
|||||||
#include <media/AudioTrack.h>
|
#include <media/AudioTrack.h>
|
||||||
#include <media/mediarecorder.h>
|
#include <media/mediarecorder.h>
|
||||||
|
|
||||||
#include <speex/speex_echo.h>
|
|
||||||
|
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "JNIHelp.h"
|
#include "JNIHelp.h"
|
||||||
|
|
||||||
@@ -447,8 +445,6 @@ private:
|
|||||||
int mDeviceSocket;
|
int mDeviceSocket;
|
||||||
AudioTrack mTrack;
|
AudioTrack mTrack;
|
||||||
AudioRecord mRecord;
|
AudioRecord mRecord;
|
||||||
|
|
||||||
SpeexEchoState *mEchoState;
|
|
||||||
|
|
||||||
bool networkLoop();
|
bool networkLoop();
|
||||||
bool deviceLoop();
|
bool deviceLoop();
|
||||||
@@ -510,7 +506,6 @@ AudioGroup::AudioGroup()
|
|||||||
mEventQueue = -1;
|
mEventQueue = -1;
|
||||||
mDtmfEvent = -1;
|
mDtmfEvent = -1;
|
||||||
mDeviceSocket = -1;
|
mDeviceSocket = -1;
|
||||||
mEchoState = NULL;
|
|
||||||
mNetworkThread = new NetworkThread(this);
|
mNetworkThread = new NetworkThread(this);
|
||||||
mDeviceThread = new DeviceThread(this);
|
mDeviceThread = new DeviceThread(this);
|
||||||
}
|
}
|
||||||
@@ -523,9 +518,6 @@ AudioGroup::~AudioGroup()
|
|||||||
mRecord.stop();
|
mRecord.stop();
|
||||||
close(mEventQueue);
|
close(mEventQueue);
|
||||||
close(mDeviceSocket);
|
close(mDeviceSocket);
|
||||||
if (mEchoState) {
|
|
||||||
speex_echo_state_destroy(mEchoState);
|
|
||||||
}
|
|
||||||
while (mChain) {
|
while (mChain) {
|
||||||
AudioStream *next = mChain->mNext;
|
AudioStream *next = mChain->mNext;
|
||||||
delete mChain;
|
delete mChain;
|
||||||
@@ -574,8 +566,7 @@ bool AudioGroup::set(int sampleRate, int sampleCount)
|
|||||||
}
|
}
|
||||||
LOGD("latency: output %d, input %d", mTrack.latency(), mRecord.latency());
|
LOGD("latency: output %d, input %d", mTrack.latency(), mRecord.latency());
|
||||||
|
|
||||||
// Initialize echo canceller.
|
// TODO: initialize echo canceler here.
|
||||||
mEchoState = speex_echo_state_init(sampleCount, sampleRate);
|
|
||||||
|
|
||||||
// Create device socket.
|
// Create device socket.
|
||||||
int pair[2];
|
int pair[2];
|
||||||
@@ -642,7 +633,6 @@ bool AudioGroup::setMode(int mode)
|
|||||||
if (mode == MUTED) {
|
if (mode == MUTED) {
|
||||||
mRecord.stop();
|
mRecord.stop();
|
||||||
} else {
|
} else {
|
||||||
speex_echo_state_reset(mEchoState);
|
|
||||||
mRecord.start();
|
mRecord.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,7 +793,7 @@ bool AudioGroup::deviceLoop()
|
|||||||
|
|
||||||
status_t status = mRecord.obtainBuffer(&buffer, 1);
|
status_t status = mRecord.obtainBuffer(&buffer, 1);
|
||||||
if (status == NO_ERROR) {
|
if (status == NO_ERROR) {
|
||||||
int count = ((int)buffer.frameCount < toRead) ?
|
int count = (buffer.frameCount < toRead) ?
|
||||||
buffer.frameCount : toRead;
|
buffer.frameCount : toRead;
|
||||||
memcpy(&input[mSampleCount - toRead], buffer.i8, count * 2);
|
memcpy(&input[mSampleCount - toRead], buffer.i8, count * 2);
|
||||||
toRead -= count;
|
toRead -= count;
|
||||||
@@ -827,9 +817,8 @@ bool AudioGroup::deviceLoop()
|
|||||||
if (mMode == NORMAL) {
|
if (mMode == NORMAL) {
|
||||||
send(mDeviceSocket, input, sizeof(input), MSG_DONTWAIT);
|
send(mDeviceSocket, input, sizeof(input), MSG_DONTWAIT);
|
||||||
} else {
|
} else {
|
||||||
int16_t result[mSampleCount];
|
// TODO: Echo canceller runs here.
|
||||||
speex_echo_cancellation(mEchoState, input, output, result);
|
send(mDeviceSocket, input, sizeof(input), MSG_DONTWAIT);
|
||||||
send(mDeviceSocket, result, sizeof(result), MSG_DONTWAIT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user