Delete obsolete class methods and update related code
Delete obsolete methods from QAudioFormat and QAudioDeviceInfo and update code that relied on the obsolete methods. Change-Id: I007e36375a45399b1d5a289341bc5d5a05dc68cc Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
952bd004be
commit
53fdcca366
@@ -528,25 +528,25 @@ bool Engine::selectFormat()
|
||||
}
|
||||
} else {
|
||||
|
||||
QList<int> frequenciesList;
|
||||
QList<int> sampleRatesList;
|
||||
#ifdef Q_OS_WIN
|
||||
// The Windows audio backend does not correctly report format support
|
||||
// (see QTBUG-9100). Furthermore, although the audio subsystem captures
|
||||
// at 11025Hz, the resulting audio is corrupted.
|
||||
frequenciesList += 8000;
|
||||
sampleRatesList += 8000;
|
||||
#endif
|
||||
|
||||
if (!m_generateTone)
|
||||
frequenciesList += m_audioInputDevice.supportedFrequencies();
|
||||
sampleRatesList += m_audioInputDevice.supportedSampleRates();
|
||||
|
||||
frequenciesList += m_audioOutputDevice.supportedFrequencies();
|
||||
frequenciesList = frequenciesList.toSet().toList(); // remove duplicates
|
||||
qSort(frequenciesList);
|
||||
ENGINE_DEBUG << "Engine::initialize frequenciesList" << frequenciesList;
|
||||
sampleRatesList += m_audioOutputDevice.supportedSampleRates();
|
||||
sampleRatesList = sampleRatesList.toSet().toList(); // remove duplicates
|
||||
qSort(sampleRatesList);
|
||||
ENGINE_DEBUG << "Engine::initialize frequenciesList" << sampleRatesList;
|
||||
|
||||
QList<int> channelsList;
|
||||
channelsList += m_audioInputDevice.supportedChannels();
|
||||
channelsList += m_audioOutputDevice.supportedChannels();
|
||||
channelsList += m_audioInputDevice.supportedChannelCounts();
|
||||
channelsList += m_audioOutputDevice.supportedChannelCounts();
|
||||
channelsList = channelsList.toSet().toList();
|
||||
qSort(channelsList);
|
||||
ENGINE_DEBUG << "Engine::initialize channelsList" << channelsList;
|
||||
@@ -556,13 +556,13 @@ bool Engine::selectFormat()
|
||||
format.setCodec("audio/pcm");
|
||||
format.setSampleSize(16);
|
||||
format.setSampleType(QAudioFormat::SignedInt);
|
||||
int frequency, channels;
|
||||
foreach (frequency, frequenciesList) {
|
||||
int sampleRate, channels;
|
||||
foreach (sampleRate, sampleRatesList) {
|
||||
if (foundSupportedFormat)
|
||||
break;
|
||||
format.setFrequency(frequency);
|
||||
format.setSampleRate(sampleRate);
|
||||
foreach (channels, channelsList) {
|
||||
format.setChannels(channels);
|
||||
format.setChannelCount(channels);
|
||||
const bool inputSupport = m_generateTone ||
|
||||
m_audioInputDevice.isFormatSupported(format);
|
||||
const bool outputSupport = m_audioOutputDevice.isFormatSupported(format);
|
||||
@@ -703,7 +703,7 @@ void Engine::setFormat(const QAudioFormat &format)
|
||||
m_format = format;
|
||||
m_levelBufferLength = audioLength(m_format, LevelWindowUs);
|
||||
m_spectrumBufferLength = SpectrumLengthSamples *
|
||||
(m_format.sampleSize() / 8) * m_format.channels();
|
||||
(m_format.sampleSize() / 8) * m_format.channelCount();
|
||||
if (changed)
|
||||
emit formatChanged(m_format);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ void SpectrumAnalyser::calculate(const QByteArray &buffer,
|
||||
if (isReady()) {
|
||||
Q_ASSERT(isPCMS16LE(format));
|
||||
|
||||
const int bytesPerSample = format.sampleSize() * format.channels() / 8;
|
||||
const int bytesPerSample = format.sampleSize() * format.channelCount() / 8;
|
||||
|
||||
#ifdef DUMP_SPECTRUMANALYSER
|
||||
m_count++;
|
||||
@@ -235,7 +235,7 @@ void SpectrumAnalyser::calculate(const QByteArray &buffer,
|
||||
const bool b = QMetaObject::invokeMethod(m_thread, "calculateSpectrum",
|
||||
Qt::AutoConnection,
|
||||
Q_ARG(QByteArray, buffer),
|
||||
Q_ARG(int, format.frequency()),
|
||||
Q_ARG(int, format.sampleRate()),
|
||||
Q_ARG(int, bytesPerSample));
|
||||
Q_ASSERT(b);
|
||||
Q_UNUSED(b) // suppress warnings in release builds
|
||||
|
||||
@@ -50,7 +50,7 @@ void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray
|
||||
Q_ASSERT(isPCMS16LE(format));
|
||||
|
||||
const int channelBytes = format.sampleSize() / 8;
|
||||
const int sampleBytes = format.channels() * channelBytes;
|
||||
const int sampleBytes = format.channelCount() * channelBytes;
|
||||
int length = buffer.size();
|
||||
const int numSamples = buffer.size() / sampleBytes;
|
||||
|
||||
@@ -61,7 +61,7 @@ void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray
|
||||
|
||||
qreal phase = 0.0;
|
||||
|
||||
const qreal d = 2 * M_PI / format.frequency();
|
||||
const qreal d = 2 * M_PI / format.sampleRate();
|
||||
|
||||
// We can't generate a zero-frequency sine wave
|
||||
const qreal startFreq = tone.startFreq ? tone.startFreq : 1.0;
|
||||
@@ -76,7 +76,7 @@ void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray
|
||||
while (length) {
|
||||
const qreal x = tone.amplitude * qSin(phase);
|
||||
const qint16 value = realToPcm(x);
|
||||
for (int i=0; i<format.channels(); ++i) {
|
||||
for (int i=0; i<format.channelCount(); ++i) {
|
||||
qToLittleEndian<qint16>(value, ptr);
|
||||
ptr += channelBytes;
|
||||
length -= channelBytes;
|
||||
|
||||
@@ -44,12 +44,12 @@
|
||||
qint64 audioDuration(const QAudioFormat &format, qint64 bytes)
|
||||
{
|
||||
return (bytes * 1000000) /
|
||||
(format.frequency() * format.channels() * (format.sampleSize() / 8));
|
||||
(format.sampleRate() * format.channelCount() * (format.sampleSize() / 8));
|
||||
}
|
||||
|
||||
qint64 audioLength(const QAudioFormat &format, qint64 microSeconds)
|
||||
{
|
||||
qint64 result = (format.frequency() * format.channels() * (format.sampleSize() / 8))
|
||||
qint64 result = (format.sampleRate() * format.channelCount() * (format.sampleSize() / 8))
|
||||
* microSeconds / 1000000;
|
||||
result -= result % (format.channelCount() * format.sampleSize());
|
||||
return result;
|
||||
@@ -57,7 +57,7 @@ qint64 audioLength(const QAudioFormat &format, qint64 microSeconds)
|
||||
|
||||
qreal nyquistFrequency(const QAudioFormat &format)
|
||||
{
|
||||
return format.frequency() / 2;
|
||||
return format.sampleRate() / 2;
|
||||
}
|
||||
|
||||
QString formatToString(const QAudioFormat &format)
|
||||
@@ -87,8 +87,8 @@ QString formatToString(const QAudioFormat &format)
|
||||
break;
|
||||
}
|
||||
|
||||
QString formatChannels = QString("%1 channels").arg(format.channels());
|
||||
switch (format.channels()) {
|
||||
QString formatChannels = QString("%1 channels").arg(format.channelCount());
|
||||
switch (format.channelCount()) {
|
||||
case 1:
|
||||
formatChannels = "mono";
|
||||
break;
|
||||
@@ -98,7 +98,7 @@ QString formatToString(const QAudioFormat &format)
|
||||
}
|
||||
|
||||
result = QString("%1 Hz %2 bit %3 %4 %5")
|
||||
.arg(format.frequency())
|
||||
.arg(format.sampleRate())
|
||||
.arg(format.sampleSize())
|
||||
.arg(formatType)
|
||||
.arg(formatEndian)
|
||||
|
||||
@@ -366,7 +366,7 @@ void Waveform::paintTile(int index)
|
||||
|
||||
const qint16* base = reinterpret_cast<const qint16*>(m_buffer.constData());
|
||||
const qint16* buffer = base + ((tileStart - m_bufferPosition) / 2);
|
||||
const int numSamples = m_tileLength / (2 * m_format.channels());
|
||||
const int numSamples = m_tileLength / (2 * m_format.channelCount());
|
||||
|
||||
QPainter painter(tile.pixmap);
|
||||
|
||||
@@ -378,7 +378,7 @@ void Waveform::paintTile(int index)
|
||||
// Calculate initial PCM value
|
||||
qint16 previousPcmValue = 0;
|
||||
if (buffer > base)
|
||||
previousPcmValue = *(buffer - m_format.channels());
|
||||
previousPcmValue = *(buffer - m_format.channelCount());
|
||||
|
||||
// Calculate initial point
|
||||
const qreal previousRealValue = pcmToReal(previousPcmValue);
|
||||
@@ -388,7 +388,7 @@ void Waveform::paintTile(int index)
|
||||
QLine line(origin, origin);
|
||||
|
||||
for (int i=0; i<numSamples; ++i) {
|
||||
const qint16* ptr = buffer + i * m_format.channels();
|
||||
const qint16* ptr = buffer + i * m_format.channelCount();
|
||||
|
||||
const int offset = reinterpret_cast<const char*>(ptr) - m_buffer.constData();
|
||||
Q_ASSERT(offset >= 0);
|
||||
@@ -398,7 +398,7 @@ void Waveform::paintTile(int index)
|
||||
const qint16 pcmValue = *ptr;
|
||||
const qreal realValue = pcmToReal(pcmValue);
|
||||
|
||||
const int x = tilePixelOffset(i * 2 * m_format.channels());
|
||||
const int x = tilePixelOffset(i * 2 * m_format.channelCount());
|
||||
const int y = ((realValue + 1.0) / 2) * m_pixmapSize.height();
|
||||
|
||||
line.setP2(QPoint(x, y));
|
||||
|
||||
@@ -137,9 +137,9 @@ bool WavFile::readHeader()
|
||||
m_fileFormat.setByteOrder(QAudioFormat::BigEndian);
|
||||
|
||||
int bps = qFromLittleEndian<quint16>(header.wave.bitsPerSample);
|
||||
m_fileFormat.setChannels(qFromLittleEndian<quint16>(header.wave.numChannels));
|
||||
m_fileFormat.setChannelCount(qFromLittleEndian<quint16>(header.wave.numChannels));
|
||||
m_fileFormat.setCodec("audio/pcm");
|
||||
m_fileFormat.setFrequency(qFromLittleEndian<quint32>(header.wave.sampleRate));
|
||||
m_fileFormat.setSampleRate(qFromLittleEndian<quint32>(header.wave.sampleRate));
|
||||
m_fileFormat.setSampleSize(qFromLittleEndian<quint16>(header.wave.bitsPerSample));
|
||||
m_fileFormat.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user