AudioQueue not playing the PCM I provide

88 Views Asked by At

I am trying to play pcm data in an iOS app using AudioQueues. I provide the pcm data in a buffer like so:

status = AudioQueueEnqueueBuffer(audioQueue!, buffer!, 0, nil)

where the buffer has been filled with:

memcpy(buffer!.pointee.mAudioData, outPCMData, outPCMData.count) buffer!.pointee.mAudioDataByteSize = UInt32(outPCMData.count)

and I can see that the buffer contains the correct data since if I output the bytes to a file, I can play it with ffplay and it sounds as expected.

The ASBD is configured as:

AudioStreamBasicDescription(mSampleRate: 44100,
                                        mFormatID: kAudioFormatLinearPCM,
                                        mFormatFlags: kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked,
                                        mBytesPerPacket: 2,
                                        mFramesPerPacket: 1,
                                        mBytesPerFrame: 2 ,
                                        mChannelsPerFrame: 1,
                                        mBitsPerChannel: 16,
                                        mReserved: 0)

Any ideas as to where could I look to know how to fix it?

Cheers

0

There are 0 best solutions below