Browse Source

refactor(ToxCall): end call on destruction

reviewable/pr6235/r23
sudden6 5 years ago committed by Anthony Bilinski
parent
commit
d26f7044e6
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 15
      src/core/toxcall.cpp
  2. 10
      src/core/toxcall.h
  3. 9
      src/widget/form/chatform.cpp
  4. 1
      src/widget/form/groupchatform.cpp

15
src/core/toxcall.cpp

@ -155,9 +155,7 @@ ToxFriendCall::ToxFriendCall(uint32_t friendNum, bool VideoEnabled, CoreAV& av_, @@ -155,9 +155,7 @@ ToxFriendCall::ToxFriendCall(uint32_t friendNum, bool VideoEnabled, CoreAV& av_,
ToxFriendCall::~ToxFriendCall()
{
if (videoEnabled) {
cameraSource.unsubscribe();
}
av.cancelCall(friendId);
QObject::disconnect(audioSinkInvalid);
}
@ -202,11 +200,6 @@ void ToxFriendCall::playAudioBuffer(const int16_t* data, int samples, unsigned c @@ -202,11 +200,6 @@ void ToxFriendCall::playAudioBuffer(const int16_t* data, int samples, unsigned c
}
}
void ToxFriendCall::endCall()
{
av.cancelCall(friendId);
}
ToxGroupCall::ToxGroupCall(const Group& group_, CoreAV& av_, IAudioControl& audio_)
: ToxCall(false, av_, audio_)
, group{group_}
@ -226,6 +219,7 @@ ToxGroupCall::ToxGroupCall(const Group& group_, CoreAV& av_, IAudioControl& audi @@ -226,6 +219,7 @@ ToxGroupCall::ToxGroupCall(const Group& group_, CoreAV& av_, IAudioControl& audi
ToxGroupCall::~ToxGroupCall()
{
av.leaveGroupCall(group.getId());
// disconnect all Qt connections
clearPeers();
}
@ -308,8 +302,3 @@ void ToxGroupCall::playAudioBuffer(const ToxPk& peer, const int16_t* data, int s @@ -308,8 +302,3 @@ void ToxGroupCall::playAudioBuffer(const ToxPk& peer, const int16_t* data, int s
source->second->playAudioBuffer(data, samples, channels, sampleRate);
}
}
void ToxGroupCall::endCall()
{
av.leaveGroupCall(group.getId());
}

10
src/core/toxcall.h

@ -71,8 +71,6 @@ public: @@ -71,8 +71,6 @@ public:
bool getNullVideoBitrate() const;
void setNullVideoBitrate(bool value);
virtual void endCall() = 0;
CoreVideoSource* getVideoSource() const;
protected:
@ -105,10 +103,6 @@ public: @@ -105,10 +103,6 @@ public:
void playAudioBuffer(const int16_t* data, int samples, unsigned channels, int sampleRate) const;
// ToxCall interface
public:
void endCall() override;
private slots:
void onAudioSourceInvalidated();
void onAudioSinkInvalidated();
@ -136,10 +130,6 @@ public: @@ -136,10 +130,6 @@ public:
void playAudioBuffer(const ToxPk& peer, const int16_t* data, int samples, unsigned channels,
int sampleRate);
// ToxCall interface
public:
void endCall() override;
private:
void addPeer(ToxPk peerId);
bool havePeer(ToxPk peerId);

9
src/widget/form/chatform.cpp

@ -415,11 +415,7 @@ void ChatForm::onAnswerCallTriggered(bool video) @@ -415,11 +415,7 @@ void ChatForm::onAnswerCallTriggered(bool video)
void ChatForm::onRejectCallTriggered()
{
headWidget->removeCallConfirm();
if (call) {
call->endCall();
call.reset();
}
call.reset();
emit rejectCall(f->getId());
}
@ -429,7 +425,6 @@ void ChatForm::onCallTriggered() @@ -429,7 +425,6 @@ void ChatForm::onCallTriggered()
uint32_t friendId = f->getId();
if (call) {
call->endCall();
call.reset();
} else {
call = av->startCall(friendId, false);
@ -447,7 +442,6 @@ void ChatForm::onVideoCallTriggered() @@ -447,7 +442,6 @@ void ChatForm::onVideoCallTriggered()
uint32_t friendId = f->getId();
if (call) {
call->endCall();
call.reset();
} else {
call = av->startCall(friendId, true);
@ -471,6 +465,7 @@ void ChatForm::updateCallButtons() @@ -471,6 +465,7 @@ void ChatForm::updateCallButtons()
void ChatForm::onMicMuteToggle()
{
// Technically this is not atomic, but the probability of hitting the non-atomic case is negible
call->setMuteMic(!call->getMuteMic());
updateMuteMicButton();
}

1
src/widget/form/groupchatform.cpp

@ -463,7 +463,6 @@ void GroupChatForm::joinGroupCall() @@ -463,7 +463,6 @@ void GroupChatForm::joinGroupCall()
void GroupChatForm::leaveGroupCall()
{
call->endCall();
call.reset();
audioInputFlag = false;
audioOutputFlag = false;

Loading…
Cancel
Save