mirror of
https://github.com/WinDurango/WinDurango.git
synced 2026-01-07 11:49:45 -06:00
This commit introduces a new `Logger` class to replace all instances of `printf` and `DEBUG_LOG` throughout the codebase. Key changes include: - Replaced logging calls in `Audio2.cpp` and `appmodel.cpp` with structured log levels (`LOG_WARNING`, `LOG_DEBUG`, etc.). - Removed `DebugLogger.h` and `Logger.cpp`, consolidating logging functionality into `Logger.h`. - Added `Config.h` for configuration management using TOML files. - Updated project files to reflect the removal of old logging files and inclusion of the new logging system. These changes enhance logging capabilities, improve code maintainability, and standardize logging practices across the codebase.
68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
#include "pch.h"
|
|
#include "MMDeviceCollectionWrapper.h"
|
|
#include <stdio.h>
|
|
|
|
MMDeviceCollectionWrapper::MMDeviceCollectionWrapper(IMMDeviceCollection* realCollection)
|
|
: m_realCollection(realCollection)
|
|
{
|
|
if (m_realCollection)
|
|
m_realCollection->AddRef();
|
|
}
|
|
|
|
HRESULT STDMETHODCALLTYPE MMDeviceCollectionWrapper::QueryInterface(REFIID riid, void** ppvObject)
|
|
{
|
|
LPOLESTR str = nullptr;
|
|
StringFromIID(riid, &str);
|
|
LOG_INFO_W(L"[QueryInterface] IID requested: %ls\n", str);
|
|
CoTaskMemFree(str);
|
|
if (!ppvObject) return E_POINTER;
|
|
|
|
if (riid == IID_IUnknown || riid == __uuidof(IMMDeviceCollection))
|
|
{
|
|
*ppvObject = static_cast<IMMDeviceCollection*>(this);
|
|
AddRef();
|
|
return S_OK;
|
|
}
|
|
|
|
return m_realCollection->QueryInterface(riid, ppvObject);
|
|
}
|
|
|
|
ULONG STDMETHODCALLTYPE MMDeviceCollectionWrapper::AddRef()
|
|
{
|
|
return InterlockedIncrement(&m_refCount);
|
|
}
|
|
|
|
ULONG STDMETHODCALLTYPE MMDeviceCollectionWrapper::Release()
|
|
{
|
|
ULONG count = InterlockedDecrement(&m_refCount);
|
|
if (count == 0)
|
|
{
|
|
if (m_realCollection) m_realCollection->Release();
|
|
delete this;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
HRESULT STDMETHODCALLTYPE MMDeviceCollectionWrapper::GetCount(UINT* pcDevices)
|
|
{
|
|
LOG_INFO("[MMDeviceCollectionWrapper] GetCount called\n");
|
|
return m_realCollection->GetCount(pcDevices);
|
|
}
|
|
|
|
HRESULT STDMETHODCALLTYPE MMDeviceCollectionWrapper::Item(UINT nDevice, IMMDevice** ppDevice)
|
|
{
|
|
if (!ppDevice) return E_POINTER;
|
|
IMMDevice* realDevice = nullptr;
|
|
HRESULT hr = m_realCollection->Item(nDevice, &realDevice);
|
|
|
|
if (SUCCEEDED(hr) && realDevice)
|
|
{
|
|
*ppDevice = new MMDeviceWrapper(realDevice);
|
|
}
|
|
else
|
|
{
|
|
*ppDevice = nullptr;
|
|
}
|
|
|
|
return hr;
|
|
} |