mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
[AFV] Ref T730, renamed to COutput
This commit is contained in:
@@ -36,9 +36,9 @@ namespace BlackCore
|
||||
|
||||
qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen)
|
||||
{
|
||||
int sampleBytes = m_outputFormat.sampleSize() / 8;
|
||||
int channelCount = m_outputFormat.channelCount();
|
||||
qint64 count = maxlen / (sampleBytes * channelCount);
|
||||
const int sampleBytes = m_outputFormat.sampleSize() / 8;
|
||||
const int channelCount = m_outputFormat.channelCount();
|
||||
const qint64 count = maxlen / (sampleBytes * channelCount);
|
||||
QVector<float> buffer;
|
||||
m_sampleProvider->readSamples(buffer, count);
|
||||
|
||||
@@ -81,17 +81,17 @@ namespace BlackCore
|
||||
return -1;
|
||||
}
|
||||
|
||||
Output::Output(QObject *parent) : QObject(parent)
|
||||
COutput::COutput(QObject *parent) : QObject(parent)
|
||||
{
|
||||
this->setObjectName("COutput");
|
||||
}
|
||||
|
||||
void Output::start(const CAudioDeviceInfo &outputDevice, ISampleProvider *sampleProvider)
|
||||
void COutput::start(const CAudioDeviceInfo &outputDevice, ISampleProvider *sampleProvider)
|
||||
{
|
||||
if (m_started) { return; }
|
||||
|
||||
m_audioOutputBuffer = new CAudioOutputBuffer(sampleProvider, this);
|
||||
connect(m_audioOutputBuffer, &CAudioOutputBuffer::outputVolumeStream, this, &Output::outputVolumeStream);
|
||||
connect(m_audioOutputBuffer, &CAudioOutputBuffer::outputVolumeStream, this, &COutput::outputVolumeStream);
|
||||
|
||||
m_device = outputDevice;
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace BlackCore
|
||||
outputFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||
outputFormat.setCodec("audio/pcm");
|
||||
|
||||
QAudioDeviceInfo selectedDevice = getLowestLatencyDevice(outputDevice, outputFormat);
|
||||
const QAudioDeviceInfo selectedDevice = getLowestLatencyDevice(outputDevice, outputFormat);
|
||||
m_audioOutputCom.reset(new QAudioOutput(selectedDevice, outputFormat));
|
||||
m_audioOutputBuffer->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
|
||||
m_audioOutputBuffer->setAudioFormat(outputFormat);
|
||||
@@ -112,7 +112,7 @@ namespace BlackCore
|
||||
m_started = true;
|
||||
}
|
||||
|
||||
void Output::stop()
|
||||
void COutput::stop()
|
||||
{
|
||||
if (!m_started) { return; }
|
||||
m_started = false;
|
||||
|
||||
@@ -66,16 +66,16 @@ namespace BlackCore
|
||||
};
|
||||
|
||||
//! Output
|
||||
class Output : public QObject
|
||||
class COutput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
Output(QObject *parent = nullptr);
|
||||
COutput(QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~Output() override
|
||||
virtual ~COutput() override
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace BlackCore
|
||||
CContinuousWorker(owner, "CAfvClient"),
|
||||
m_connection(new CClientConnection(apiServer, this)),
|
||||
m_input(new CInput(SampleRate, this)),
|
||||
m_output(new Output(this)),
|
||||
m_output(new COutput(this)),
|
||||
m_voiceServerPositionTimer(new QTimer(this))
|
||||
{
|
||||
this->setObjectName("AFV client");
|
||||
@@ -55,7 +55,7 @@ namespace BlackCore
|
||||
connect(m_input, &CInput::opusDataAvailable, this, &CAfvClient::opusDataAvailable);
|
||||
connect(m_input, &CInput::inputVolumeStream, this, &CAfvClient::inputVolumeStream);
|
||||
|
||||
connect(m_output, &Output::outputVolumeStream, this, &CAfvClient::outputVolumeStream);
|
||||
connect(m_output, &COutput::outputVolumeStream, this, &CAfvClient::outputVolumeStream);
|
||||
connect(m_connection, &CClientConnection::audioReceived, this, &CAfvClient::audioOutDataAvailable);
|
||||
connect(m_voiceServerPositionTimer, &QTimer::timeout, this, &CAfvClient::onPositionUpdateTimer);
|
||||
|
||||
@@ -219,8 +219,8 @@ namespace BlackCore
|
||||
if (m_outputSampleProvider) { m_outputSampleProvider->deleteLater(); }
|
||||
m_outputSampleProvider = new CVolumeSampleProvider(m_soundcardSampleProvider, this);
|
||||
m_outputSampleProvider->setVolume(m_outputVolume);
|
||||
|
||||
m_output->start(outputDevice, m_outputSampleProvider);
|
||||
|
||||
m_input->start(inputDevice);
|
||||
|
||||
m_startDateTimeUtc = QDateTime::currentDateTimeUtc();
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace BlackCore
|
||||
QString m_callsign;
|
||||
|
||||
Audio::CInput *m_input = nullptr;
|
||||
Audio::Output *m_output = nullptr;
|
||||
Audio::COutput *m_output = nullptr;
|
||||
|
||||
Audio::CSoundcardSampleProvider *m_soundcardSampleProvider = nullptr;
|
||||
BlackSound::SampleProvider::CVolumeSampleProvider *m_outputSampleProvider = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user