blob: 0fb790bf819cd66557bc423f39350cc910df3691 (
plain) (
blame)
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
|
/* SPDX-License-Identifier: BSD-3-Clause */
/* SPDX-FileCopyrightText: OpenMPT Project Developers and Contributors */
#pragma once
#include "openmpt/all/BuildSettings.hpp"
#include "SoundDevice.hpp"
#include "SoundDeviceUtilities.hpp"
#include "mpt/string/types.hpp"
#include "openmpt/base/Types.hpp"
#include "openmpt/logging/Logger.hpp"
#include <memory>
#include <vector>
#if defined(MPT_WITH_PULSEAUDIO) && defined(MPT_WITH_PULSEAUDIOSIMPLE)
#include <pulse/pulseaudio.h>
#include <pulse/simple.h>
#endif // MPT_WITH_PULSEAUDIO && MPT_WITH_PULSEAUDIOSIMPLE
OPENMPT_NAMESPACE_BEGIN
namespace SoundDevice
{
#if defined(MPT_WITH_PULSEAUDIO) && defined(MPT_WITH_PULSEAUDIOSIMPLE)
class PulseaudioSimple
: public ThreadBase
{
private:
static mpt::ustring PulseErrorString(int error);
public:
static std::unique_ptr<SoundDevice::BackendInitializer> BackendInitializer() { return std::make_unique<SoundDevice::BackendInitializer>(); }
static std::vector<SoundDevice::Info> EnumerateDevices(ILogger &logger, SoundDevice::SysInfo sysInfo);
public:
PulseaudioSimple(ILogger &logger, SoundDevice::Info info, SoundDevice::SysInfo sysInfo);
SoundDevice::Caps InternalGetDeviceCaps();
SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates);
bool InternalIsOpen() const;
bool InternalOpen();
void InternalStartFromSoundThread();
void InternalFillAudioBuffer();
void InternalWaitFromSoundThread();
SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const;
SoundDevice::Statistics GetStatistics() const;
void InternalStopFromSoundThread();
bool InternalClose();
~PulseaudioSimple();
private:
pa_simple *m_PA_SimpleOutput;
SoundDevice::BufferAttributes m_EffectiveBufferAttributes;
std::vector<float32> m_OutputBuffer;
std::atomic<uint32> m_StatisticLastLatencyFrames;
};
#endif // MPT_WITH_PULSEAUDIO && MPT_WITH_PULSEAUDIOSIMPLE
} // namespace SoundDevice
OPENMPT_NAMESPACE_END
|