Name
DecodeAudioFrame -- get audio frame from packet (V5.0)
Synopsis
int status = DecodeAudioFrame(APTR handle, APTR packet,
               struct DecodeAudioFrameCtrl *ctrl);
Function
This function must decode the specified audio packet into PCM audio frames. Hollywood will pass a pointer to a struct DecodeAudioFrameCtrl structure to this function. This structure looks like the following:

 
struct DecodeAudioFrameCtrl
{
    WORD *Buffer;     // [in]
    int BufferSize;   // [in]
    int Written;      // [out]
    int Done;         // [out]
};

Your DecodeAudioFrame() implementation has to write to the following members of this structure:

Buffer:
This contains a pointer to a memory buffer allocated for you by Hollywood. You have to write the individual PCM frames to this buffer. Please note that audio must always be written as 16-bit PCM frames in native endian byte order. In case the video uses stereo sound, the PCM samples must be stored in interleaved order.

BufferSize:
Contains the size of the memory buffer in bytes. This should always be enough to hold one second of audio PCM data but be sure to check against this value when writing PCM frames to the buffer allocated by Hollywood or you might trash innocent memory. If there's not enough space, simply set Done to False and Hollywood will call you again.

Written:
This must be set to the number of bytes that you have copied to the memory buffer. Please note that this is specified in bytes, not in PCM frames or samples.

Done:
This must be set to False if there is more audio data to decode in this packet. In that case, Hollywood will call you again. If you've decoded all audio data that is in this packet, set this member to True. Hollywood will then free the packet using FreePacket().

This function must return a status code: 0 indicates success, any other value indicates failure.

This function must be implemented in a thread-safe way.

Inputs
handle
handle returned by OpenVideo()
packet
pointer to a packet allocated by NextPacket()
ctrl
pointer to a struct DecodeAudioFrameCtrl to be filled out by the function
Results
status
a status code (see above)

Show TOC