summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h314
1 files changed, 314 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h
new file mode 100644
index 0000000..97510f7
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h
@@ -0,0 +1,314 @@
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
18extern "C"
19{
20#endif /* __cplusplus */
21
22 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
23 // "C" Definitions, structures and enumerators of audio engine
24 //{{{
25
26 //============================================================================
27 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineStreamOptions enum AudioEngineStreamOptions
28 /// @ingroup cpp_kodi_audioengine_Defs
29 /// @brief **Bit options to pass to CAEStream**\n
30 /// A bit field of stream options.
31 ///
32 ///
33 /// ------------------------------------------------------------------------
34 ///
35 /// **Usage example:**
36 /// ~~~~~~~~~~~~~{.cpp}
37 /// // Here only as minimal, "format" must be set to wanted types
38 /// kodi::audioengine::AudioEngineFormat format;
39 /// m_audioengine = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_FORCE_RESAMPLE | AUDIO_STREAM_AUTOSTART);
40 /// ~~~~~~~~~~~~~
41 ///
42 ///@{
43 typedef enum AudioEngineStreamOptions
44 {
45 /// force resample even if rates match
46 AUDIO_STREAM_FORCE_RESAMPLE = 1 << 0,
47 /// create the stream paused
48 AUDIO_STREAM_PAUSED = 1 << 1,
49 /// autostart the stream when enough data is buffered
50 AUDIO_STREAM_AUTOSTART = 1 << 2,
51 } AudioEngineStreamOptions;
52 ///@}
53 //----------------------------------------------------------------------------
54
55 //============================================================================
56 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineChannel enum AudioEngineChannel
57 /// @ingroup cpp_kodi_audioengine_Defs
58 /// @brief **The possible channels**\n
59 /// Used to set available or used channels on stream.
60 ///
61 ///
62 /// ------------------------------------------------------------------------
63 ///
64 /// **Usage example:**
65 /// ~~~~~~~~~~~~~{.cpp}
66 /// kodi::audioengine::AudioEngineFormat format;
67 /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR));
68 /// ~~~~~~~~~~~~~
69 ///
70 ///@{
71 enum AudioEngineChannel
72 {
73 /// Used inside to indicate the end of a list and not for addon use directly.
74 AUDIOENGINE_CH_NULL = -1,
75 /// RAW Audio format
76 AUDIOENGINE_CH_RAW,
77 /// Front left
78 AUDIOENGINE_CH_FL,
79 /// Front right
80 AUDIOENGINE_CH_FR,
81 /// Front center
82 AUDIOENGINE_CH_FC,
83 /// LFE / Subwoofer
84 AUDIOENGINE_CH_LFE,
85 /// Back left
86 AUDIOENGINE_CH_BL,
87 /// Back right
88 AUDIOENGINE_CH_BR,
89 /// Front left over center
90 AUDIOENGINE_CH_FLOC,
91 /// Front right over center
92 AUDIOENGINE_CH_FROC,
93 /// Back center
94 AUDIOENGINE_CH_BC,
95 /// Side left
96 AUDIOENGINE_CH_SL,
97 /// Side right
98 AUDIOENGINE_CH_SR,
99 /// Top front left
100 AUDIOENGINE_CH_TFL,
101 /// Top front right
102 AUDIOENGINE_CH_TFR,
103 /// Top front center
104 AUDIOENGINE_CH_TFC,
105 /// Top center
106 AUDIOENGINE_CH_TC,
107 /// Top back left
108 AUDIOENGINE_CH_TBL,
109 /// Top back right
110 AUDIOENGINE_CH_TBR,
111 /// Top back center
112 AUDIOENGINE_CH_TBC,
113 /// Back left over center
114 AUDIOENGINE_CH_BLOC,
115 /// Back right over center
116 AUDIOENGINE_CH_BROC,
117 /// Maximum possible value, to use e.g. as size inside list
118 AUDIOENGINE_CH_MAX
119 };
120 ///@}
121 //----------------------------------------------------------------------------
122
123 //============================================================================
124 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineDataFormat enum AudioEngineDataFormat
125 /// @ingroup cpp_kodi_audioengine_Defs
126 /// @brief **Audio sample formats**\n
127 /// The bit layout of the audio data.
128 ///
129 /// LE = Little Endian, BE = Big Endian, NE = Native Endian
130 ///
131 /// For planar sample formats, each audio channel is in a separate data plane,
132 /// and linesize is the buffer size, in bytes, for a single plane. All data
133 /// planes must be the same size. For packed sample formats, only the first
134 /// data plane is used, and samples for each channel are interleaved. In this
135 /// case, linesize is the buffer size, in bytes, for the 1 plane.
136 ///
137 /// @note This is ordered from the worst to best preferred formats
138 ///
139 ///
140 /// ------------------------------------------------------------------------
141 ///
142 /// **Usage example:**
143 /// ~~~~~~~~~~~~~{.cpp}
144 /// kodi::audioengine::AudioEngineFormat format;
145 /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP);
146 /// ~~~~~~~~~~~~~
147 ///
148 ///@{
149 enum AudioEngineDataFormat
150 {
151 /// To define format as invalid
152 AUDIOENGINE_FMT_INVALID = -1,
153
154 /// Unsigned integer 8 bit
155 AUDIOENGINE_FMT_U8,
156
157 /// Big Endian signed integer 16 bit
158 AUDIOENGINE_FMT_S16BE,
159 /// Little Endian signed integer 16 bit
160 AUDIOENGINE_FMT_S16LE,
161 /// Native Endian signed integer 16 bit
162 AUDIOENGINE_FMT_S16NE,
163
164 /// Big Endian signed integer 32 bit
165 AUDIOENGINE_FMT_S32BE,
166 /// Little Endian signed integer 32 bit
167 AUDIOENGINE_FMT_S32LE,
168 /// Native Endian signed integer 32 bit
169 AUDIOENGINE_FMT_S32NE,
170
171 /// Big Endian signed integer 24 bit (in 4 bytes)
172 AUDIOENGINE_FMT_S24BE4,
173 /// Little Endian signed integer 24 bit (in 4 bytes)
174 AUDIOENGINE_FMT_S24LE4,
175 /// Native Endian signed integer 24 bit (in 4 bytes)
176 AUDIOENGINE_FMT_S24NE4,
177 /// S32 with bits_per_sample < 32
178 AUDIOENGINE_FMT_S24NE4MSB,
179
180 /// Big Endian signed integer 24 bit (3 bytes)
181 AUDIOENGINE_FMT_S24BE3,
182 /// Little Endian signed integer 24 bit (3 bytes)
183 AUDIOENGINE_FMT_S24LE3,
184 /// Native Endian signed integer 24 bit (3 bytes)
185 AUDIOENGINE_FMT_S24NE3,
186
187 /// Double floating point
188 AUDIOENGINE_FMT_DOUBLE,
189 /// Floating point
190 AUDIOENGINE_FMT_FLOAT,
191
192 /// **Bitstream**\n
193 /// RAW Audio format
194 AUDIOENGINE_FMT_RAW,
195
196 /// **Planar format**\n
197 /// Unsigned byte
198 AUDIOENGINE_FMT_U8P,
199 /// **Planar format**\n
200 /// Native Endian signed 16 bit
201 AUDIOENGINE_FMT_S16NEP,
202 /// **Planar format**\n
203 /// Native Endian signed 32 bit
204 AUDIOENGINE_FMT_S32NEP,
205 /// **Planar format**\n
206 /// Native Endian signed integer 24 bit (in 4 bytes)
207 AUDIOENGINE_FMT_S24NE4P,
208 /// **Planar format**\n
209 /// S32 with bits_per_sample < 32
210 AUDIOENGINE_FMT_S24NE4MSBP,
211 /// **Planar format**\n
212 /// Native Endian signed integer 24 bit (in 3 bytes)
213 AUDIOENGINE_FMT_S24NE3P,
214 /// **Planar format**\n
215 /// Double floating point
216 AUDIOENGINE_FMT_DOUBLEP,
217 /// **Planar format**\n
218 /// Floating point
219 AUDIOENGINE_FMT_FLOATP,
220
221 /// Amount of sample formats.
222 AUDIOENGINE_FMT_MAX
223 };
224 ///@}
225 //----------------------------------------------------------------------------
226
227 /*!
228 * @brief Internal API structure which are used for data exchange between
229 * Kodi and addon.
230 */
231 struct AUDIO_ENGINE_FORMAT
232 {
233 /*! The stream's data format (eg, AUDIOENGINE_FMT_S16LE) */
234 enum AudioEngineDataFormat m_dataFormat;
235
236 /*! The stream's sample rate (eg, 48000) */
237 unsigned int m_sampleRate;
238
239 /*! The encoded streams sample rate if a bitstream, otherwise undefined */
240 unsigned int m_encodedRate;
241
242 /*! The amount of used speaker channels */
243 unsigned int m_channelCount;
244
245 /*! The stream's channel layout */
246 enum AudioEngineChannel m_channels[AUDIOENGINE_CH_MAX];
247
248 /*! The number of frames per period */
249 unsigned int m_frames;
250
251 /*! The size of one frame in bytes */
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 */
268 typedef struct AddonToKodiFuncTable_kodi_audioengine
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);
306 } AddonToKodiFuncTable_kodi_audioengine;
307
308 //}}}
309
310#ifdef __cplusplus
311}
312#endif /* __cplusplus */
313
314#endif /* !C_API_AUDIO_ENGINE_H */