mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
d83a3d71bc
Merge in RedPhone // FREEBIE
34 lines
791 B
C++
34 lines
791 B
C++
#include "JitterBuffer.h"
|
|
|
|
#include <android/log.h>
|
|
|
|
#define TAG "JitterBuffer"
|
|
|
|
JitterBuffer::JitterBuffer() :
|
|
pendingAudio()
|
|
{
|
|
pthread_mutex_init(&lock, NULL);
|
|
}
|
|
|
|
void JitterBuffer::addAudio(int64_t sequence, char* encodedData, int encodedDataLen) {
|
|
EncodedAudioData *encodedAudioData = new EncodedAudioData(encodedData, encodedDataLen, sequence);
|
|
|
|
pthread_mutex_lock(&lock);
|
|
pendingAudio.push(encodedAudioData);
|
|
__android_log_print(ANDROID_LOG_WARN, TAG, "Queue Size: %d", pendingAudio.size());
|
|
pthread_mutex_unlock(&lock);
|
|
}
|
|
|
|
EncodedAudioData* JitterBuffer::getAudio() {
|
|
EncodedAudioData *next = NULL;
|
|
|
|
pthread_mutex_lock(&lock);
|
|
|
|
if (!pendingAudio.empty()) {
|
|
next = pendingAudio.top();
|
|
pendingAudio.pop();
|
|
}
|
|
|
|
pthread_mutex_unlock(&lock);
|
|
return next;
|
|
} |