AVAssetReader to AudioQueueBuffer

前端 未结 2 474
一生所求
一生所求 2021-01-15 11:01

Currently, I\'m doing a little test project to see if I can get samples from an AVAssetReader to play back using an AudioQueue on iOS.

I\'ve read this: ( Play raw un

2条回答
  •  深忆病人
    2021-01-15 11:32

    For some reason, even though every example I've seen of the audio queue using LPCM had

    ASBD.mBitsPerChannel = 8* sizeof (AudioUnitSampleType);
    

    For me it turns out I needed

    ASBD.mBitsPerChannel    = 2*bytesPerSample;
    

    for a description of:

    ASBD.mFormatID          = kAudioFormatLinearPCM;
    ASBD.mFormatFlags       = kAudioFormatFlagsAudioUnitCanonical;
    ASBD.mBytesPerPacket    = bytesPerSample;
    ASBD.mBytesPerFrame     = bytesPerSample;
    ASBD.mFramesPerPacket   = 1;
    ASBD.mBitsPerChannel    = 2*bytesPerSample;
    ASBD.mChannelsPerFrame  = 2;           
    ASBD.mSampleRate        = 48000;
    

    I have no idea why this works, which bothers me a great deal... but hopefully I can figure it all out eventually.

    If anyone can explain to me why this works, I'd be very thankful.

提交回复
热议问题