mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Ref T730, removed unused timer code in input
This commit is contained in:
committed by
Mat Sutcliffe
parent
713d2ee626
commit
ca90a225e1
@@ -28,24 +28,23 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
namespace Audio
|
namespace Audio
|
||||||
{
|
{
|
||||||
|
|
||||||
CAudioInputBuffer::CAudioInputBuffer(QObject *parent) :
|
CAudioInputBuffer::CAudioInputBuffer(QObject *parent) :
|
||||||
QIODevice(parent)
|
QIODevice(parent)
|
||||||
{}
|
{
|
||||||
|
this->setObjectName("CAudioInputBuffer");
|
||||||
|
}
|
||||||
|
|
||||||
void CAudioInputBuffer::start()
|
void CAudioInputBuffer::start()
|
||||||
|
{
|
||||||
|
if (!this->isOpen())
|
||||||
{
|
{
|
||||||
open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CAudioInputBuffer::stop()
|
void CAudioInputBuffer::stop()
|
||||||
{
|
{
|
||||||
if (m_timerId > 0)
|
this->close();
|
||||||
{
|
|
||||||
killTimer(m_timerId);
|
|
||||||
m_timerId = 0;
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 CAudioInputBuffer::readData(char *data, qint64 maxlen)
|
qint64 CAudioInputBuffer::readData(char *data, qint64 maxlen)
|
||||||
@@ -67,6 +66,7 @@ namespace BlackCore
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
void CAudioInputBuffer::timerEvent(QTimerEvent *event)
|
void CAudioInputBuffer::timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
@@ -83,12 +83,14 @@ namespace BlackCore
|
|||||||
emit frameAvailable(m_buffer.left(1920));
|
emit frameAvailable(m_buffer.left(1920));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
**/
|
||||||
|
|
||||||
CInput::CInput(int sampleRate, QObject *parent) :
|
CInput::CInput(int sampleRate, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_sampleRate(sampleRate),
|
m_sampleRate(sampleRate),
|
||||||
m_encoder(sampleRate, 1, OPUS_APPLICATION_VOIP)
|
m_encoder(sampleRate, 1, OPUS_APPLICATION_VOIP)
|
||||||
{
|
{
|
||||||
|
this->setObjectName("CInput");
|
||||||
m_encoder.setBitRate(16 * 1024);
|
m_encoder.setBitRate(16 * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +123,7 @@ namespace BlackCore
|
|||||||
m_started = false;
|
m_started = false;
|
||||||
if (m_audioInput) { m_audioInput->stop(); }
|
if (m_audioInput) { m_audioInput->stop(); }
|
||||||
m_audioInput.reset();
|
m_audioInput.reset();
|
||||||
|
m_audioInputBuffer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInput::audioInDataAvailable(const QByteArray &frame)
|
void CInput::audioInDataAvailable(const QByteArray &frame)
|
||||||
@@ -147,7 +150,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
int length;
|
int length;
|
||||||
QByteArray encodedBuffer = m_encoder.encode(samples, samples.size(), &length);
|
const QByteArray encodedBuffer = m_encoder.encode(samples, samples.size(), &length);
|
||||||
m_opusBytesEncoded += length;
|
m_opusBytesEncoded += length;
|
||||||
|
|
||||||
m_sampleCount += samples.size();
|
m_sampleCount += samples.size();
|
||||||
|
|||||||
@@ -51,15 +51,9 @@ namespace BlackCore
|
|||||||
//! Frame is available
|
//! Frame is available
|
||||||
void frameAvailable(const QByteArray &frame);
|
void frameAvailable(const QByteArray &frame);
|
||||||
|
|
||||||
protected:
|
|
||||||
//! \copydoc QIODevice::timerEvent
|
|
||||||
void timerEvent(QTimerEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr qint64 frameSize = 960;
|
static constexpr qint64 frameSize = 960;
|
||||||
qint64 m_lastFrameSent = -1;
|
|
||||||
QByteArray m_buffer;
|
QByteArray m_buffer;
|
||||||
int m_timerId = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OpusDataAvailableArgs
|
struct OpusDataAvailableArgs
|
||||||
|
|||||||
Reference in New Issue
Block a user