From a196dfe50d1d8a2fcd2ffbe5c8eea10687f1698f Mon Sep 17 00:00:00 2001 From: spycrab Date: Sat, 10 Feb 2018 21:03:27 +0100 Subject: AudioCommon: Implement WASAPI --- Source/Core/AudioCommon/WASAPIStream.h | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Source/Core/AudioCommon/WASAPIStream.h (limited to 'Source/Core/AudioCommon/WASAPIStream.h') diff --git a/Source/Core/AudioCommon/WASAPIStream.h b/Source/Core/AudioCommon/WASAPIStream.h new file mode 100644 index 0000000000..54becb68c0 --- /dev/null +++ b/Source/Core/AudioCommon/WASAPIStream.h @@ -0,0 +1,52 @@ +// Copyright 2018 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#ifdef _WIN32 +// clang-format off +#include +#include +// clang-format on +#endif + +#include +#include +#include +#include + +#include "AudioCommon/SoundStream.h" + +struct IAudioClient; +struct IAudioRenderClient; +struct IMMDevice; +struct IMMDeviceEnumerator; + +class WASAPIStream final : public SoundStream +{ +#ifdef _WIN32 +public: + explicit WASAPIStream(); + ~WASAPIStream(); + bool Init() override; + bool SetRunning(bool running) override; + void SoundLoop() override; + + static bool isValid(); + static std::vector GetAvailableDevices(); + static IMMDevice* GetDeviceByName(std::string name); + +private: + u32 m_frames_in_buffer = 0; + std::atomic m_running = false; + std::atomic m_stopped = false; + std::thread m_thread; + + IAudioClient* m_audio_client = nullptr; + IAudioRenderClient* m_audio_renderer = nullptr; + IMMDeviceEnumerator* m_enumerator = nullptr; + HANDLE m_need_data_event = nullptr; + WAVEFORMATEXTENSIBLE m_format; +#endif // _WIN32 +}; -- cgit v1.2.3