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
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "cores/AudioEngine/Interfaces/AESink.h"
#include "cores/AudioEngine/Sinks/osx/CoreAudioDevice.h"
#include "cores/AudioEngine/Utils/AEDeviceInfo.h"
class AERingBuffer;
struct AEDelayStatus;
class CAESinkDARWINOSX : public IAESink
{
public:
const char* GetName() override { return "DARWINOSX"; }
CAESinkDARWINOSX();
~CAESinkDARWINOSX() override;
static void Register();
static void EnumerateDevicesEx(AEDeviceInfoList &list, bool force);
static IAESink* Create(std::string &device, AEAudioFormat &desiredFormat);
bool Initialize(AEAudioFormat& format, std::string& device) override;
void Deinitialize() override;
void GetDelay(AEDelayStatus& status) override;
double GetCacheTotal() override;
unsigned int AddPackets(uint8_t** data, unsigned int frames, unsigned int offset) override;
void Drain() override;
private:
static OSStatus renderCallback(AudioDeviceID inDevice, const AudioTimeStamp* inNow, const AudioBufferList* inInputData, const AudioTimeStamp* inInputTime, AudioBufferList* outOutputData, const AudioTimeStamp* inOutputTime, void* inClientData);
void SetHogMode(bool on);
CAEDeviceInfo m_info;
CCoreAudioDevice m_device;
CCoreAudioStream m_outputStream;
unsigned int m_latentFrames = 0;
unsigned int m_outputBufferIndex = 0;
bool m_outputBitstream =
false; ///< true if we're bistreaming into a LinearPCM stream rather than AC3 stream.
unsigned int m_planes = 1; ///< number of audio planes (1 if non-planar)
unsigned int m_frameSizePerPlane = 0; ///< frame size (per plane) in bytes
unsigned int m_framesPerSecond = 0; ///< sample rate
AERingBuffer* m_buffer = nullptr;
volatile bool m_started =
false; // set once we get a callback from CoreAudio, which can take a little while.
CAESpinSection m_render_locker;
volatile int64_t m_render_tick = 0;
volatile double m_render_delay = 0.0;
};
|