mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 13:38:21 +00:00
Probably fixed deadlock on some Linux configurations (telegramdesktop/tdesktop#3408)
This commit is contained in:
parent
73bf810c79
commit
937a857886
@ -39,6 +39,8 @@ JitterBuffer::JitterBuffer(MediaStreamItf *out, uint32_t step):bufferPool(JITTER
|
||||
}
|
||||
lossesToReset=(uint32_t) ServerConfig::GetSharedInstance()->GetInt("jitter_losses_to_reset", 20);
|
||||
resyncThreshold=ServerConfig::GetSharedInstance()->GetDouble("jitter_resync_threshold", 1.0);
|
||||
//dump=fopen("/sdcard/tgvoip_jitter_dump.txt", "a");
|
||||
//fprintf(dump, "==================================\n");
|
||||
Reset();
|
||||
init_mutex(mutex);
|
||||
}
|
||||
@ -260,6 +262,7 @@ void JitterBuffer::PutInternal(jitter_packet_t* pkt){
|
||||
memcpy(slots[i].buffer, pkt->buffer, pkt->size);
|
||||
else
|
||||
LOGE("WTF!!");
|
||||
//fprintf(dump, "%f %d\n", time-prevRecvTime, GetCurrentDelay());
|
||||
prevRecvTime=time;
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include "MediaStreamItf.h"
|
||||
#include "BlockingQueue.h"
|
||||
#include "BufferPool.h"
|
||||
@ -83,6 +84,7 @@ private:
|
||||
int deviationPtr;
|
||||
double lastMeasuredJitter;
|
||||
double lastMeasuredDelay;
|
||||
//FILE* dump;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -61,6 +61,7 @@ AudioInput *AudioInput::Create(std::string deviceID){
|
||||
delete aip;
|
||||
else
|
||||
return aip;
|
||||
LOGW("in: PulseAudio available but not working; trying ALSA");
|
||||
}
|
||||
return new AudioInputALSA(deviceID);
|
||||
#endif
|
||||
|
||||
@ -59,6 +59,7 @@ AudioOutput *AudioOutput::Create(std::string deviceID){
|
||||
delete aop;
|
||||
else
|
||||
return aop;
|
||||
LOGW("out: PulseAudio available but not working; trying ALSA");
|
||||
}
|
||||
return new AudioOutputALSA(deviceID);
|
||||
#endif
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include "../../VoIPController.h"
|
||||
|
||||
#define BUFFER_SIZE 960
|
||||
#define CHECK_ERROR(res, msg) if(res!=0){LOGE(msg "failed: %s", pa_strerror(res)); failed=true; return;}
|
||||
#define CHECK_ERROR(res, msg) if(res!=0){LOGE(msg " failed: %s", pa_strerror(res)); failed=true; return;}
|
||||
#define CHECK_DL_ERROR(res, msg) if(!res){LOGE(msg ": %s", dlerror()); failed=true; return;}
|
||||
#define LOAD_DL_FUNCTION(name) {_import_##name=(typeof(_import_##name))dlsym(lib, #name); CHECK_DL_ERROR(_import_##name, "Error getting entry point for " #name);}
|
||||
|
||||
@ -120,7 +120,6 @@ AudioInputPulse::AudioInputPulse(std::string devID){
|
||||
return;
|
||||
}
|
||||
pa_context_set_state_callback(context, AudioInputPulse::ContextStateCallback, this);
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
int err=pa_threaded_mainloop_start(mainloop);
|
||||
CHECK_ERROR(err, "pa_threaded_mainloop_start");
|
||||
|
||||
@ -128,7 +127,9 @@ AudioInputPulse::AudioInputPulse(std::string devID){
|
||||
CHECK_ERROR(err, "pa_context_connect");
|
||||
|
||||
while(true){
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
pa_context_state_t contextState=pa_context_get_state(context);
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
if(!PA_CONTEXT_IS_GOOD(contextState)){
|
||||
LOGE("Error initializing PulseAudio (PA_CONTEXT_IS_GOOD)");
|
||||
failed=true;
|
||||
@ -213,7 +214,6 @@ bool AudioInputPulse::IsRecording(){
|
||||
void AudioInputPulse::SetCurrentDevice(std::string devID){
|
||||
currentDevice=devID;
|
||||
if(isRecording && isConnected){
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
pa_stream_disconnect(stream);
|
||||
isConnected=false;
|
||||
}
|
||||
@ -235,7 +235,9 @@ void AudioInputPulse::SetCurrentDevice(std::string devID){
|
||||
CHECK_ERROR(err, "pa_stream_connect_record");
|
||||
|
||||
while(true){
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
pa_stream_state_t streamState=pa_stream_get_state(stream);
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
if(!PA_STREAM_IS_GOOD(streamState)){
|
||||
LOGE("Error connecting to audio device '%s'", devID.c_str());
|
||||
failed=true;
|
||||
@ -247,7 +249,6 @@ void AudioInputPulse::SetCurrentDevice(std::string devID){
|
||||
}
|
||||
|
||||
isConnected=true;
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
|
||||
if(isRecording){
|
||||
pa_operation_unref(pa_stream_cork(stream, 0, AudioInputPulse::StreamSuccessCallback, mainloop));
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include "../../VoIPController.h"
|
||||
|
||||
#define BUFFER_SIZE 960
|
||||
#define CHECK_ERROR(res, msg) if(res!=0){LOGE(msg "failed: %s", pa_strerror(res)); failed=true; return;}
|
||||
#define CHECK_ERROR(res, msg) if(res!=0){LOGE(msg " failed: %s", pa_strerror(res)); failed=true; return;}
|
||||
#define CHECK_DL_ERROR(res, msg) if(!res){LOGE(msg ": %s", dlerror()); failed=true; return;}
|
||||
#define LOAD_DL_FUNCTION(name) {_import_##name=(typeof(_import_##name))dlsym(lib, #name); CHECK_DL_ERROR(_import_##name, "Error getting entry point for " #name);}
|
||||
|
||||
@ -120,7 +120,6 @@ AudioOutputPulse::AudioOutputPulse(std::string devID){
|
||||
return;
|
||||
}
|
||||
pa_context_set_state_callback(context, AudioOutputPulse::ContextStateCallback, this);
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
int err=pa_threaded_mainloop_start(mainloop);
|
||||
CHECK_ERROR(err, "pa_threaded_mainloop_start");
|
||||
|
||||
@ -128,7 +127,9 @@ AudioOutputPulse::AudioOutputPulse(std::string devID){
|
||||
CHECK_ERROR(err, "pa_context_connect");
|
||||
|
||||
while(true){
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
pa_context_state_t contextState=pa_context_get_state(context);
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
if(!PA_CONTEXT_IS_GOOD(contextState)){
|
||||
LOGE("Error initializing PulseAudio (PA_CONTEXT_IS_GOOD)");
|
||||
failed=true;
|
||||
@ -213,7 +214,6 @@ bool AudioOutputPulse::IsPlaying(){
|
||||
void AudioOutputPulse::SetCurrentDevice(std::string devID){
|
||||
currentDevice=devID;
|
||||
if(isPlaying && isConnected){
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
pa_stream_disconnect(stream);
|
||||
isConnected=false;
|
||||
}
|
||||
@ -235,7 +235,9 @@ void AudioOutputPulse::SetCurrentDevice(std::string devID){
|
||||
CHECK_ERROR(err, "pa_stream_connect_playback");
|
||||
|
||||
while(true){
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
pa_stream_state_t streamState=pa_stream_get_state(stream);
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
if(!PA_STREAM_IS_GOOD(streamState)){
|
||||
LOGE("Error connecting to audio device '%s'", devID.c_str());
|
||||
failed=true;
|
||||
@ -247,7 +249,6 @@ void AudioOutputPulse::SetCurrentDevice(std::string devID){
|
||||
}
|
||||
|
||||
isConnected=true;
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
|
||||
if(isPlaying){
|
||||
pa_operation_unref(pa_stream_cork(stream, 0, AudioOutputPulse::StreamSuccessCallback, mainloop));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user