Skip to content

Commit 0a4ca15

Browse files
committed
Update argument for AudioFileReadPacketData
1 parent e289d5f commit 0a4ca15

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: code/iphone/BackgroundMusic.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,23 @@ void BackgroundTrackMgr2::QueueCallback( void * inUserData, AudioQueueRef inAQ,
269269
OSStatus result = noErr;
270270
BackgroundTrackMgr2 *THIS = (BackgroundTrackMgr2*)inUserData;
271271
UInt32 nPackets = 0;
272+
UInt32 ioNumBytes;
272273
// loop the current buffer if the following:
273274
// 1. file was loaded into the buffer previously
274275
// 2. only one file in the queue
275276
// 3. we have not been told to stop at playlist completion
276277
if ((CurFileInfo->mFileDataInQueue) && (!THIS->mStopAtEnd)) {
277278
nPackets = THIS->mNumPacketsToRead;
278279
} else {
279-
UInt32 numBytes;
280280
while (nPackets == 0) {
281281
// if loadAtOnce, get all packets in the file, otherwise ~.5 seconds of data
282-
nPackets = THIS->mNumPacketsToRead;
283-
result = AudioFileReadPacketData(CurFileInfo->mAFID, false, &numBytes, THIS->mPacketDescs, THIS->mCurrentPacket, &nPackets, inCompleteAQBuffer->mAudioData);
282+
nPackets = THIS->mNumPacketsToRead;
283+
ioNumBytes = kAudioFilePropertyMaximumPacketSize * nPackets;
284+
285+
result = AudioFileReadPacketData(CurFileInfo->mAFID, false, &ioNumBytes, THIS->mPacketDescs, THIS->mCurrentPacket, &nPackets, inCompleteAQBuffer->mAudioData);
284286
AssertNoError("Error reading file data", end);
285287

286-
inCompleteAQBuffer->mAudioDataByteSize = numBytes;
287-
288+
inCompleteAQBuffer->mAudioDataByteSize = ioNumBytes;
288289
if (nPackets == 0) { // no packets were read, this file has ended.
289290
if (CurFileInfo->mLoadAtOnce) {
290291
CurFileInfo->mFileDataInQueue = true;

0 commit comments

Comments
 (0)