mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(audio): alternate audio fix implementation from #4139
This commit is contained in:
parent
38cecdc780
commit
62ac480171
|
@ -534,6 +534,10 @@ void Core::onGroupMessage(Tox*, uint32_t groupId, uint32_t peerId, TOX_MESSAGE_T
|
|||
void Core::onGroupNamelistChange(Tox*, uint32_t groupId, uint32_t peerId,
|
||||
TOX_CONFERENCE_STATE_CHANGE change, void* core)
|
||||
{
|
||||
CoreAV* coreAv = static_cast<Core*>(core)->getAv();
|
||||
if((change == TOX_CONFERENCE_STATE_CHANGE_PEER_EXIT) && (coreAv->isGroupAvEnabled(groupId))) {
|
||||
CoreAV::invalidateGroupCallPeerSource(groupId, peerId);
|
||||
}
|
||||
qDebug() << QString("Group namelist change %1:%2 %3").arg(groupId).arg(peerId).arg(change);
|
||||
emit static_cast<Core*>(core)->groupNamelistChanged(groupId, peerId, change);
|
||||
}
|
||||
|
|
|
@ -497,13 +497,24 @@ void CoreAV::groupCallCallback(void* tox, int group, int peer,
|
|||
return;
|
||||
|
||||
Audio& audio = Audio::getInstance();
|
||||
if (!call.alSource)
|
||||
audio.subscribeOutput(call.alSource);
|
||||
if (!call.peers[peer])
|
||||
audio.subscribeOutput(call.peers[peer]);
|
||||
|
||||
audio.playAudioBuffer(call.alSource, data, samples, channels,
|
||||
audio.playAudioBuffer(call.peers[peer], data, samples, channels,
|
||||
sample_rate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called from core to make sure the source for that peer is invalidated when they leave.
|
||||
* @param group Group Index
|
||||
* @param peer Peer Index
|
||||
*/
|
||||
void CoreAV::invalidateGroupCallPeerSource(int group, int peer) {
|
||||
Audio &audio = Audio::getInstance();
|
||||
audio.unsubscribeOutput(groupCalls[group].peers[peer]);
|
||||
groupCalls[group].peers[peer] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a call's video source.
|
||||
* @param friendNum Id of friend in call list.
|
||||
|
@ -662,7 +673,7 @@ void CoreAV::invalidateCallSources()
|
|||
{
|
||||
for (ToxGroupCall& call : groupCalls)
|
||||
{
|
||||
call.alSource = 0;
|
||||
call.peers.clear();
|
||||
}
|
||||
|
||||
for (ToxFriendCall& call : calls)
|
||||
|
|
|
@ -79,6 +79,7 @@ public:
|
|||
const int16_t* data, unsigned samples,
|
||||
uint8_t channels, unsigned sample_rate,
|
||||
void* core);
|
||||
static void invalidateGroupCallPeerSource(int group, int peer);
|
||||
|
||||
public slots:
|
||||
bool startCall(uint32_t friendNum, bool video=false);
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
*
|
||||
* @var TOXAV_FRIEND_CALL_STATE ToxFriendCall::state
|
||||
* @brief State of the peer (not ours!)
|
||||
*
|
||||
* @var QMap ToxGroupCall::peers
|
||||
* @brief Keeps sources for users in group calls.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
@ -192,6 +195,16 @@ ToxGroupCall::ToxGroupCall(ToxGroupCall&& other) noexcept
|
|||
{
|
||||
}
|
||||
|
||||
ToxGroupCall::~ToxGroupCall()
|
||||
{
|
||||
Audio& audio = Audio::getInstance();
|
||||
|
||||
for(quint32 v : peers)
|
||||
{
|
||||
audio.unsubscribeOutput(v);
|
||||
}
|
||||
}
|
||||
|
||||
ToxGroupCall &ToxGroupCall::operator=(ToxGroupCall &&other) noexcept
|
||||
{
|
||||
ToxCall::operator =(move(other));
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <cstdint>
|
||||
#include <QtGlobal>
|
||||
#include <QMetaObject>
|
||||
#include <QMap>
|
||||
|
||||
#include "src/core/indexedlist.h"
|
||||
|
||||
|
@ -69,9 +70,12 @@ struct ToxGroupCall : public ToxCall
|
|||
ToxGroupCall() = default;
|
||||
ToxGroupCall(int GroupNum, CoreAV& av);
|
||||
ToxGroupCall(ToxGroupCall&& other) noexcept;
|
||||
~ToxGroupCall();
|
||||
|
||||
ToxGroupCall& operator=(ToxGroupCall&& other) noexcept;
|
||||
|
||||
QMap<int, quint32> peers;
|
||||
|
||||
// If you add something here, don't forget to override the ctors and move operators!
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user