diff --git a/src/core.cpp b/src/core.cpp index 9d49c6f18..19e1725ce 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -56,6 +56,9 @@ Core::Core(Camera* cam, QThread *CoreThread, QString loadPath) : coreThread = CoreThread; + audioThread = new QThread(); + audioThread->start(); + videobuf = new uint8_t[videobufsize]; for (int i = 0; i < ptCounter; i++) diff --git a/src/core.h b/src/core.h index 98cd9399b..16e3523a9 100644 --- a/src/core.h +++ b/src/core.h @@ -295,7 +295,7 @@ private: static const int videobufsize; static uint8_t* videobuf; - static QThread *coreThread; + static QThread *coreThread, *audioThread; }; #endif // CORE_HPP diff --git a/src/coreav.cpp b/src/coreav.cpp index fb6ad3343..8c8eaae5a 100644 --- a/src/coreav.cpp +++ b/src/coreav.cpp @@ -23,6 +23,7 @@ ToxCall Core::calls[TOXAV_MAX_CALLS]; const int Core::videobufsize{TOXAV_MAX_VIDEO_WIDTH * TOXAV_MAX_VIDEO_HEIGHT * 4}; uint8_t* Core::videobuf; +QThread* Core::audioThread{nullptr}; bool Core::anyActiveCalls() { @@ -630,6 +631,7 @@ void Core::joinGroupCall(int groupId) groupCalls[groupId].sendAudioTimer->setSingleShot(true); connect(groupCalls[groupId].sendAudioTimer, &QTimer::timeout, [=](){sendGroupCallAudio(groupId,toxav);}); groupCalls[groupId].sendAudioTimer->start(); + groupCalls[groupId].sendAudioTimer->moveToThread(audioThread); } void Core::leaveGroupCall(int groupId) @@ -640,6 +642,7 @@ void Core::leaveGroupCall(int groupId) groupCalls[groupId].sendAudioTimer->stop(); groupCalls[groupId].alSources.clear(); Audio::unsuscribeInput(); + delete groupCalls[groupId].sendAudioTimer; } void Core::sendGroupCallAudio(int groupId, ToxAv* toxav)