Browse Source

fix(toxcall): handle Null sink correctly

This was introduced in 82a4f1b412

(cherry picked from commit bf3921ce94)
reviewable/pr6021/r3
sudden6 6 years ago committed by Anthony Bilinski
parent
commit
f02943c191
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 18
      src/core/toxcall.cpp

18
src/core/toxcall.cpp

@ -132,14 +132,15 @@ ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av, @@ -132,14 +132,15 @@ ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av,
this->av->sendCallAudio(this->friendId, pcm, samples, chans, rate);
});
audioSrcInvalid = QObject::connect(audioSource.get(), &IAudioSource::invalidated,
[this]() { this->onAudioSourceInvalidated(); });
connect(audioSource.get(), &IAudioSource::invalidated, this, &ToxFriendCall::onAudioSourceInvalidated);
if (!audioInConn) {
qDebug() << "Audio input connection not working";
}
if (sink) {
audioSinkInvalid = sink->connectTo_invalidated(this, [this]() { this->onAudioSinkInvalidated(); });
}
// register video
if (videoEnabled) {
@ -175,15 +176,17 @@ void ToxFriendCall::onAudioSourceInvalidated() @@ -175,15 +176,17 @@ void ToxFriendCall::onAudioSourceInvalidated()
});
audioSource = std::move(newSrc);
audioSrcInvalid = QObject::connect(audioSource.get(), &IAudioSource::invalidated,
[this]() { this->onAudioSourceInvalidated(); });
connect(audioSource.get(), &IAudioSource::invalidated, this, &ToxFriendCall::onAudioSourceInvalidated);
}
void ToxFriendCall::onAudioSinkInvalidated()
{
auto newSink = audio.makeSink();
if (newSink) {
audioSinkInvalid = newSink->connectTo_invalidated(this, [this]() { this->onAudioSinkInvalidated(); });
}
sink = std::move(newSink);
}
@ -269,7 +272,12 @@ void ToxGroupCall::removePeer(ToxPk peerId) @@ -269,7 +272,12 @@ void ToxGroupCall::removePeer(ToxPk peerId)
void ToxGroupCall::addPeer(ToxPk peerId)
{
std::unique_ptr<IAudioSink> newSink = audio.makeSink();
QMetaObject::Connection con = newSink->connectTo_invalidated(this, [this, peerId]() { this->onAudioSinkInvalidated(peerId); });
QMetaObject::Connection con;
if (newSink) {
con = newSink->connectTo_invalidated(this, [this, peerId]() { this->onAudioSinkInvalidated(peerId); });
}
peers.emplace(peerId, std::move(newSink));
sinkInvalid.insert({peerId, con});

Loading…
Cancel
Save