aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/wasapi.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-31 22:11:15 -0700
committerChris Robinson <[email protected]>2023-06-01 06:33:41 -0700
commitedc20c87d3cd37608e8fa50556d718cd32755f3d (patch)
treeca712a140ff79a21ba2c49d5c13b686c9679a143 /alc/backends/wasapi.cpp
parentd684c7617f2e13572b1c3f9a933a23e1f0e32d49 (diff)
Specify the device type for the event callback
Diffstat (limited to 'alc/backends/wasapi.cpp')
-rw-r--r--alc/backends/wasapi.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index ccdc54e7..32a4334d 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -237,23 +237,33 @@ public:
#if defined(ALSOFT_UWP)
mActiveClientEvent = CreateEventW(nullptr, FALSE, FALSE, nullptr);
- auto cb = [](const WCHAR *devid)
+ auto cb = [](alc::DeviceType type, const WCHAR *devid)
{
const std::string msg{"Default device changed: "+wstr_to_utf8(devid)};
- alc::Event(alc::EventType::DefaultDeviceChanged, msg);
+ alc::Event(alc::EventType::DefaultDeviceChanged, type, msg);
};
mRenderDeviceChangedToken = MediaDevice::DefaultAudioRenderDeviceChanged +=
ref new TypedEventHandler<Platform::Object ^, DefaultAudioRenderDeviceChangedEventArgs ^>(
[this,cb](Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args) {
- if (args->Role == AudioDeviceRole::Default)
- cb(args->Id->Data());
+ if(args->Role == AudioDeviceRole::Default)
+ {
+ const std::string msg{"Default playback device changed: "+
+ wstr_to_utf8(args->Id->Data())};
+ alc::Event(alc::EventType::DefaultDeviceChanged, alc::DeviceType::Playback,
+ msg);
+ }
});
mCaptureDeviceChangedToken = MediaDevice::DefaultAudioCaptureDeviceChanged +=
ref new TypedEventHandler<Platform::Object ^, DefaultAudioCaptureDeviceChangedEventArgs ^>(
[this,cb](Platform::Object ^ sender, DefaultAudioCaptureDeviceChangedEventArgs ^ args) {
- if (args->Role == AudioDeviceRole::Default)
- cb(args->Id->Data());
+ if(args->Role == AudioDeviceRole::Default)
+ {
+ const std::string msg{"Default capture device changed: "+
+ wstr_to_utf8(args->Id->Data())};
+ alc::Event(alc::EventType::DefaultDeviceChanged, alc::DeviceType::Capture,
+ msg);
+ }
});
#else
HRESULT hr{CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER,
@@ -370,10 +380,20 @@ public:
STDMETHODIMP OnPropertyValueChanged(LPCWSTR /*pwstrDeviceId*/, const PROPERTYKEY /*key*/) noexcept override { return S_OK; }
STDMETHODIMP OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId) noexcept override
{
- if(role == eMultimedia && (flow == eRender || flow == eCapture))
+ if(role != eMultimedia)
+ return S_OK;
+
+ if(flow == eRender)
+ {
+ const std::string msg{"Default playback device changed: "+
+ wstr_to_utf8(pwstrDefaultDeviceId)};
+ alc::Event(alc::EventType::DefaultDeviceChanged, alc::DeviceType::Playback, msg);
+ }
+ else if(flow == eCapture)
{
- const std::string msg{"Default device changed: "+wstr_to_utf8(pwstrDefaultDeviceId)};
- alc::Event(alc::EventType::DefaultDeviceChanged, msg);
+ const std::string msg{"Default capture device changed: "+
+ wstr_to_utf8(pwstrDefaultDeviceId)};
+ alc::Event(alc::EventType::DefaultDeviceChanged, alc::DeviceType::Capture, msg);
}
return S_OK;
}