blob: 9c6ef67d45852fe33330d21c7ecae0e62caf2bc2 (
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
|
/* SPDX-License-Identifier: BSD-3-Clause */
/* SPDX-FileCopyrightText: Olivier Lapicque */
/* SPDX-FileCopyrightText: OpenMPT Project Developers and Contributors */
#pragma once
#include "openmpt/all/BuildSettings.hpp"
#include "SoundDevice.hpp"
#include "SoundDeviceUtilities.hpp"
#include "openmpt/base/Types.hpp"
#include "openmpt/logging/Logger.hpp"
#include <atomic>
#include <memory>
#include <vector>
#if defined(MPT_WITH_DIRECTSOUND)
#include <dsound.h>
#endif // MPT_WITH_DIRECTSOUND
OPENMPT_NAMESPACE_BEGIN
namespace SoundDevice
{
#if defined(MPT_WITH_DIRECTSOUND)
class CDSoundDevice : public CSoundDeviceWithThread
{
protected:
IDirectSound *m_piDS;
IDirectSoundBuffer *m_pPrimary;
IDirectSoundBuffer *m_pMixBuffer;
uint32 m_nDSoundBufferSize;
BOOL m_bMixRunning;
DWORD m_dwWritePos;
std::atomic<uint32> m_StatisticLatencyFrames;
std::atomic<uint32> m_StatisticPeriodFrames;
public:
CDSoundDevice(ILogger &logger, SoundDevice::Info info, SoundDevice::SysInfo sysInfo);
~CDSoundDevice();
public:
bool InternalOpen();
bool InternalClose();
void InternalFillAudioBuffer();
void StartFromSoundThread();
void StopFromSoundThread();
bool InternalIsOpen() const { return (m_pMixBuffer != NULL); }
SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const;
SoundDevice::Statistics GetStatistics() const;
SoundDevice::Caps InternalGetDeviceCaps();
SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates);
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);
};
#endif // MPT_WITH_DIRECTSOUND
} // namespace SoundDevice
OPENMPT_NAMESPACE_END
|