dolphin/Source/Core/AudioCommon/WASAPIStream.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.4 KiB
C
Raw Normal View History

2018-02-10 21:03:27 +01:00
// Copyright 2018 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2018-02-10 21:03:27 +01:00
#pragma once
2024-08-13 21:33:10 +02:00
#ifdef _WIN32
2018-02-10 21:03:27 +01:00
// clang-format off
#include <Windows.h>
#include <mmreg.h>
#include <objbase.h>
2018-02-10 21:03:27 +01:00
// clang-format on
#include <atomic>
#include <string>
#include <thread>
#include <vector>
#include <wrl/client.h>
2024-08-29 22:02:28 +02:00
#endif
2018-02-10 21:03:27 +01:00
#include "AudioCommon/SoundStream.h"
struct IAudioClient;
struct IAudioRenderClient;
struct IMMDevice;
struct IMMDeviceEnumerator;
class WASAPIStream final : public SoundStream
{
2024-08-13 21:33:10 +02:00
#ifdef _WIN32
2018-02-10 21:03:27 +01:00
public:
explicit WASAPIStream();
~WASAPIStream();
bool Init() override;
bool SetRunning(bool running) override;
static bool IsValid();
2018-02-10 21:03:27 +01:00
static std::vector<std::string> GetAvailableDevices();
static Microsoft::WRL::ComPtr<IMMDevice> GetDeviceByName(std::string_view name);
2018-02-10 21:03:27 +01:00
private:
void SoundLoop();
2018-02-10 21:03:27 +01:00
u32 m_frames_in_buffer = 0;
std::atomic<bool> m_running = false;
std::thread m_thread;
// CoUninitialize must be called after all WASAPI COM objects have been destroyed,
// therefore this member must be located before them, as first class fields are destructed last
2024-08-13 21:33:10 +02:00
bool m_coinitialize{false};
Microsoft::WRL::ComPtr<IMMDeviceEnumerator> m_enumerator;
Microsoft::WRL::ComPtr<IAudioClient> m_audio_client;
Microsoft::WRL::ComPtr<IAudioRenderClient> m_audio_renderer;
2024-08-13 21:33:10 +02:00
HANDLE m_need_data_event;
2018-02-10 21:03:27 +01:00
WAVEFORMATEXTENSIBLE m_format;
2024-08-29 22:02:28 +02:00
#endif // _MSC_VER
2018-02-10 21:03:27 +01:00
};