This file is indexed.

/usr/include/kodi/libKODI_audioengine.h is in kodi-addons-dev 2:17.1+dfsg1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#pragma once
/*
 *      Copyright (C) 2005-2014 Team KODI
 *      http://kodi.tv
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with KODI; see the file COPYING.  If not, see
 *  <http://www.gnu.org/licenses/>.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>

#include "kodi_audioengine_types.h"
#ifdef BUILD_KODI_ADDON
  #include "kodi/AudioEngine/AEChannelData.h"
  #include "kodi/AudioEngine/AEChannelInfo.h"
  #include "kodi/AudioEngine/AEStreamData.h"
#else
  #include "cores/AudioEngine/Utils/AEChannelData.h"
  #include "cores/AudioEngine/Utils/AEChannelInfo.h"
  #include "cores/AudioEngine/Utils/AEStreamData.h"
#endif

#include "libXBMC_addon.h"

#define AUDIOENGINE_HELPER_DLL KODI_DLL("audioengine")
#define AUDIOENGINE_HELPER_DLL_NAME KODI_DLL_NAME("audioengine")

class CAddonAEStream;

class CHelper_libKODI_audioengine
{
public:
  CHelper_libKODI_audioengine(void)
  {
    m_libKODI_audioengine = NULL;
    m_Handle              = NULL;
  }

  ~CHelper_libKODI_audioengine(void)
  {
    if (m_libKODI_audioengine)
    {
      AudioEngine_unregister_me(m_Handle, m_Callbacks);
      dlclose(m_libKODI_audioengine);
    }
  }

  /*!
   * @brief Resolve all callback methods
   * @param handle Pointer to the add-on
   * @return True when all methods were resolved, false otherwise.
   */
  bool RegisterMe(void* handle)
  {
    m_Handle = handle;

    std::string libBasePath;
    libBasePath  = ((cb_array*)m_Handle)->libPath;
    libBasePath += AUDIOENGINE_HELPER_DLL;

    m_libKODI_audioengine = dlopen(libBasePath.c_str(), RTLD_LAZY);
    if (m_libKODI_audioengine == NULL)
    {
      fprintf(stderr, "Unable to load %s\n", dlerror());
      return false;
    }

    AudioEngine_register_me = (void* (*)(void *HANDLE))
      dlsym(m_libKODI_audioengine, "AudioEngine_register_me");
    if (AudioEngine_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }

    AudioEngine_unregister_me = (void(*)(void* HANDLE, void* CB))
      dlsym(m_libKODI_audioengine, "AudioEngine_unregister_me");
    if (AudioEngine_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }

    AudioEngine_MakeStream = (CAddonAEStream* (*)(void*, void*, AudioEngineFormat, unsigned int))
      dlsym(m_libKODI_audioengine, "AudioEngine_make_stream");
    if (AudioEngine_MakeStream == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }

    AudioEngine_FreeStream = (void(*)(CAddonAEStream*))
      dlsym(m_libKODI_audioengine, "AudioEngine_free_stream");
    if (AudioEngine_FreeStream == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }

    AudioEngine_GetCurrentSinkFormat = (bool(*)(void*, void*, AudioEngineFormat*))
      dlsym(m_libKODI_audioengine, "AudioEngine_get_current_sink_Format");
    if (AudioEngine_GetCurrentSinkFormat == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }

    m_Callbacks = AudioEngine_register_me(m_Handle);
    return m_Callbacks != NULL;
  }

  /**
   * Creates and returns a new handle to an IAEStream in the format specified, this function should never fail
   * @param DataFormat The data format the incoming audio will be in (eg, AE_FMT_S16LE)
   * @param SampleRate The sample rate of the audio data (eg, 48000)
   * @param ChannelLayout The order of the channels in the audio data
   * @param Options A bit field of stream options (see: enum AEStreamOptions)
   * @return a new Handle to an IAEStream that will accept data in the requested format
   */
  CAddonAEStream* MakeStream(AudioEngineFormat Format, unsigned int Options = 0)
  {
    return AudioEngine_MakeStream(m_Handle, m_Callbacks, Format, Options);
  }

  /**
  * This method will remove the specifyed stream from the engine.
  * For OSX/IOS this is essential to reconfigure the audio output.
  * @param stream The stream to be altered
  * @return NULL
  */
  void FreeStream(CAddonAEStream **Stream)
  {
    AudioEngine_FreeStream(*Stream);
    *Stream = NULL;
  }

  /**
   * Get the current sink data format
   *
   * @param Current sink data format. For more details see AudioEngineFormat.
   * @return Returns true on success, else false.
   */
  bool GetCurrentSinkFormat(AudioEngineFormat &SinkFormat)
  {
    return AudioEngine_GetCurrentSinkFormat(m_Handle, m_Callbacks, &SinkFormat);
  }

protected:
  void* (*AudioEngine_register_me)(void*);
  void (*AudioEngine_unregister_me)(void*, void*);
  CAddonAEStream* (*AudioEngine_MakeStream)(void*, void*, AudioEngineFormat, unsigned int);
  bool (*AudioEngine_GetCurrentSinkFormat)(void*, void*, AudioEngineFormat *SinkFormat);
  void (*AudioEngine_FreeStream)(CAddonAEStream*);

private:
  void* m_libKODI_audioengine;
  void* m_Handle;
  void* m_Callbacks;
  struct cb_array
  {
    const char* libPath;
  };
};

// Audio Engine Stream Class
class CAddonAEStream
{
public:
  CAddonAEStream(void *Addon, void *Callbacks, AEStreamHandle *StreamHandle);
  virtual ~CAddonAEStream();

  /**
  * Returns the amount of space available in the stream
  * @return The number of bytes AddData will consume
  */
  virtual unsigned int GetSpace();

  /**
  * Add planar or interleaved PCM data to the stream
  * @param Data array of pointers to the planes
  * @param Offset to frame in frames
  * @param Frames number of frames
  * @return The number of frames consumed
  */
  virtual unsigned int AddData(uint8_t* const *Data, unsigned int Offset, unsigned int Frames);

  /**
  * Returns the time in seconds that it will take
  * for the next added packet to be heard from the speakers.
  * @return seconds
  */
  virtual double GetDelay();

  /**
  * Returns if the stream is buffering
  * @return True if the stream is buffering
  */
  virtual bool IsBuffering();

  /**
   * Returns the time in seconds of the stream's
   * cached audio samples. Engine buffers excluded.
  * @return seconds
  */
  virtual double GetCacheTime();

  /**
  * Returns the total time in seconds of the cache
  * @return seconds
  */
  virtual double GetCacheTotal();

  /**
  * Pauses the stream playback
  */
  virtual void Pause();

  /**
  * Resumes the stream after pausing
  */
  virtual void Resume();

  /**
  * Start draining the stream
  * @note Once called AddData will not consume more data.
  */
  virtual void Drain(bool Wait);

  /**
  * Returns true if the is stream draining
  */
  virtual bool IsDraining();

  /**
  * Returns true if the is stream has finished draining
  */
  virtual bool IsDrained();

  /**
  * Flush all buffers dropping the audio data
  */
  virtual void Flush();

  /**
  * Return the stream's current volume level
  * @return The volume level between 0.0 and 1.0
  */
  virtual float GetVolume();

  /**
  * Set the stream's volume level
  * @param volume The new volume level between 0.0 and 1.0
  */
  virtual void  SetVolume(float Volume);

  /**
  * Gets the stream's volume amplification in linear units.
  * @return The volume amplification factor between 1.0 and 1000.0
  */
  virtual float GetAmplification();

  /**
  * Sets the stream's volume amplification in linear units.
  * @param The volume amplification factor between 1.0 and 1000.0
  */
  virtual void SetAmplification(float Amplify);

  /**
  * Returns the size of one audio frame in bytes (channelCount * resolution)
  * @return The size in bytes of one frame
  */
  virtual const unsigned int GetFrameSize() const;

  /**
  * Returns the number of channels the stream is configured to accept
  * @return The channel count
  */
  virtual const unsigned int GetChannelCount() const;

  /**
  * Returns the stream's sample rate, if the stream is using a dynamic sample rate, this value will NOT reflect any changes made by calls to SetResampleRatio()
  * @return The stream's sample rate (eg, 48000)
  */
  virtual const unsigned int GetSampleRate() const;

  /**
  * Return the data format the stream has been configured with
  * @return The stream's data format (eg, AE_FMT_S16LE)
  */
  virtual const AEDataFormat GetDataFormat() const;

  /**
  * Return the resample ratio
  * @note This will return an undefined value if the stream is not resampling
  * @return the current resample ratio or undefined if the stream is not resampling
  */
  virtual double GetResampleRatio();

  /**
  * Sets the resample ratio
  * @note This function may return false if the stream is not resampling, if you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option
  * @param ratio the new sample rate ratio, calculated by ((double)desiredRate / (double)GetSampleRate())
  */
  virtual void SetResampleRatio(double Ratio);

  private:
    AEStreamHandle  *m_StreamHandle;
    void            *m_Callbacks;
    void            *m_AddonHandle;
};