summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorJustin McPherson <justin.mcpherson@nokia.com>2010-06-21 05:18:32 (GMT)
committerJustin McPherson <justin.mcpherson@nokia.com>2010-06-22 01:44:56 (GMT)
commit66d02e4bde0a628978436217032abe555ed77fad (patch)
treed3f423b539a838963bb3f639521b05e8f07b7ef6 /src/multimedia
parentb82ed43086aebb4698a8a52965eeb17349ef1d04 (diff)
downloadQt-66d02e4bde0a628978436217032abe555ed77fad.zip
Qt-66d02e4bde0a628978436217032abe555ed77fad.tar.gz
Qt-66d02e4bde0a628978436217032abe555ed77fad.tar.bz2
Audio(osx); refactor input period conversion
Reviewed-by:Dmytro Poplavskiy
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp
index b99fe11..5897e75 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.cpp
+++ b/src/multimedia/audio/qaudioinput_mac_p.cpp
@@ -210,6 +210,11 @@ public:
return true;
}
+ bool empty() const
+ {
+ return position == totalPackets;
+ }
+
private:
UInt32 totalPackets;
UInt32 position;
@@ -275,36 +280,32 @@ public:
if (m_audioConverter != 0) {
QAudioPacketFeeder feeder(m_inputBufferList);
- bool wecan = true;
int copied = 0;
-
const int available = m_buffer->free();
- while (err == noErr && wecan) {
+ while (err == noErr && !feeder.empty()) {
QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available);
- if (region.second > 0) {
- AudioBufferList output;
- output.mNumberBuffers = 1;
- output.mBuffers[0].mNumberChannels = 1;
- output.mBuffers[0].mDataByteSize = region.second;
- output.mBuffers[0].mData = region.first;
-
- UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket;
- err = AudioConverterFillComplexBuffer(m_audioConverter,
- converterCallback,
- &feeder,
- &packetSize,
- &output,
- 0);
-
- region.second = output.mBuffers[0].mDataByteSize;
- copied += region.second;
+ if (region.second == 0)
+ break;
+
+ AudioBufferList output;
+ output.mNumberBuffers = 1;
+ output.mBuffers[0].mNumberChannels = 1;
+ output.mBuffers[0].mDataByteSize = region.second;
+ output.mBuffers[0].mData = region.first;
+
+ UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket;
+ err = AudioConverterFillComplexBuffer(m_audioConverter,
+ converterCallback,
+ &feeder,
+ &packetSize,
+ &output,
+ 0);
+ region.second = output.mBuffers[0].mDataByteSize;
+ copied += region.second;
- m_buffer->releaseWriteRegion(region);
- }
- else
- wecan = false;
+ m_buffer->releaseWriteRegion(region);
}
framesRendered += copied / m_outputFormat.mBytesPerFrame;