Name
StreamSamples -- get raw PCM frames from sound stream (V5.0)
Synopsis
int error = StreamSamples(APTR handle, struct StreamSamplesCtrl *ctrl);
Function
This function has to read the number of raw PCM frames requested from the specified sound stream and copy them to the memory buffer that is passed to this function. Hollywood will pass a pointer to a struct StreamSamplesCtrl to this function. This structure looks like this:

 
struct StreamSamplesCtrl
{
    APTR Buffer;    // [in]
    int Request;    // [in]
    int Written;    // [out]
    int Done;       // [out]
};

Here is the meaning of the individual members:

Buffer:
This is a pointer to a memory buffer. You have to copy the PCM frames to this buffer.

Request:
Contains the number of PCM frames that Hollywood wants you to copy to the memory buffer. Note that this value is specified in PCM frames, not in bytes. So if the request is 1024 and your PCM samples are formatted as 16-bit wide stereo frames, you would have to copy 4096 bytes to the memory buffer.

Written:
This must be set by your implementation to the number of PCM frames that has actually been written to Buffer. Once again, the value is specified in PCM frames, not in bytes.

Done:
Set this to True if the stream end has been reached. Otherwise set it to False.

StreamSamples() must return an error code or 0 for success.

This function must be implemented in a thread-safe way. Hollywood will usually call this function from a helper thread so make sure that your implementation is thread-safe.

Inputs
handle
handle returned by OpenStream()
ctrl
pointer to a struct StreamSamplesCtrl containing Hollywood's request
Results
error
error code or 0 for success

Show TOC