12#include "c-api/audio_engine.h"
110 m_cStructure->m_sampleRate = 0;
111 m_cStructure->m_encodedRate = 0;
112 m_cStructure->m_frames = 0;
113 m_cStructure->m_frameSize = 0;
114 m_cStructure->m_channelCount = 0;
151 void SetSampleRate(
unsigned int rate) { m_cStructure->m_sampleRate = rate; }
166 m_cStructure->m_channelCount = 0;
172 m_cStructure->m_channels[ch] = layout[ch];
173 m_cStructure->m_channelCount++;
180 std::vector<enum AudioEngineChannel> channels;
186 channels.push_back(m_cStructure->m_channels[ch]);
198 void SetFrameSize(
unsigned int frameSize) { m_cStructure->m_frameSize = frameSize; }
201 unsigned int GetFrameSize()
const {
return m_cStructure->m_frameSize; }
211 if (m_cStructure->m_dataFormat != fmt->m_cStructure->
m_dataFormat ||
212 m_cStructure->m_sampleRate != fmt->m_cStructure->
m_sampleRate ||
213 m_cStructure->m_encodedRate != fmt->m_cStructure->
m_encodedRate ||
214 m_cStructure->m_frames != fmt->m_cStructure->
m_frames ||
215 m_cStructure->m_frameSize != fmt->m_cStructure->
m_frameSize ||
216 m_cStructure->m_channelCount != fmt->m_cStructure->
m_channelCount)
223 if (fmt->m_cStructure->
m_channels[ch] != m_cStructure->m_channels[ch])
306 : m_kodiBase(::kodi::addon::CPrivateBase::m_interface->toKodi->kodiBase),
307 m_cb(::kodi::addon::CPrivateBase::m_interface->toKodi->kodi_audioengine)
309 m_StreamHandle = m_cb->make_stream(m_kodiBase, format, options);
310 if (m_StreamHandle ==
nullptr)
325 m_cb->free_stream(m_kodiBase, m_StreamHandle);
326 m_StreamHandle =
nullptr;
337 unsigned int GetSpace() {
return m_cb->aestream_get_space(m_kodiBase, m_StreamHandle); }
356 bool hasDownmix =
false,
357 double centerMixLevel = 1.0)
359 return m_cb->aestream_add_data(m_kodiBase, m_StreamHandle, data, offset, frames, pts,
360 hasDownmix, centerMixLevel);
371 double GetDelay() {
return m_cb->aestream_get_delay(m_kodiBase, m_StreamHandle); }
380 bool IsBuffering() {
return m_cb->aestream_is_buffering(m_kodiBase, m_StreamHandle); }
390 double GetCacheTime() {
return m_cb->aestream_get_cache_time(m_kodiBase, m_StreamHandle); }
399 double GetCacheTotal() {
return m_cb->aestream_get_cache_total(m_kodiBase, m_StreamHandle); }
406 void Pause() {
return m_cb->aestream_pause(m_kodiBase, m_StreamHandle); }
413 void Resume() {
return m_cb->aestream_resume(m_kodiBase, m_StreamHandle); }
425 void Drain(
bool wait =
true) {
return m_cb->aestream_drain(m_kodiBase, m_StreamHandle, wait); }
432 bool IsDraining() {
return m_cb->aestream_is_draining(m_kodiBase, m_StreamHandle); }
439 bool IsDrained() {
return m_cb->aestream_is_drained(m_kodiBase, m_StreamHandle); }
446 void Flush() {
return m_cb->aestream_flush(m_kodiBase, m_StreamHandle); }
455 float GetVolume() {
return m_cb->aestream_get_volume(m_kodiBase, m_StreamHandle); }
466 return m_cb->aestream_set_volume(m_kodiBase, m_StreamHandle, volume);
476 float GetAmplification() {
return m_cb->aestream_get_amplification(m_kodiBase, m_StreamHandle); }
487 return m_cb->aestream_set_amplification(m_kodiBase, m_StreamHandle, amplify);
499 return m_cb->aestream_get_frame_size(m_kodiBase, m_StreamHandle);
511 return m_cb->aestream_get_channel_count(m_kodiBase, m_StreamHandle);
525 return m_cb->aestream_get_sample_rate(m_kodiBase, m_StreamHandle);
537 return m_cb->aestream_get_data_format(m_kodiBase, m_StreamHandle);
551 return m_cb->aestream_get_resample_ratio(m_kodiBase, m_StreamHandle);
567 m_cb->aestream_set_resample_ratio(m_kodiBase, m_StreamHandle, ratio);
574 AEStreamHandle* m_StreamHandle;
608 using namespace kodi::addon;
609 return CPrivateBase::m_interface->toKodi->kodi_audioengine->get_current_sink_format(
610 CPrivateBase::m_interface->toKodi->kodiBase, format);
Definition AddonBase.h:206
Definition AudioEngine.h:258
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
bool IsBuffering()
Returns if the stream is buffering.
Definition AudioEngine.h:380
void Flush()
Flush all buffers dropping the audio data.
Definition AudioEngine.h:446
float GetAmplification()
Gets the stream's volume amplification in linear units.
Definition AudioEngine.h:476
bool IsDraining()
Returns true if the is stream draining.
Definition AudioEngine.h:432
unsigned int GetFrameSize() const
Returns the size of one audio frame in bytes (channelCount * resolution).
Definition AudioEngine.h:497
~CAEStream()
Class destructor.
Definition AudioEngine.h:321
void SetAmplification(float amplify)
Sets the stream's volume amplification in linear units.
Definition AudioEngine.h:485
void SetVolume(float volume)
Set the stream's volume level.
Definition AudioEngine.h:464
double GetResampleRatio()
Return the resample ratio.
Definition AudioEngine.h:549
void Pause()
Pauses the stream playback.
Definition AudioEngine.h:406
AudioEngineDataFormat GetDataFormat() const
Return the data format the stream has been configured with.
Definition AudioEngine.h:535
float GetVolume()
Return the stream's current volume level.
Definition AudioEngine.h:455
void Resume()
Resumes the stream after pausing.
Definition AudioEngine.h:413
double GetCacheTotal()
Returns the total time in seconds of the cache.
Definition AudioEngine.h:399
unsigned int GetSpace()
Returns the amount of space available in the stream.
Definition AudioEngine.h:337
unsigned int AddData(uint8_t *const *data, unsigned int offset, unsigned int frames, double pts=0, bool hasDownmix=false, double centerMixLevel=1.0)
Add planar or interleaved PCM data to the stream.
Definition AudioEngine.h:352
unsigned int GetSampleRate() const
Returns the stream's sample rate, if the stream is using a dynamic sample rate, this value will NOT r...
Definition AudioEngine.h:523
double GetDelay()
Returns the time in seconds that it will take for the next added packet to be heard from the speakers...
Definition AudioEngine.h:371
void SetResampleRatio(double ratio)
Sets the resample ratio.
Definition AudioEngine.h:565
double GetCacheTime()
Returns the time in seconds of the stream's cached audio samples. Engine buffers excluded.
Definition AudioEngine.h:390
CAEStream(AudioEngineFormat &format, unsigned int options=0)
Constructs new class to a Kodi IAEStream in the format specified.
Definition AudioEngine.h:305
unsigned int GetChannelCount() const
Returns the number of channels the stream is configured to accept.
Definition AudioEngine.h:509
bool IsDrained()
Returns true if the is stream has finished draining.
Definition AudioEngine.h:439
void Drain(bool wait=true)
Start draining the stream.
Definition AudioEngine.h:425
@ AUDIOENGINE_CH_NULL
Used inside to indicate the end of a list and not for addon use directly.
Definition audio_engine.h:72
@ AUDIOENGINE_CH_MAX
Maximum possible value, to use e.g. as size inside list.
Definition audio_engine.h:116
bool ATTR_DLL_LOCAL GetCurrentSinkFormat(AudioEngineFormat &format)
Get the current sink data format.
Definition AudioEngine.h:606
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938
Internal API structure which are used for data exchange between Kodi and addon.
Definition audio_engine.h:230
unsigned int m_sampleRate
Definition audio_engine.h:235
enum AudioEngineChannel m_channels[AUDIOENGINE_CH_MAX]
Definition audio_engine.h:244
unsigned int m_frames
Definition audio_engine.h:247
unsigned int m_encodedRate
Definition audio_engine.h:238
enum AudioEngineDataFormat m_dataFormat
Definition audio_engine.h:232
unsigned int m_frameSize
Definition audio_engine.h:250
unsigned int m_channelCount
Definition audio_engine.h:241
Definition audio_engine.h:267