예제 #1
0
파일: coreav.cpp 프로젝트: barry-ran/qTox
bool CoreAV::cancelCall(uint32_t friendNum)
{
    if (QThread::currentThread() != coreavThread.get()) {
        if (threadSwitchLock.test_and_set(std::memory_order_acquire)) {
            qDebug() << "CoreAV::cancelCall: Backed off of thread-switch lock";
            return false;
        }

        bool ret;
        QMetaObject::invokeMethod(this, "cancelCall", Qt::BlockingQueuedConnection,
                                  Q_RETURN_ARG(bool, ret), Q_ARG(uint32_t, friendNum));

        threadSwitchLock.clear(std::memory_order_release);
        return ret;
    }

    qDebug() << QString("Cancelling call with %1").arg(friendNum);
    if (!toxav_call_control(toxav, friendNum, TOXAV_CALL_CONTROL_CANCEL, nullptr)) {
        qWarning() << QString("Failed to cancel call with %1").arg(friendNum);
        return false;
    }

    calls.erase(friendNum);
    emit avEnd(friendNum);
    return true;
}
예제 #2
0
파일: coreav.cpp 프로젝트: Pik-9/qTox
void CoreAV::timeoutCall(uint32_t friendNum)
{
    // Non-blocking switch to the CoreAV thread, we really don't want to be coming
    // blocking-queued from the UI thread while we emit blocking-queued to it
    if (QThread::currentThread() != coreavThread.get())
    {
        QMetaObject::invokeMethod(this, "timeoutCall", Qt::QueuedConnection,
                                    Q_ARG(uint32_t, friendNum));
        return;
    }

    if (!cancelCall(friendNum))
    {
        qWarning() << QString("Failed to timeout call with %1").arg(friendNum);
        return;
    }
    qDebug() << "Call with friend"<<friendNum<<"timed out";
    emit avEnd(friendNum);
}