Qt 4.8
Functions
qaudio_mac.cpp File Reference
#include "qaudio_mac_p.h"

Go to the source code of this file.

Functions

QDebug operator<< (QDebug dbg, const QAudioFormat &audioFormat)
 
AudioStreamBasicDescription toAudioStreamBasicDescription (QAudioFormat const &audioFormat)
 
QAudioFormat toQAudioFormat (AudioStreamBasicDescription const &sf)
 

Function Documentation

◆ operator<<()

QDebug operator<< ( QDebug  dbg,
const QAudioFormat audioFormat 
)

Definition at line 48 of file qaudio_mac.cpp.

49 {
50  dbg.nospace() << "QAudioFormat(" <<
51  audioFormat.frequency() << "," <<
52  audioFormat.channels() << "," <<
53  audioFormat.sampleSize()<< "," <<
54  audioFormat.codec() << "," <<
55  audioFormat.byteOrder() << "," <<
56  audioFormat.sampleType() << ")";
57 
58  return dbg.space();
59 }
int frequency() const
Use sampleRate() instead.
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
int sampleSize() const
Returns the current sample size value.
QAudioFormat::Endian byteOrder() const
Returns the current byteOrder value.
QAudioFormat::SampleType sampleType() const
Returns the current SampleType value.
QString codec() const
Returns the current codec value.
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91
int channels() const
Use channelCount() instead.

◆ toAudioStreamBasicDescription()

AudioStreamBasicDescription toAudioStreamBasicDescription ( QAudioFormat const &  audioFormat)

Definition at line 82 of file qaudio_mac.cpp.

83 {
84  AudioStreamBasicDescription sf;
85 
86  sf.mFormatFlags = kAudioFormatFlagIsPacked;
87  sf.mSampleRate = audioFormat.frequency();
88  sf.mFramesPerPacket = 1;
89  sf.mChannelsPerFrame = audioFormat.channels();
90  sf.mBitsPerChannel = audioFormat.sampleSize();
91  sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8);
92  sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame;
93  sf.mFormatID = kAudioFormatLinearPCM;
94 
95  switch (audioFormat.sampleType()) {
96  case QAudioFormat::SignedInt: sf.mFormatFlags |= kAudioFormatFlagIsSignedInteger; break;
97  case QAudioFormat::UnSignedInt: /* default */ break;
98  case QAudioFormat::Float: sf.mFormatFlags |= kAudioFormatFlagIsFloat; break;
99  case QAudioFormat::Unknown: default: break;
100  }
101 
102  if (audioFormat.byteOrder() == QAudioFormat::BigEndian)
103  sf.mFormatFlags |= kAudioFormatFlagIsBigEndian;
104 
105  return sf;
106 }

◆ toQAudioFormat()

QAudioFormat toQAudioFormat ( AudioStreamBasicDescription const &  sf)

Definition at line 63 of file qaudio_mac.cpp.

Referenced by QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), and QtMultimediaInternal::QAudioInputBuffer::QAudioInputBuffer().

64 {
65  QAudioFormat audioFormat;
66 
67  audioFormat.setFrequency(sf.mSampleRate);
68  audioFormat.setChannels(sf.mChannelsPerFrame);
69  audioFormat.setSampleSize(sf.mBitsPerChannel);
70  audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
71  audioFormat.setByteOrder((sf.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian);
73  if ((sf.mFormatFlags & kAudioFormatFlagIsSignedInteger) != 0)
75  else if ((sf.mFormatFlags & kAudioFormatFlagIsFloat) != 0)
76  type = QAudioFormat::Float;
77  audioFormat.setSampleType(type);
78 
79  return audioFormat;
80 }
int type
Definition: qmetatype.cpp:239
void setSampleType(QAudioFormat::SampleType sampleType)
Sets the sampleType to sampleType.
void setChannels(int channels)
Use setChannelCount() instead.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void setFrequency(int frequency)
Use setSampleRate() instead.
The QAudioFormat class stores audio parameter information.
Definition: qaudioformat.h:60
void setSampleSize(int sampleSize)
Sets the sample size to the sampleSize specified.
void setCodec(const QString &codec)
Sets the codec to codec.
void setByteOrder(QAudioFormat::Endian byteOrder)
Sets the byteOrder to byteOrder.