mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: run formatting script
This commit is contained in:
parent
5b908184fc
commit
47402fae90
|
@ -14,28 +14,28 @@ AlSink::~AlSink()
|
||||||
QMutexLocker{&killLock};
|
QMutexLocker{&killLock};
|
||||||
|
|
||||||
// unsubscribe only if not already killed
|
// unsubscribe only if not already killed
|
||||||
if(!killed) {
|
if (!killed) {
|
||||||
audio.destroySink(*this);
|
audio.destroySink(*this);
|
||||||
killed = true;
|
killed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlSink::playAudioBuffer(const int16_t *data, int samples, unsigned channels, int sampleRate) const
|
void AlSink::playAudioBuffer(const int16_t* data, int samples, unsigned channels, int sampleRate) const
|
||||||
{
|
{
|
||||||
QMutexLocker{&killLock};
|
QMutexLocker{&killLock};
|
||||||
|
|
||||||
if(killed) {
|
if (killed) {
|
||||||
qCritical() << "Trying to play audio on an invalid sink";
|
qCritical() << "Trying to play audio on an invalid sink";
|
||||||
} else {
|
} else {
|
||||||
audio.playAudioBuffer(sourceId, data, samples, channels, sampleRate);
|
audio.playAudioBuffer(sourceId, data, samples, channels, sampleRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlSink::playMono16Sound(const IAudioSink::Sound &sound)
|
void AlSink::playMono16Sound(const IAudioSink::Sound& sound)
|
||||||
{
|
{
|
||||||
QMutexLocker{&killLock};
|
QMutexLocker{&killLock};
|
||||||
|
|
||||||
if(killed) {
|
if (killed) {
|
||||||
qCritical() << "Trying to play sound on an invalid sink";
|
qCritical() << "Trying to play sound on an invalid sink";
|
||||||
} else {
|
} else {
|
||||||
audio.playMono16Sound(*this, sound);
|
audio.playMono16Sound(*this, sound);
|
||||||
|
@ -46,7 +46,7 @@ void AlSink::startLoop()
|
||||||
{
|
{
|
||||||
QMutexLocker{&killLock};
|
QMutexLocker{&killLock};
|
||||||
|
|
||||||
if(killed) {
|
if (killed) {
|
||||||
qCritical() << "Trying to start loop on an invalid sink";
|
qCritical() << "Trying to start loop on an invalid sink";
|
||||||
} else {
|
} else {
|
||||||
audio.startLoop(sourceId);
|
audio.startLoop(sourceId);
|
||||||
|
@ -57,7 +57,7 @@ void AlSink::stopLoop()
|
||||||
{
|
{
|
||||||
QMutexLocker{&killLock};
|
QMutexLocker{&killLock};
|
||||||
|
|
||||||
if(killed) {
|
if (killed) {
|
||||||
qCritical() << "Trying to stop loop on an invalid sink";
|
qCritical() << "Trying to stop loop on an invalid sink";
|
||||||
} else {
|
} else {
|
||||||
audio.stopLoop(sourceId);
|
audio.stopLoop(sourceId);
|
||||||
|
@ -83,8 +83,7 @@ AlSink::AlSink(OpenAL& al, uint sourceId)
|
||||||
: audio{al}
|
: audio{al}
|
||||||
, sourceId{sourceId}
|
, sourceId{sourceId}
|
||||||
, killLock{QMutex::Recursive}
|
, killLock{QMutex::Recursive}
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
AlSink::operator bool() const
|
AlSink::operator bool() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef ALSINK_H
|
#ifndef ALSINK_H
|
||||||
#define ALSINK_H
|
#define ALSINK_H
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
#include "src/audio/iaudiosink.h"
|
#include "src/audio/iaudiosink.h"
|
||||||
|
|
||||||
|
@ -12,15 +12,14 @@ class AlSink : public IAudioSink
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AlSink(OpenAL &al, uint sourceId);
|
AlSink(OpenAL& al, uint sourceId);
|
||||||
AlSink(const AlSink &src) = delete;
|
AlSink(const AlSink& src) = delete;
|
||||||
AlSink & operator=(const AlSink&) = delete;
|
AlSink& operator=(const AlSink&) = delete;
|
||||||
AlSink(AlSink&& other) = delete;
|
AlSink(AlSink&& other) = delete;
|
||||||
AlSink & operator=(AlSink&& other) = delete;
|
AlSink& operator=(AlSink&& other) = delete;
|
||||||
~AlSink();
|
~AlSink();
|
||||||
|
|
||||||
void playAudioBuffer(const int16_t* data, int samples, unsigned channels,
|
void playAudioBuffer(const int16_t* data, int samples, unsigned channels, int sampleRate) const;
|
||||||
int sampleRate) const;
|
|
||||||
void playMono16Sound(const IAudioSink::Sound& sound);
|
void playMono16Sound(const IAudioSink::Sound& sound);
|
||||||
void startLoop();
|
void startLoop();
|
||||||
void stopLoop();
|
void stopLoop();
|
||||||
|
|
|
@ -33,16 +33,16 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void applyGain(int16_t* buffer, uint32_t bufferSize, qreal gainFactor)
|
void applyGain(int16_t* buffer, uint32_t bufferSize, qreal gainFactor)
|
||||||
{
|
{
|
||||||
for (quint32 i = 0; i < bufferSize; ++i) {
|
for (quint32 i = 0; i < bufferSize; ++i) {
|
||||||
// gain amplification with clipping to 16-bit boundaries
|
// gain amplification with clipping to 16-bit boundaries
|
||||||
buffer[i] = qBound<int16_t>(std::numeric_limits<int16_t>::min(),
|
buffer[i] =
|
||||||
qRound(buffer[i] * gainFactor),
|
qBound<int16_t>(std::numeric_limits<int16_t>::min(), qRound(buffer[i] * gainFactor),
|
||||||
std::numeric_limits<int16_t>::max());
|
std::numeric_limits<int16_t>::max());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class OpenAL
|
* @class OpenAL
|
||||||
|
@ -82,13 +82,15 @@ OpenAL::OpenAL()
|
||||||
captureTimer.setSingleShot(false);
|
captureTimer.setSingleShot(false);
|
||||||
captureTimer.moveToThread(audioThread);
|
captureTimer.moveToThread(audioThread);
|
||||||
// TODO for Qt 5.6+: use qOverload
|
// TODO for Qt 5.6+: use qOverload
|
||||||
connect(audioThread, &QThread::started, &captureTimer, static_cast<void (QTimer::*)(void)>(&QTimer::start));
|
connect(audioThread, &QThread::started, &captureTimer,
|
||||||
|
static_cast<void (QTimer::*)(void)>(&QTimer::start));
|
||||||
|
|
||||||
cleanupTimer.setInterval(1000);
|
cleanupTimer.setInterval(1000);
|
||||||
cleanupTimer.setSingleShot(false);
|
cleanupTimer.setSingleShot(false);
|
||||||
connect(&cleanupTimer, &QTimer::timeout, this, &OpenAL::cleanupSound);
|
connect(&cleanupTimer, &QTimer::timeout, this, &OpenAL::cleanupSound);
|
||||||
// TODO for Qt 5.6+: use qOverload
|
// TODO for Qt 5.6+: use qOverload
|
||||||
connect(audioThread, &QThread::started, &cleanupTimer, static_cast<void (QTimer::*)(void)>(&QTimer::start));
|
connect(audioThread, &QThread::started, &cleanupTimer,
|
||||||
|
static_cast<void (QTimer::*)(void)>(&QTimer::start));
|
||||||
|
|
||||||
audioThread->start();
|
audioThread->start();
|
||||||
}
|
}
|
||||||
|
@ -245,7 +247,7 @@ bool OpenAL::reinitOutput(const QString& outDevDesc)
|
||||||
* @brief Allocates ressources for a new audio output
|
* @brief Allocates ressources for a new audio output
|
||||||
* @return AudioSink on success, nullptr on failure
|
* @return AudioSink on success, nullptr on failure
|
||||||
*/
|
*/
|
||||||
IAudioSink *OpenAL::makeSink()
|
IAudioSink* OpenAL::makeSink()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&audioLock);
|
QMutexLocker locker(&audioLock);
|
||||||
|
|
||||||
|
@ -332,8 +334,7 @@ void OpenAL::unsubscribeInput()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
inSubscriptions--;
|
inSubscriptions--;
|
||||||
qDebug() << "Unsubscribed from audio input device [" << inSubscriptions
|
qDebug() << "Unsubscribed from audio input device [" << inSubscriptions << "subscriptions left ]";
|
||||||
<< "subscriptions left ]";
|
|
||||||
|
|
||||||
if (!inSubscriptions)
|
if (!inSubscriptions)
|
||||||
cleanupInput();
|
cleanupInput();
|
||||||
|
@ -377,8 +378,8 @@ bool OpenAL::initInput(const QString& deviceName, uint32_t channels)
|
||||||
this->channels = channels;
|
this->channels = channels;
|
||||||
int stereoFlag = channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
|
int stereoFlag = channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
|
||||||
const int bytesPerSample = 2;
|
const int bytesPerSample = 2;
|
||||||
const int safetyFactor = 2; // internal OpenAL ring buffer. must be larger than our inputBuffer to avoid the ring
|
const int safetyFactor = 2; // internal OpenAL ring buffer. must be larger than our inputBuffer
|
||||||
// from overwriting itself between captures.
|
// to avoid the ring from overwriting itself between captures.
|
||||||
AUDIO_FRAME_SAMPLE_COUNT_TOTAL = AUDIO_FRAME_SAMPLE_COUNT_PER_CHANNEL * channels;
|
AUDIO_FRAME_SAMPLE_COUNT_TOTAL = AUDIO_FRAME_SAMPLE_COUNT_PER_CHANNEL * channels;
|
||||||
const ALCsizei ringBufSize = AUDIO_FRAME_SAMPLE_COUNT_TOTAL * bytesPerSample * safetyFactor;
|
const ALCsizei ringBufSize = AUDIO_FRAME_SAMPLE_COUNT_TOTAL * bytesPerSample * safetyFactor;
|
||||||
|
|
||||||
|
@ -446,18 +447,18 @@ bool OpenAL::initOutput(const QString& deviceName)
|
||||||
/**
|
/**
|
||||||
* @brief Play a 48kHz mono 16bit PCM sound
|
* @brief Play a 48kHz mono 16bit PCM sound
|
||||||
*/
|
*/
|
||||||
void OpenAL::playMono16Sound(AlSink& sink, const IAudioSink::Sound &sound)
|
void OpenAL::playMono16Sound(AlSink& sink, const IAudioSink::Sound& sound)
|
||||||
{
|
{
|
||||||
const uint sourceId = sink.getSourceId();
|
const uint sourceId = sink.getSourceId();
|
||||||
QFile sndFile(IAudioSink::getSound(sound));
|
QFile sndFile(IAudioSink::getSound(sound));
|
||||||
if(!sndFile.exists()) {
|
if (!sndFile.exists()) {
|
||||||
qDebug() << "Trying to open non existent sound file";
|
qDebug() << "Trying to open non existent sound file";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sndFile.open(QIODevice::ReadOnly);
|
sndFile.open(QIODevice::ReadOnly);
|
||||||
const QByteArray data{sndFile.readAll()};
|
const QByteArray data{sndFile.readAll()};
|
||||||
if(data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
qDebug() << "Sound file contained no data";
|
qDebug() << "Sound file contained no data";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -606,9 +607,9 @@ float OpenAL::getVolume()
|
||||||
float sumOfSquares = 0;
|
float sumOfSquares = 0;
|
||||||
for (quint32 i = 0; i < samples; i++) {
|
for (quint32 i = 0; i < samples; i++) {
|
||||||
float sample = static_cast<float>(inputBuffer[i]) / std::numeric_limits<int16_t>::max();
|
float sample = static_cast<float>(inputBuffer[i]) / std::numeric_limits<int16_t>::max();
|
||||||
sumOfSquares += std::pow(sample , 2);
|
sumOfSquares += std::pow(sample, 2);
|
||||||
}
|
}
|
||||||
const float rms = std::sqrt(sumOfSquares/samples);
|
const float rms = std::sqrt(sumOfSquares / samples);
|
||||||
// our calculated normalized volume could possibly be above 1 because our RMS assumes a sinusoidal wave
|
// our calculated normalized volume could possibly be above 1 because our RMS assumes a sinusoidal wave
|
||||||
const float normalizedVolume = std::min(rms * rootTwo, 1.0f);
|
const float normalizedVolume = std::min(rms * rootTwo, 1.0f);
|
||||||
return normalizedVolume;
|
return normalizedVolume;
|
||||||
|
@ -650,7 +651,8 @@ void OpenAL::doInput()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit Audio::frameAvailable(inputBuffer, AUDIO_FRAME_SAMPLE_COUNT_PER_CHANNEL, channels, AUDIO_SAMPLE_RATE);
|
emit Audio::frameAvailable(inputBuffer, AUDIO_FRAME_SAMPLE_COUNT_PER_CHANNEL, channels,
|
||||||
|
AUDIO_SAMPLE_RATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenAL::doOutput()
|
void OpenAL::doOutput()
|
||||||
|
@ -725,7 +727,8 @@ QStringList OpenAL::inDeviceNames()
|
||||||
* @brief Free all buffers that finished playing on a source
|
* @brief Free all buffers that finished playing on a source
|
||||||
* @param sourceId where to remove the buffers from
|
* @param sourceId where to remove the buffers from
|
||||||
*/
|
*/
|
||||||
void OpenAL::cleanupBuffers(uint sourceId) {
|
void OpenAL::cleanupBuffers(uint sourceId)
|
||||||
|
{
|
||||||
// unqueue all buffers from the source
|
// unqueue all buffers from the source
|
||||||
ALint processed = 0;
|
ALint processed = 0;
|
||||||
alGetSourcei(sourceId, AL_BUFFERS_PROCESSED, &processed);
|
alGetSourcei(sourceId, AL_BUFFERS_PROCESSED, &processed);
|
||||||
|
|
|
@ -52,8 +52,14 @@ public:
|
||||||
OpenAL();
|
OpenAL();
|
||||||
virtual ~OpenAL();
|
virtual ~OpenAL();
|
||||||
|
|
||||||
qreal maxOutputVolume() const { return 1; }
|
qreal maxOutputVolume() const
|
||||||
qreal minOutputVolume() const { return 0; }
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
qreal minOutputVolume() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
qreal outputVolume() const;
|
qreal outputVolume() const;
|
||||||
void setOutputVolume(qreal volume);
|
void setOutputVolume(qreal volume);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#include <filter_audio.h>
|
#include <filter_audio.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +81,7 @@ OpenAL2::OpenAL2()
|
||||||
, alProxyContext{nullptr}
|
, alProxyContext{nullptr}
|
||||||
, alProxySource{0}
|
, alProxySource{0}
|
||||||
, alProxyBuffer{0}
|
, alProxyBuffer{0}
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenAL2::initInput(const QString& deviceName)
|
bool OpenAL2::initInput(const QString& deviceName)
|
||||||
{
|
{
|
||||||
|
@ -324,7 +324,8 @@ void OpenAL2::doOutput()
|
||||||
alcMakeContextCurrent(alOutContext);
|
alcMakeContextCurrent(alOutContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
alBufferData(bufids[0], AL_FORMAT_MONO16, outBuf, AUDIO_FRAME_SAMPLE_COUNT_PER_CHANNEL * 2, AUDIO_SAMPLE_RATE);
|
alBufferData(bufids[0], AL_FORMAT_MONO16, outBuf, AUDIO_FRAME_SAMPLE_COUNT_PER_CHANNEL * 2,
|
||||||
|
AUDIO_SAMPLE_RATE);
|
||||||
|
|
||||||
alSourceQueueBuffers(alProxySource, 1, bufids);
|
alSourceQueueBuffers(alProxySource, 1, bufids);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@
|
||||||
#include <AL/alc.h>
|
#include <AL/alc.h>
|
||||||
#include <AL/alext.h>
|
#include <AL/alext.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#include <filter_audio.h>
|
#include <filter_audio.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,7 @@
|
||||||
ToxCall::ToxCall(bool VideoEnabled, CoreAV& av)
|
ToxCall::ToxCall(bool VideoEnabled, CoreAV& av)
|
||||||
: av{&av}
|
: av{&av}
|
||||||
, videoEnabled{VideoEnabled}
|
, videoEnabled{VideoEnabled}
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
ToxCall::~ToxCall()
|
ToxCall::~ToxCall()
|
||||||
{
|
{
|
||||||
|
@ -110,8 +109,8 @@ ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av)
|
||||||
Audio& audio = Audio::getInstance();
|
Audio& audio = Audio::getInstance();
|
||||||
audio.subscribeInput();
|
audio.subscribeInput();
|
||||||
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
||||||
[&av, FriendNum](const int16_t* pcm, size_t samples, uint8_t chans,
|
[&av, FriendNum](const int16_t* pcm, size_t samples,
|
||||||
uint32_t rate) {
|
uint8_t chans, uint32_t rate) {
|
||||||
av.sendCallAudio(FriendNum, pcm, samples, chans, rate);
|
av.sendCallAudio(FriendNum, pcm, samples, chans, rate);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -120,9 +119,7 @@ ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av)
|
||||||
}
|
}
|
||||||
|
|
||||||
audioSinkInvalid = QObject::connect(sink.get(), &IAudioSink::invalidated,
|
audioSinkInvalid = QObject::connect(sink.get(), &IAudioSink::invalidated,
|
||||||
[this]() {
|
[this]() { this->onAudioSinkInvalidated(); });
|
||||||
this->onAudioSinkInvalidated();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// register video
|
// register video
|
||||||
|
@ -154,9 +151,7 @@ void ToxFriendCall::onAudioSinkInvalidated()
|
||||||
const auto newSink = Audio::getInstance().makeSink();
|
const auto newSink = Audio::getInstance().makeSink();
|
||||||
|
|
||||||
audioSinkInvalid = QObject::connect(newSink, &IAudioSink::invalidated,
|
audioSinkInvalid = QObject::connect(newSink, &IAudioSink::invalidated,
|
||||||
[this]() {
|
[this]() { this->onAudioSinkInvalidated(); });
|
||||||
this->onAudioSinkInvalidated();
|
|
||||||
});
|
|
||||||
sink.reset(newSink);
|
sink.reset(newSink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +188,7 @@ void ToxFriendCall::setState(const TOXAV_FRIEND_CALL_STATE& value)
|
||||||
state = value;
|
state = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::unique_ptr<IAudioSink> &ToxFriendCall::getAudioSink() const
|
const std::unique_ptr<IAudioSink>& ToxFriendCall::getAudioSink() const
|
||||||
{
|
{
|
||||||
return sink;
|
return sink;
|
||||||
}
|
}
|
||||||
|
@ -206,8 +201,8 @@ ToxGroupCall::ToxGroupCall(int GroupNum, CoreAV& av)
|
||||||
Audio& audio = Audio::getInstance();
|
Audio& audio = Audio::getInstance();
|
||||||
audio.subscribeInput();
|
audio.subscribeInput();
|
||||||
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
||||||
[&av, GroupNum](const int16_t* pcm, size_t samples, uint8_t chans,
|
[&av, GroupNum](const int16_t* pcm, size_t samples,
|
||||||
uint32_t rate) {
|
uint8_t chans, uint32_t rate) {
|
||||||
av.sendGroupCallAudio(GroupNum, pcm, samples, chans, rate);
|
av.sendGroupCallAudio(GroupNum, pcm, samples, chans, rate);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -231,7 +226,7 @@ void ToxGroupCall::onAudioSinkInvalidated(ToxPk peerId)
|
||||||
void ToxGroupCall::removePeer(ToxPk peerId)
|
void ToxGroupCall::removePeer(ToxPk peerId)
|
||||||
{
|
{
|
||||||
const auto& source = peers.find(peerId);
|
const auto& source = peers.find(peerId);
|
||||||
if(source == peers.cend()) {
|
if (source == peers.cend()) {
|
||||||
qDebug() << "Peer:" << peerId.toString() << "does not have a source, can't remove";
|
qDebug() << "Peer:" << peerId.toString() << "does not have a source, can't remove";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -247,10 +242,9 @@ void ToxGroupCall::addPeer(ToxPk peerId)
|
||||||
IAudioSink* newSink = audio.makeSink();
|
IAudioSink* newSink = audio.makeSink();
|
||||||
peers.emplace(peerId, std::unique_ptr<IAudioSink>(newSink));
|
peers.emplace(peerId, std::unique_ptr<IAudioSink>(newSink));
|
||||||
|
|
||||||
QMetaObject::Connection con = QObject::connect(newSink, &IAudioSink::invalidated,
|
QMetaObject::Connection con =
|
||||||
[this, peerId]() {
|
QObject::connect(newSink, &IAudioSink::invalidated,
|
||||||
this->onAudioSinkInvalidated(peerId);
|
[this, peerId]() { this->onAudioSinkInvalidated(peerId); });
|
||||||
});
|
|
||||||
|
|
||||||
sinkInvalid.insert({peerId, con});
|
sinkInvalid.insert({peerId, con});
|
||||||
}
|
}
|
||||||
|
@ -264,16 +258,16 @@ bool ToxGroupCall::havePeer(ToxPk peerId)
|
||||||
void ToxGroupCall::clearPeers()
|
void ToxGroupCall::clearPeers()
|
||||||
{
|
{
|
||||||
peers.clear();
|
peers.clear();
|
||||||
for(auto con : sinkInvalid) {
|
for (auto con : sinkInvalid) {
|
||||||
QObject::disconnect(con.second);
|
QObject::disconnect(con.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
sinkInvalid.clear();
|
sinkInvalid.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::unique_ptr<IAudioSink> &ToxGroupCall::getAudioSink(ToxPk peer)
|
const std::unique_ptr<IAudioSink>& ToxGroupCall::getAudioSink(ToxPk peer)
|
||||||
{
|
{
|
||||||
if(!havePeer(peer)) {
|
if (!havePeer(peer)) {
|
||||||
addPeer(peer);
|
addPeer(peer);
|
||||||
}
|
}
|
||||||
const auto& source = peers.find(peer);
|
const auto& source = peers.find(peer);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
TOXAV_FRIEND_CALL_STATE getState() const;
|
TOXAV_FRIEND_CALL_STATE getState() const;
|
||||||
void setState(const TOXAV_FRIEND_CALL_STATE& value);
|
void setState(const TOXAV_FRIEND_CALL_STATE& value);
|
||||||
|
|
||||||
const std::unique_ptr<IAudioSink> &getAudioSink() const;
|
const std::unique_ptr<IAudioSink>& getAudioSink() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<QTimer> timeoutTimer;
|
std::unique_ptr<QTimer> timeoutTimer;
|
||||||
|
@ -109,7 +109,8 @@ public:
|
||||||
bool havePeer(ToxPk peerId);
|
bool havePeer(ToxPk peerId);
|
||||||
void clearPeers();
|
void clearPeers();
|
||||||
|
|
||||||
const std::unique_ptr<IAudioSink> &getAudioSink(ToxPk peer);
|
const std::unique_ptr<IAudioSink>& getAudioSink(ToxPk peer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<ToxPk, std::unique_ptr<IAudioSink>> peers;
|
std::map<ToxPk, std::unique_ptr<IAudioSink>> peers;
|
||||||
std::map<ToxPk, QMetaObject::Connection> sinkInvalid;
|
std::map<ToxPk, QMetaObject::Connection> sinkInvalid;
|
||||||
|
|
|
@ -150,7 +150,7 @@ void AVForm::showEvent(QShowEvent* event)
|
||||||
subscribedToAudioIn = true;
|
subscribedToAudioIn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(audioSink == nullptr) {
|
if (audioSink == nullptr) {
|
||||||
audioSink.reset(audio->makeSink());
|
audioSink.reset(audio->makeSink());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ void AVForm::on_outDevCombobox_currentIndexChanged(int deviceIndex)
|
||||||
|
|
||||||
const QString oldName = audioSettings->getOutDev();
|
const QString oldName = audioSettings->getOutDev();
|
||||||
|
|
||||||
if(oldName != deviceName) {
|
if (oldName != deviceName) {
|
||||||
audioSettings->setOutDev(deviceName);
|
audioSettings->setOutDev(deviceName);
|
||||||
audio->reinitOutput(deviceName);
|
audio->reinitOutput(deviceName);
|
||||||
audioSink.reset(Audio::getInstance().makeSink());
|
audioSink.reset(Audio::getInstance().makeSink());
|
||||||
|
|
|
@ -41,8 +41,8 @@ class AVForm : public GenericForm, private Ui::AVForm
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AVForm(Audio* audio, CoreAV* coreAV, CameraSource& camera,
|
AVForm(Audio* audio, CoreAV* coreAV, CameraSource& camera, IAudioSettings* audioSettings,
|
||||||
IAudioSettings* audioSettings, IVideoSettings* videoSettings);
|
IVideoSettings* videoSettings);
|
||||||
~AVForm() override;
|
~AVForm() override;
|
||||||
QString getFormName() final override
|
QString getFormName() final override
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user