From 66d02e4bde0a628978436217032abe555ed77fad Mon Sep 17 00:00:00 2001
From: Justin McPherson <justin.mcpherson@nokia.com>
Date: Mon, 21 Jun 2010 15:18:32 +1000
Subject: [PATCH] Audio(osx); refactor input period conversion
Reviewed-by:Dmytro Poplavskiy
---
src/multimedia/audio/qaudioinput_mac_p.cpp | 51 ++++++++++++++-------------
1 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp
index b99fe11..5897e75 100644
|
|
public: |
210 | 210 | return true; |
211 | 211 | } |
212 | 212 | |
| 213 | bool empty() const |
| 214 | { |
| 215 | return position == totalPackets; |
| 216 | } |
| 217 | |
213 | 218 | private: |
214 | 219 | UInt32 totalPackets; |
215 | 220 | UInt32 position; |
… |
… |
public: |
275 | 280 | if (m_audioConverter != 0) { |
276 | 281 | QAudioPacketFeeder feeder(m_inputBufferList); |
277 | 282 | |
278 | | bool wecan = true; |
279 | 283 | int copied = 0; |
280 | | |
281 | 284 | const int available = m_buffer->free(); |
282 | 285 | |
283 | | while (err == noErr && wecan) { |
| 286 | while (err == noErr && !feeder.empty()) { |
284 | 287 | QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available); |
285 | 288 | |
286 | | if (region.second > 0) { |
287 | | AudioBufferList output; |
288 | | output.mNumberBuffers = 1; |
289 | | output.mBuffers[0].mNumberChannels = 1; |
290 | | output.mBuffers[0].mDataByteSize = region.second; |
291 | | output.mBuffers[0].mData = region.first; |
292 | | |
293 | | UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket; |
294 | | err = AudioConverterFillComplexBuffer(m_audioConverter, |
295 | | converterCallback, |
296 | | &feeder, |
297 | | &packetSize, |
298 | | &output, |
299 | | 0); |
300 | | |
301 | | region.second = output.mBuffers[0].mDataByteSize; |
302 | | copied += region.second; |
| 289 | if (region.second == 0) |
| 290 | break; |
| 291 | |
| 292 | AudioBufferList output; |
| 293 | output.mNumberBuffers = 1; |
| 294 | output.mBuffers[0].mNumberChannels = 1; |
| 295 | output.mBuffers[0].mDataByteSize = region.second; |
| 296 | output.mBuffers[0].mData = region.first; |
| 297 | |
| 298 | UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket; |
| 299 | err = AudioConverterFillComplexBuffer(m_audioConverter, |
| 300 | converterCallback, |
| 301 | &feeder, |
| 302 | &packetSize, |
| 303 | &output, |
| 304 | 0); |
| 305 | region.second = output.mBuffers[0].mDataByteSize; |
| 306 | copied += region.second; |
303 | 307 | |
304 | | m_buffer->releaseWriteRegion(region); |
305 | | } |
306 | | else |
307 | | wecan = false; |
| 308 | m_buffer->releaseWriteRegion(region); |
308 | 309 | } |
309 | 310 | |
310 | 311 | framesRendered += copied / m_outputFormat.mBytesPerFrame; |