NNSSndStrmCallback

C Specification

#include <nnsys/snd.h>
typedef void (*NNSSndStrmCallback)(
        NNSSndStrmCallbackStatus status,
        int numChannles,
        void* buffer[],
        u32 len,
        NNSSndStrmFormat format,
        void* arg );

Arguments

status The callback state.
numChannles The number of channels.
buffer The array of the top address of the buffer for every channel.
len The byte length of the buffer for each channel.
format The sample data format.
arg The user argument.

Return Values

None.

Description

The callback function called when wave data must be supplied during stream play.

This callback function is registered by the NNS_SndStrmSetup, NNS_SndArcStrmStartEx2, and the NNS_SndArcStrmPrepareEx2 functions.

The callback function registered with the NNS_SndStrmSetup function is responsible for supplying the wave data to/for the passed buffer. The callback function registered with the NNS_SndArcStrmStartEx2 or NNS_SndArcStrmPrepareEx2 function is called after wave data is supplied by the sound archive stream library. Therefore, it is not responsible for supplying wave data. However, processing of wave data is possible.

The callback function is called at two different times. First, it is called because it is necessary to pass wave data in advance to all stream buffers before starting stream play. At this time, NNS_SND_STRM_CALLBACK_SETUP is passed in the callback state status. The other time it is called is during stream play. Here it is called because it is necessary to supply continuous wave data to/in the buffer consumed by playing. At this time, NNS_SND_STRM_CALLBACK_INTERVAL is passed in the callback state status.

The number of channels used for stream play is passed for the number of channels numChannles. The number of elements of the array buffer of the top address of the buffer is the numChannles number. The buffer size for each channel is len bytes.

The sample data format format is one of the following values.

Table: NNSSndStrmFormat

Label Description
NNS_SND_STRM_FORMAT_PCM8 8-bit PCM
NNS_SND_STRM_FORMAT_PCM16 16-bit PCM

Note

After supplying (processing) the wave data, call the DC_FlushRange function so that it is certain to be written to main memory.

Note that the callback function registered with the NNS_SndStrmSetup function is not called while interrupts are prohibited. Also, note that the callback function registered with the NNS_SndArcStrmStartEx2 or the NNS_SndArcStrmPrepareEx2 function is called from the stream thread.

It is not always necessary to complete supply of wave data with the callback function. However, by not completing supply until that region is played next, normal sound will not be output.

See Also

NNS_SndStrmSetup, NNS_SndArcStrmStartEx2, NNS_SndArcStrmPrepareEx2

Revision History

2004/11/26 Extracted from description of NNS_SndStrmSetup function.


CONFIDENTIAL