Is there any comprehensive documentation/tutorial for this function (for iOS core audio) CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer? Couldn't find anything on the web, and the examples on stack over flow leave much to be desired.
-
The thing that's not obvious at all from the documentation cited in the answer below is that you can ask CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer how big the AudioBufferList should be. I've added a C++ code example in a related stackoverflow question that might help you. https://stackoverflow.com/questions/27444000/how-do-i-call-cmsamplebuffergetaudiobufferlistwithretainedblockbuffer – Mark Coniglio Jan 31 '19 at 07:52
1 Answers
after months of working with CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer, i've learned that while it's hard to find a post or link specifically about the said function, it's also easy to find a ton of resources about the general topic of audio in iOS, chief amongst them is the book Learning Core Audio..
it takes time for the dense concepts of iOS core audio to sink in and it takes a lot of practice.. once things sink in.. the above method will become an easy tool in a much bigger tool box.. and all its parameters and uses will make intuitive sense
also a quick way to find out about the parameters and what the function does above exactly.. simply go to the documentation provided in the header file (ie in XCode, highlight the method and right click-> Jump to Definition).. you'll see this in CMSampleBuffer.h (but again if you're new to core audio.. don't get frustrated if you look at all these parameters and understand only 10% of it.. it happened to all of us and it takes time):
/*!
@function CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer
@abstract Creates an AudioBufferList containing the data from the CMSampleBuffer,
and a CMBlockBuffer which references (and manages the lifetime of) the
data in that AudioBufferList. The data may or may not be copied,
depending on the contiguity and 16-byte alignment of the CMSampleBuffer's
data. The buffers placed in the AudioBufferList are guaranteed to be contiguous.
The buffers in the AudioBufferList will be 16-byte-aligned if
kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment is passed in.
*/
CM_EXPORT
OSStatus CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
CMSampleBufferRef sbuf, /*! @param sbuf
CMSampleBuffer being accessed. */
size_t *bufferListSizeNeededOut, /*! @param bufferListSizeNeededOut
Receives the size of the AudioBufferList required to
accommodate the data. May be NULL. */
AudioBufferList *bufferListOut, /*! @param bufferListOut
Allocated by the caller, sized as specified by bufferListSizeNeededOut.
It is filled in with pointers into the retained blockBufferOut.
May be NULL. */
size_t bufferListSize, /*! @param bufferListSize
Size of the bufferListOut allocated by the client. If bufferListOut
is not NULL and bufferListSize is insufficient, kFigSampleBufferError_ArrayTooSmall
is returned. */
CFAllocatorRef bbufStructAllocator, /*! @param bbufStructAllocator
Allocator to use when creating the CMBlockBuffer structure. */
CFAllocatorRef bbufMemoryAllocator, /*! @param bbufMemoryAllocator
Allocator to use for memory block held by the CMBlockBuffer. */
uint32_t flags, /*! @param flags
Flags controlling operation. */
CMBlockBufferRef *blockBufferOut) /*! @param blockBufferOut
The retained CMBlockBuffer. */
__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0);

- 23,101
- 16
- 132
- 246
-
I still don't understand that last parameter. It says "_The_ retained CMBlockBuffer." That's a presumptuous use of the definite article! What `CMBlockBuffer`? The one returned by `CMSampleBufferGetDataBuffer`? – Jocko Homo May 21 '13 at 20:41
-
-
i find this interesting.. is this answer still useful after swift was introduced? this is all obj-c! – abbood May 17 '18 at 15:31