Question

I am trying to write a lowish level audio writer with the AudioFile & ExtAudioFile APIs. I am creating a new audio file with AudioFileInitializeWithCallbacks but it appears that this needs read & get size callbacks implemented. Why can't this just accept a single write callback and trust that the data has been written sucessfully.

What if I am writing to a stream which I can not seek into such as a CD or a network socket?

Surely this should just continually push data to the write callback and it is my responsibility to write this data where needed returning an error code if the operation didn't succeed.

The docs for AudioFile_SetSizeProc and AudioFile_WriteProc appear to be incorrect as they both talk about read operations "inPosition An offset into the data from which to read.", "@result The callback should return the size of the data.".

At the moment I have got past this by only writing to a file but I get a kExtAudioFileError_InvalidOperationOrder after the first write procedure. What does this mean? There are no comments in the docs about it.

Any pointers or help would be much appriciated.

No correct solution

OTHER TIPS

Apple documentation is wrong here. Check header file AudioFile.h:

/*!
@typedef    AudioFile_SetSizeProc
@abstract   A callback for setting the size of the file data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
@discussion a function that will be called when AudioFile needs to set the size of the file data. This size is for all of the 
            data in the file, not just the audio data. This will only be called if the file is written to.
@param      inClientData    A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
@result                     The callback should return the size of the data.
*/

typedef OSStatus (*AudioFile_SetSizeProc)(
                            void *      inClientData,
                            SInt64      inSize);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top