Audio Engine Stream Class
Class that can be created by the addon in order to be able to transfer audiostream data processed on the addon to Kodi and output it audibly.
This can create individually several times and performed in different processes simultaneously.
It has the header #include <kodi/AudioEngine.h> be included to enjoy it.
◆ CAEStream()
Constructs new class to a Kodi IAEStream in the format specified.
- Parameters
-
The following table contains values that can be set with class AudioEngineFormat :
Further is CompareFormat included to compare this class with another.
**Bit options to pass (on Kodi by IAE::MakeStream
)**
enum AEStreamOptions | Value: | Description: |
AUDIO_STREAM_FORCE_RESAMPLE | 1 << 0 | Force resample even if rates match |
AUDIO_STREAM_PAUSED | 1 << 1 | Create the stream paused |
AUDIO_STREAM_AUTOSTART | 1 << 2 | Autostart the stream when enough data is buffered |
Example:
#include <kodi/AudioEngine.h>
...
kodi::audioengine::AudioEngineFormat format;
◆ ~CAEStream()
◆ GetSpace()
unsigned int GetSpace |
( |
| ) |
|
|
inline |
Returns the amount of space available in the stream.
- Returns
- The number of bytes AddData will consume
◆ AddData()
unsigned int AddData |
( |
uint8_t *const * | data, |
|
|
unsigned int | offset, |
|
|
unsigned int | frames, |
|
|
double | pts = 0, |
|
|
bool | hasDownmix = false, |
|
|
double | centerMixLevel = 1.0 ) |
|
inline |
Add planar or interleaved PCM data to the stream.
- Parameters
-
[in] | data | array of pointers to the planes |
[in] | offset | to frame in frames |
[in] | frames | number of frames |
[in] | pts | [opt] presentation timestamp, default is 0 |
[in] | hasDownmix | [opt] set true if downmix is present, default is false |
[in] | centerMixLevel | [opt] level to mix left and right to center default is 1.0 |
- Returns
- The number of frames consumed
◆ GetDelay()
Returns the time in seconds that it will take for the next added packet to be heard from the speakers.
- Returns
- seconds
◆ IsBuffering()
Returns if the stream is buffering.
- Returns
- True if the stream is buffering
◆ GetCacheTime()
Returns the time in seconds of the stream's cached audio samples. Engine buffers excluded.
- Returns
- seconds
◆ GetCacheTotal()
Returns the total time in seconds of the cache.
- Returns
- seconds
◆ Pause()
Pauses the stream playback.
◆ Resume()
Resumes the stream after pausing.
◆ Drain()
void Drain |
( |
bool | wait = true | ) |
|
|
inline |
Start draining the stream.
- Parameters
-
[in] | wait | [opt] Wait until drain is finished if set to true, otherwise it returns direct |
- Note
- Once called AddData will not consume more data.
◆ IsDraining()
Returns true if the is stream draining.
◆ IsDrained()
Returns true if the is stream has finished draining.
◆ Flush()
Flush all buffers dropping the audio data.
◆ GetVolume()
Return the stream's current volume level.
- Returns
- The volume level between 0.0 and 1.0
◆ SetVolume()
void SetVolume |
( |
float | volume | ) |
|
|
inline |
Set the stream's volume level.
- Parameters
-
[in] | volume | The new volume level between 0.0 and 1.0 |
◆ GetAmplification()
float GetAmplification |
( |
| ) |
|
|
inline |
Gets the stream's volume amplification in linear units.
- Returns
- The volume amplification factor between 1.0 and 1000.0
◆ SetAmplification()
void SetAmplification |
( |
float | amplify | ) |
|
|
inline |
Sets the stream's volume amplification in linear units.
- Parameters
-
[in] | amplify | The volume amplification factor between 1.0 and 1000.0 |
◆ GetFrameSize()
unsigned int GetFrameSize |
( |
| ) |
const |
|
inline |
Returns the size of one audio frame in bytes (channelCount * resolution).
- Returns
- The size in bytes of one frame
◆ GetChannelCount()
unsigned int GetChannelCount |
( |
| ) |
const |
|
inline |
Returns the number of channels the stream is configured to accept.
- Returns
- The channel count
◆ GetSampleRate()
unsigned int GetSampleRate |
( |
| ) |
const |
|
inline |
Returns the stream's sample rate, if the stream is using a dynamic sample rate, this value will NOT reflect any changes made by calls to SetResampleRatio().
- Returns
- The stream's sample rate (eg, 48000)
◆ GetDataFormat()
Return the data format the stream has been configured with.
- Returns
- The stream's data format (eg, AUDIOENGINE_FMT_S16LE)
◆ GetResampleRatio()
double GetResampleRatio |
( |
| ) |
|
|
inline |
Return the resample ratio.
- Note
- This will return an undefined value if the stream is not resampling.
- Returns
- the current resample ratio or undefined if the stream is not resampling
◆ SetResampleRatio()
void SetResampleRatio |
( |
double | ratio | ) |
|
|
inline |
Sets the resample ratio.
- Note
- This function may return false if the stream is not resampling, if you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option.
- Parameters
-
[in] | ratio | the new sample rate ratio, calculated by ((double)desiredRate / (double)GetSampleRate()) |