carb::audio::SoundDataSetPosCallback

Defined in carb/audio/IAudioData.h

typedef AudioResult (*carb::audio::SoundDataSetPosCallback)(const SoundData *soundData, size_t position, UnitType type, void *context)

an optional callback to reposition the data pointer for a user decoded stream.

Remark

This is used to handle operations to reposition the read cursor for user decoded sounds. This callback occurs when a sound being decoded loops or when the current playback/decode position is explicitly changed. The callback will perform the actual work of positioning the decode cursor and the new decoding state information should be updated on the host app side. The return value may be returned directly from the function that caused the read cursor position to change in the first place.

Param soundData

[in] the sound data object to set the position for. This object will be valid and can be used to read data format information. Note that the host app is expected to know how to convert the requested decoded position into an encoded position. This may not be nullptr.

Param position

[in] the new position to set for the stream. This value must be greater than or equal to 0, and less than the length of the sound (as returned from getLength()). This value is interpreted according to the type value.

Param type

[in] the units to interpret the new read cursor position in. Note that if this is specified in milliseconds, the actual position that it seeks to may not be accurate. Similarly, if a position in bytes is given, it will be rounded up to the next frame boundary.

Param context

[in] the callback context value specified in the SoundDataLoadDesc object. This is passed in unmodified.

Return

AudioResult.eOk if the positioning operation was successful.

Return

AudioResult.eInvalidParameter if the requested offset is outside the range of the active sound.

Return

an AudioResult.* error code if the operation fails for any other reason.