0

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

  • Anybody? ////// – TheCodeAspirer Dec 09 '21 at 09:11
  • I notice that if I set the mAudioDataByteSize to the double of the value I am using, then I get sound, but it does not sound good because the mAudioDataByteSize is incorrect I guess – TheCodeAspirer Dec 09 '21 at 14:05
  • How do you know the ASBD config matches the actual config of the PCM you are trying to play? Since you mention `ffplay` with `--verbose` or `ffprobe` you should get more data what it detects. – Kamil.S Feb 03 '22 at 14:14

0 Answers0