1
0
mirror of https://github.com/danog/php-libtgvoip.git synced 2024-11-30 04:19:26 +01:00
This commit is contained in:
Daniil Gentili 2017-07-24 18:50:54 +02:00
parent e1913713f2
commit 564e9abbbb
4 changed files with 17 additions and 3 deletions

View File

@ -15,6 +15,7 @@ using namespace tgvoip::audio;
AudioOutputModule::AudioOutputModule(std::string deviceID, VoIPController *controller)
{
isRunningThread = false;
wrapper = (VoIP *)(controller->implData);
wrapper->out = this;
wrapper->outputState = AUDIO_STATE_CREATED;
@ -23,7 +24,8 @@ AudioOutputModule::~AudioOutputModule()
{
wrapper->outputState = AUDIO_STATE_NONE;
wrapper->out = NULL;
if (receiverThread)
LOGD("before check join receiverThread");
if (isRunningThread)
{
LOGD("before join receiverThread");
join_thread(receiverThread);
@ -53,6 +55,7 @@ void AudioOutputModule::Start()
wrapper->outputState = AUDIO_STATE_RUNNING;
LOGE("STARTING RECEIVER THREAD");
isRunningThread = true;
start_thread(receiverThread, StartReceiverThread, this);
set_thread_priority(receiverThread, get_thread_max_priority());
set_thread_name(receiverThread, "voip-receiver");

View File

@ -43,6 +43,7 @@ public:
int outputSamplesSize;
size_t outputCSamplesSize;
float outputLevel = 0.0;
bool isRunningThread;
private:
tgvoip_thread_t receiverThread;

View File

@ -93,6 +93,9 @@ void VoIP::deinitVoIPController() {
Php::Value VoIP::discard(Php::Parameters &params)
{
if (callState == CALL_STATE_ENDED) {
return false;
}
Php::Value self(this);
if (self["internalStorage"]["madeline"].value().instanceOf("danog\\MadelineProto\\MTProto")) {
Php::Array reason;
@ -127,12 +130,12 @@ Php::Value VoIP::accept()
void VoIP::__wakeup()
{
Php::Value self(this);
if (!self["internalStorage"]["madeline"].value().instanceOf("danog\\MadelineProto\\MTProto")) {
callState = self["internalStorage"]["callState"].value();
if (!self["internalStorage"]["madeline"].value().instanceOf("danog\\MadelineProto\\MTProto") || callState == CALL_STATE_READY) {
callState = CALL_STATE_ENDED;
return;
}
callState = self["internalStorage"]["callState"].value();
initVoIPController();
if (self["configuration"]) {
@ -179,6 +182,11 @@ Php::Value VoIP::getOtherID()
Php::Value self(this);
return self["internalStorage"]["otherID"];
}
Php::Value VoIP::getMadeline()
{
Php::Value self(this);
return self["internalStorage"]["madeline"];
}
Php::Value VoIP::getProtocol()
{
Php::Value self(this);
@ -496,6 +504,7 @@ extern "C" {
voip.method<&VoIP::setVisualization>("setVisualization", Php::Public | Php::Final, {Php::ByVal("visualization", Php::Type::Array)});
voip.method<&VoIP::getOtherID>("getOtherID", Php::Public | Php::Final);
voip.method<&VoIP::getProtocol>("getProtocol", Php::Public | Php::Final);
voip.method<&VoIP::getMadeline>("getMadeline", Php::Public | Php::Final);
voip.method<&VoIP::getCallID>("getCallID", Php::Public | Php::Final);
voip.method<&VoIP::isCreator>("isCreator", Php::Public | Php::Final);
voip.method<&VoIP::whenCreated>("whenCreated", Php::Public | Php::Final);

1
main.h
View File

@ -78,6 +78,7 @@ public:
Php::Value setMicMute(Php::Parameters &params);
Php::Value getProtocol();
Php::Value getMadeline();
Php::Value getState();
Php::Value getOutputState();
Php::Value getInputState();