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
|
@ -83,8 +83,7 @@ AlSink::AlSink(OpenAL& al, uint sourceId)
|
|||
: audio{al}
|
||||
, sourceId{sourceId}
|
||||
, killLock{QMutex::Recursive}
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
AlSink::operator bool() const
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef ALSINK_H
|
||||
#define ALSINK_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
#include "src/audio/iaudiosink.h"
|
||||
|
||||
|
@ -19,8 +19,7 @@ public:
|
|||
AlSink& operator=(AlSink&& other) = delete;
|
||||
~AlSink();
|
||||
|
||||
void playAudioBuffer(const int16_t* data, int samples, unsigned channels,
|
||||
int sampleRate) const;
|
||||
void playAudioBuffer(const int16_t* data, int samples, unsigned channels, int sampleRate) const;
|
||||
void playMono16Sound(const IAudioSink::Sound& sound);
|
||||
void startLoop();
|
||||
void stopLoop();
|
||||
|
|
|
@ -37,12 +37,12 @@ namespace {
|
|||
{
|
||||
for (quint32 i = 0; i < bufferSize; ++i) {
|
||||
// gain amplification with clipping to 16-bit boundaries
|
||||
buffer[i] = qBound<int16_t>(std::numeric_limits<int16_t>::min(),
|
||||
qRound(buffer[i] * gainFactor),
|
||||
buffer[i] =
|
||||
qBound<int16_t>(std::numeric_limits<int16_t>::min(), qRound(buffer[i] * gainFactor),
|
||||
std::numeric_limits<int16_t>::max());
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
/**
|
||||
* @class OpenAL
|
||||
|
@ -82,13 +82,15 @@ OpenAL::OpenAL()
|
|||
captureTimer.setSingleShot(false);
|
||||
captureTimer.moveToThread(audioThread);
|
||||
// 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.setSingleShot(false);
|
||||
connect(&cleanupTimer, &QTimer::timeout, this, &OpenAL::cleanupSound);
|
||||
// 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();
|
||||
}
|
||||
|
@ -332,8 +334,7 @@ void OpenAL::unsubscribeInput()
|
|||
return;
|
||||
|
||||
inSubscriptions--;
|
||||
qDebug() << "Unsubscribed from audio input device [" << inSubscriptions
|
||||
<< "subscriptions left ]";
|
||||
qDebug() << "Unsubscribed from audio input device [" << inSubscriptions << "subscriptions left ]";
|
||||
|
||||
if (!inSubscriptions)
|
||||
cleanupInput();
|
||||
|
@ -377,8 +378,8 @@ bool OpenAL::initInput(const QString& deviceName, uint32_t channels)
|
|||
this->channels = channels;
|
||||
int stereoFlag = channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
|
||||
const int bytesPerSample = 2;
|
||||
const int safetyFactor = 2; // internal OpenAL ring buffer. must be larger than our inputBuffer to avoid the ring
|
||||
// from overwriting itself between captures.
|
||||
const int safetyFactor = 2; // internal OpenAL ring buffer. must be larger than our inputBuffer
|
||||
// to avoid the ring from overwriting itself between captures.
|
||||
AUDIO_FRAME_SAMPLE_COUNT_TOTAL = AUDIO_FRAME_SAMPLE_COUNT_PER_CHANNEL * channels;
|
||||
const ALCsizei ringBufSize = AUDIO_FRAME_SAMPLE_COUNT_TOTAL * bytesPerSample * safetyFactor;
|
||||
|
||||
|
@ -650,7 +651,8 @@ void OpenAL::doInput()
|
|||
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()
|
||||
|
@ -725,7 +727,8 @@ QStringList OpenAL::inDeviceNames()
|
|||
* @brief Free all buffers that finished playing on a source
|
||||
* @param sourceId where to remove the buffers from
|
||||
*/
|
||||
void OpenAL::cleanupBuffers(uint sourceId) {
|
||||
void OpenAL::cleanupBuffers(uint sourceId)
|
||||
{
|
||||
// unqueue all buffers from the source
|
||||
ALint processed = 0;
|
||||
alGetSourcei(sourceId, AL_BUFFERS_PROCESSED, &processed);
|
||||
|
|
|
@ -52,8 +52,14 @@ public:
|
|||
OpenAL();
|
||||
virtual ~OpenAL();
|
||||
|
||||
qreal maxOutputVolume() const { return 1; }
|
||||
qreal minOutputVolume() const { return 0; }
|
||||
qreal maxOutputVolume() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
qreal minOutputVolume() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
qreal outputVolume() const;
|
||||
void setOutputVolume(qreal volume);
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#include <filter_audio.h>
|
||||
}
|
||||
|
||||
|
@ -80,8 +81,7 @@ OpenAL2::OpenAL2()
|
|||
, alProxyContext{nullptr}
|
||||
, alProxySource{0}
|
||||
, alProxyBuffer{0}
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
bool OpenAL2::initInput(const QString& deviceName)
|
||||
{
|
||||
|
@ -324,7 +324,8 @@ void OpenAL2::doOutput()
|
|||
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);
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
#include <AL/alc.h>
|
||||
#include <AL/alext.h>
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#include <filter_audio.h>
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
ToxCall::ToxCall(bool VideoEnabled, CoreAV& av)
|
||||
: av{&av}
|
||||
, videoEnabled{VideoEnabled}
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
ToxCall::~ToxCall()
|
||||
{
|
||||
|
@ -110,8 +109,8 @@ ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av)
|
|||
Audio& audio = Audio::getInstance();
|
||||
audio.subscribeInput();
|
||||
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
||||
[&av, FriendNum](const int16_t* pcm, size_t samples, uint8_t chans,
|
||||
uint32_t rate) {
|
||||
[&av, FriendNum](const int16_t* pcm, size_t samples,
|
||||
uint8_t chans, uint32_t 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,
|
||||
[this]() {
|
||||
this->onAudioSinkInvalidated();
|
||||
});
|
||||
[this]() { this->onAudioSinkInvalidated(); });
|
||||
|
||||
|
||||
// register video
|
||||
|
@ -154,9 +151,7 @@ void ToxFriendCall::onAudioSinkInvalidated()
|
|||
const auto newSink = Audio::getInstance().makeSink();
|
||||
|
||||
audioSinkInvalid = QObject::connect(newSink, &IAudioSink::invalidated,
|
||||
[this]() {
|
||||
this->onAudioSinkInvalidated();
|
||||
});
|
||||
[this]() { this->onAudioSinkInvalidated(); });
|
||||
sink.reset(newSink);
|
||||
}
|
||||
|
||||
|
@ -206,8 +201,8 @@ ToxGroupCall::ToxGroupCall(int GroupNum, CoreAV& av)
|
|||
Audio& audio = Audio::getInstance();
|
||||
audio.subscribeInput();
|
||||
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
||||
[&av, GroupNum](const int16_t* pcm, size_t samples, uint8_t chans,
|
||||
uint32_t rate) {
|
||||
[&av, GroupNum](const int16_t* pcm, size_t samples,
|
||||
uint8_t chans, uint32_t rate) {
|
||||
av.sendGroupCallAudio(GroupNum, pcm, samples, chans, rate);
|
||||
});
|
||||
|
||||
|
@ -247,10 +242,9 @@ void ToxGroupCall::addPeer(ToxPk peerId)
|
|||
IAudioSink* newSink = audio.makeSink();
|
||||
peers.emplace(peerId, std::unique_ptr<IAudioSink>(newSink));
|
||||
|
||||
QMetaObject::Connection con = QObject::connect(newSink, &IAudioSink::invalidated,
|
||||
[this, peerId]() {
|
||||
this->onAudioSinkInvalidated(peerId);
|
||||
});
|
||||
QMetaObject::Connection con =
|
||||
QObject::connect(newSink, &IAudioSink::invalidated,
|
||||
[this, peerId]() { this->onAudioSinkInvalidated(peerId); });
|
||||
|
||||
sinkInvalid.insert({peerId, con});
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ public:
|
|||
void clearPeers();
|
||||
|
||||
const std::unique_ptr<IAudioSink>& getAudioSink(ToxPk peer);
|
||||
|
||||
private:
|
||||
std::map<ToxPk, std::unique_ptr<IAudioSink>> peers;
|
||||
std::map<ToxPk, QMetaObject::Connection> sinkInvalid;
|
||||
|
|
|
@ -41,8 +41,8 @@ class AVForm : public GenericForm, private Ui::AVForm
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AVForm(Audio* audio, CoreAV* coreAV, CameraSource& camera,
|
||||
IAudioSettings* audioSettings, IVideoSettings* videoSettings);
|
||||
AVForm(Audio* audio, CoreAV* coreAV, CameraSource& camera, IAudioSettings* audioSettings,
|
||||
IVideoSettings* videoSettings);
|
||||
~AVForm() override;
|
||||
QString getFormName() final override
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user