Kodi Development  19.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 #pragma once
10 
11 #ifndef C_API_AUDIO_ENGINE_H
12 #define C_API_AUDIO_ENGINE_H
13 
14 #include <stdbool.h>
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif /* __cplusplus */
21 
22  //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
23  // "C" Definitions, structures and enumerators of audio engine
24  //{{{
25 
26  //============================================================================
44  {
53  //----------------------------------------------------------------------------
54 
55  //============================================================================
72  {
119  };
121  //----------------------------------------------------------------------------
122 
123  //============================================================================
150  {
153 
156 
163 
170 
179 
186 
191 
195 
220 
223  };
225  //----------------------------------------------------------------------------
226 
232  {
235 
237  unsigned int m_sampleRate;
238 
240  unsigned int m_encodedRate;
241 
243  unsigned int m_channelCount;
244 
247 
249  unsigned int m_frames;
250 
252  unsigned int m_frameSize;
253  };
254 
255  /* A stream handle pointer, which is only used internally by the addon stream handle */
256  typedef void AEStreamHandle;
257 
258  //}}}
259 
260  //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
261  // "C" Internal interface tables for intercommunications between addon and kodi
262  //{{{
263 
264  /*
265  * Function address structure, not need to visible on dev kit doxygen
266  * documentation
267  */
269  {
270  AEStreamHandle* (*make_stream)(void* kodiBase,
271  struct AUDIO_ENGINE_FORMAT* format,
272  unsigned int options);
273  void (*free_stream)(void* kodiBase, AEStreamHandle* stream);
274  bool (*get_current_sink_format)(void* kodiBase, struct AUDIO_ENGINE_FORMAT* sink_format);
275 
276  // Audio Engine Stream definitions
277  unsigned int (*aestream_get_space)(void* kodiBase, AEStreamHandle* handle);
278  unsigned int (*aestream_add_data)(void* kodiBase,
279  AEStreamHandle* handle,
280  uint8_t* const* data,
281  unsigned int offset,
282  unsigned int frames,
283  double pts,
284  bool hasDownmix,
285  double centerMixLevel);
286  double (*aestream_get_delay)(void* kodiBase, AEStreamHandle* handle);
287  bool (*aestream_is_buffering)(void* kodiBase, AEStreamHandle* handle);
288  double (*aestream_get_cache_time)(void* kodiBase, AEStreamHandle* handle);
289  double (*aestream_get_cache_total)(void* kodiBase, AEStreamHandle* handle);
290  void (*aestream_pause)(void* kodiBase, AEStreamHandle* handle);
291  void (*aestream_resume)(void* kodiBase, AEStreamHandle* handle);
292  void (*aestream_drain)(void* kodiBase, AEStreamHandle* handle, bool wait);
293  bool (*aestream_is_draining)(void* kodiBase, AEStreamHandle* handle);
294  bool (*aestream_is_drained)(void* kodiBase, AEStreamHandle* handle);
295  void (*aestream_flush)(void* kodiBase, AEStreamHandle* handle);
296  float (*aestream_get_volume)(void* kodiBase, AEStreamHandle* handle);
297  void (*aestream_set_volume)(void* kodiBase, AEStreamHandle* handle, float volume);
298  float (*aestream_get_amplification)(void* kodiBase, AEStreamHandle* handle);
299  void (*aestream_set_amplification)(void* kodiBase, AEStreamHandle* handle, float amplify);
300  unsigned int (*aestream_get_frame_size)(void* kodiBase, AEStreamHandle* handle);
301  unsigned int (*aestream_get_channel_count)(void* kodiBase, AEStreamHandle* handle);
302  unsigned int (*aestream_get_sample_rate)(void* kodiBase, AEStreamHandle* handle);
303  enum AudioEngineDataFormat (*aestream_get_data_format)(void* kodiBase, AEStreamHandle* handle);
304  double (*aestream_get_resample_ratio)(void* kodiBase, AEStreamHandle* handle);
305  void (*aestream_set_resample_ratio)(void* kodiBase, AEStreamHandle* handle, double ratio);
307 
308  //}}}
309 
310 #ifdef __cplusplus
311 }
312 #endif /* __cplusplus */
313 
314 #endif /* !C_API_AUDIO_ENGINE_H */
AUDIOENGINE_FMT_S24BE3
@ AUDIOENGINE_FMT_S24BE3
Big Endian signed integer 24 bit (3 bytes)
Definition: audio_engine.h:181
AUDIOENGINE_CH_TBR
@ AUDIOENGINE_CH_TBR
Top back right.
Definition: audio_engine.h:110
AUDIO_STREAM_PAUSED
@ AUDIO_STREAM_PAUSED
create the stream paused
Definition: audio_engine.h:48
AUDIOENGINE_CH_BROC
@ AUDIOENGINE_CH_BROC
Back right over center.
Definition: audio_engine.h:116
AUDIO_ENGINE_FORMAT
Internal API structure which are used for data exchange between Kodi and addon.
Definition: audio_engine.h:232
AUDIOENGINE_CH_TBC
@ AUDIOENGINE_CH_TBC
Top back center.
Definition: audio_engine.h:112
AUDIOENGINE_FMT_S24LE3
@ AUDIOENGINE_FMT_S24LE3
Little Endian signed integer 24 bit (3 bytes)
Definition: audio_engine.h:183
AUDIOENGINE_FMT_S32NE
@ AUDIOENGINE_FMT_S32NE
Native Endian signed integer 32 bit.
Definition: audio_engine.h:169
AUDIOENGINE_FMT_S32BE
@ AUDIOENGINE_FMT_S32BE
Big Endian signed integer 32 bit.
Definition: audio_engine.h:165
AUDIOENGINE_CH_NULL
@ AUDIOENGINE_CH_NULL
Used inside to indicate the end of a list and not for addon use directly.
Definition: audio_engine.h:74
AUDIOENGINE_FMT_S16BE
@ AUDIOENGINE_FMT_S16BE
Big Endian signed integer 16 bit.
Definition: audio_engine.h:158
AUDIOENGINE_CH_BC
@ AUDIOENGINE_CH_BC
Back center.
Definition: audio_engine.h:94
AUDIOENGINE_FMT_U8
@ AUDIOENGINE_FMT_U8
Unsigned integer 8 bit.
Definition: audio_engine.h:155
AUDIO_ENGINE_FORMAT::m_dataFormat
enum AudioEngineDataFormat m_dataFormat
Definition: audio_engine.h:234
AUDIOENGINE_FMT_S24NE3P
@ AUDIOENGINE_FMT_S24NE3P
Definition: audio_engine.h:213
AUDIOENGINE_FMT_MAX
@ AUDIOENGINE_FMT_MAX
Amount of sample formats.
Definition: audio_engine.h:222
AUDIOENGINE_FMT_S24BE4
@ AUDIOENGINE_FMT_S24BE4
Big Endian signed integer 24 bit (in 4 bytes)
Definition: audio_engine.h:172
AUDIOENGINE_FMT_S16LE
@ AUDIOENGINE_FMT_S16LE
Little Endian signed integer 16 bit.
Definition: audio_engine.h:160
AUDIOENGINE_FMT_S24LE4
@ AUDIOENGINE_FMT_S24LE4
Little Endian signed integer 24 bit (in 4 bytes)
Definition: audio_engine.h:174
AUDIOENGINE_FMT_INVALID
@ AUDIOENGINE_FMT_INVALID
To define format as invalid.
Definition: audio_engine.h:152
AUDIOENGINE_CH_FL
@ AUDIOENGINE_CH_FL
Front left.
Definition: audio_engine.h:78
AUDIOENGINE_FMT_S24NE4MSB
@ AUDIOENGINE_FMT_S24NE4MSB
S32 with bits_per_sample < 32.
Definition: audio_engine.h:178
AUDIOENGINE_CH_FR
@ AUDIOENGINE_CH_FR
Front right.
Definition: audio_engine.h:80
AUDIOENGINE_FMT_S32LE
@ AUDIOENGINE_FMT_S32LE
Little Endian signed integer 32 bit.
Definition: audio_engine.h:167
AUDIOENGINE_CH_BL
@ AUDIOENGINE_CH_BL
Back left.
Definition: audio_engine.h:86
AUDIOENGINE_FMT_DOUBLEP
@ AUDIOENGINE_FMT_DOUBLEP
Definition: audio_engine.h:216
AUDIOENGINE_FMT_FLOAT
@ AUDIOENGINE_FMT_FLOAT
Floating point.
Definition: audio_engine.h:190
AUDIOENGINE_CH_FROC
@ AUDIOENGINE_CH_FROC
Front right over center.
Definition: audio_engine.h:92
AUDIO_STREAM_AUTOSTART
@ AUDIO_STREAM_AUTOSTART
autostart the stream when enough data is buffered
Definition: audio_engine.h:50
AudioEngineChannel
AudioEngineChannel
Definition: audio_engine.h:72
AUDIO_ENGINE_FORMAT::m_channels
enum AudioEngineChannel m_channels[AUDIOENGINE_CH_MAX]
Definition: audio_engine.h:246
AUDIO_ENGINE_FORMAT::m_encodedRate
unsigned int m_encodedRate
Definition: audio_engine.h:240
AUDIOENGINE_CH_TC
@ AUDIOENGINE_CH_TC
Top center.
Definition: audio_engine.h:106
AUDIOENGINE_CH_BR
@ AUDIOENGINE_CH_BR
Back right.
Definition: audio_engine.h:88
AudioEngineStreamOptions
AudioEngineStreamOptions
Definition: audio_engine.h:44
AUDIOENGINE_CH_MAX
@ AUDIOENGINE_CH_MAX
Maximum possible value, to use e.g. as size inside list.
Definition: audio_engine.h:118
AUDIOENGINE_CH_FLOC
@ AUDIOENGINE_CH_FLOC
Front left over center.
Definition: audio_engine.h:90
AUDIOENGINE_CH_BLOC
@ AUDIOENGINE_CH_BLOC
Back left over center.
Definition: audio_engine.h:114
AUDIOENGINE_FMT_DOUBLE
@ AUDIOENGINE_FMT_DOUBLE
Double floating point.
Definition: audio_engine.h:188
AUDIOENGINE_FMT_FLOATP
@ AUDIOENGINE_FMT_FLOATP
Definition: audio_engine.h:219
AUDIOENGINE_CH_TFR
@ AUDIOENGINE_CH_TFR
Top front right.
Definition: audio_engine.h:102
AUDIOENGINE_CH_LFE
@ AUDIOENGINE_CH_LFE
LFE / Subwoofer.
Definition: audio_engine.h:84
AUDIO_STREAM_FORCE_RESAMPLE
@ AUDIO_STREAM_FORCE_RESAMPLE
force resample even if rates match
Definition: audio_engine.h:46
AUDIOENGINE_CH_TFC
@ AUDIOENGINE_CH_TFC
Top front center.
Definition: audio_engine.h:104
AUDIOENGINE_CH_FC
@ AUDIOENGINE_CH_FC
Front center.
Definition: audio_engine.h:82
AUDIO_ENGINE_FORMAT::m_frames
unsigned int m_frames
Definition: audio_engine.h:249
AUDIOENGINE_CH_TBL
@ AUDIOENGINE_CH_TBL
Top back left.
Definition: audio_engine.h:108
AUDIO_ENGINE_FORMAT::m_channelCount
unsigned int m_channelCount
Definition: audio_engine.h:243
AUDIOENGINE_CH_SL
@ AUDIOENGINE_CH_SL
Side left.
Definition: audio_engine.h:96
AUDIOENGINE_CH_TFL
@ AUDIOENGINE_CH_TFL
Top front left.
Definition: audio_engine.h:100
AUDIOENGINE_FMT_S24NE4P
@ AUDIOENGINE_FMT_S24NE4P
Definition: audio_engine.h:207
AUDIO_ENGINE_FORMAT::m_sampleRate
unsigned int m_sampleRate
Definition: audio_engine.h:237
AddonToKodiFuncTable_kodi_audioengine
Definition: audio_engine.h:269
AUDIOENGINE_FMT_U8P
@ AUDIOENGINE_FMT_U8P
Definition: audio_engine.h:198
AUDIOENGINE_FMT_S16NE
@ AUDIOENGINE_FMT_S16NE
Native Endian signed integer 16 bit.
Definition: audio_engine.h:162
AUDIOENGINE_FMT_S32NEP
@ AUDIOENGINE_FMT_S32NEP
Definition: audio_engine.h:204
AUDIOENGINE_CH_RAW
@ AUDIOENGINE_CH_RAW
RAW Audio format.
Definition: audio_engine.h:76
AUDIOENGINE_FMT_S24NE3
@ AUDIOENGINE_FMT_S24NE3
Native Endian signed integer 24 bit (3 bytes)
Definition: audio_engine.h:185
AudioEngineDataFormat
AudioEngineDataFormat
Definition: audio_engine.h:150
AUDIO_ENGINE_FORMAT::m_frameSize
unsigned int m_frameSize
Definition: audio_engine.h:252
AUDIOENGINE_FMT_S16NEP
@ AUDIOENGINE_FMT_S16NEP
Definition: audio_engine.h:201
AUDIOENGINE_CH_SR
@ AUDIOENGINE_CH_SR
Side right.
Definition: audio_engine.h:98
AUDIOENGINE_FMT_S24NE4
@ AUDIOENGINE_FMT_S24NE4
Native Endian signed integer 24 bit (in 4 bytes)
Definition: audio_engine.h:176
AUDIOENGINE_FMT_S24NE4MSBP
@ AUDIOENGINE_FMT_S24NE4MSBP
Definition: audio_engine.h:210
AUDIOENGINE_FMT_RAW
@ AUDIOENGINE_FMT_RAW
Definition: audio_engine.h:194