Browse Source

refactor(coreav): remove ToxCall state changes before destruct, cleanup

reviewable/pr6235/r24
Anthony Bilinski 5 years ago
parent
commit
ddcc6db30c
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 17
      src/core/coreav.cpp

17
src/core/coreav.cpp

@ -284,9 +284,6 @@ bool CoreAV::cancelCall(uint32_t friendNum) @@ -284,9 +284,6 @@ bool CoreAV::cancelCall(uint32_t friendNum)
return false;
}
// Set inactive for others
it->second->setActive(false);
calls.erase(friendNum);
locker.unlock();
@ -437,7 +434,7 @@ void CoreAV::groupCallCallback(void* tox, uint32_t group, uint32_t peer, const i @@ -437,7 +434,7 @@ void CoreAV::groupCallCallback(void* tox, uint32_t group, uint32_t peer, const i
return;
}
ToxGroupCall& call = *it->second;
auto& call = *it->second;
if (call.getMuteVol() || !call.isActive()) {
return;
@ -462,14 +459,14 @@ CoreAV::ToxGroupCallPtr CoreAV::joinGroupCall(const Group& group) @@ -462,14 +459,14 @@ CoreAV::ToxGroupCallPtr CoreAV::joinGroupCall(const Group& group)
ToxGroupCallPtr groupcall = ToxGroupCallPtr(new ToxGroupCall{group, *this, *audio});
// Call Objects must be owned by CoreAV or there will be locking problems with Audio
groupcall->moveToThread(thread());
assert(groupcall != nullptr);
auto ret = groupCalls.emplace(group.getId(), groupcall);
groupcall->moveToThread(this->thread());
auto ret = groupCalls.emplace(group.getId(), groupcall.get());
if (ret.second == false) {
qWarning() << "This group call already exists, not joining!";
return {};
}
ret.first->second->setActive(true);
groupcall->setActive(true);
return groupcall;
}
@ -492,7 +489,7 @@ bool CoreAV::sendGroupCallAudio(int groupNum, const int16_t* pcm, size_t samples @@ -492,7 +489,7 @@ bool CoreAV::sendGroupCallAudio(int groupNum, const int16_t* pcm, size_t samples
{
QReadLocker locker{&callsLock};
std::map<int, ToxGroupCallPtr>::const_iterator it = groupCalls.find(groupNum);
auto it = groupCalls.find(groupId);
if (it == groupCalls.end()) {
return false;
}
@ -584,15 +581,11 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi @@ -584,15 +581,11 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
if (state & TOXAV_FRIEND_CALL_STATE_ERROR) {
qWarning() << "Call with friend" << friendNum << "died of unnatural causes!";
// Set inactive for others
it->second->setActive(false);
self->calls.erase(friendNum);
locker.unlock();
emit self->avEnd(friendNum, true);
} else if (state & TOXAV_FRIEND_CALL_STATE_FINISHED) {
qDebug() << "Call with friend" << friendNum << "finished quietly";
// Set inactive for others
it->second->setActive(false);
self->calls.erase(friendNum);
locker.unlock();
emit self->avEnd(friendNum);

Loading…
Cancel
Save