summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudioinput_mac_p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/audio/qaudioinput_mac_p.cpp')
-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;