parent
b5b564cfe1
commit
56a3c99289
8 changed files with 27 additions and 33 deletions
|
@ -50,9 +50,15 @@ CallAudioManager::~CallAudioManager() {
|
||||||
__android_log_print(ANDROID_LOG_WARN, TAG, "Shutting down...");
|
__android_log_print(ANDROID_LOG_WARN, TAG, "Shutting down...");
|
||||||
|
|
||||||
microphoneReader.stop();
|
microphoneReader.stop();
|
||||||
|
|
||||||
|
__android_log_print(ANDROID_LOG_WARN, TAG, "Stopping audio player...");
|
||||||
audioPlayer.stop();
|
audioPlayer.stop();
|
||||||
|
|
||||||
|
__android_log_print(ANDROID_LOG_WARN, TAG, "Stopping jitter buffer...");
|
||||||
webRtcJitterBuffer.stop();
|
webRtcJitterBuffer.stop();
|
||||||
|
|
||||||
|
__android_log_print(ANDROID_LOG_WARN, TAG, "Freeing resources...");
|
||||||
|
|
||||||
if (sockAddr != NULL) {
|
if (sockAddr != NULL) {
|
||||||
free(sockAddr);
|
free(sockAddr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ class CallAudioManager {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
volatile int running;
|
volatile int running;
|
||||||
volatile int finished;
|
int finished;
|
||||||
SLObjectItf engineObject;
|
SLObjectItf engineObject;
|
||||||
SLEngineItf engineEngine;
|
SLEngineItf engineEngine;
|
||||||
AudioCodec audioCodec;
|
AudioCodec audioCodec;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "WebRtcJitterBuffer.h"
|
#include "WebRtcJitterBuffer.h"
|
||||||
#include <time.h>
|
//#include <time.h>
|
||||||
|
|
||||||
#define TAG "WebRtcJitterBuffer"
|
#define TAG "WebRtcJitterBuffer"
|
||||||
|
|
||||||
|
@ -15,9 +15,7 @@ int WebRtcJitterBuffer::init() {
|
||||||
webrtc::NetEq::Config config;
|
webrtc::NetEq::Config config;
|
||||||
config.sample_rate_hz = 8000;
|
config.sample_rate_hz = 8000;
|
||||||
|
|
||||||
pthread_mutex_lock(&lock);
|
|
||||||
neteq = webrtc::NetEq::Create(config);
|
neteq = webrtc::NetEq::Create(config);
|
||||||
pthread_mutex_unlock(&lock);
|
|
||||||
|
|
||||||
if (neteq == NULL) {
|
if (neteq == NULL) {
|
||||||
__android_log_print(ANDROID_LOG_WARN, TAG, "Failed to construct NetEq!");
|
__android_log_print(ANDROID_LOG_WARN, TAG, "Failed to construct NetEq!");
|
||||||
|
@ -29,7 +27,8 @@ int WebRtcJitterBuffer::init() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pthread_create(&stats, NULL, &WebRtcJitterBuffer::collectStats, this);
|
// pthread_t thread;
|
||||||
|
// pthread_create(&thread, NULL, &WebRtcJitterBuffer::collectStats, this);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -67,21 +66,13 @@ int WebRtcJitterBuffer::getAudio(short *rawData, int maxRawData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcJitterBuffer::stop() {
|
void WebRtcJitterBuffer::stop() {
|
||||||
// pthread_mutex_lock(&lock);
|
|
||||||
running = 0;
|
running = 0;
|
||||||
// pthread_cond_signal(&condition);
|
|
||||||
// pthread_mutex_unlock(&lock);
|
|
||||||
|
|
||||||
// pthread_join(stats, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcJitterBuffer::collectStats() {
|
void WebRtcJitterBuffer::collectStats() {
|
||||||
while (running) {
|
while (running) {
|
||||||
webrtc::NetEqNetworkStatistics stats;
|
webrtc::NetEqNetworkStatistics stats;
|
||||||
|
|
||||||
pthread_mutex_lock(&lock);
|
|
||||||
neteq->NetworkStatistics(&stats);
|
neteq->NetworkStatistics(&stats);
|
||||||
pthread_mutex_unlock(&lock);
|
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_WARN, "WebRtcJitterBuffer",
|
__android_log_print(ANDROID_LOG_WARN, "WebRtcJitterBuffer",
|
||||||
"Jitter Stats:\n{\n" \
|
"Jitter Stats:\n{\n" \
|
||||||
|
@ -107,21 +98,22 @@ void WebRtcJitterBuffer::collectStats() {
|
||||||
stats.clockdrift_ppm,
|
stats.clockdrift_ppm,
|
||||||
stats.added_zero_samples);
|
stats.added_zero_samples);
|
||||||
|
|
||||||
struct timespec timeToWait;
|
// struct timespec timeToWait;
|
||||||
struct timeval now;
|
// struct timeval now;
|
||||||
gettimeofday(&now, NULL);
|
// gettimeofday(&now, NULL);
|
||||||
|
//
|
||||||
timeToWait.tv_sec = now.tv_sec;
|
// timeToWait.tv_sec = now.tv_sec;
|
||||||
timeToWait.tv_nsec = now.tv_usec * 1000;
|
// timeToWait.tv_nsec = now.tv_usec * 1000;
|
||||||
timeToWait.tv_sec += 30;
|
// timeToWait.tv_sec += 30;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&lock);
|
// pthread_mutex_lock(&lock);
|
||||||
|
//
|
||||||
if (running) {
|
// if (running) {
|
||||||
pthread_cond_timedwait(&condition, &lock, &timeToWait);
|
// pthread_cond_timedwait(&condition, &lock, &timeToWait);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&lock);
|
// pthread_mutex_unlock(&lock);
|
||||||
|
sleep(30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,6 @@ private:
|
||||||
webrtc::NetEq *neteq;
|
webrtc::NetEq *neteq;
|
||||||
WebRtcCodec webRtcCodec;
|
WebRtcCodec webRtcCodec;
|
||||||
|
|
||||||
pthread_t stats;
|
|
||||||
pthread_mutex_t lock;
|
|
||||||
pthread_cond_t condition;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WebRtcJitterBuffer(AudioCodec &codec);
|
WebRtcJitterBuffer(AudioCodec &codec);
|
||||||
~WebRtcJitterBuffer();
|
~WebRtcJitterBuffer();
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -47,7 +47,7 @@ public class CallAudioManager {
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_COMMUNICATION);
|
ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_COMMUNICATION);
|
||||||
} else {
|
} else {
|
||||||
ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_CALL);
|
// ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_CALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue