]> repos.lx-s.de Git - winmute.git/commitdiff
Changed COM interface definitions
authorlx-s <lx-s@users.noreply.github.com>
Wed, 2 Oct 2024 06:42:14 +0000 (08:42 +0200)
committerlx-s <lx-s@users.noreply.github.com>
Wed, 2 Oct 2024 06:42:14 +0000 (08:42 +0200)
WinMute/MMNotificationClient.cpp
WinMute/MMNotificationClient.h
WinMute/common.h

index cea710d143c978d380d76668fdce09ed6883ab11..a6dacc8df259af9ca57b0812499a246b1bdc6c90 100644 (file)
@@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
 class WinAudio;
 
 MMNotificationClient::MMNotificationClient(WinAudio* notifyParent) :
-   ref_(1), pEnumerator_(nullptr), notifyParent_(notifyParent)
+   ref_count_(1), pEnumerator_(nullptr), notifyParent_(notifyParent)
 {
 }
 
@@ -49,21 +49,21 @@ MMNotificationClient::~MMNotificationClient()
    SafeRelease(&pEnumerator_);
 }
 
-ULONG STDMETHODCALLTYPE MMNotificationClient::AddRef()
+STDMETHODIMP_(ULONG) MMNotificationClient::AddRef()
 {
-   return InterlockedIncrement(&ref_);
+   return ++ref_count_;
 }
 
-ULONG STDMETHODCALLTYPE MMNotificationClient::Release()
+STDMETHODIMP_(ULONG) MMNotificationClient::Release()
 {
-   ULONG ref = InterlockedDecrement(&ref_);
+   const ULONG ref = --ref_count_;
    if (ref == 0) {
       delete this;
    }
    return ref;
 }
 
-HRESULT STDMETHODCALLTYPE MMNotificationClient::QueryInterface(
+STDMETHODIMP_(HRESULT) MMNotificationClient::QueryInterface(
    REFIID riid, VOID** ppvInterface)
 {
    if (IID_IUnknown == riid) {
@@ -80,13 +80,13 @@ HRESULT STDMETHODCALLTYPE MMNotificationClient::QueryInterface(
 }
 
 
-HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDefaultDeviceChanged(
+STDMETHODIMP_(HRESULT) MMNotificationClient::OnDefaultDeviceChanged(
    EDataFlow, ERole, LPCWSTR)
 {
    return S_OK;
 }
 
-HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDeviceAdded(LPCWSTR pwstrDeviceId)
+STDMETHODIMP_(HRESULT) MMNotificationClient::OnDeviceAdded(LPCWSTR pwstrDeviceId)
 {
    if (notifyParent_ && pwstrDeviceId != nullptr) {
       const auto deviceName = GetFriendlyDeviceName(pwstrDeviceId);
@@ -96,7 +96,7 @@ HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDeviceAdded(LPCWSTR pwstrDevic
    return S_OK;
 }
 
-HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDeviceRemoved(LPCWSTR pwstrDeviceId)
+STDMETHODIMP_(HRESULT) MMNotificationClient::OnDeviceRemoved(LPCWSTR pwstrDeviceId)
 {
    if (notifyParent_ && pwstrDeviceId != nullptr) {
       const auto deviceName = GetFriendlyDeviceName(pwstrDeviceId);
@@ -106,7 +106,7 @@ HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDeviceRemoved(LPCWSTR pwstrDev
    return S_OK;
 }
 
-HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDeviceStateChanged(
+STDMETHODIMP_(HRESULT) MMNotificationClient::OnDeviceStateChanged(
    LPCWSTR pwstrDeviceId, DWORD dwNewState)
 {
    bool notify = true;
@@ -136,7 +136,7 @@ HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDeviceStateChanged(
    return S_OK;
 }
 
-HRESULT STDMETHODCALLTYPE MMNotificationClient::OnPropertyValueChanged(
+STDMETHODIMP_(HRESULT) MMNotificationClient::OnPropertyValueChanged(
    LPCWSTR, const PROPERTYKEY)
 {
    return S_OK;
index 7452816564552ccd342c7552f68377c866ec83fc..acc832c92454ca7300a81a90019624b8fbe9ccaa 100644 (file)
@@ -42,21 +42,21 @@ public:
    explicit MMNotificationClient(WinAudio* notifyParent);
    ~MMNotificationClient();
 
-   ULONG STDMETHODCALLTYPE AddRef();
-   ULONG STDMETHODCALLTYPE Release();
-   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID** ppvInterface);
+   STDMETHODIMP_(ULONG) AddRef();
+   STDMETHODIMP_(ULONG) Release();
+   STDMETHODIMP_(HRESULT) QueryInterface(REFIID riid, VOID** ppvInterface);
 
-   HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow flow, ERole role,
+   STDMETHODIMP_(HRESULT) OnDefaultDeviceChanged(EDataFlow flow, ERole role,
       LPCWSTR pwstrDeviceId);
-   HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId);
-   HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId);
-   HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR pwstrDeviceId,
+   STDMETHODIMP_(HRESULT) OnDeviceAdded(LPCWSTR pwstrDeviceId);
+   STDMETHODIMP_(HRESULT) OnDeviceRemoved(LPCWSTR pwstrDeviceId);
+   STDMETHODIMP_(HRESULT) OnDeviceStateChanged(LPCWSTR pwstrDeviceId,
       DWORD dwNewState);
-   HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(LPCWSTR pwstrDeviceId,
+   STDMETHODIMP_(HRESULT) OnPropertyValueChanged(LPCWSTR pwstrDeviceId,
       const PROPERTYKEY key);
 
 private:
-   LONG ref_;
+   std::atomic<LONG> ref_count_;
    IMMDeviceEnumerator* pEnumerator_;
    WinAudio* notifyParent_;
 
index 30b326751574347f8a9717f31497510050807eb2..ecb0c95ccbd3cc4192ad94d82a72a8c1684d02d7 100644 (file)
@@ -55,6 +55,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #define _WIN32_WINNT 0x0601
 #include <sdkddkver.h>
 
+#include <atomic>
 #include <algorithm>
 #include <array>
 #include <cassert>