xbmc
AudioEngine.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "addons/kodi-dev-kit/include/kodi/AudioEngine.h"
12 #include "cores/AudioEngine/Utils/AEChannelData.h"
13 
14 extern "C"
15 {
16 namespace ADDON
17 {
18 
20 {
21  static void Init(AddonGlobalInterface* addonInterface);
22  static void DeInit(AddonGlobalInterface* addonInterface);
23 
32  static AEChannel TranslateAEChannelToKodi(AudioEngineChannel channel);
33  static AudioEngineChannel TranslateAEChannelToAddon(AEChannel channel);
34  static AEDataFormat TranslateAEFormatToKodi(AudioEngineDataFormat format);
35  static AudioEngineDataFormat TranslateAEFormatToAddon(AEDataFormat format);
37 
44  static AEStreamHandle* audioengine_make_stream(void* kodiBase,
45  AUDIO_ENGINE_FORMAT* streamFormat,
46  unsigned int options);
47 
53  static void audioengine_free_stream(void* kodiBase, AEStreamHandle* streamHandle);
54 
61  static bool get_current_sink_format(void* kodiBase, AUDIO_ENGINE_FORMAT* sinkFormat);
62 
67  static unsigned int aestream_get_space(void* kodiBase, AEStreamHandle* streamHandle);
68 
76  static unsigned int aestream_add_data(void* kodiBase,
77  AEStreamHandle* streamHandle,
78  uint8_t* const* data,
79  unsigned int offset,
80  unsigned int frames,
81  double pts,
82  bool hasDownmix,
83  double centerMixLevel);
84 
90  static double aestream_get_delay(void* kodiBase, AEStreamHandle* streamHandle);
91 
96  static bool aestream_is_buffering(void* kodiBase, AEStreamHandle* streamHandle);
97 
103  static double aestream_get_cache_time(void* kodiBase, AEStreamHandle* streamHandle);
104 
109  static double aestream_get_cache_total(void* kodiBase, AEStreamHandle* streamHandle);
110 
114  static void aestream_pause(void* kodiBase, AEStreamHandle* streamHandle);
115 
119  static void aestream_resume(void* kodiBase, AEStreamHandle* streamHandle);
120 
125  static void aestream_drain(void* kodiBase, AEStreamHandle* streamHandle, bool wait);
126 
130  static bool aestream_is_draining(void* kodiBase, AEStreamHandle* streamHandle);
131 
135  static bool aestream_is_drained(void* kodiBase, AEStreamHandle* streamHandle);
136 
140  static void aestream_flush(void* kodiBase, AEStreamHandle* streamHandle);
141 
146  static float aestream_get_volume(void* kodiBase, AEStreamHandle* streamHandle);
147 
152  static void aestream_set_volume(void* kodiBase, AEStreamHandle* streamHandle, float volume);
153 
158  static float aestream_get_amplification(void* kodiBase, AEStreamHandle* streamHandle);
159 
164  static void aestream_set_amplification(void* kodiBase,
165  AEStreamHandle* streamHandle,
166  float amplify);
167 
172  static unsigned int aestream_get_frame_size(void* kodiBase, AEStreamHandle* streamHandle);
173 
178  static unsigned int aestream_get_channel_count(void* kodiBase, AEStreamHandle* streamHandle);
179 
185  static unsigned int aestream_get_sample_rate(void* kodiBase, AEStreamHandle* streamHandle);
186 
191  static AudioEngineDataFormat aestream_get_data_format(void* kodiBase,
192  AEStreamHandle* streamHandle);
193 
199  static double aestream_get_resample_ratio(void* kodiBase, AEStreamHandle* streamHandle);
200 
206  static void aestream_set_resample_ratio(void* kodiBase,
207  AEStreamHandle* streamHandle,
208  double ratio);
209 };
210 
211 } /* namespace ADDON */
212 } /* extern "C" */
static double aestream_get_delay(void *kodiBase, AEStreamHandle *streamHandle)
Returns the time in seconds that it will take for the next added packet to be heard from the speakers...
Definition: AudioEngine.cpp:432
static bool get_current_sink_format(void *kodiBase, AUDIO_ENGINE_FORMAT *sinkFormat)
Get the current sink data format.
Definition: AudioEngine.cpp:357
static double aestream_get_cache_total(void *kodiBase, AEStreamHandle *streamHandle)
Returns the total time in seconds of the cache.
Definition: AudioEngine.cpp:480
static unsigned int aestream_get_sample_rate(void *kodiBase, AEStreamHandle *streamHandle)
Returns the stream's sample rate, if the stream is using a dynamic sample rate, this value will NOT r...
Definition: AudioEngine.cpp:692
static double aestream_get_cache_time(void *kodiBase, AEStreamHandle *streamHandle)
Returns the time in seconds that it will take to underrun the cache if no sample is added...
Definition: AudioEngine.cpp:464
static unsigned int aestream_get_frame_size(void *kodiBase, AEStreamHandle *streamHandle)
Returns the size of one audio frame in bytes (channelCount * resolution)
Definition: AudioEngine.cpp:658
static void aestream_set_resample_ratio(void *kodiBase, AEStreamHandle *streamHandle, double ratio)
Sets the resample ratio.
Definition: AudioEngine.cpp:743
Main structure passed from kodi to addon with basic information needed to create add-on.
Definition: addon_base.h:378
Definition: AudioEngine.h:19
static bool aestream_is_draining(void *kodiBase, AEStreamHandle *streamHandle)
Returns true if the is stream draining.
Definition: AudioEngine.cpp:541
static void audioengine_free_stream(void *kodiBase, AEStreamHandle *streamHandle)
This method will remove the specified stream from the engine.
Definition: AudioEngine.cpp:342
static float aestream_get_volume(void *kodiBase, AEStreamHandle *streamHandle)
Return the stream's current volume level.
Definition: AudioEngine.cpp:589
static void aestream_resume(void *kodiBase, AEStreamHandle *streamHandle)
Resumes the stream after pausing.
Definition: AudioEngine.cpp:512
Internal API structure which are used for data exchange between Kodi and addon.
Definition: audio_engine.h:229
static double aestream_get_resample_ratio(void *kodiBase, AEStreamHandle *streamHandle)
Return the resample ratio.
Definition: AudioEngine.cpp:726
static unsigned int aestream_add_data(void *kodiBase, AEStreamHandle *streamHandle, uint8_t *const *data, unsigned int offset, unsigned int frames, double pts, bool hasDownmix, double centerMixLevel)
Add planar or interleaved PCM data to the stream.
Definition: AudioEngine.cpp:405
AudioEngineDataFormat
Definition: audio_engine.h:147
static bool aestream_is_drained(void *kodiBase, AEStreamHandle *streamHandle)
Returns true if the is stream has finished draining.
Definition: AudioEngine.cpp:557
static unsigned int aestream_get_channel_count(void *kodiBase, AEStreamHandle *streamHandle)
Returns the number of channels the stream is configured to accept.
Definition: AudioEngine.cpp:675
static unsigned int aestream_get_space(void *kodiBase, AEStreamHandle *streamHandle)
Returns the amount of space available in the stream.
Definition: AudioEngine.cpp:392
static AEChannel TranslateAEChannelToKodi(AudioEngineChannel channel)
Translation functions to separate Kodi and addons.
Definition: AudioEngine.cpp:69
static void aestream_set_amplification(void *kodiBase, AEStreamHandle *streamHandle, float amplify)
Sets the stream's volume amplification in linear units.
Definition: AudioEngine.cpp:640
static bool aestream_is_buffering(void *kodiBase, AEStreamHandle *streamHandle)
Returns if the stream is buffering.
Definition: AudioEngine.cpp:448
static void aestream_pause(void *kodiBase, AEStreamHandle *streamHandle)
Pauses the stream playback.
Definition: AudioEngine.cpp:496
static void aestream_flush(void *kodiBase, AEStreamHandle *streamHandle)
Flush all buffers dropping the audio data.
Definition: AudioEngine.cpp:573
static float aestream_get_amplification(void *kodiBase, AEStreamHandle *streamHandle)
Gets the stream's volume amplification in linear units.
Definition: AudioEngine.cpp:623
Definition: Addon.cpp:39
static AEStreamHandle * audioengine_make_stream(void *kodiBase, AUDIO_ENGINE_FORMAT *streamFormat, unsigned int options)
Creates and returns a new handle to an IAEStream in the format specified, this function should never ...
Definition: AudioEngine.cpp:301
static AudioEngineDataFormat aestream_get_data_format(void *kodiBase, AEStreamHandle *streamHandle)
Return the data format the stream has been configured with.
Definition: AudioEngine.cpp:709
static void aestream_set_volume(void *kodiBase, AEStreamHandle *streamHandle, float volume)
Set the stream's volume level.
Definition: AudioEngine.cpp:605
AudioEngineChannel
Definition: audio_engine.h:69
static void aestream_drain(void *kodiBase, AEStreamHandle *streamHandle, bool wait)
Start draining the stream.
Definition: AudioEngine.cpp:525