diff --git a/jni/redphone/CallAudioManager.cpp b/jni/redphone/CallAudioManager.cpp index f7802a0b7..1aced0c34 100644 --- a/jni/redphone/CallAudioManager.cpp +++ b/jni/redphone/CallAudioManager.cpp @@ -50,9 +50,15 @@ CallAudioManager::~CallAudioManager() { __android_log_print(ANDROID_LOG_WARN, TAG, "Shutting down..."); microphoneReader.stop(); + + __android_log_print(ANDROID_LOG_WARN, TAG, "Stopping audio player..."); audioPlayer.stop(); + + __android_log_print(ANDROID_LOG_WARN, TAG, "Stopping jitter buffer..."); webRtcJitterBuffer.stop(); + __android_log_print(ANDROID_LOG_WARN, TAG, "Freeing resources..."); + if (sockAddr != NULL) { free(sockAddr); } diff --git a/jni/redphone/CallAudioManager.h b/jni/redphone/CallAudioManager.h index 408d6f6d0..2e5d0d774 100644 --- a/jni/redphone/CallAudioManager.h +++ b/jni/redphone/CallAudioManager.h @@ -15,7 +15,7 @@ class CallAudioManager { private: volatile int running; - volatile int finished; + int finished; SLObjectItf engineObject; SLEngineItf engineEngine; AudioCodec audioCodec; diff --git a/jni/redphone/WebRtcJitterBuffer.cpp b/jni/redphone/WebRtcJitterBuffer.cpp index fbb6c3629..13adcf06c 100644 --- a/jni/redphone/WebRtcJitterBuffer.cpp +++ b/jni/redphone/WebRtcJitterBuffer.cpp @@ -1,5 +1,5 @@ #include "WebRtcJitterBuffer.h" -#include +//#include #define TAG "WebRtcJitterBuffer" @@ -15,9 +15,7 @@ int WebRtcJitterBuffer::init() { webrtc::NetEq::Config config; config.sample_rate_hz = 8000; - pthread_mutex_lock(&lock); neteq = webrtc::NetEq::Create(config); - pthread_mutex_unlock(&lock); if (neteq == NULL) { __android_log_print(ANDROID_LOG_WARN, TAG, "Failed to construct NetEq!"); @@ -29,7 +27,8 @@ int WebRtcJitterBuffer::init() { return -1; } -// pthread_create(&stats, NULL, &WebRtcJitterBuffer::collectStats, this); +// pthread_t thread; +// pthread_create(&thread, NULL, &WebRtcJitterBuffer::collectStats, this); return 0; } @@ -67,21 +66,13 @@ int WebRtcJitterBuffer::getAudio(short *rawData, int maxRawData) { } void WebRtcJitterBuffer::stop() { -// pthread_mutex_lock(&lock); running = 0; -// pthread_cond_signal(&condition); -// pthread_mutex_unlock(&lock); - -// pthread_join(stats, NULL); } void WebRtcJitterBuffer::collectStats() { while (running) { webrtc::NetEqNetworkStatistics stats; - - pthread_mutex_lock(&lock); neteq->NetworkStatistics(&stats); - pthread_mutex_unlock(&lock); __android_log_print(ANDROID_LOG_WARN, "WebRtcJitterBuffer", "Jitter Stats:\n{\n" \ @@ -107,21 +98,22 @@ void WebRtcJitterBuffer::collectStats() { stats.clockdrift_ppm, stats.added_zero_samples); - struct timespec timeToWait; - struct timeval now; - gettimeofday(&now, NULL); - - timeToWait.tv_sec = now.tv_sec; - timeToWait.tv_nsec = now.tv_usec * 1000; - timeToWait.tv_sec += 30; - - pthread_mutex_lock(&lock); - - if (running) { - pthread_cond_timedwait(&condition, &lock, &timeToWait); - } - - pthread_mutex_unlock(&lock); +// struct timespec timeToWait; +// struct timeval now; +// gettimeofday(&now, NULL); +// +// timeToWait.tv_sec = now.tv_sec; +// timeToWait.tv_nsec = now.tv_usec * 1000; +// timeToWait.tv_sec += 30; +// +// pthread_mutex_lock(&lock); +// +// if (running) { +// pthread_cond_timedwait(&condition, &lock, &timeToWait); +// } +// +// pthread_mutex_unlock(&lock); + sleep(30); } } diff --git a/jni/redphone/WebRtcJitterBuffer.h b/jni/redphone/WebRtcJitterBuffer.h index bd93afa66..016704b55 100644 --- a/jni/redphone/WebRtcJitterBuffer.h +++ b/jni/redphone/WebRtcJitterBuffer.h @@ -18,10 +18,6 @@ private: webrtc::NetEq *neteq; WebRtcCodec webRtcCodec; - pthread_t stats; - pthread_mutex_t lock; - pthread_cond_t condition; - public: WebRtcJitterBuffer(AudioCodec &codec); ~WebRtcJitterBuffer(); diff --git a/libs/armeabi-v7a/libredphone-audio.so b/libs/armeabi-v7a/libredphone-audio.so index df76528c8..a8241c8e5 100755 Binary files a/libs/armeabi-v7a/libredphone-audio.so and b/libs/armeabi-v7a/libredphone-audio.so differ diff --git a/libs/armeabi/libredphone-audio.so b/libs/armeabi/libredphone-audio.so index a059de6d6..7949956a0 100755 Binary files a/libs/armeabi/libredphone-audio.so and b/libs/armeabi/libredphone-audio.so differ diff --git a/libs/x86/libredphone-audio.so b/libs/x86/libredphone-audio.so index 1e8e87c43..597cc96c1 100755 Binary files a/libs/x86/libredphone-audio.so and b/libs/x86/libredphone-audio.so differ diff --git a/src/org/thoughtcrime/redphone/audio/CallAudioManager.java b/src/org/thoughtcrime/redphone/audio/CallAudioManager.java index 0c336268b..34a5c8b7a 100644 --- a/src/org/thoughtcrime/redphone/audio/CallAudioManager.java +++ b/src/org/thoughtcrime/redphone/audio/CallAudioManager.java @@ -47,7 +47,7 @@ public class CallAudioManager { if (Build.VERSION.SDK_INT >= 11) { ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_COMMUNICATION); } else { - ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_CALL); +// ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_CALL); } try {