mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-20 01:59:17 +00:00
Splits the WASAPINotify class out of win-wasapi.cpp and makes it a shared object in the plugin, then also creates a callback to reset audio monitoring if the default output device changes.
35 lines
785 B
C++
35 lines
785 B
C++
#pragma once
|
|
|
|
#include <util/windows/ComPtr.hpp>
|
|
#include <Mmdeviceapi.h>
|
|
|
|
#include <unordered_map>
|
|
#include <functional>
|
|
#include <mutex>
|
|
|
|
typedef std::function<void(EDataFlow, ERole, LPCWSTR)>
|
|
WASAPINotifyDefaultDeviceChangedCallback;
|
|
|
|
class NotificationClient;
|
|
|
|
class WASAPINotify {
|
|
public:
|
|
WASAPINotify();
|
|
~WASAPINotify();
|
|
|
|
void AddDefaultDeviceChangedCallback(
|
|
void *handle, WASAPINotifyDefaultDeviceChangedCallback cb);
|
|
void RemoveDefaultDeviceChangedCallback(void *handle);
|
|
|
|
private:
|
|
void OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR id);
|
|
|
|
std::mutex mutex;
|
|
|
|
ComPtr<IMMDeviceEnumerator> enumerator;
|
|
ComPtr<NotificationClient> notificationClient;
|
|
|
|
std::unordered_map<void *, WASAPINotifyDefaultDeviceChangedCallback>
|
|
defaultDeviceChangedCallbacks;
|
|
};
|