mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(coreav): add assertions to check for threading errors
This commit is contained in:
parent
c332cc0cca
commit
29f659c659
|
@ -168,6 +168,7 @@ void CoreAV::start()
|
||||||
|
|
||||||
void CoreAV::process()
|
void CoreAV::process()
|
||||||
{
|
{
|
||||||
|
assert(QThread::currentThread() == coreavThread.get());
|
||||||
toxav_iterate(toxav.get());
|
toxav_iterate(toxav.get());
|
||||||
iterateTimer->start(toxav_iteration_interval(toxav.get()));
|
iterateTimer->start(toxav_iteration_interval(toxav.get()));
|
||||||
}
|
}
|
||||||
|
@ -235,6 +236,9 @@ bool CoreAV::answerCall(uint32_t friendNum, bool video)
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&callsLock};
|
QMutexLocker locker{&callsLock};
|
||||||
|
|
||||||
|
// This callback should come from the Core thread
|
||||||
|
assert(QThread::currentThread() != coreavThread.get());
|
||||||
|
|
||||||
qDebug() << QString("Answering call %1").arg(friendNum);
|
qDebug() << QString("Answering call %1").arg(friendNum);
|
||||||
auto it = calls.find(friendNum);
|
auto it = calls.find(friendNum);
|
||||||
assert(it != calls.end());
|
assert(it != calls.end());
|
||||||
|
@ -257,6 +261,9 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&callsLock};
|
QMutexLocker locker{&callsLock};
|
||||||
|
|
||||||
|
// This callback should come from the Core thread
|
||||||
|
assert(QThread::currentThread() != coreavThread.get());
|
||||||
|
|
||||||
qDebug() << QString("Starting call with %1").arg(friendNum);
|
qDebug() << QString("Starting call with %1").arg(friendNum);
|
||||||
auto it = calls.find(friendNum);
|
auto it = calls.find(friendNum);
|
||||||
if (it != calls.end()) {
|
if (it != calls.end()) {
|
||||||
|
@ -282,6 +289,9 @@ bool CoreAV::cancelCall(uint32_t friendNum)
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&callsLock};
|
QMutexLocker locker{&callsLock};
|
||||||
|
|
||||||
|
// This callback should come from the Core thread
|
||||||
|
assert(QThread::currentThread() != coreavThread.get());
|
||||||
|
|
||||||
qDebug() << QString("Cancelling call with %1").arg(friendNum);
|
qDebug() << QString("Cancelling call with %1").arg(friendNum);
|
||||||
if (!toxav_call_control(toxav.get(), friendNum, TOXAV_CALL_CONTROL_CANCEL, nullptr)) {
|
if (!toxav_call_control(toxav.get(), friendNum, TOXAV_CALL_CONTROL_CANCEL, nullptr)) {
|
||||||
qWarning() << QString("Failed to cancel call with %1").arg(friendNum);
|
qWarning() << QString("Failed to cancel call with %1").arg(friendNum);
|
||||||
|
@ -450,6 +460,7 @@ void CoreAV::groupCallCallback(void* tox, uint32_t group, uint32_t peer, const i
|
||||||
CoreAV* cav = c->getAv();
|
CoreAV* cav = c->getAv();
|
||||||
|
|
||||||
QMutexLocker locker{&cav->callsLock};
|
QMutexLocker locker{&cav->callsLock};
|
||||||
|
assert(QThread::currentThread() == cav->coreavThread.get());
|
||||||
|
|
||||||
const ToxPk peerPk = c->getGroupPeerPk(group, peer);
|
const ToxPk peerPk = c->getGroupPeerPk(group, peer);
|
||||||
const Settings& s = Settings::getInstance();
|
const Settings& s = Settings::getInstance();
|
||||||
|
@ -549,6 +560,7 @@ bool CoreAV::sendGroupCallAudio(int groupId, const int16_t* pcm, size_t samples,
|
||||||
uint32_t rate) const
|
uint32_t rate) const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&callsLock};
|
QMutexLocker locker{&callsLock};
|
||||||
|
assert(QThread::currentThread() == coreavThread.get());
|
||||||
|
|
||||||
std::map<int, ToxGroupCallPtr>::const_iterator it = groupCalls.find(groupId);
|
std::map<int, ToxGroupCallPtr>::const_iterator it = groupCalls.find(groupId);
|
||||||
if (it == groupCalls.end()) {
|
if (it == groupCalls.end()) {
|
||||||
|
@ -672,6 +684,8 @@ bool CoreAV::isCallOutputMuted(const Friend* f) const
|
||||||
void CoreAV::sendNoVideo()
|
void CoreAV::sendNoVideo()
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&callsLock};
|
QMutexLocker locker{&callsLock};
|
||||||
|
// This callback should come from the Core thread
|
||||||
|
assert(QThread::currentThread() != coreavThread.get());
|
||||||
|
|
||||||
// We don't change the audio bitrate, but we signal that we're not sending video anymore
|
// We don't change the audio bitrate, but we signal that we're not sending video anymore
|
||||||
qDebug() << "CoreAV: Signaling end of video sending";
|
qDebug() << "CoreAV: Signaling end of video sending";
|
||||||
|
@ -687,6 +701,8 @@ void CoreAV::callCallback(ToxAV* toxav, uint32_t friendNum, bool audio, bool vid
|
||||||
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
||||||
|
|
||||||
QMutexLocker locker{&self->callsLock};
|
QMutexLocker locker{&self->callsLock};
|
||||||
|
// This callback should come from the Core thread
|
||||||
|
assert(QThread::currentThread() != self->coreavThread.get());
|
||||||
|
|
||||||
// Audio backend must be set before receiving a call
|
// Audio backend must be set before receiving a call
|
||||||
assert(self->audio != nullptr);
|
assert(self->audio != nullptr);
|
||||||
|
@ -716,6 +732,8 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
|
||||||
{
|
{
|
||||||
Q_UNUSED(toxav);
|
Q_UNUSED(toxav);
|
||||||
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
||||||
|
// This callback should come from the Core thread
|
||||||
|
assert(QThread::currentThread() != self->coreavThread.get());
|
||||||
|
|
||||||
QMutexLocker locker{&self->callsLock};
|
QMutexLocker locker{&self->callsLock};
|
||||||
|
|
||||||
|
@ -799,6 +817,8 @@ void CoreAV::audioFrameCallback(ToxAV*, uint32_t friendNum, const int16_t* pcm,
|
||||||
uint8_t channels, uint32_t samplingRate, void* vSelf)
|
uint8_t channels, uint32_t samplingRate, void* vSelf)
|
||||||
{
|
{
|
||||||
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
||||||
|
// This callback should come from the CoreAV thread
|
||||||
|
assert(QThread::currentThread() == self->coreavThread.get());
|
||||||
QMutexLocker locker{&self->callsLock};
|
QMutexLocker locker{&self->callsLock};
|
||||||
|
|
||||||
auto it = self->calls.find(friendNum);
|
auto it = self->calls.find(friendNum);
|
||||||
|
@ -820,6 +840,8 @@ void CoreAV::videoFrameCallback(ToxAV*, uint32_t friendNum, uint16_t w, uint16_t
|
||||||
int32_t ystride, int32_t ustride, int32_t vstride, void* vSelf)
|
int32_t ystride, int32_t ustride, int32_t vstride, void* vSelf)
|
||||||
{
|
{
|
||||||
auto self = static_cast<CoreAV*>(vSelf);
|
auto self = static_cast<CoreAV*>(vSelf);
|
||||||
|
// This callback should come from the CoreAV thread
|
||||||
|
assert(QThread::currentThread() == self->coreavThread.get());
|
||||||
QMutexLocker locker{&self->callsLock};
|
QMutexLocker locker{&self->callsLock};
|
||||||
|
|
||||||
auto it = self->calls.find(friendNum);
|
auto it = self->calls.find(friendNum);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user