Last active
July 19, 2019 01:41
-
-
Save SunXiaoShan/75f83728b19621e2075046427254ead2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: load audio data | |
// If the packetIndex is out of range, the ioNumPackets will be 0 | |
UInt32 ioNumBytes = outBufferSize; | |
UInt32 ioNumPackets = numPacketsToRead; | |
status = AudioFileReadPacketData( | |
_audioFile, | |
NO, | |
&ioNumBytes, | |
packetDescs, | |
packetIndex, | |
&ioNumPackets, | |
audioQueueBuffer->mAudioData | |
); | |
if (status != noErr) NSLog(@"AudioQueueSetParameter failed %d", status); | |
// Step 2: prevent load audio data failed | |
if (ioNumPackets <= 0) { | |
return; | |
} | |
// Step 3: re-assign the data size | |
audioQueueBuffer->mAudioDataByteSize = ioNumBytes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment