xbmc
AESinkDARWINOSX.h
1 /*
2  * Copyright (C) 2005-2018 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 #include "cores/AudioEngine/Interfaces/AESink.h"
12 #include "cores/AudioEngine/Sinks/osx/CoreAudioDevice.h"
13 #include "cores/AudioEngine/Utils/AEDeviceInfo.h"
14 
15 class AERingBuffer;
16 struct AEDelayStatus;
17 
18 class CAESinkDARWINOSX : public IAESink
19 {
20 public:
21  const char* GetName() override { return "DARWINOSX"; }
22 
24  ~CAESinkDARWINOSX() override;
25 
26  static void Register();
27  static void EnumerateDevicesEx(AEDeviceInfoList &list, bool force);
28  static std::unique_ptr<IAESink> Create(std::string& device, AEAudioFormat& desiredFormat);
29 
30  bool Initialize(AEAudioFormat& format, std::string& device) override;
31  void Deinitialize() override;
32 
33  void GetDelay(AEDelayStatus& status) override;
34  double GetCacheTotal() override;
35  unsigned int AddPackets(uint8_t** data, unsigned int frames, unsigned int offset) override;
36  void Drain() override;
37 
38 private:
39  static OSStatus renderCallback(AudioDeviceID inDevice, const AudioTimeStamp* inNow, const AudioBufferList* inInputData, const AudioTimeStamp* inInputTime, AudioBufferList* outOutputData, const AudioTimeStamp* inOutputTime, void* inClientData);
40  void SetHogMode(bool on);
41 
42  CAEDeviceInfo m_info;
43 
44  CCoreAudioDevice m_device;
45  CCoreAudioStream m_outputStream;
46  unsigned int m_latentFrames = 0;
47  unsigned int m_outputBufferIndex = 0;
48 
49  bool m_outputBitstream =
50  false;
51  unsigned int m_planes = 1;
52  unsigned int m_frameSizePerPlane = 0;
53  unsigned int m_framesPerSecond = 0;
54 
55  AERingBuffer* m_buffer = nullptr;
56  volatile bool m_started =
57  false; // set once we get a callback from CoreAudio, which can take a little while.
58 
59  CAESpinSection m_render_locker;
60  volatile int64_t m_render_tick = 0;
61  volatile double m_render_delay = 0.0;
62 };
This classt provides the details of what the audio output hardware is capable of. ...
Definition: AEDeviceInfo.h:31
bool Initialize(AEAudioFormat &format, std::string &device) override
Definition: AESinkDARWINOSX.cpp:181
Definition: AESink.h:18
Definition: AESinkDARWINOSX.h:18
Definition: CoreAudioStream.h:23
Definition: CoreAudioDevice.h:25
The audio format structure that fully defines a stream&#39;s audio information.
Definition: AEAudioFormat.h:19
Definition: AEUtil.h:27
lockless consistency guaranteeer
Definition: AEUtil.h:54
This buffer can be used by one read and one write thread at any one time without the risk of data cor...
Definition: AERingBuffer.h:29
unsigned int AddPackets(uint8_t **data, unsigned int frames, unsigned int offset) override
Adds packets to be sent out, this routine MUST block or sleep.
Definition: AESinkDARWINOSX.cpp:422
void GetDelay(AEDelayStatus &status) override
Return a timestamped status structure with delay and sink info.
Definition: AESinkDARWINOSX.cpp:391