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
@@ -171,7 +171,7 @@ public Q_SLOTS:
|
||||
return;
|
||||
}
|
||||
alBufferData(m_alBuffer, alFormat, m_sample->data().data(),
|
||||
m_sample->data().size(), m_sample->format().frequency());
|
||||
m_sample->data().size(), m_sample->format().sampleRate());
|
||||
|
||||
if (!QAudioEnginePrivate::checkNoError("fill buffer")) {
|
||||
return;
|
||||
|
||||
@@ -49,8 +49,8 @@ QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf)
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
|
||||
audioFormat.setFrequency(sf.mSampleRate);
|
||||
audioFormat.setChannels(sf.mChannelsPerFrame);
|
||||
audioFormat.setSampleRate(sf.mSampleRate);
|
||||
audioFormat.setChannelCount(sf.mChannelsPerFrame);
|
||||
audioFormat.setSampleSize(sf.mBitsPerChannel);
|
||||
audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
|
||||
audioFormat.setByteOrder((sf.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian);
|
||||
@@ -69,9 +69,9 @@ AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& au
|
||||
AudioStreamBasicDescription sf;
|
||||
|
||||
sf.mFormatFlags = kAudioFormatFlagIsPacked;
|
||||
sf.mSampleRate = audioFormat.frequency();
|
||||
sf.mSampleRate = audioFormat.sampleRate();
|
||||
sf.mFramesPerPacket = 1;
|
||||
sf.mChannelsPerFrame = audioFormat.channels();
|
||||
sf.mChannelsPerFrame = audioFormat.channelCount();
|
||||
sf.mBitsPerChannel = audioFormat.sampleSize();
|
||||
sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8);
|
||||
sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame;
|
||||
|
||||
@@ -279,12 +279,12 @@ QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const
|
||||
QAudioFormat nearest = settings;
|
||||
|
||||
QList<QString> testCodecs = supportedCodecs();
|
||||
QList<int> testChannels = supportedChannels();
|
||||
QList<int> testChannels = supportedChannelCounts();
|
||||
QList<QAudioFormat::Endian> testByteOrders = supportedByteOrders();
|
||||
QList<QAudioFormat::SampleType> testSampleTypes;
|
||||
QList<QAudioFormat::SampleType> sampleTypesAvailable = supportedSampleTypes();
|
||||
QMap<int,int> testFrequencies;
|
||||
QList<int> frequenciesAvailable = supportedFrequencies();
|
||||
QMap<int,int> testSampleRates;
|
||||
QList<int> sampleRatesAvailable = supportedSampleRates();
|
||||
QMap<int,int> testSampleSizes;
|
||||
QList<int> sampleSizesAvailable = supportedSampleSizes();
|
||||
|
||||
@@ -293,8 +293,8 @@ QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const
|
||||
testCodecs.removeAll(settings.codec());
|
||||
testCodecs.insert(0, settings.codec());
|
||||
}
|
||||
testChannels.removeAll(settings.channels());
|
||||
testChannels.insert(0, settings.channels());
|
||||
testChannels.removeAll(settings.channelCount());
|
||||
testChannels.insert(0, settings.channelCount());
|
||||
testByteOrders.removeAll(settings.byteOrder());
|
||||
testByteOrders.insert(0, settings.byteOrder());
|
||||
|
||||
@@ -317,15 +317,15 @@ QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const
|
||||
int diff = larger - smaller;
|
||||
testSampleSizes.insert((isMultiple ? diff : diff+100000), size);
|
||||
}
|
||||
if (frequenciesAvailable.contains(settings.frequency()))
|
||||
testFrequencies.insert(0,settings.frequency());
|
||||
frequenciesAvailable.removeAll(settings.frequency());
|
||||
foreach (int frequency, frequenciesAvailable) {
|
||||
int larger = (frequency > settings.frequency()) ? frequency : settings.frequency();
|
||||
int smaller = (frequency > settings.frequency()) ? settings.frequency() : frequency;
|
||||
if (sampleRatesAvailable.contains(settings.sampleRate()))
|
||||
testSampleRates.insert(0,settings.sampleRate());
|
||||
sampleRatesAvailable.removeAll(settings.sampleRate());
|
||||
foreach (int sampleRate, sampleRatesAvailable) {
|
||||
int larger = (sampleRate > settings.sampleRate()) ? sampleRate : settings.sampleRate();
|
||||
int smaller = (sampleRate > settings.sampleRate()) ? settings.sampleRate() : sampleRate;
|
||||
bool isMultiple = ( 0 == (larger % smaller));
|
||||
int diff = larger - smaller;
|
||||
testFrequencies.insert((isMultiple ? diff : diff+100000), frequency);
|
||||
testSampleRates.insert((isMultiple ? diff : diff+100000), sampleRate);
|
||||
}
|
||||
|
||||
// Try to find nearest
|
||||
@@ -340,11 +340,11 @@ QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const
|
||||
sz.next();
|
||||
nearest.setSampleSize(sz.value());
|
||||
foreach (int channel, testChannels) {
|
||||
nearest.setChannels(channel);
|
||||
QMapIterator<int, int> i(testFrequencies);
|
||||
nearest.setChannelCount(channel);
|
||||
QMapIterator<int, int> i(testSampleRates);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
nearest.setFrequency(i.value());
|
||||
nearest.setSampleRate(i.value());
|
||||
if (isFormatSupported(nearest))
|
||||
return nearest;
|
||||
}
|
||||
@@ -378,16 +378,6 @@ QStringList QAudioDeviceInfo::supportedCodecs() const
|
||||
|
||||
*/
|
||||
QList<int> QAudioDeviceInfo::supportedSampleRates() const
|
||||
{
|
||||
return supportedFrequencies();
|
||||
}
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
Use supportedSampleRates() instead.
|
||||
*/
|
||||
QList<int> QAudioDeviceInfo::supportedFrequencies() const
|
||||
{
|
||||
return isNull() ? QList<int>() : d->info->supportedSampleRates();
|
||||
}
|
||||
@@ -399,16 +389,6 @@ QList<int> QAudioDeviceInfo::supportedFrequencies() const
|
||||
|
||||
*/
|
||||
QList<int> QAudioDeviceInfo::supportedChannelCounts() const
|
||||
{
|
||||
return supportedChannels();
|
||||
}
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
Use supportedChannelCount() instead.
|
||||
*/
|
||||
QList<int> QAudioDeviceInfo::supportedChannels() const
|
||||
{
|
||||
return isNull() ? QList<int>() : d->info->supportedChannelCounts();
|
||||
}
|
||||
|
||||
@@ -88,9 +88,7 @@ public:
|
||||
QAudioFormat nearestFormat(const QAudioFormat &format) const;
|
||||
|
||||
QStringList supportedCodecs() const;
|
||||
QList<int> supportedFrequencies() const;
|
||||
QList<int> supportedSampleRates() const;
|
||||
QList<int> supportedChannels() const;
|
||||
QList<int> supportedChannelCounts() const;
|
||||
QList<int> supportedSampleSizes() const;
|
||||
QList<QAudioFormat::Endian> supportedByteOrders() const;
|
||||
|
||||
@@ -80,20 +80,20 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
|
||||
{
|
||||
QAudioFormat nearest;
|
||||
if(mode == QAudio::AudioOutput) {
|
||||
nearest.setFrequency(44100);
|
||||
nearest.setChannels(2);
|
||||
nearest.setSampleRate(44100);
|
||||
nearest.setChannelCount(2);
|
||||
nearest.setByteOrder(QAudioFormat::LittleEndian);
|
||||
nearest.setSampleType(QAudioFormat::SignedInt);
|
||||
nearest.setSampleSize(16);
|
||||
nearest.setCodec(QLatin1String("audio/pcm"));
|
||||
} else {
|
||||
nearest.setFrequency(8000);
|
||||
nearest.setChannels(1);
|
||||
nearest.setSampleRate(8000);
|
||||
nearest.setChannelCount(1);
|
||||
nearest.setSampleType(QAudioFormat::UnSignedInt);
|
||||
nearest.setSampleSize(8);
|
||||
nearest.setCodec(QLatin1String("audio/pcm"));
|
||||
if(!testSettings(nearest)) {
|
||||
nearest.setChannels(2);
|
||||
nearest.setChannelCount(2);
|
||||
nearest.setSampleSize(16);
|
||||
nearest.setSampleType(QAudioFormat::SignedInt);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ QStringList QAudioDeviceInfoInternal::supportedCodecs()
|
||||
QList<int> QAudioDeviceInfoInternal::supportedSampleRates()
|
||||
{
|
||||
updateLists();
|
||||
return freqz;
|
||||
return sampleRatez;
|
||||
}
|
||||
|
||||
QList<int> QAudioDeviceInfoInternal::supportedChannelCounts()
|
||||
@@ -239,7 +239,7 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
|
||||
|
||||
bool testChannel = false;
|
||||
bool testCodec = false;
|
||||
bool testFreq = false;
|
||||
bool testSampleRate = false;
|
||||
bool testType = false;
|
||||
bool testSize = false;
|
||||
|
||||
@@ -250,8 +250,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
|
||||
snd_pcm_hw_params_any( handle, params );
|
||||
|
||||
// set the values!
|
||||
snd_pcm_hw_params_set_channels(handle,params,format.channels());
|
||||
snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir);
|
||||
snd_pcm_hw_params_set_channels(handle,params,format.channelCount());
|
||||
snd_pcm_hw_params_set_rate(handle,params,format.sampleRate(),dir);
|
||||
|
||||
err = -1;
|
||||
|
||||
@@ -295,20 +295,20 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
|
||||
} else
|
||||
testCodec = true;
|
||||
|
||||
if(err>=0 && format.channels() != -1) {
|
||||
err = snd_pcm_hw_params_test_channels(handle,params,format.channels());
|
||||
if (err>=0 && format.channelCount() != -1) {
|
||||
err = snd_pcm_hw_params_test_channels(handle,params,format.channelCount());
|
||||
if(err>=0)
|
||||
err = snd_pcm_hw_params_set_channels(handle,params,format.channels());
|
||||
err = snd_pcm_hw_params_set_channels(handle,params,format.channelCount());
|
||||
if(err>=0)
|
||||
testChannel = true;
|
||||
}
|
||||
|
||||
if(err>=0 && format.frequency() != -1) {
|
||||
err = snd_pcm_hw_params_test_rate(handle,params,format.frequency(),0);
|
||||
if (err>=0 && format.sampleRate() != -1) {
|
||||
err = snd_pcm_hw_params_test_rate(handle,params,format.sampleRate(),0);
|
||||
if(err>=0)
|
||||
err = snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir);
|
||||
err = snd_pcm_hw_params_set_rate(handle,params,format.sampleRate(),dir);
|
||||
if(err>=0)
|
||||
testFreq = true;
|
||||
testSampleRate = true;
|
||||
}
|
||||
|
||||
if((err>=0 && format.sampleSize() != -1) &&
|
||||
@@ -370,7 +370,7 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
|
||||
void QAudioDeviceInfoInternal::updateLists()
|
||||
{
|
||||
// redo all lists based on current settings
|
||||
freqz.clear();
|
||||
sampleRatez.clear();
|
||||
channelz.clear();
|
||||
sizez.clear();
|
||||
byteOrderz.clear();
|
||||
@@ -385,7 +385,7 @@ void QAudioDeviceInfoInternal::updateLists()
|
||||
|
||||
for(int i=0; i<(int)MAX_SAMPLE_RATES; i++) {
|
||||
//if(snd_pcm_hw_params_test_rate(handle, params, SAMPLE_RATES[i], dir) == 0)
|
||||
freqz.append(SAMPLE_RATES[i]);
|
||||
sampleRatez.append(SAMPLE_RATES[i]);
|
||||
}
|
||||
channelz.append(1);
|
||||
channelz.append(2);
|
||||
@@ -493,7 +493,6 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice()
|
||||
|
||||
void QAudioDeviceInfoInternal::checkSurround()
|
||||
{
|
||||
QList<QByteArray> devices;
|
||||
surround40 = false;
|
||||
surround51 = false;
|
||||
surround71 = false;
|
||||
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
QString device;
|
||||
QAudio::Mode mode;
|
||||
QAudioFormat nearest;
|
||||
QList<int> freqz;
|
||||
QList<int> sampleRatez;
|
||||
QList<int> channelz;
|
||||
QList<int> sizez;
|
||||
QList<QAudioFormat::Endian> byteOrderz;
|
||||
|
||||
@@ -126,15 +126,15 @@ bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) con
|
||||
QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
|
||||
{
|
||||
QAudioFormat nearest;
|
||||
if(mode == QAudio::AudioOutput) {
|
||||
nearest.setFrequency(44100);
|
||||
if (mode == QAudio::AudioOutput) {
|
||||
nearest.setSampleRate(44100);
|
||||
nearest.setChannelCount(2);
|
||||
nearest.setByteOrder(QAudioFormat::LittleEndian);
|
||||
nearest.setSampleType(QAudioFormat::SignedInt);
|
||||
nearest.setSampleSize(16);
|
||||
nearest.setCodec(QLatin1String("audio/pcm"));
|
||||
} else {
|
||||
nearest.setFrequency(11025);
|
||||
nearest.setSampleRate(11025);
|
||||
nearest.setChannelCount(1);
|
||||
nearest.setByteOrder(QAudioFormat::LittleEndian);
|
||||
nearest.setSampleType(QAudioFormat::SignedInt);
|
||||
@@ -158,7 +158,7 @@ QStringList QAudioDeviceInfoInternal::supportedCodecs()
|
||||
QList<int> QAudioDeviceInfoInternal::supportedSampleRates()
|
||||
{
|
||||
updateLists();
|
||||
return freqz;
|
||||
return sampleRatez;
|
||||
}
|
||||
|
||||
QList<int> QAudioDeviceInfoInternal::supportedChannelCounts()
|
||||
@@ -213,8 +213,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
|
||||
// check channel
|
||||
match = false;
|
||||
if (!failed) {
|
||||
for( int i = 0; i < channelz.count(); i++) {
|
||||
if (format.channels() == channelz.at(i)) {
|
||||
for (int i = 0; i < channelz.count(); i++) {
|
||||
if (format.channelCount() == channelz.at(i)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
@@ -223,11 +223,11 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
|
||||
failed = true;
|
||||
}
|
||||
|
||||
// check frequency
|
||||
// check sampleRate
|
||||
match = false;
|
||||
if (!failed) {
|
||||
for( int i = 0; i < freqz.count(); i++) {
|
||||
if (format.frequency() == freqz.at(i)) {
|
||||
for (int i = 0; i < sampleRatez.count(); i++) {
|
||||
if (format.sampleRate() == sampleRatez.at(i)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ void QAudioDeviceInfoInternal::updateLists()
|
||||
}
|
||||
}
|
||||
sizez.clear();
|
||||
freqz.clear();
|
||||
sampleRatez.clear();
|
||||
channelz.clear();
|
||||
byteOrderz.clear();
|
||||
typez.clear();
|
||||
@@ -339,31 +339,31 @@ void QAudioDeviceInfoInternal::updateLists()
|
||||
|| (fmt & WAVE_FORMAT_1S08)
|
||||
|| (fmt & WAVE_FORMAT_1M16)
|
||||
|| (fmt & WAVE_FORMAT_1S16)) {
|
||||
freqz.append(11025);
|
||||
sampleRatez.append(11025);
|
||||
}
|
||||
if ((fmt & WAVE_FORMAT_2M08)
|
||||
|| (fmt & WAVE_FORMAT_2S08)
|
||||
|| (fmt & WAVE_FORMAT_2M16)
|
||||
|| (fmt & WAVE_FORMAT_2S16)) {
|
||||
freqz.append(22050);
|
||||
sampleRatez.append(22050);
|
||||
}
|
||||
if ((fmt & WAVE_FORMAT_4M08)
|
||||
|| (fmt & WAVE_FORMAT_4S08)
|
||||
|| (fmt & WAVE_FORMAT_4M16)
|
||||
|| (fmt & WAVE_FORMAT_4S16)) {
|
||||
freqz.append(44100);
|
||||
sampleRatez.append(44100);
|
||||
}
|
||||
if ((fmt & WAVE_FORMAT_48M08)
|
||||
|| (fmt & WAVE_FORMAT_48S08)
|
||||
|| (fmt & WAVE_FORMAT_48M16)
|
||||
|| (fmt & WAVE_FORMAT_48S16)) {
|
||||
freqz.append(48000);
|
||||
sampleRatez.append(48000);
|
||||
}
|
||||
if ((fmt & WAVE_FORMAT_96M08)
|
||||
|| (fmt & WAVE_FORMAT_96S08)
|
||||
|| (fmt & WAVE_FORMAT_96M16)
|
||||
|| (fmt & WAVE_FORMAT_96S16)) {
|
||||
freqz.append(96000);
|
||||
sampleRatez.append(96000);
|
||||
}
|
||||
channelz.append(1);
|
||||
channelz.append(2);
|
||||
@@ -380,8 +380,8 @@ void QAudioDeviceInfoInternal::updateLists()
|
||||
|
||||
codecz.append(QLatin1String("audio/pcm"));
|
||||
}
|
||||
if (freqz.count() > 0)
|
||||
freqz.prepend(8000);
|
||||
if (sampleRatez.count() > 0)
|
||||
sampleRatez.prepend(8000);
|
||||
}
|
||||
|
||||
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
|
||||
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
QString device;
|
||||
quint32 devId;
|
||||
QAudioFormat nearest;
|
||||
QList<int> freqz;
|
||||
QList<int> sampleRatez;
|
||||
QList<int> channelz;
|
||||
QList<int> sizez;
|
||||
QList<QAudioFormat::Endian> byteOrderz;
|
||||
|
||||
@@ -64,7 +64,7 @@ class QAudioFormatPrivate : public QSharedData
|
||||
public:
|
||||
QAudioFormatPrivate()
|
||||
{
|
||||
frequency = -1;
|
||||
sampleRate = -1;
|
||||
channels = -1;
|
||||
sampleSize = -1;
|
||||
byteOrder = QAudioFormat::Endian(QSysInfo::ByteOrder);
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
codec(other.codec),
|
||||
byteOrder(other.byteOrder),
|
||||
sampleType(other.sampleType),
|
||||
frequency(other.frequency),
|
||||
sampleRate(other.sampleRate),
|
||||
channels(other.channels),
|
||||
sampleSize(other.sampleSize)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
codec = other.codec;
|
||||
byteOrder = other.byteOrder;
|
||||
sampleType = other.sampleType;
|
||||
frequency = other.frequency;
|
||||
sampleRate = other.sampleRate;
|
||||
channels = other.channels;
|
||||
sampleSize = other.sampleSize;
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
QString codec;
|
||||
QAudioFormat::Endian byteOrder;
|
||||
QAudioFormat::SampleType sampleType;
|
||||
int frequency;
|
||||
int sampleRate;
|
||||
int channels;
|
||||
int sampleSize;
|
||||
};
|
||||
@@ -206,7 +206,7 @@ QAudioFormat& QAudioFormat::operator=(const QAudioFormat &other)
|
||||
*/
|
||||
bool QAudioFormat::operator==(const QAudioFormat &other) const
|
||||
{
|
||||
return d->frequency == other.d->frequency &&
|
||||
return d->sampleRate == other.d->sampleRate &&
|
||||
d->channels == other.d->channels &&
|
||||
d->sampleSize == other.d->sampleSize &&
|
||||
d->byteOrder == other.d->byteOrder &&
|
||||
@@ -230,7 +230,7 @@ bool QAudioFormat::operator!=(const QAudioFormat& other) const
|
||||
*/
|
||||
bool QAudioFormat::isValid() const
|
||||
{
|
||||
return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 &&
|
||||
return d->sampleRate != -1 && d->channels != -1 && d->sampleSize != -1 &&
|
||||
d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty();
|
||||
}
|
||||
|
||||
@@ -240,17 +240,7 @@ bool QAudioFormat::isValid() const
|
||||
*/
|
||||
void QAudioFormat::setSampleRate(int samplerate)
|
||||
{
|
||||
d->frequency = samplerate;
|
||||
}
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
Use setSampleRate() instead.
|
||||
*/
|
||||
void QAudioFormat::setFrequency(int frequency)
|
||||
{
|
||||
d->frequency = frequency;
|
||||
d->sampleRate = samplerate;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -259,17 +249,7 @@ void QAudioFormat::setFrequency(int frequency)
|
||||
*/
|
||||
int QAudioFormat::sampleRate() const
|
||||
{
|
||||
return d->frequency;
|
||||
}
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
Use sampleRate() instead.
|
||||
*/
|
||||
int QAudioFormat::frequency() const
|
||||
{
|
||||
return d->frequency;
|
||||
return d->sampleRate;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -281,16 +261,6 @@ void QAudioFormat::setChannelCount(int channels)
|
||||
d->channels = channels;
|
||||
}
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
Use setChannelCount() instead.
|
||||
*/
|
||||
void QAudioFormat::setChannels(int channels)
|
||||
{
|
||||
d->channels = channels;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current channel count value.
|
||||
|
||||
@@ -300,16 +270,6 @@ int QAudioFormat::channelCount() const
|
||||
return d->channels;
|
||||
}
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
Use channelCount() instead.
|
||||
*/
|
||||
int QAudioFormat::channels() const
|
||||
{
|
||||
return d->channels;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the sample size to the \a sampleSize specified, in bits.
|
||||
|
||||
|
||||
@@ -73,13 +73,9 @@ public:
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
void setFrequency(int frequency);
|
||||
int frequency() const;
|
||||
void setSampleRate(int sampleRate);
|
||||
int sampleRate() const;
|
||||
|
||||
void setChannels(int channels);
|
||||
int channels() const;
|
||||
void setChannelCount(int channelCount);
|
||||
int channelCount() const;
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ bool QAudioInputPrivate::open()
|
||||
int dir;
|
||||
int err = 0;
|
||||
int count=0;
|
||||
unsigned int freakuency=settings.frequency();
|
||||
unsigned int sampleRate=settings.sampleRate();
|
||||
|
||||
if (!settings.isValid()) {
|
||||
qWarning("QAudioOutput: open error, invalid format.");
|
||||
@@ -373,14 +373,14 @@ bool QAudioInputPrivate::open()
|
||||
}
|
||||
}
|
||||
if ( !fatal ) {
|
||||
err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() );
|
||||
err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channelCount() );
|
||||
if ( err < 0 ) {
|
||||
fatal = true;
|
||||
errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_channels: err = %1").arg(err);
|
||||
}
|
||||
}
|
||||
if ( !fatal ) {
|
||||
err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 );
|
||||
err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &sampleRate, 0 );
|
||||
if ( err < 0 ) {
|
||||
fatal = true;
|
||||
errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err);
|
||||
@@ -686,8 +686,8 @@ int QAudioInputPrivate::notifyInterval() const
|
||||
qint64 QAudioInputPrivate::processedUSecs() const
|
||||
{
|
||||
qint64 result = qint64(1000000) * totalTimeValue /
|
||||
(settings.channels()*(settings.sampleSize()/8)) /
|
||||
settings.frequency();
|
||||
(settings.channelCount()*(settings.sampleSize()/8)) /
|
||||
settings.sampleRate();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -863,7 +863,7 @@ int QAudioInputPrivate::notifyInterval() const
|
||||
|
||||
qint64 QAudioInputPrivate::processedUSecs() const
|
||||
{
|
||||
return totalFrames * 1000000 / audioFormat.frequency();
|
||||
return totalFrames * 1000000 / audioFormat.sampleRate();
|
||||
}
|
||||
|
||||
qint64 QAudioInputPrivate::elapsedUSecs() const
|
||||
|
||||
@@ -242,12 +242,12 @@ bool QAudioInputPrivate::open()
|
||||
} else if (settings.sampleSize() <= 0) {
|
||||
qWarning("QAudioInput: open error, invalid sample size (%d).",
|
||||
settings.sampleSize());
|
||||
} else if (settings.frequency() < 8000 || settings.frequency() > 96000) {
|
||||
qWarning("QAudioInput: open error, frequency out of range (%d).", settings.frequency());
|
||||
} else if (settings.sampleRate() < 8000 || settings.sampleRate() > 96000) {
|
||||
qWarning("QAudioInput: open error, sample rate out of range (%d).", settings.sampleRate());
|
||||
} else if (buffer_size == 0) {
|
||||
|
||||
buffer_size
|
||||
= (settings.frequency()
|
||||
= (settings.sampleRate()
|
||||
* settings.channelCount()
|
||||
* settings.sampleSize()
|
||||
+ 39) / 40;
|
||||
@@ -265,9 +265,9 @@ bool QAudioInputPrivate::open()
|
||||
|
||||
timeStamp.restart();
|
||||
elapsedTimeOffset = 0;
|
||||
wfx.nSamplesPerSec = settings.frequency();
|
||||
wfx.nSamplesPerSec = settings.sampleRate();
|
||||
wfx.wBitsPerSample = settings.sampleSize();
|
||||
wfx.nChannels = settings.channels();
|
||||
wfx.nChannels = settings.channelCount();
|
||||
wfx.cbSize = 0;
|
||||
|
||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
@@ -539,8 +539,8 @@ qint64 QAudioInputPrivate::processedUSecs() const
|
||||
if (deviceState == QAudio::StoppedState)
|
||||
return 0;
|
||||
qint64 result = qint64(1000000) * totalTimeValue /
|
||||
(settings.channels()*(settings.sampleSize()/8)) /
|
||||
settings.frequency();
|
||||
(settings.channelCount()*(settings.sampleSize()/8)) /
|
||||
settings.sampleRate();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ bool QAudioOutputPrivate::open()
|
||||
int dir;
|
||||
int err = 0;
|
||||
int count=0;
|
||||
unsigned int freakuency=settings.frequency();
|
||||
unsigned int sampleRate=settings.sampleRate();
|
||||
|
||||
if (!settings.isValid()) {
|
||||
qWarning("QAudioOutput: open error, invalid format.");
|
||||
@@ -387,14 +387,14 @@ bool QAudioOutputPrivate::open()
|
||||
}
|
||||
}
|
||||
if ( !fatal ) {
|
||||
err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() );
|
||||
err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channelCount() );
|
||||
if ( err < 0 ) {
|
||||
fatal = true;
|
||||
errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_channels: err = %1").arg(err);
|
||||
}
|
||||
}
|
||||
if ( !fatal ) {
|
||||
err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 );
|
||||
err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &sampleRate, 0 );
|
||||
if ( err < 0 ) {
|
||||
fatal = true;
|
||||
errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err);
|
||||
@@ -630,7 +630,7 @@ int QAudioOutputPrivate::notifyInterval() const
|
||||
|
||||
qint64 QAudioOutputPrivate::processedUSecs() const
|
||||
{
|
||||
return qint64(1000000) * totalTimeValue / settings.frequency();
|
||||
return qint64(1000000) * totalTimeValue / settings.sampleRate();
|
||||
}
|
||||
|
||||
void QAudioOutputPrivate::resume()
|
||||
|
||||
@@ -87,8 +87,8 @@ public:
|
||||
m_device(0)
|
||||
{
|
||||
m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize)));
|
||||
m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channels();
|
||||
m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.frequency();
|
||||
m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channelCount();
|
||||
m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.sampleRate();
|
||||
|
||||
m_fillTimer = new QTimer(this);
|
||||
connect(m_fillTimer, SIGNAL(timeout()), SLOT(fillBuffer()));
|
||||
@@ -579,7 +579,7 @@ int QAudioOutputPrivate::notifyInterval() const
|
||||
|
||||
qint64 QAudioOutputPrivate::processedUSecs() const
|
||||
{
|
||||
return totalFrames * 1000000 / audioFormat.frequency();
|
||||
return totalFrames * 1000000 / audioFormat.sampleRate();
|
||||
}
|
||||
|
||||
qint64 QAudioOutputPrivate::elapsedUSecs() const
|
||||
|
||||
@@ -280,12 +280,12 @@ bool QAudioOutputPrivate::open()
|
||||
} else if (settings.sampleSize() <= 0) {
|
||||
qWarning("QAudioOutput: open error, invalid sample size (%d).",
|
||||
settings.sampleSize());
|
||||
} else if (settings.frequency() < 8000 || settings.frequency() > 96000) {
|
||||
qWarning("QAudioOutput: open error, frequency out of range (%d).", settings.frequency());
|
||||
} else if (settings.sampleRate() < 8000 || settings.sampleRate() > 96000) {
|
||||
qWarning("QAudioOutput: open error, sample rate out of range (%d).", settings.sampleRate());
|
||||
} else if (buffer_size == 0) {
|
||||
// Default buffer size, 200ms, default period size is 40ms
|
||||
buffer_size
|
||||
= (settings.frequency()
|
||||
= (settings.sampleRate()
|
||||
* settings.channelCount()
|
||||
* settings.sampleSize()
|
||||
+ 39) / 40;
|
||||
@@ -315,14 +315,14 @@ bool QAudioOutputPrivate::open()
|
||||
timeStamp.restart();
|
||||
elapsedTimeOffset = 0;
|
||||
|
||||
wfx.nSamplesPerSec = settings.frequency();
|
||||
wfx.nSamplesPerSec = settings.sampleRate();
|
||||
wfx.wBitsPerSample = settings.sampleSize();
|
||||
wfx.nChannels = settings.channels();
|
||||
wfx.nChannels = settings.channelCount();
|
||||
wfx.cbSize = 0;
|
||||
|
||||
bool surround = false;
|
||||
|
||||
if (settings.channels() > 2)
|
||||
if (settings.channelCount() > 2)
|
||||
surround = true;
|
||||
|
||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
@@ -347,9 +347,9 @@ bool QAudioOutputPrivate::open()
|
||||
} else {
|
||||
WAVEFORMATEXTENSIBLE wfex;
|
||||
wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
||||
wfex.Format.nChannels = settings.channels();
|
||||
wfex.Format.nChannels = settings.channelCount();
|
||||
wfex.Format.wBitsPerSample = settings.sampleSize();
|
||||
wfex.Format.nSamplesPerSec = settings.frequency();
|
||||
wfex.Format.nSamplesPerSec = settings.sampleRate();
|
||||
wfex.Format.nBlockAlign = wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
|
||||
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*wfex.Format.nBlockAlign;
|
||||
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
||||
@@ -359,11 +359,11 @@ bool QAudioOutputPrivate::open()
|
||||
wfex.Format.cbSize=22;
|
||||
|
||||
wfex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
|
||||
if (settings.channels() >= 4)
|
||||
if (settings.channelCount() >= 4)
|
||||
wfex.dwChannelMask |= SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
|
||||
if (settings.channels() >= 6)
|
||||
if (settings.channelCount() >= 6)
|
||||
wfex.dwChannelMask |= SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY;
|
||||
if (settings.channels() == 8)
|
||||
if (settings.channelCount() == 8)
|
||||
wfex.dwChannelMask |= SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
|
||||
|
||||
if (waveOutOpen(&hWaveOut, UINT_PTR(deviceId), &wfex.Format,
|
||||
@@ -401,8 +401,8 @@ void QAudioOutputPrivate::close()
|
||||
|
||||
deviceState = QAudio::StoppedState;
|
||||
errorState = QAudio::NoError;
|
||||
int delay = (buffer_size-bytesFree())*1000/(settings.frequency()
|
||||
*settings.channels()*(settings.sampleSize()/8));
|
||||
int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate()
|
||||
*settings.channelCount()*(settings.sampleSize()/8));
|
||||
waveOutReset(hWaveOut);
|
||||
Sleep(delay+10);
|
||||
|
||||
@@ -452,8 +452,8 @@ qint64 QAudioOutputPrivate::processedUSecs() const
|
||||
if (deviceState == QAudio::StoppedState)
|
||||
return 0;
|
||||
qint64 result = qint64(1000000) * totalTimeValue /
|
||||
(settings.channels()*(settings.sampleSize()/8)) /
|
||||
settings.frequency();
|
||||
(settings.channelCount()*(settings.sampleSize()/8)) /
|
||||
settings.sampleRate();
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -553,8 +553,8 @@ void QAudioOutputPrivate::resume()
|
||||
void QAudioOutputPrivate::suspend()
|
||||
{
|
||||
if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) {
|
||||
int delay = (buffer_size-bytesFree())*1000/(settings.frequency()
|
||||
*settings.channels()*(settings.sampleSize()/8));
|
||||
int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate()
|
||||
*settings.channelCount()*(settings.sampleSize()/8));
|
||||
waveOutPause(hWaveOut);
|
||||
Sleep(delay+10);
|
||||
deviceState = QAudio::SuspendedState;
|
||||
|
||||
@@ -76,8 +76,8 @@ inline pa_sample_spec audioFormatToSampleSpec(const QAudioFormat &format)
|
||||
{
|
||||
pa_sample_spec spec;
|
||||
|
||||
spec.rate = format.frequency();
|
||||
spec.channels = format.channels();
|
||||
spec.rate = format.sampleRate();
|
||||
spec.channels = format.channelCount();
|
||||
|
||||
if (format.sampleSize() == 8)
|
||||
spec.format = PA_SAMPLE_U8;
|
||||
|
||||
@@ -74,7 +74,7 @@ QAudioFormat QWaveDecoder::audioFormat() const
|
||||
|
||||
int QWaveDecoder::duration() const
|
||||
{
|
||||
return size() * 1000 / (format.sampleSize() / 8) / format.channels() / format.frequency();
|
||||
return size() * 1000 / (format.sampleSize() / 8) / format.channelCount() / format.sampleRate();
|
||||
}
|
||||
|
||||
qint64 QWaveDecoder::size() const
|
||||
@@ -179,17 +179,17 @@ void QWaveDecoder::handleData()
|
||||
|
||||
format.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt);
|
||||
format.setByteOrder(QAudioFormat::BigEndian);
|
||||
format.setFrequency(qFromBigEndian<quint32>(wave.sampleRate));
|
||||
format.setSampleRate(qFromBigEndian<quint32>(wave.sampleRate));
|
||||
format.setSampleSize(bps);
|
||||
format.setChannels(qFromBigEndian<quint16>(wave.numChannels));
|
||||
format.setChannelCount(qFromBigEndian<quint16>(wave.numChannels));
|
||||
} else {
|
||||
int bps = qFromLittleEndian<quint16>(wave.bitsPerSample);
|
||||
|
||||
format.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt);
|
||||
format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
format.setFrequency(qFromLittleEndian<quint32>(wave.sampleRate));
|
||||
format.setSampleRate(qFromLittleEndian<quint32>(wave.sampleRate));
|
||||
format.setSampleSize(bps);
|
||||
format.setChannels(qFromLittleEndian<quint16>(wave.numChannels));
|
||||
format.setChannelCount(qFromLittleEndian<quint16>(wave.numChannels));
|
||||
}
|
||||
|
||||
state = QWaveDecoder::WaitingForDataState;
|
||||
|
||||
@@ -56,8 +56,8 @@ AudioCaptureSession::AudioCaptureSession(QObject *parent):
|
||||
m_position = 0;
|
||||
m_state = QMediaRecorder::StoppedState;
|
||||
|
||||
m_format.setFrequency(8000);
|
||||
m_format.setChannels(1);
|
||||
m_format.setSampleRate(8000);
|
||||
m_format.setChannelCount(1);
|
||||
m_format.setSampleSize(8);
|
||||
m_format.setSampleType(QAudioFormat::UnSignedInt);
|
||||
m_format.setCodec("audio/pcm");
|
||||
@@ -264,10 +264,10 @@ void AudioCaptureSession::record()
|
||||
memcpy(header.wave.descriptor.id,"fmt ",4);
|
||||
header.wave.descriptor.size = 16;
|
||||
header.wave.audioFormat = 1; // for PCM data
|
||||
header.wave.numChannels = m_format.channels();
|
||||
header.wave.sampleRate = m_format.frequency();
|
||||
header.wave.byteRate = m_format.frequency()*m_format.channels()*m_format.sampleSize()/8;
|
||||
header.wave.blockAlign = m_format.channels()*m_format.sampleSize()/8;
|
||||
header.wave.numChannels = m_format.channelCount();
|
||||
header.wave.sampleRate = m_format.sampleRate();
|
||||
header.wave.byteRate = m_format.sampleRate()*m_format.channelCount()*m_format.sampleSize()/8;
|
||||
header.wave.blockAlign = m_format.channelCount()*m_format.sampleSize()/8;
|
||||
header.wave.bitsPerSample = m_format.sampleSize();
|
||||
memcpy(header.data.descriptor.id,"data",4);
|
||||
header.data.descriptor.size = 0xFFFFFFFF; // This should be updated on stop(),samples*channels*sampleSize/8
|
||||
|
||||
@@ -53,8 +53,8 @@ AudioEncoderControl::AudioEncoderControl(QObject *parent)
|
||||
|
||||
QT_PREPEND_NAMESPACE(QAudioFormat) fmt;
|
||||
fmt.setSampleSize(8);
|
||||
fmt.setChannels(1);
|
||||
fmt.setFrequency(8000);
|
||||
fmt.setChannelCount(1);
|
||||
fmt.setSampleRate(8000);
|
||||
fmt.setSampleType(QT_PREPEND_NAMESPACE(QAudioFormat)::SignedInt);
|
||||
fmt.setCodec("audio/pcm");
|
||||
fmt.setByteOrder(QAudioFormat::LittleEndian);
|
||||
@@ -94,7 +94,7 @@ QList<int> AudioEncoderControl::supportedSampleRates(const QAudioEncoderSettings
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return m_session->deviceInfo()->supportedFrequencies();
|
||||
return m_session->deviceInfo()->supportedSampleRates();
|
||||
}
|
||||
|
||||
QAudioEncoderSettings AudioEncoderControl::audioSettings() const
|
||||
@@ -109,26 +109,26 @@ void AudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings
|
||||
if (settings.encodingMode() == QtMultimedia::ConstantQualityEncoding) {
|
||||
if (settings.quality() == QtMultimedia::LowQuality) {
|
||||
fmt.setSampleSize(8);
|
||||
fmt.setChannels(1);
|
||||
fmt.setFrequency(8000);
|
||||
fmt.setChannelCount(1);
|
||||
fmt.setSampleRate(8000);
|
||||
fmt.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
} else if (settings.quality() == QtMultimedia::NormalQuality) {
|
||||
fmt.setSampleSize(16);
|
||||
fmt.setChannels(1);
|
||||
fmt.setFrequency(22050);
|
||||
fmt.setChannelCount(1);
|
||||
fmt.setSampleRate(22050);
|
||||
fmt.setSampleType(QAudioFormat::SignedInt);
|
||||
|
||||
} else {
|
||||
fmt.setSampleSize(16);
|
||||
fmt.setChannels(1);
|
||||
fmt.setFrequency(44100);
|
||||
fmt.setChannelCount(1);
|
||||
fmt.setSampleRate(44100);
|
||||
fmt.setSampleType(QAudioFormat::SignedInt);
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.setChannels(settings.channelCount());
|
||||
fmt.setFrequency(settings.sampleRate());
|
||||
fmt.setChannelCount(settings.channelCount());
|
||||
fmt.setSampleRate(settings.sampleRate());
|
||||
if (settings.sampleRate() == 8000 && settings.bitRate() == 8000) {
|
||||
fmt.setSampleType(QAudioFormat::UnSignedInt);
|
||||
fmt.setSampleSize(8);
|
||||
|
||||
@@ -274,7 +274,7 @@ bool QPulseAudioOutput::open()
|
||||
QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance();
|
||||
pa_threaded_mainloop_lock(pulseEngine->mainloop());
|
||||
|
||||
qint64 bytesPerSecond = m_format.sampleRate() * m_format.channels() * m_format.sampleSize() / 8;
|
||||
qint64 bytesPerSecond = m_format.sampleRate() * m_format.channelCount() * m_format.sampleSize() / 8;
|
||||
|
||||
pa_proplist *propList = pa_proplist_new();
|
||||
if (m_category.isNull()) {
|
||||
@@ -503,8 +503,8 @@ int QPulseAudioOutput::notifyInterval() const
|
||||
qint64 QPulseAudioOutput::processedUSecs() const
|
||||
{
|
||||
qint64 result = qint64(1000000) * m_totalTimeValue /
|
||||
(m_format.channels() * (m_format.sampleSize() / 8)) /
|
||||
m_format.frequency();
|
||||
(m_format.channelCount() * (m_format.sampleSize() / 8)) /
|
||||
m_format.sampleRate();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ pa_sample_spec audioFormatToSampleSpec(const QAudioFormat &format)
|
||||
{
|
||||
pa_sample_spec spec;
|
||||
|
||||
spec.rate = format.frequency();
|
||||
spec.channels = format.channels();
|
||||
spec.rate = format.sampleRate();
|
||||
spec.channels = format.channelCount();
|
||||
|
||||
if (format.sampleSize() == 8) {
|
||||
spec.format = PA_SAMPLE_U8;
|
||||
@@ -139,7 +139,7 @@ QString stateToQString(pa_context_state_t state)
|
||||
QAudioFormat sampleSpecToAudioFormat(pa_sample_spec spec)
|
||||
{
|
||||
QAudioFormat format;
|
||||
format.setFrequency(spec.rate);
|
||||
format.setSampleRate(spec.rate);
|
||||
format.setChannelCount(spec.channels);
|
||||
format.setCodec("audio/pcm");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user