diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index 85e6ad1aff117d24f5543095db47086ceea1f069..3f8fa4016b522685272221741d3d8abea589b667 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -240,8 +240,21 @@ SIPAccount::newOutgoingCall(const std::string& toUrl) getSrtpKeyExchange() ); - if (not created or not SIPStartCall(call)) + if (created) { + auto shared_this = std::static_pointer_cast<SIPAccount>(shared_from_this()); + std::weak_ptr<SIPCall> weak_call = call; + manager.addTask([shared_this, weak_call] { + auto call = weak_call.lock(); + + if (not call or not shared_this->SIPStartCall(call)) { + RING_ERR("Could not send outgoing INVITE request for new call"); + call->onFailure(); + } + return false; + }); + } else { throw VoipLinkException("Could not send outgoing INVITE request for new call"); + } return call; }