Streaming

Summary
Opens a file and sets it up for streaming.
Opens a file image from memory and sets it up for streaming, similar to alureCreateStreamFromFile.
Identical to alureCreateStreamFromMemory, except the given memory is used directly and not duplicated.
Creates a stream using the specified callback to retrieve data.
Buffers the given buffer objects with the next chunks of data from the stream.
Rewinds the stream so that the next alureBufferDataFromStream call will restart from the beginning of the audio file.
Closes an opened stream.

Functions

alureCreateStreamFromFile

ALURE_API alureStream* ALURE_APIENTRY alureCreateStreamFromFile(
   const ALchar *fname,
   ALsizei chunkLength,
   ALsizei numBufs,
   ALuint *bufs
)

Opens a file and sets it up for streaming.  The given chunkLength is the number of bytes each buffer will fill with.  ALURE will optionally generate the specified number of buffer objects, fill them with the beginning of the data, then place the new IDs into the provided storage, before returning.  Requires an active context.

Returns

An opaque handle used to control the opened stream, or NULL on error.

See Also

alureCreateStreamFromMemory, alureCreateStreamFromStaticMemory, alureCreateStreamFromCallback, alureBufferDataFromStream, alureRewindStream, alureDestroyStream

alureCreateStreamFromMemory

ALURE_API alureStream* ALURE_APIENTRY alureCreateStreamFromMemory(
   const ALubyte *fdata,
   ALuint length,
   ALsizei chunkLength,
   ALsizei numBufs,
   ALuint *bufs
)

Opens a file image from memory and sets it up for streaming, similar to alureCreateStreamFromFile.  The given data buffer can be safely deleted after calling this function.  Requires an active context.

Returns

An opaque handle used to control the opened stream, or NULL on error.

See Also

alureCreateStreamFromFile, alureCreateStreamFromStaticMemory, alureCreateStreamFromCallback, alureBufferDataFromStream, alureRewindStream, alureDestroyStream

alureCreateStreamFromStaticMemory

ALURE_API alureStream* ALURE_APIENTRY alureCreateStreamFromStaticMemory(
   const ALubyte *fdata,
   ALuint length,
   ALsizei chunkLength,
   ALsizei numBufs,
   ALuint *bufs
)

Identical to alureCreateStreamFromMemory, except the given memory is used directly and not duplicated.  As a consequence, the data buffer must remain valid while the stream is alive.  Requires an active context.

Returns

An opaque handle used to control the opened stream, or NULL on error.

See Also

alureCreateStreamFromFile, alureCreateStreamFromMemory, alureCreateStreamFromCallback, alureBufferDataFromStream, alureRewindStream, alureDestroyStream

alureCreateStreamFromCallback

ALURE_API alureStream* ALURE_APIENTRY alureCreateStreamFromCallback(
   ALuint (*callback)(void *userdata, ALubyte *data, ALuint bytes),
   void *userdata,
   ALenum format,
   ALuint samplerate,
   ALsizei chunkLength,
   ALsizei numBufs,
   ALuint *bufs
)

Creates a stream using the specified callback to retrieve data.  Requires an active context.

Parameters

callbackThis is called when more data is needed from the stream.  Up to the specified number of bytes should be written to the data pointer, and the number of bytes actually written should be returned.  The number of bytes written must be block aligned for the format (eg. a multiple of 4 for AL_FORMAT_STEREO16), or an OpenAL error may occur during buffering.
userdataA handle passed through to the callback.
formatThe format of the data the callback will be giving.  The format must be valid for the context.
samplerateThe sample rate (frequency) of the stream

Returns

An opaque handle used to control the opened stream, or NULL on error.

See Also

alureCreateStreamFromFile, alureCreateStreamFromMemory, alureCreateStreamFromStaticMemory, alureBufferDataFromStream, alureRewindStream, alureDestroyStream

alureBufferDataFromStream

ALURE_API ALsizei ALURE_APIENTRY alureBufferDataFromStream(alureStream *stream,
ALsizei numBufs,
ALuint *bufs)

Buffers the given buffer objects with the next chunks of data from the stream.  The given buffer objects do not need to be ones given by the alureCreateStreamFrom* functions.  Requires an active context.

Returns

The number of buffers filled with new data, or -1 on error.  If the value returned is less than the number requested, the end of the stream has been reached.

See Also

alureCreateStreamFromFile, alureCreateStreamFromMemory, alureCreateStreamFromStaticMemory, alureCreateStreamFromCallback, alureRewindStream, alureDestroyStream

alureRewindStream

ALURE_API ALboolean ALURE_APIENTRY alureRewindStream(alureStream *stream)

Rewinds the stream so that the next alureBufferDataFromStream call will restart from the beginning of the audio file.

Returns

AL_FALSE on error.

See Also

alureCreateStreamFromFile, alureCreateStreamFromMemory, alureCreateStreamFromStaticMemory, alureCreateStreamFromCallback, alureBufferDataFromStream, alureDestroyStream

alureDestroyStream

ALURE_API ALboolean ALURE_APIENTRY alureDestroyStream(alureStream *stream,
ALsizei numBufs,
ALuint *bufs)

Closes an opened stream.  For convenience, it will also delete the given buffer objects.  The given buffer objects do not need to be ones given by the alureCreateStreamFrom* functions.  Requires an active context.

Returns

AL_FALSE on error.

See Also

alureCreateStreamFromFile, alureCreateStreamFromMemory, alureCreateStreamFromStaticMemory, alureCreateStreamFromCallback, alureBufferDataFromStream, alureRewindStream

ALURE_API alureStream* ALURE_APIENTRY alureCreateStreamFromFile(
   const ALchar *fname,
   ALsizei chunkLength,
   ALsizei numBufs,
   ALuint *bufs
)
Opens a file and sets it up for streaming.
ALURE_API alureStream* ALURE_APIENTRY alureCreateStreamFromMemory(
   const ALubyte *fdata,
   ALuint length,
   ALsizei chunkLength,
   ALsizei numBufs,
   ALuint *bufs
)
Opens a file image from memory and sets it up for streaming, similar to alureCreateStreamFromFile.
ALURE_API alureStream* ALURE_APIENTRY alureCreateStreamFromStaticMemory(
   const ALubyte *fdata,
   ALuint length,
   ALsizei chunkLength,
   ALsizei numBufs,
   ALuint *bufs
)
Identical to alureCreateStreamFromMemory, except the given memory is used directly and not duplicated.
ALURE_API alureStream* ALURE_APIENTRY alureCreateStreamFromCallback(
   ALuint (*callback)(void *userdata, ALubyte *data, ALuint bytes),
   void *userdata,
   ALenum format,
   ALuint samplerate,
   ALsizei chunkLength,
   ALsizei numBufs,
   ALuint *bufs
)
Creates a stream using the specified callback to retrieve data.
ALURE_API ALsizei ALURE_APIENTRY alureBufferDataFromStream(alureStream *stream,
ALsizei numBufs,
ALuint *bufs)
Buffers the given buffer objects with the next chunks of data from the stream.
ALURE_API ALboolean ALURE_APIENTRY alureRewindStream(alureStream *stream)
Rewinds the stream so that the next alureBufferDataFromStream call will restart from the beginning of the audio file.
ALURE_API ALboolean ALURE_APIENTRY alureDestroyStream(alureStream *stream,
ALsizei numBufs,
ALuint *bufs)
Closes an opened stream.