/* 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 #include #include #if defined(MPT_WITH_DIRECTSOUND) #include #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 m_StatisticLatencyFrames; std::atomic 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 &baseSampleRates); public: static std::unique_ptr BackendInitializer() { return std::make_unique(); } static std::vector EnumerateDevices(ILogger &logger, SoundDevice::SysInfo sysInfo); }; #endif // MPT_WITH_DIRECTSOUND } // namespace SoundDevice OPENMPT_NAMESPACE_END