Kodi Development  20.0
for Binary and Script based Add-Ons
audio_engine.h
1 /*
2  * Copyright (C) 2005-2019 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 #ifndef C_API_AUDIO_ENGINE_H
10 #define C_API_AUDIO_ENGINE_H
11 
12 #include <stdbool.h>
13 #include <stdint.h>
14 
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif /* __cplusplus */
19 
20  //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
21  // "C" Definitions, structures and enumerators of audio engine
22  //{{{
23 
24  //============================================================================
42  {
51  //----------------------------------------------------------------------------
52 
53  //============================================================================
70  {
117  };
119  //----------------------------------------------------------------------------
120 
121  //============================================================================
148  {
151 
154 
161 
168 
177 
184 
189 
193 
218 
221  };
223  //----------------------------------------------------------------------------
224 
230  {
233 
235  unsigned int m_sampleRate;
236 
238  unsigned int m_encodedRate;
239 
241  unsigned int m_channelCount;
242 
245 
247  unsigned int m_frames;
248 
250  unsigned int m_frameSize;
251  };
252 
253  /* A stream handle pointer, which is only used internally by the addon stream handle */
254  typedef void AEStreamHandle;
255 
256  //}}}
257 
258  //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
259  // "C" Internal interface tables for intercommunications between addon and kodi
260  //{{{
261 
262  /*
263  * Function address structure, not need to visible on dev kit doxygen
264  * documentation
265  */
267  {
268  AEStreamHandle* (*make_stream)(void* kodiBase,
269  struct AUDIO_ENGINE_FORMAT* format,
270  unsigned int options);
271  void (*free_stream)(void* kodiBase, AEStreamHandle* stream);
272  bool (*get_current_sink_format)(void* kodiBase, struct AUDIO_ENGINE_FORMAT* sink_format);
273 
274  // Audio Engine Stream definitions
275  unsigned int (*aestream_get_space)(void* kodiBase, AEStreamHandle* handle);
276  unsigned int (*aestream_add_data)(void* kodiBase,
277  AEStreamHandle* handle,
278  uint8_t* const* data,
279  unsigned int offset,
280  unsigned int frames,
281  double pts,
282  bool hasDownmix,
283  double centerMixLevel);
284  double (*aestream_get_delay)(void* kodiBase, AEStreamHandle* handle);
285  bool (*aestream_is_buffering)(void* kodiBase, AEStreamHandle* handle);
286  double (*aestream_get_cache_time)(void* kodiBase, AEStreamHandle* handle);
287  double (*aestream_get_cache_total)(void* kodiBase, AEStreamHandle* handle);
288  void (*aestream_pause)(void* kodiBase, AEStreamHandle* handle);
289  void (*aestream_resume)(void* kodiBase, AEStreamHandle* handle);
290  void (*aestream_drain)(void* kodiBase, AEStreamHandle* handle, bool wait);
291  bool (*aestream_is_draining)(void* kodiBase, AEStreamHandle* handle);
292  bool (*aestream_is_drained)(void* kodiBase, AEStreamHandle* handle);
293  void (*aestream_flush)(void* kodiBase, AEStreamHandle* handle);
294  float (*aestream_get_volume)(void* kodiBase, AEStreamHandle* handle);
295  void (*aestream_set_volume)(void* kodiBase, AEStreamHandle* handle, float volume);
296  float (*aestream_get_amplification)(void* kodiBase, AEStreamHandle* handle);
297  void (*aestream_set_amplification)(void* kodiBase, AEStreamHandle* handle, float amplify);
298  unsigned int (*aestream_get_frame_size)(void* kodiBase, AEStreamHandle* handle);
299  unsigned int (*aestream_get_channel_count)(void* kodiBase, AEStreamHandle* handle);
300  unsigned int (*aestream_get_sample_rate)(void* kodiBase, AEStreamHandle* handle);
301  enum AudioEngineDataFormat (*aestream_get_data_format)(void* kodiBase, AEStreamHandle* handle);
302  double (*aestream_get_resample_ratio)(void* kodiBase, AEStreamHandle* handle);
303  void (*aestream_set_resample_ratio)(void* kodiBase, AEStreamHandle* handle, double ratio);
305 
306  //}}}
307 
308 #ifdef __cplusplus
309 }
310 #endif /* __cplusplus */
311 
312 #endif /* !C_API_AUDIO_ENGINE_H */
AudioEngineChannel
Definition: audio_engine.h:70
@ AUDIOENGINE_CH_SL
Side left.
Definition: audio_engine.h:94
@ 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_TC
Top center.
Definition: audio_engine.h:104
@ AUDIOENGINE_CH_FROC
Front right over center.
Definition: audio_engine.h:90
@ AUDIOENGINE_CH_TFL
Top front left.
Definition: audio_engine.h:98
@ AUDIOENGINE_CH_RAW
RAW Audio format.
Definition: audio_engine.h:74
@ AUDIOENGINE_CH_SR
Side right.
Definition: audio_engine.h:96
@ AUDIOENGINE_CH_TFC
Top front center.
Definition: audio_engine.h:102
@ AUDIOENGINE_CH_FR
Front right.
Definition: audio_engine.h:78
@ AUDIOENGINE_CH_BL
Back left.
Definition: audio_engine.h:84
@ AUDIOENGINE_CH_MAX
Maximum possible value, to use e.g. as size inside list.
Definition: audio_engine.h:116
@ AUDIOENGINE_CH_FL
Front left.
Definition: audio_engine.h:76
@ AUDIOENGINE_CH_BR
Back right.
Definition: audio_engine.h:86
@ AUDIOENGINE_CH_BROC
Back right over center.
Definition: audio_engine.h:114
@ AUDIOENGINE_CH_LFE
LFE / Subwoofer.
Definition: audio_engine.h:82
@ AUDIOENGINE_CH_TBL
Top back left.
Definition: audio_engine.h:106
@ AUDIOENGINE_CH_FC
Front center.
Definition: audio_engine.h:80
@ AUDIOENGINE_CH_TBC
Top back center.
Definition: audio_engine.h:110
@ AUDIOENGINE_CH_FLOC
Front left over center.
Definition: audio_engine.h:88
@ AUDIOENGINE_CH_BLOC
Back left over center.
Definition: audio_engine.h:112
@ AUDIOENGINE_CH_TFR
Top front right.
Definition: audio_engine.h:100
@ AUDIOENGINE_CH_BC
Back center.
Definition: audio_engine.h:92
@ AUDIOENGINE_CH_TBR
Top back right.
Definition: audio_engine.h:108
AudioEngineDataFormat
Definition: audio_engine.h:148
@ AUDIOENGINE_FMT_S24NE3
Native Endian signed integer 24 bit (3 bytes)
Definition: audio_engine.h:183
@ AUDIOENGINE_FMT_S16NE
Native Endian signed integer 16 bit.
Definition: audio_engine.h:160
@ AUDIOENGINE_FMT_S24BE4
Big Endian signed integer 24 bit (in 4 bytes)
Definition: audio_engine.h:170
@ AUDIOENGINE_FMT_S24BE3
Big Endian signed integer 24 bit (3 bytes)
Definition: audio_engine.h:179
@ AUDIOENGINE_FMT_DOUBLEP
Definition: audio_engine.h:214
@ AUDIOENGINE_FMT_RAW
Definition: audio_engine.h:192
@ AUDIOENGINE_FMT_S16NEP
Definition: audio_engine.h:199
@ AUDIOENGINE_FMT_S32BE
Big Endian signed integer 32 bit.
Definition: audio_engine.h:163
@ AUDIOENGINE_FMT_S24NE3P
Definition: audio_engine.h:211
@ AUDIOENGINE_FMT_S32NEP
Definition: audio_engine.h:202
@ AUDIOENGINE_FMT_S16BE
Big Endian signed integer 16 bit.
Definition: audio_engine.h:156
@ AUDIOENGINE_FMT_U8P
Definition: audio_engine.h:196
@ AUDIOENGINE_FMT_FLOAT
Floating point.
Definition: audio_engine.h:188
@ AUDIOENGINE_FMT_S24NE4MSBP
Definition: audio_engine.h:208
@ AUDIOENGINE_FMT_S16LE
Little Endian signed integer 16 bit.
Definition: audio_engine.h:158
@ AUDIOENGINE_FMT_S24NE4
Native Endian signed integer 24 bit (in 4 bytes)
Definition: audio_engine.h:174
@ AUDIOENGINE_FMT_DOUBLE
Double floating point.
Definition: audio_engine.h:186
@ AUDIOENGINE_FMT_S24LE4
Little Endian signed integer 24 bit (in 4 bytes)
Definition: audio_engine.h:172
@ AUDIOENGINE_FMT_S24LE3
Little Endian signed integer 24 bit (3 bytes)
Definition: audio_engine.h:181
@ AUDIOENGINE_FMT_U8
Unsigned integer 8 bit.
Definition: audio_engine.h:153
@ AUDIOENGINE_FMT_S24NE4MSB
S32 with bits_per_sample < 32.
Definition: audio_engine.h:176
@ AUDIOENGINE_FMT_S24NE4P
Definition: audio_engine.h:205
@ AUDIOENGINE_FMT_S32LE
Little Endian signed integer 32 bit.
Definition: audio_engine.h:165
@ AUDIOENGINE_FMT_INVALID
To define format as invalid.
Definition: audio_engine.h:150
@ AUDIOENGINE_FMT_S32NE
Native Endian signed integer 32 bit.
Definition: audio_engine.h:167
@ AUDIOENGINE_FMT_MAX
Amount of sample formats.
Definition: audio_engine.h:220
@ AUDIOENGINE_FMT_FLOATP
Definition: audio_engine.h:217
AudioEngineStreamOptions
Definition: audio_engine.h:42
@ AUDIO_STREAM_FORCE_RESAMPLE
force resample even if rates match
Definition: audio_engine.h:44
@ AUDIO_STREAM_AUTOSTART
autostart the stream when enough data is buffered
Definition: audio_engine.h:48
@ AUDIO_STREAM_PAUSED
create the stream paused
Definition: audio_engine.h:46
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