Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.2.1
-
None
-
Qt 5.2.1
QtCreator 3.0.1
iPhone5 iOS7 real device
Mac OSX 10.9.2 (Maveriks)
-
-
d2b54b360ec0cedf2dfd64c72cc8f476fb93bc7c
Description
I have the following code to test QAudioDeviceInfo capabilities in different platforms
void printDevInfoSupported( QAudioDeviceInfo const& devinfo )
{
qDebug() << "DeviceName: " << devinfo.deviceName();
qDebug() << "supportedByteOrders: ";
foreach ( QAudioFormat::Endian item, devinfo.supportedByteOrders())
qDebug() << "supportedChannelCounts: ";
foreach (int item, devinfo.supportedChannelCounts())
qDebug() << "supportedCodecs: ";
foreach ( QString item, devinfo.supportedCodecs())
qDebug() << "supportedSampleRates: ";
foreach ( int item, devinfo.supportedSampleRates())
qDebug() << "supportedSampleSizes: ";
foreach ( int item, devinfo.supportedSampleSizes())
qDebug() << "supportedSampleTypes: ";
foreach ( QAudioFormat::SampleType item, devinfo.supportedSampleTypes())
}
void printFormat( QAudioDeviceInfo const& devinfo, QAudioFormat const& format, QString const& str )
{
qDebug() << "------------------------------- " << str << "------------------------------- ";
qDebug() << "codec(): " << format.codec();
qDebug() << "sampleRate(): " << format.sampleRate();
qDebug() << "channelCount(): " << format.channelCount();
qDebug() << "sampleSize(): " << format.sampleSize();
qDebug() << "byteOrder(): " << format.byteOrder();
qDebug() << "sampleType(): " << format.sampleType();
if (!devinfo.isFormatSupported(format))
{ qWarning() << "Raw audio format not supported by backend, cannot play audio."; }else
{ qDebug() << "Audio format OK"; } qDebug() << "------------------------------- " << str << "------------------------------- ";
}
//.....
QAudioDeviceInfo devinfo(QAudioDeviceInfo::defaultOutputDevice());
printDevInfoSupported(devinfo);
QAudioFormat prefFormat = devinfo.preferredFormat();
printFormat(devinfo, prefFormat, "prefFormat");
QAudioFormat nearestFormat = devinfo.nearestFormat(format);
printFormat(devinfo, nearestFormat, "nearestFormat");
//.....
On Windows, OSX and Android works fine.
But on iOS, I get the following values:
DeviceName: "default"
supportedByteOrders:
supportedByteOrder: LittleEndian
supportedByteOrder: BigEndian
supportedChannelCounts:
supportedChannelCount: 1
supportedCodecs:
supportedCodec: "audio/pcm"
supportedSampleRates:
supportedSampleRates Size: 5
supportedSampleRate: 11025
supportedSampleRate: 22050
supportedSampleRate: 48000
supportedSampleRate: 44100
supportedSampleRate: 8000
supportedSampleSizes:
supportedSampleSize: 8
supportedSampleSize: 16
supportedSampleSize: 24
supportedSampleSize: 32
supportedSampleSize: 64
supportedSampleTypes:
supportedSampleType: SignedInt
supportedSampleType: UnSignedInt
supportedSampleType: Float
-
-
-
- The problem is here:
-
-
supportedChannelCounts:
supportedChannelCount: 1
It says that only support One-Channel when iOS effectively supports Two-Channels, see:
"Here is a fully fledged audio stream basic description example that illustrates a two-channel, canonical iPhone audio unit sample format with a 44.1 kHz sample rate."
https://developer.apple.com/LIBRARY/ios/documentation/MusicAudio/Conceptual/CoreAudioOverview/CoreAudioEssentials/CoreAudioEssentials.html
Therefore, the following formats are not supported:
//.....
QAudioFormat prefFormat = devinfo.preferredFormat();
printFormat(devinfo, prefFormat, "prefFormat");
QAudioFormat myformat;
myformat.setCodec("audio/pcm");
myformat.setSampleRate(48000);
myformat.setChannelCount(2);
myformat.setSampleSize(16);
myformat.setByteOrder(QAudioFormat::LittleEndian);
myformat.setSampleType(QAudioFormat::SignedInt);
printFormat(devinfo, myformat, "myformat");
//.....
------------------------------- "prefFormat" -------------------------------
codec(): "audio/pcm"
sampleRate(): 44100
channelCount(): 2
sampleSize(): 16
byteOrder(): LittleEndian
sampleType(): SignedInt
Raw audio format not supported by backend, cannot play audio.
------------------------------- "prefFormat" -------------------------------
------------------------------- "myformat" -------------------------------
codec(): "audio/pcm"
sampleRate(): 48000
channelCount(): 2
sampleSize(): 16
byteOrder(): LittleEndian
sampleType(): SignedInt
Raw audio format not supported by backend, cannot play audio.
------------------------------- "myformat" -------------------------------
This format works fine...
//.....
QAudioFormat nearestFormat = devinfo.nearestFormat(myformat);
printFormat(devinfo, nearestFormat, "nearestFormat");
//.....
------------------------------- "nearestFormat" -------------------------------
codec(): "audio/pcm"
sampleRate(): 48000
channelCount(): 1
sampleSize(): 16
byteOrder(): LittleEndian
sampleType(): SignedInt
Audio format OK
------------------------------- "nearestFormat" -------------------------------
but... I need a Two-Channel format....
I guess the problem is the channelCount.
Ironically the QAudioDeviceInfo::preferredFormat() is not a supported format.
Regards,
Fernando.