mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
Ref T730, changes of RR/KB testing dual channels and WSAPI issues
This commit is contained in:
committed by
Mat Sutcliffe
parent
11275d3560
commit
9bbb710823
@@ -28,7 +28,7 @@ namespace BlackCore
|
|||||||
void CAudioInputBuffer::start()
|
void CAudioInputBuffer::start()
|
||||||
{
|
{
|
||||||
open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
||||||
m_timerId = startTimer(5, Qt::PreciseTimer);
|
// m_timerId = startTimer(5, Qt::PreciseTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAudioInputBuffer::stop()
|
void CAudioInputBuffer::stop()
|
||||||
@@ -50,11 +50,13 @@ namespace BlackCore
|
|||||||
|
|
||||||
qint64 CAudioInputBuffer::writeData(const char *data, qint64 len)
|
qint64 CAudioInputBuffer::writeData(const char *data, qint64 len)
|
||||||
{
|
{
|
||||||
// QByteArray buffer(data, static_cast<int>(len));
|
|
||||||
// m_buffer.append(buffer);
|
|
||||||
m_buffer.append(data, static_cast<int>(len));
|
m_buffer.append(data, static_cast<int>(len));
|
||||||
|
while (m_buffer.size() > 1920)
|
||||||
qDebug() << QDateTime::currentMSecsSinceEpoch() << "[writeData] " << len << "buffer " << m_buffer.size();
|
{
|
||||||
|
qDebug() << QDateTime::currentMSecsSinceEpoch() << "CAudioInputBuffer::writeData " << m_buffer.size();
|
||||||
|
emit frameAvailable(m_buffer.left(1920));
|
||||||
|
m_buffer.remove(0, 1920);
|
||||||
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,20 +90,24 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (m_started) { return; }
|
if (m_started) { return; }
|
||||||
|
|
||||||
QAudioFormat waveFormat;
|
QAudioFormat inputFormat;
|
||||||
|
|
||||||
waveFormat.setSampleRate(m_sampleRate);
|
inputFormat.setSampleRate(m_sampleRate);
|
||||||
waveFormat.setChannelCount(1);
|
inputFormat.setChannelCount(1);
|
||||||
waveFormat.setSampleSize(16);
|
inputFormat.setSampleSize(16);
|
||||||
waveFormat.setSampleType(QAudioFormat::SignedInt);
|
inputFormat.setSampleType(QAudioFormat::SignedInt);
|
||||||
waveFormat.setByteOrder(QAudioFormat::LittleEndian);
|
inputFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||||
waveFormat.setCodec("audio/pcm");
|
inputFormat.setCodec("audio/pcm");
|
||||||
|
|
||||||
QAudioFormat inputFormat = waveFormat;
|
|
||||||
if (!inputDevice.isFormatSupported(inputFormat))
|
if (!inputDevice.isFormatSupported(inputFormat))
|
||||||
{
|
{
|
||||||
qWarning() << "Default format not supported - trying to use nearest";
|
qWarning() << "Default INPUT format not supported - trying to use nearest";
|
||||||
inputFormat = inputDevice.nearestFormat(inputFormat);
|
qWarning() << "Default format not supported - trying to use nearest:";
|
||||||
|
qWarning() << "Sample rate: " << inputFormat.sampleRate();
|
||||||
|
qWarning() << "Sample size: " << inputFormat.sampleSize();
|
||||||
|
qWarning() << "Sample type: " << inputFormat.sampleType();
|
||||||
|
qWarning() << "Byte order: " << inputFormat.byteOrder();
|
||||||
|
qWarning() << "Codec: " << inputFormat.codec();
|
||||||
|
qWarning() << "Channel count: " << inputFormat.channelCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_audioInput.reset(new QAudioInput(inputDevice, inputFormat));
|
m_audioInput.reset(new QAudioInput(inputDevice, inputFormat));
|
||||||
|
|||||||
@@ -61,7 +61,16 @@ namespace BlackCore
|
|||||||
m_maxSampleOutput = 0;
|
m_maxSampleOutput = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(data, buffer.constData(), maxlen);
|
// if (maxlen > buffer.size()) { maxlen = buffer.size(); }
|
||||||
|
// memcpy(data, buffer.constData(), maxlen > buffer.size() ? buffer.size() : maxlen);
|
||||||
|
qint16 *p = reinterpret_cast<qint16 *>(data);
|
||||||
|
int index = 0;
|
||||||
|
for (int n = 0; n < count; n++)
|
||||||
|
{
|
||||||
|
p[index++] = buffer[n];
|
||||||
|
if (channelCount == 2) p[index++] = buffer[n];
|
||||||
|
}
|
||||||
|
|
||||||
return maxlen;
|
return maxlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +99,15 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (!device.isFormatSupported(outputFormat))
|
if (!device.isFormatSupported(outputFormat))
|
||||||
{
|
{
|
||||||
qWarning() << "Default format not supported - trying to use nearest";
|
qWarning() << "Default OUTPUT format not supported - trying to use nearest";
|
||||||
outputFormat = device.nearestFormat(outputFormat);
|
outputFormat = device.nearestFormat(outputFormat);
|
||||||
|
qWarning() << "Default format not supported - trying to use nearest:";
|
||||||
|
qWarning() << "Sample rate: " << outputFormat.sampleRate();
|
||||||
|
qWarning() << "Sample size: " << outputFormat.sampleSize();
|
||||||
|
qWarning() << "Sample type: " << outputFormat.sampleType();
|
||||||
|
qWarning() << "Byte order: " << outputFormat.byteOrder();
|
||||||
|
qWarning() << "Codec: " << outputFormat.codec();
|
||||||
|
qWarning() << "Channel count: " << outputFormat.channelCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_audioOutputCom1.reset(new QAudioOutput(device, outputFormat));
|
m_audioOutputCom1.reset(new QAudioOutput(device, outputFormat));
|
||||||
|
|||||||
Reference in New Issue
Block a user