diff options
| author | spycrab <spycrab@users.noreply.github.com> | 2018-05-26 20:04:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-26 20:04:55 +0200 |
| commit | 71c6eb2a5d5cbd8aeff9bc8da02fe9a57dfa119c (patch) | |
| tree | 54be1b33b18679704d715e22a863b921f4219be3 /Source/Core/AudioCommon/WASAPIStream.h | |
| parent | 36f5af6c86490cd080a633d6cb45b4d0cd5b773e (diff) | |
| parent | a196dfe50d1d8a2fcd2ffbe5c8eea10687f1698f (diff) | |
Merge pull request #6372 from spycrab/wasapi
AudioCommon: Implement WASAPI (Exclusive Mode)
Diffstat (limited to 'Source/Core/AudioCommon/WASAPIStream.h')
| -rw-r--r-- | Source/Core/AudioCommon/WASAPIStream.h | 52 |
1 files changed, 52 insertions, 0 deletions
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 <Windows.h> +#include <mmreg.h> +// clang-format on +#endif + +#include <atomic> +#include <string> +#include <thread> +#include <vector> + +#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<std::string> GetAvailableDevices(); + static IMMDevice* GetDeviceByName(std::string name); + +private: + u32 m_frames_in_buffer = 0; + std::atomic<bool> m_running = false; + std::atomic<bool> 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 +}; |
