mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 16:07:30 +00:00
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;
|
||
|
}
|