|
Ultralight C API 2.0.0
|
User-defined audio output interface.
#include <Ultralight/CAPI/CAPI_AudioOutput.h>
The library uses this to play the sound of <video> and <audio> elements. It decodes the audio and pushes the samples to your callbacks, which play them on a device.
A platform-specific implementation is provided for you when you call ulCreateApp(). If you are using ulCreateRenderer() and don't provide one, media plays without sound.
Each callback matches the method of the same name in <Ultralight/platform/AudioOutput.h>, and the rules documented there apply here too. Read that header before implementing this one.
Classes | |
| struct | ULAudioFormat |
| An audio sample format (channel count and sample rate). More... | |
| struct | ULAudioOutput |
| User-defined audio output interface. More... | |
Typedefs | |
| typedef void(*) | ULAudioOutputCreateStreamCallback(void *user_data, unsigned int stream_id, ULAudioFormat format) |
| The callback invoked to create a new audio stream (before its first samples are pushed). | |
| typedef void(*) | ULAudioOutputPushSamplesCallback(void *user_data, unsigned int stream_id, const float *samples, unsigned int num_frames) |
| The callback invoked to push decoded PCM samples into a stream (num_frames * channels interleaved floats). | |
| typedef void(*) | ULAudioOutputSetVolumeCallback(void *user_data, unsigned int stream_id, float volume) |
| The callback invoked to set a stream's volume, from 0.0 (silent) to 1.0 (full volume). | |
| typedef void(*) | ULAudioOutputSetPausedCallback(void *user_data, unsigned int stream_id, bool paused) |
| The callback invoked to pause or resume a stream. | |
| typedef void(*) | ULAudioOutputFlushCallback(void *user_data, unsigned int stream_id) |
| The callback invoked when the media seeks, to discard a stream's buffered audio. | |
| typedef void(*) | ULAudioOutputStopCallback(void *user_data, unsigned int stream_id) |
| The callback invoked when no more samples are coming for a stream. | |
| typedef void(*) | ULAudioOutputDestroyStreamCallback(void *user_data, unsigned int stream_id) |
| The callback invoked to destroy a stream and free its resources. | |
| typedef unsigned long long(*) | ULAudioOutputGetPlaybackPositionCallback(void *user_data, unsigned int stream_id) |
| The callback invoked to get the number of frames of a stream the device has played since the last flush (or since the stream was created). | |
| typedef ULAudioFormat(*) | ULAudioOutputGetPreferredOutputFormatCallback(void *user_data) |
| The callback invoked to get the device's preferred audio format. | |
| typedef void(*) ULAudioOutputCreateStreamCallback(void *user_data, unsigned int stream_id, ULAudioFormat format) |
The callback invoked to create a new audio stream (before its first samples are pushed).
Samples will arrive in format. If you can't create the stream, ignore later calls with its id.
| typedef void(*) ULAudioOutputDestroyStreamCallback(void *user_data, unsigned int stream_id) |
The callback invoked to destroy a stream and free its resources.
| typedef void(*) ULAudioOutputFlushCallback(void *user_data, unsigned int stream_id) |
The callback invoked when the media seeks, to discard a stream's buffered audio.
Leave a paused stream paused.
| typedef unsigned long long(*) ULAudioOutputGetPlaybackPositionCallback(void *user_data, unsigned int stream_id) |
The callback invoked to get the number of frames of a stream the device has played since the last flush (or since the stream was created).
The count must not advance while the stream is paused. Return 0 if your backend can't report this.
| typedef ULAudioFormat(*) ULAudioOutputGetPreferredOutputFormatCallback(void *user_data) |
The callback invoked to get the device's preferred audio format.
| typedef void(*) ULAudioOutputPushSamplesCallback(void *user_data, unsigned int stream_id, const float *samples, unsigned int num_frames) |
The callback invoked to push decoded PCM samples into a stream (num_frames * channels interleaved floats).
When your buffer is full, wait for room instead of dropping samples.
| typedef void(*) ULAudioOutputSetPausedCallback(void *user_data, unsigned int stream_id, bool paused) |
The callback invoked to pause or resume a stream.
Keep the buffered samples while paused.
| typedef void(*) ULAudioOutputSetVolumeCallback(void *user_data, unsigned int stream_id, float volume) |
The callback invoked to set a stream's volume, from 0.0 (silent) to 1.0 (full volume).
| typedef void(*) ULAudioOutputStopCallback(void *user_data, unsigned int stream_id) |
The callback invoked when no more samples are coming for a stream.
The stream stays valid, and a push_samples call waiting for room must return.