-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
/
ActiveAESink.h
146 lines (129 loc) · 3.08 KB
/
ActiveAESink.h
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
/*
* Copyright (C) 2010-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/AESinkFactory.h"
#include "cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.h"
#include "cores/AudioEngine/Interfaces/AE.h"
#include "cores/AudioEngine/Interfaces/AESink.h"
#include "threads/Event.h"
#include "threads/Thread.h"
#include "utils/ActorProtocol.h"
class CAEBitstreamPacker;
namespace ActiveAE
{
using namespace Actor;
class CEngineStats;
struct SinkConfig
{
AEAudioFormat format;
CEngineStats *stats;
const std::string *device;
};
struct SinkReply
{
AEAudioFormat format;
float cacheTotal;
float latency;
bool hasVolume;
};
class CSinkControlProtocol : public Protocol
{
public:
CSinkControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
enum OutSignal
{
CONFIGURE,
UNCONFIGURE,
STREAMING,
APPFOCUSED,
VOLUME,
FLUSH,
TIMEOUT,
SETSILENCETIMEOUT,
SETNOISETYPE,
};
enum InSignal
{
ACC,
ERR,
STATS,
};
};
class CSinkDataProtocol : public Protocol
{
public:
CSinkDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
enum OutSignal
{
SAMPLE = 0,
DRAIN,
};
enum InSignal
{
RETURNSAMPLE,
ACC,
};
};
class CActiveAESink : private CThread
{
public:
explicit CActiveAESink(CEvent *inMsgEvent);
void EnumerateSinkList(bool force, std::string driver);
void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough);
void Start();
void Dispose();
AEDeviceType GetDeviceType(const std::string &device);
bool HasPassthroughDevice();
bool SupportsFormat(const std::string &device, AEAudioFormat &format);
bool DeviceExist(std::string driver, std::string device);
CSinkControlProtocol m_controlPort;
CSinkDataProtocol m_dataPort;
protected:
void Process() override;
void StateMachine(int signal, Protocol *port, Message *msg);
void PrintSinks(std::string& driver);
void GetDeviceFriendlyName(std::string &device);
void OpenSink();
void ReturnBuffers();
void SetSilenceTimer();
bool NeedIECPacking();
unsigned int OutputSamples(CSampleBuffer* samples);
void SwapInit(CSampleBuffer* samples);
void GenerateNoise();
CEvent m_outMsgEvent;
CEvent *m_inMsgEvent;
int m_state;
bool m_bStateMachineSelfTrigger;
int m_extTimeout;
int m_silenceTimeOut;
bool m_extError;
unsigned int m_extSilenceTimeout;
bool m_extAppFocused;
bool m_extStreaming;
XbmcThreads::EndTime m_extSilenceTimer;
CSampleBuffer m_sampleOfSilence;
enum
{
CHECK_SWAP,
NEED_CONVERT,
NEED_BYTESWAP,
SKIP_SWAP,
} m_swapState;
std::string m_deviceFriendlyName;
std::string m_device;
std::vector<AE::AESinkInfo> m_sinkInfoList;
IAESink *m_sink;
AEAudioFormat m_sinkFormat, m_requestedFormat;
CEngineStats *m_stats;
float m_volume;
int m_sinkLatency;
CAEBitstreamPacker *m_packer;
bool m_needIecPack;
bool m_streamNoise;
};
}