[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / addons / interfaces / AudioEngine.cpp
blob0efcc07f3f0914cb8a97a57c77959b43d819f427
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "AudioEngine.h"
11 #include "ServiceBroker.h"
12 #include "addons/kodi-dev-kit/include/kodi/AddonBase.h"
13 #include "cores/AudioEngine/Interfaces/AE.h"
14 #include "cores/AudioEngine/Interfaces/AEStream.h"
15 #include "cores/AudioEngine/Utils/AEStreamData.h"
16 #include "utils/log.h"
18 using namespace kodi; // addon-dev-kit namespace
19 using namespace kodi::audioengine; // addon-dev-kit namespace
21 namespace ADDON
24 void Interface_AudioEngine::Init(AddonGlobalInterface* addonInterface)
26 addonInterface->toKodi->kodi_audioengine = new AddonToKodiFuncTable_kodi_audioengine();
28 // write KODI audio DSP specific add-on function addresses to callback table
29 addonInterface->toKodi->kodi_audioengine->make_stream = audioengine_make_stream;
30 addonInterface->toKodi->kodi_audioengine->free_stream = audioengine_free_stream;
31 addonInterface->toKodi->kodi_audioengine->get_current_sink_format = get_current_sink_format;
33 // AEStream add-on function callback table
34 addonInterface->toKodi->kodi_audioengine->aestream_get_space = aestream_get_space;
35 addonInterface->toKodi->kodi_audioengine->aestream_add_data = aestream_add_data;
36 addonInterface->toKodi->kodi_audioengine->aestream_get_delay = aestream_get_delay;
37 addonInterface->toKodi->kodi_audioengine->aestream_is_buffering = aestream_is_buffering;
38 addonInterface->toKodi->kodi_audioengine->aestream_get_cache_time = aestream_get_cache_time;
39 addonInterface->toKodi->kodi_audioengine->aestream_get_cache_total = aestream_get_cache_total;
40 addonInterface->toKodi->kodi_audioengine->aestream_pause = aestream_pause;
41 addonInterface->toKodi->kodi_audioengine->aestream_resume = aestream_resume;
42 addonInterface->toKodi->kodi_audioengine->aestream_drain = aestream_drain;
43 addonInterface->toKodi->kodi_audioengine->aestream_is_draining = aestream_is_draining;
44 addonInterface->toKodi->kodi_audioengine->aestream_is_drained = aestream_is_drained;
45 addonInterface->toKodi->kodi_audioengine->aestream_flush = aestream_flush;
46 addonInterface->toKodi->kodi_audioengine->aestream_get_volume = aestream_get_volume;
47 addonInterface->toKodi->kodi_audioengine->aestream_set_volume = aestream_set_volume;
48 addonInterface->toKodi->kodi_audioengine->aestream_get_amplification = aestream_get_amplification;
49 addonInterface->toKodi->kodi_audioengine->aestream_set_amplification = aestream_set_amplification;
50 addonInterface->toKodi->kodi_audioengine->aestream_get_frame_size = aestream_get_frame_size;
51 addonInterface->toKodi->kodi_audioengine->aestream_get_channel_count = aestream_get_channel_count;
52 addonInterface->toKodi->kodi_audioengine->aestream_get_sample_rate = aestream_get_sample_rate;
53 addonInterface->toKodi->kodi_audioengine->aestream_get_data_format = aestream_get_data_format;
54 addonInterface->toKodi->kodi_audioengine->aestream_get_resample_ratio =
55 aestream_get_resample_ratio;
56 addonInterface->toKodi->kodi_audioengine->aestream_set_resample_ratio =
57 aestream_set_resample_ratio;
60 void Interface_AudioEngine::DeInit(AddonGlobalInterface* addonInterface)
62 if (addonInterface->toKodi) /* <-- Safe check, needed so long old addon way is present */
64 delete addonInterface->toKodi->kodi_audioengine;
65 addonInterface->toKodi->kodi_audioengine = nullptr;
69 AEChannel Interface_AudioEngine::TranslateAEChannelToKodi(AudioEngineChannel channel)
71 switch (channel)
73 case AUDIOENGINE_CH_RAW:
74 return AE_CH_RAW;
75 case AUDIOENGINE_CH_FL:
76 return AE_CH_FL;
77 case AUDIOENGINE_CH_FR:
78 return AE_CH_FR;
79 case AUDIOENGINE_CH_FC:
80 return AE_CH_FC;
81 case AUDIOENGINE_CH_LFE:
82 return AE_CH_LFE;
83 case AUDIOENGINE_CH_BL:
84 return AE_CH_BL;
85 case AUDIOENGINE_CH_BR:
86 return AE_CH_BR;
87 case AUDIOENGINE_CH_FLOC:
88 return AE_CH_FLOC;
89 case AUDIOENGINE_CH_FROC:
90 return AE_CH_FROC;
91 case AUDIOENGINE_CH_BC:
92 return AE_CH_BC;
93 case AUDIOENGINE_CH_SL:
94 return AE_CH_SL;
95 case AUDIOENGINE_CH_SR:
96 return AE_CH_SR;
97 case AUDIOENGINE_CH_TFL:
98 return AE_CH_TFL;
99 case AUDIOENGINE_CH_TFR:
100 return AE_CH_TFR;
101 case AUDIOENGINE_CH_TFC:
102 return AE_CH_TFC;
103 case AUDIOENGINE_CH_TC:
104 return AE_CH_TC;
105 case AUDIOENGINE_CH_TBL:
106 return AE_CH_TBL;
107 case AUDIOENGINE_CH_TBR:
108 return AE_CH_TBR;
109 case AUDIOENGINE_CH_TBC:
110 return AE_CH_TBC;
111 case AUDIOENGINE_CH_BLOC:
112 return AE_CH_BLOC;
113 case AUDIOENGINE_CH_BROC:
114 return AE_CH_BROC;
115 case AUDIOENGINE_CH_MAX:
116 return AE_CH_MAX;
117 case AUDIOENGINE_CH_NULL:
118 default:
119 return AE_CH_NULL;
123 AudioEngineChannel Interface_AudioEngine::TranslateAEChannelToAddon(AEChannel channel)
125 switch (channel)
127 case AE_CH_RAW:
128 return AUDIOENGINE_CH_RAW;
129 case AE_CH_FL:
130 return AUDIOENGINE_CH_FL;
131 case AE_CH_FR:
132 return AUDIOENGINE_CH_FR;
133 case AE_CH_FC:
134 return AUDIOENGINE_CH_FC;
135 case AE_CH_LFE:
136 return AUDIOENGINE_CH_LFE;
137 case AE_CH_BL:
138 return AUDIOENGINE_CH_BL;
139 case AE_CH_BR:
140 return AUDIOENGINE_CH_BR;
141 case AE_CH_FLOC:
142 return AUDIOENGINE_CH_FLOC;
143 case AE_CH_FROC:
144 return AUDIOENGINE_CH_FROC;
145 case AE_CH_BC:
146 return AUDIOENGINE_CH_BC;
147 case AE_CH_SL:
148 return AUDIOENGINE_CH_SL;
149 case AE_CH_SR:
150 return AUDIOENGINE_CH_SR;
151 case AE_CH_TFL:
152 return AUDIOENGINE_CH_TFL;
153 case AE_CH_TFR:
154 return AUDIOENGINE_CH_TFR;
155 case AE_CH_TFC:
156 return AUDIOENGINE_CH_TFC;
157 case AE_CH_TC:
158 return AUDIOENGINE_CH_TC;
159 case AE_CH_TBL:
160 return AUDIOENGINE_CH_TBL;
161 case AE_CH_TBR:
162 return AUDIOENGINE_CH_TBR;
163 case AE_CH_TBC:
164 return AUDIOENGINE_CH_TBC;
165 case AE_CH_BLOC:
166 return AUDIOENGINE_CH_BLOC;
167 case AE_CH_BROC:
168 return AUDIOENGINE_CH_BROC;
169 case AE_CH_MAX:
170 return AUDIOENGINE_CH_MAX;
171 case AE_CH_NULL:
172 default:
173 return AUDIOENGINE_CH_NULL;
177 AEDataFormat Interface_AudioEngine::TranslateAEFormatToKodi(AudioEngineDataFormat format)
179 switch (format)
181 case AUDIOENGINE_FMT_U8:
182 return AE_FMT_U8;
183 case AUDIOENGINE_FMT_S16BE:
184 return AE_FMT_S16BE;
185 case AUDIOENGINE_FMT_S16LE:
186 return AE_FMT_S16LE;
187 case AUDIOENGINE_FMT_S16NE:
188 return AE_FMT_S16NE;
189 case AUDIOENGINE_FMT_S32BE:
190 return AE_FMT_S32BE;
191 case AUDIOENGINE_FMT_S32LE:
192 return AE_FMT_S32LE;
193 case AUDIOENGINE_FMT_S32NE:
194 return AE_FMT_S32NE;
195 case AUDIOENGINE_FMT_S24BE4:
196 return AE_FMT_S24BE4;
197 case AUDIOENGINE_FMT_S24LE4:
198 return AE_FMT_S24LE4;
199 case AUDIOENGINE_FMT_S24NE4:
200 return AE_FMT_S24NE4;
201 case AUDIOENGINE_FMT_S24NE4MSB:
202 return AE_FMT_S24NE4MSB;
203 case AUDIOENGINE_FMT_S24BE3:
204 return AE_FMT_S24BE3;
205 case AUDIOENGINE_FMT_S24LE3:
206 return AE_FMT_S24LE3;
207 case AUDIOENGINE_FMT_S24NE3:
208 return AE_FMT_S24NE3;
209 case AUDIOENGINE_FMT_DOUBLE:
210 return AE_FMT_DOUBLE;
211 case AUDIOENGINE_FMT_FLOAT:
212 return AE_FMT_FLOAT;
213 case AUDIOENGINE_FMT_RAW:
214 return AE_FMT_RAW;
215 case AUDIOENGINE_FMT_U8P:
216 return AE_FMT_U8P;
217 case AUDIOENGINE_FMT_S16NEP:
218 return AE_FMT_S16NEP;
219 case AUDIOENGINE_FMT_S32NEP:
220 return AE_FMT_S32NEP;
221 case AUDIOENGINE_FMT_S24NE4P:
222 return AE_FMT_S24NE4P;
223 case AUDIOENGINE_FMT_S24NE4MSBP:
224 return AE_FMT_S24NE4MSBP;
225 case AUDIOENGINE_FMT_S24NE3P:
226 return AE_FMT_S24NE3P;
227 case AUDIOENGINE_FMT_DOUBLEP:
228 return AE_FMT_DOUBLEP;
229 case AUDIOENGINE_FMT_FLOATP:
230 return AE_FMT_FLOATP;
231 case AUDIOENGINE_FMT_MAX:
232 return AE_FMT_MAX;
233 case AUDIOENGINE_FMT_INVALID:
234 default:
235 return AE_FMT_INVALID;
239 AudioEngineDataFormat Interface_AudioEngine::TranslateAEFormatToAddon(AEDataFormat format)
241 switch (format)
243 case AE_FMT_U8:
244 return AUDIOENGINE_FMT_U8;
245 case AE_FMT_S16BE:
246 return AUDIOENGINE_FMT_S16BE;
247 case AE_FMT_S16LE:
248 return AUDIOENGINE_FMT_S16LE;
249 case AE_FMT_S16NE:
250 return AUDIOENGINE_FMT_S16NE;
251 case AE_FMT_S32BE:
252 return AUDIOENGINE_FMT_S32BE;
253 case AE_FMT_S32LE:
254 return AUDIOENGINE_FMT_S32LE;
255 case AE_FMT_S32NE:
256 return AUDIOENGINE_FMT_S32NE;
257 case AE_FMT_S24BE4:
258 return AUDIOENGINE_FMT_S24BE4;
259 case AE_FMT_S24LE4:
260 return AUDIOENGINE_FMT_S24LE4;
261 case AE_FMT_S24NE4:
262 return AUDIOENGINE_FMT_S24NE4;
263 case AE_FMT_S24NE4MSB:
264 return AUDIOENGINE_FMT_S24NE4MSB;
265 case AE_FMT_S24BE3:
266 return AUDIOENGINE_FMT_S24BE3;
267 case AE_FMT_S24LE3:
268 return AUDIOENGINE_FMT_S24LE3;
269 case AE_FMT_S24NE3:
270 return AUDIOENGINE_FMT_S24NE3;
271 case AE_FMT_DOUBLE:
272 return AUDIOENGINE_FMT_DOUBLE;
273 case AE_FMT_FLOAT:
274 return AUDIOENGINE_FMT_FLOAT;
275 case AE_FMT_RAW:
276 return AUDIOENGINE_FMT_RAW;
277 case AE_FMT_U8P:
278 return AUDIOENGINE_FMT_U8P;
279 case AE_FMT_S16NEP:
280 return AUDIOENGINE_FMT_S16NEP;
281 case AE_FMT_S32NEP:
282 return AUDIOENGINE_FMT_S32NEP;
283 case AE_FMT_S24NE4P:
284 return AUDIOENGINE_FMT_S24NE4P;
285 case AE_FMT_S24NE4MSBP:
286 return AUDIOENGINE_FMT_S24NE4MSBP;
287 case AE_FMT_S24NE3P:
288 return AUDIOENGINE_FMT_S24NE3P;
289 case AE_FMT_DOUBLEP:
290 return AUDIOENGINE_FMT_DOUBLEP;
291 case AE_FMT_FLOATP:
292 return AUDIOENGINE_FMT_FLOATP;
293 case AE_FMT_MAX:
294 return AUDIOENGINE_FMT_MAX;
295 case AE_FMT_INVALID:
296 default:
297 return AUDIOENGINE_FMT_INVALID;
301 AEStreamHandle* Interface_AudioEngine::audioengine_make_stream(void* kodiBase,
302 AUDIO_ENGINE_FORMAT* streamFormat,
303 unsigned int options)
305 if (!kodiBase || !streamFormat)
307 CLog::Log(LOGERROR,
308 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamFormat='{}')",
309 __FUNCTION__, kodiBase, static_cast<void*>(streamFormat));
310 return nullptr;
313 IAE* engine = CServiceBroker::GetActiveAE();
314 if (!engine)
315 return nullptr;
317 CAEChannelInfo layout;
318 for (unsigned int ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch)
320 if (streamFormat->m_channels[ch] == AUDIOENGINE_CH_NULL)
321 break;
322 layout += TranslateAEChannelToKodi(streamFormat->m_channels[ch]);
325 AEAudioFormat format;
326 format.m_channelLayout = layout;
327 format.m_dataFormat = TranslateAEFormatToKodi(streamFormat->m_dataFormat);
328 format.m_sampleRate = streamFormat->m_sampleRate;
330 /* Translate addon options to kodi's options */
331 int kodiOption = 0;
332 if (options & AUDIO_STREAM_FORCE_RESAMPLE)
333 kodiOption |= AESTREAM_FORCE_RESAMPLE;
334 if (options & AUDIO_STREAM_PAUSED)
335 kodiOption |= AESTREAM_PAUSED;
336 if (options & AUDIO_STREAM_AUTOSTART)
337 kodiOption |= AESTREAM_AUTOSTART;
339 return engine->MakeStream(format, kodiOption).release();
342 void Interface_AudioEngine::audioengine_free_stream(void* kodiBase, AEStreamHandle* streamHandle)
344 if (!kodiBase || !streamHandle)
346 CLog::Log(LOGERROR,
347 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
348 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
349 return;
352 IAE* engine = CServiceBroker::GetActiveAE();
353 if (engine)
354 engine->FreeStream(static_cast<IAEStream*>(streamHandle), true);
357 bool Interface_AudioEngine::get_current_sink_format(void* kodiBase, AUDIO_ENGINE_FORMAT* format)
359 if (!kodiBase || !format)
361 CLog::Log(LOGERROR,
362 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', format='{}')",
363 __FUNCTION__, kodiBase, static_cast<void*>(format));
364 return false;
367 IAE* engine = CServiceBroker::GetActiveAE();
368 if (!engine)
369 return false;
371 AEAudioFormat sinkFormat;
372 if (!engine->GetCurrentSinkFormat(sinkFormat))
374 CLog::Log(LOGERROR, "Interface_AudioEngine::{} - failed to get current sink format from AE!",
375 __FUNCTION__);
376 return false;
379 format->m_dataFormat = TranslateAEFormatToAddon(sinkFormat.m_dataFormat);
380 format->m_sampleRate = sinkFormat.m_sampleRate;
381 format->m_frames = sinkFormat.m_frames;
382 format->m_frameSize = sinkFormat.m_frameSize;
383 format->m_channelCount = sinkFormat.m_channelLayout.Count();
384 for (unsigned int ch = 0; ch < format->m_channelCount && ch < AUDIOENGINE_CH_MAX; ++ch)
386 format->m_channels[ch] = TranslateAEChannelToAddon(sinkFormat.m_channelLayout[ch]);
389 return true;
392 unsigned int Interface_AudioEngine::aestream_get_space(void* kodiBase, AEStreamHandle* streamHandle)
394 if (!kodiBase || !streamHandle)
396 CLog::Log(LOGERROR,
397 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
398 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
399 return 0;
402 return static_cast<IAEStream*>(streamHandle)->GetSpace();
405 unsigned int Interface_AudioEngine::aestream_add_data(void* kodiBase,
406 AEStreamHandle* streamHandle,
407 uint8_t* const* data,
408 unsigned int offset,
409 unsigned int frames,
410 double pts,
411 bool hasDownmix,
412 double centerMixLevel)
414 if (!kodiBase || !streamHandle)
416 CLog::Log(LOGERROR,
417 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
418 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
419 return 0;
422 if (!CServiceBroker::GetActiveAE())
423 return 0;
425 IAEStream::ExtData extData;
426 extData.pts = pts;
427 extData.hasDownmix = hasDownmix;
428 extData.centerMixLevel = centerMixLevel;
429 return static_cast<IAEStream*>(streamHandle)->AddData(data, offset, frames, &extData);
432 double Interface_AudioEngine::aestream_get_delay(void* kodiBase, AEStreamHandle* streamHandle)
434 if (!kodiBase || !streamHandle)
436 CLog::Log(LOGERROR,
437 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
438 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
439 return -1.0;
442 if (!CServiceBroker::GetActiveAE())
443 return -1.0;
445 return static_cast<IAEStream*>(streamHandle)->GetDelay();
448 bool Interface_AudioEngine::aestream_is_buffering(void* kodiBase, AEStreamHandle* streamHandle)
450 if (!kodiBase || !streamHandle)
452 CLog::Log(LOGERROR,
453 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
454 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
455 return false;
458 if (!CServiceBroker::GetActiveAE())
459 return false;
461 return static_cast<IAEStream*>(streamHandle)->IsBuffering();
464 double Interface_AudioEngine::aestream_get_cache_time(void* kodiBase, AEStreamHandle* streamHandle)
466 if (!kodiBase || !streamHandle)
468 CLog::Log(LOGERROR,
469 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
470 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
471 return -1.0;
474 if (!CServiceBroker::GetActiveAE())
475 return -1.0;
477 return static_cast<IAEStream*>(streamHandle)->GetCacheTime();
480 double Interface_AudioEngine::aestream_get_cache_total(void* kodiBase, AEStreamHandle* streamHandle)
482 if (!kodiBase || !streamHandle)
484 CLog::Log(LOGERROR,
485 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
486 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
487 return -1.0;
490 if (!CServiceBroker::GetActiveAE())
491 return -1.0;
493 return static_cast<IAEStream*>(streamHandle)->GetCacheTotal();
496 void Interface_AudioEngine::aestream_pause(void* kodiBase, AEStreamHandle* streamHandle)
498 if (!kodiBase || !streamHandle)
500 CLog::Log(LOGERROR,
501 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
502 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
503 return;
506 if (!CServiceBroker::GetActiveAE())
507 return;
509 static_cast<IAEStream*>(streamHandle)->Pause();
512 void Interface_AudioEngine::aestream_resume(void* kodiBase, AEStreamHandle* streamHandle)
514 if (!kodiBase || !streamHandle)
516 CLog::Log(LOGERROR,
517 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
518 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
519 return;
522 static_cast<IAEStream*>(streamHandle)->Resume();
525 void Interface_AudioEngine::aestream_drain(void* kodiBase, AEStreamHandle* streamHandle, bool wait)
527 if (!kodiBase || !streamHandle)
529 CLog::Log(LOGERROR,
530 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
531 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
532 return;
535 if (!CServiceBroker::GetActiveAE())
536 return;
538 static_cast<IAEStream*>(streamHandle)->Drain(wait);
541 bool Interface_AudioEngine::aestream_is_draining(void* kodiBase, AEStreamHandle* streamHandle)
543 if (!kodiBase || !streamHandle)
545 CLog::Log(LOGERROR,
546 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
547 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
548 return false;
551 if (!CServiceBroker::GetActiveAE())
552 return false;
554 return static_cast<IAEStream*>(streamHandle)->IsDraining();
557 bool Interface_AudioEngine::aestream_is_drained(void* kodiBase, AEStreamHandle* streamHandle)
559 if (!kodiBase || !streamHandle)
561 CLog::Log(LOGERROR,
562 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
563 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
564 return false;
567 if (!CServiceBroker::GetActiveAE())
568 return false;
570 return static_cast<IAEStream*>(streamHandle)->IsDrained();
573 void Interface_AudioEngine::aestream_flush(void* kodiBase, AEStreamHandle* streamHandle)
575 if (!kodiBase || !streamHandle)
577 CLog::Log(LOGERROR,
578 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
579 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
580 return;
583 if (!CServiceBroker::GetActiveAE())
584 return;
586 static_cast<IAEStream*>(streamHandle)->Flush();
589 float Interface_AudioEngine::aestream_get_volume(void* kodiBase, AEStreamHandle* streamHandle)
591 if (!kodiBase || !streamHandle)
593 CLog::Log(LOGERROR,
594 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
595 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
596 return -1.0f;
599 if (!CServiceBroker::GetActiveAE())
600 return -1.0f;
602 return static_cast<IAEStream*>(streamHandle)->GetVolume();
605 void Interface_AudioEngine::aestream_set_volume(void* kodiBase,
606 AEStreamHandle* streamHandle,
607 float volume)
609 if (!kodiBase || !streamHandle)
611 CLog::Log(LOGERROR,
612 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
613 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
614 return;
617 if (!CServiceBroker::GetActiveAE())
618 return;
620 static_cast<IAEStream*>(streamHandle)->SetVolume(volume);
623 float Interface_AudioEngine::aestream_get_amplification(void* kodiBase,
624 AEStreamHandle* streamHandle)
626 if (!kodiBase || !streamHandle)
628 CLog::Log(LOGERROR,
629 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
630 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
631 return -1.0f;
634 if (!CServiceBroker::GetActiveAE())
635 return -1.0f;
637 return static_cast<IAEStream*>(streamHandle)->GetAmplification();
640 void Interface_AudioEngine::aestream_set_amplification(void* kodiBase,
641 AEStreamHandle* streamHandle,
642 float amplify)
644 if (!kodiBase || !streamHandle)
646 CLog::Log(LOGERROR,
647 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
648 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
649 return;
652 if (!CServiceBroker::GetActiveAE())
653 return;
655 static_cast<IAEStream*>(streamHandle)->SetAmplification(amplify);
658 unsigned int Interface_AudioEngine::aestream_get_frame_size(void* kodiBase,
659 AEStreamHandle* streamHandle)
661 if (!kodiBase || !streamHandle)
663 CLog::Log(LOGERROR,
664 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
665 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
666 return 0;
669 if (!CServiceBroker::GetActiveAE())
670 return 0;
672 return static_cast<IAEStream*>(streamHandle)->GetFrameSize();
675 unsigned int Interface_AudioEngine::aestream_get_channel_count(void* kodiBase,
676 AEStreamHandle* streamHandle)
678 if (!kodiBase || !streamHandle)
680 CLog::Log(LOGERROR,
681 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
682 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
683 return 0;
686 if (!CServiceBroker::GetActiveAE())
687 return 0;
689 return static_cast<IAEStream*>(streamHandle)->GetChannelCount();
692 unsigned int Interface_AudioEngine::aestream_get_sample_rate(void* kodiBase,
693 AEStreamHandle* streamHandle)
695 if (!kodiBase || !streamHandle)
697 CLog::Log(LOGERROR,
698 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
699 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
700 return 0;
703 if (!CServiceBroker::GetActiveAE())
704 return 0;
706 return static_cast<IAEStream*>(streamHandle)->GetSampleRate();
709 AudioEngineDataFormat Interface_AudioEngine::aestream_get_data_format(void* kodiBase,
710 AEStreamHandle* streamHandle)
712 if (!kodiBase || !streamHandle)
714 CLog::Log(LOGERROR,
715 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
716 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
717 return AUDIOENGINE_FMT_INVALID;
720 if (!CServiceBroker::GetActiveAE())
721 return AUDIOENGINE_FMT_INVALID;
723 return TranslateAEFormatToAddon(static_cast<IAEStream*>(streamHandle)->GetDataFormat());
726 double Interface_AudioEngine::aestream_get_resample_ratio(void* kodiBase,
727 AEStreamHandle* streamHandle)
729 if (!kodiBase || !streamHandle)
731 CLog::Log(LOGERROR,
732 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
733 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
734 return -1.0;
737 if (!CServiceBroker::GetActiveAE())
738 return -1.0;
740 return static_cast<IAEStream*>(streamHandle)->GetResampleRatio();
743 void Interface_AudioEngine::aestream_set_resample_ratio(void* kodiBase,
744 AEStreamHandle* streamHandle,
745 double ratio)
747 if (!kodiBase || !streamHandle)
749 CLog::Log(LOGERROR,
750 "Interface_AudioEngine::{} - invalid stream data (kodiBase='{}', streamHandle='{}')",
751 __FUNCTION__, kodiBase, static_cast<void*>(streamHandle));
752 return;
755 if (!CServiceBroker::GetActiveAE())
756 return;
758 static_cast<IAEStream*>(streamHandle)->SetResampleRatio(ratio);
761 } /* namespace ADDON */