diff --git a/RS_ASIO/AsioHelpers.cpp b/RS_ASIO/AsioHelpers.cpp index 0daa09c..b0bd72b 100644 --- a/RS_ASIO/AsioHelpers.cpp +++ b/RS_ASIO/AsioHelpers.cpp @@ -26,7 +26,7 @@ static bool ReadRegistryStringA(std::string& out, HKEY hKey, const TCHAR* valueN #ifdef UNICODE char converted[bufferSize]; - if (WideCharToMultiByte(CP_ACP, 0, (wchar_t*)buffer, readSize / sizeof(wchar_t), converted, bufferSize, nullptr, nullptr) == 0) + if (WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)buffer, readSize / sizeof(wchar_t), converted, bufferSize, nullptr, nullptr) == 0) return false; out = converted; @@ -125,6 +125,7 @@ static bool GetRegistryAsioDriverPath(std::string& out, const CLSID& clsid) return result; } + static bool GetRegistryDriverInfo(AsioHelpers::DriverInfo& outInfo, HKEY hKey, const TCHAR* keyName) { bool result = false; @@ -136,11 +137,7 @@ static bool GetRegistryDriverInfo(AsioHelpers::DriverInfo& outInfo, HKEY hKey, c AsioHelpers::DriverInfo tmpInfo; // set name -#ifdef UNICODE tmpInfo.Name = ConvertWStrToStr(keyName); -#else - tmpInfo.Name = keyName; -#endif // read CLSID result = ReadRegistryClsid(tmpInfo.Clsid, hksub, COM_CLSID); @@ -270,4 +267,4 @@ AsioSharedHost* AsioHelpers::CreateAsioHost(const DriverInfo& driverInfo) } return host; -} \ No newline at end of file +} diff --git a/RS_ASIO/AsioSharedHost.cpp b/RS_ASIO/AsioSharedHost.cpp index aca82d9..69dc2dc 100644 --- a/RS_ASIO/AsioSharedHost.cpp +++ b/RS_ASIO/AsioSharedHost.cpp @@ -1,4 +1,7 @@ #include "stdafx.h" + +#include + #include "AsioSharedHost.h" #define TEST_OUTPUT_NOISE 0 @@ -217,7 +220,7 @@ ASIOError AsioSharedHost::SetSamplerate(const DWORD rate) ASIOError AsioSharedHost::Setup(const WAVEFORMATEX& format, const DWORD bufferDurationFrames) { - rslog::info_ts() << __FUNCTION__ " - startCount: " << m_StartCount << std::endl; + rslog::info_ts() << __FUNCTION__ << " - startCount: " << m_StartCount << std::endl; if (!IsValid()) return ASE_NotPresent; @@ -363,7 +366,7 @@ void AsioSharedHost::Reset() ASIOError AsioSharedHost::Start() { - rslog::info_ts() << __FUNCTION__ " - enter startCount: " << m_StartCount << std::endl; + rslog::info_ts() << __FUNCTION__ << " - enter startCount: " << m_StartCount << std::endl; if (!IsValid() || !m_IsSetup) return ASE_NotPresent; @@ -384,7 +387,7 @@ ASIOError AsioSharedHost::Start() ++m_StartCount; - rslog::info_ts() << __FUNCTION__ " - leave startCount: " << m_StartCount << std::endl; + rslog::info_ts() << __FUNCTION__ << " - leave startCount: " << m_StartCount << std::endl; return ASE_OK; } @@ -393,22 +396,22 @@ void AsioSharedHost::Stop() { if (!m_AsioMutex.try_lock()) { - rslog::info_ts() << m_DriverName << " " __FUNCTION__ " - failed to get lock first time. This might be harmless, but if we freeze here this is likely related" << std::endl; + rslog::info_ts() << m_DriverName << " " << __FUNCTION__ << " - failed to get lock first time. This might be harmless, but if we freeze here this is likely related" << std::endl; m_AsioMutex.lock(); } std::lock_guard guard(m_AsioMutex, std::adopt_lock); - rslog::info_ts() << __FUNCTION__ " - enter startCount: " << m_StartCount << std::endl; + rslog::info_ts() << __FUNCTION__ << " - enter startCount: " << m_StartCount << std::endl; if (m_StartCount == 0) { - rslog::error_ts() << __FUNCTION__ " - too many stop calls!" << std::endl; + rslog::error_ts() << __FUNCTION__ << " - too many stop calls!" << std::endl; return; } else if (m_StartCount == 1) { - rslog::info_ts() << __FUNCTION__ " - stopping ASIO stream" << std::endl; + rslog::info_ts() << __FUNCTION__ << " - stopping ASIO stream" << std::endl; if (m_Driver->stop() != ASE_OK) { rslog::error_ts() << " Failed to stop ASIO stream" << std::endl; @@ -418,7 +421,7 @@ void AsioSharedHost::Stop() --m_StartCount; - rslog::info_ts() << __FUNCTION__ " - leave startCount: " << m_StartCount << std::endl; + rslog::info_ts() << __FUNCTION__ << " - leave startCount: " << m_StartCount << std::endl; } bool AsioSharedHost::GetPreferredBufferSize(DWORD& outBufferSizeFrames) const @@ -740,7 +743,7 @@ void __cdecl AsioSharedHost::AsioCalback_bufferSwitch(long doubleBufferIndex, AS { if (!m_AsioMutex.try_lock()) { - rslog::info_ts() << m_DriverName << " " __FUNCTION__ " - aborting buffer switch handling as mutex is already locked." << std::endl; + rslog::info_ts() << m_DriverName << " " << __FUNCTION__ << " - aborting buffer switch handling as mutex is already locked." << std::endl; return; } @@ -753,12 +756,12 @@ void __cdecl AsioSharedHost::AsioCalback_bufferSwitch(long doubleBufferIndex, AS if (m_dbgNumBufferSwitches < 2) { ++m_dbgNumBufferSwitches; - rslog::info_ts() << m_DriverName << " - " __FUNCTION__ " - buffer switch " << m_dbgNumBufferSwitches << std::endl; + rslog::info_ts() << m_DriverName << " - " << __FUNCTION__ << " - buffer switch " << m_dbgNumBufferSwitches << std::endl; } else if (m_dbgNumBufferSwitches == 2) { ++m_dbgNumBufferSwitches; - rslog::info_ts() << m_DriverName << " - " __FUNCTION__ " - buffer switch " << m_dbgNumBufferSwitches << " (not logging upcoming switches)" << std::endl; + rslog::info_ts() << m_DriverName << " - " << __FUNCTION__ << " - buffer switch " << m_dbgNumBufferSwitches << " (not logging upcoming switches)" << std::endl; } // zero output @@ -828,7 +831,7 @@ void __cdecl AsioSharedHost::AsioCalback_sampleRateDidChange(ASIOSampleRate sRat long __cdecl AsioSharedHost::AsioCalback_asioMessage(long selector, long value, void* message, double* opt) { - rslog::info_ts() << __FUNCTION__ " - selector: " << selector << " value: " << value << " | returning: "; + rslog::info_ts() << __FUNCTION__ << " - selector: " << selector << " value: " << value << " | returning: "; long ret = 0; diff --git a/RS_ASIO/AsioSharedHost.h b/RS_ASIO/AsioSharedHost.h index b6486b3..7735db2 100644 --- a/RS_ASIO/AsioSharedHost.h +++ b/RS_ASIO/AsioSharedHost.h @@ -2,6 +2,11 @@ #include "ComBaseUnknown.h" +#include +#include +#include +#include + class IAsioBufferSwitchListener { public: diff --git a/RS_ASIO/ComBaseUnknown.h b/RS_ASIO/ComBaseUnknown.h index 29a7c54..36dcaa2 100644 --- a/RS_ASIO/ComBaseUnknown.h +++ b/RS_ASIO/ComBaseUnknown.h @@ -1,5 +1,12 @@ #pragma once +#include +#include + +#include + +#include "Log.h" + template class ComBaseUnknown : public TBase { @@ -40,5 +47,5 @@ class ComBaseUnknown : public TBase } private: - ULONG m_RefCount = 1; + LONG m_RefCount = 1; }; diff --git a/RS_ASIO/Configurator.cpp b/RS_ASIO/Configurator.cpp index f9bd51d..f2cecdd 100644 --- a/RS_ASIO/Configurator.cpp +++ b/RS_ASIO/Configurator.cpp @@ -185,7 +185,7 @@ static bool parseIntString(const std::string& s, int& out) static void LoadConfigIni(RSConfig& out) { - const std::wstring& cfgPath = GetConfigFilePath(); + const std::string cfgPath = ConvertWStrToStr(GetConfigFilePath()); if (cfgPath.size() == 0) return; diff --git a/RS_ASIO/DebugDeviceEnum.cpp b/RS_ASIO/DebugDeviceEnum.cpp index bc3516a..1d5a6f1 100644 --- a/RS_ASIO/DebugDeviceEnum.cpp +++ b/RS_ASIO/DebugDeviceEnum.cpp @@ -32,7 +32,7 @@ HRESULT STDMETHODCALLTYPE DebugDeviceEnum::QueryInterface(REFIID riid, void **pp HRESULT STDMETHODCALLTYPE DebugDeviceEnum::EnumAudioEndpoints(EDataFlow dataFlow, DWORD dwStateMask, IMMDeviceCollection **ppDevices) { - rslog::info_ts() << __FUNCTION__ " - dataFlow: " << Dataflow2String(dataFlow) << " - dwStateMask: " << dwStateMask << std::endl; + rslog::info_ts() << __FUNCTION__ << " - dataFlow: " << Dataflow2String(dataFlow) << " - dwStateMask: " << dwStateMask << std::endl; HRESULT hr = RSBaseDeviceEnum::EnumAudioEndpoints(dataFlow, dwStateMask, ppDevices); rslog::info_ts() << " hr: " << HResultToStr(hr) << std::endl; @@ -46,7 +46,7 @@ HRESULT STDMETHODCALLTYPE DebugDeviceEnum::EnumAudioEndpoints(EDataFlow dataFlow HRESULT STDMETHODCALLTYPE DebugDeviceEnum::GetDefaultAudioEndpoint(EDataFlow dataFlow, ERole role, IMMDevice **ppEndpoint) { - rslog::info_ts() << __FUNCTION__ " - dataFlow: " << Dataflow2String(dataFlow) << " - role: " << Role2String(role) << std::endl; + rslog::info_ts() << __FUNCTION__ << " - dataFlow: " << Dataflow2String(dataFlow) << " - role: " << Role2String(role) << std::endl; HRESULT hr = RSBaseDeviceEnum::GetDefaultAudioEndpoint(dataFlow, role, ppEndpoint); rslog::info_ts() << " hr: " << HResultToStr(hr) << std::endl; diff --git a/RS_ASIO/DebugWrapperAudioClient.cpp b/RS_ASIO/DebugWrapperAudioClient.cpp index 5215226..9e9d783 100644 --- a/RS_ASIO/DebugWrapperAudioClient.cpp +++ b/RS_ASIO/DebugWrapperAudioClient.cpp @@ -34,7 +34,7 @@ DebugWrapperAudioClient::~DebugWrapperAudioClient() template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::QueryInterface(REFIID riid, void **ppvObject) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << " riid: " << riid << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << " riid: " << riid << std::endl; HRESULT hr = E_POINTER; @@ -46,7 +46,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::QueryInterface(REFIID this->AddRef(); hr = S_OK; } - else if (riid == __uuidof(MyUnknown)) + else if(riid == __uuidof(MyUnknown)) { return m_RealAudioClient.QueryInterface(riid, ppvObject); } @@ -63,7 +63,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::QueryInterface(REFIID template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::Initialize(AUDCLNT_SHAREMODE ShareMode, DWORD StreamFlags, REFERENCE_TIME hnsBufferDuration, REFERENCE_TIME hnsPeriodicity, const WAVEFORMATEX *pFormat, LPCGUID AudioSessionGuid) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ " - ShareMode: " << ShareMode << " Flags: " << std::hex << StreamFlags << " bufferDuration: " << std::dec << RefTimeToMilisecs(hnsBufferDuration) << "ms periodicity: " << RefTimeToMilisecs(hnsPeriodicity) << "ms" << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << " - ShareMode: " << ShareMode << " Flags: " << std::hex << StreamFlags << " bufferDuration: " << std::dec << RefTimeToMilisecs(hnsBufferDuration) << "ms periodicity: " << RefTimeToMilisecs(hnsPeriodicity) << "ms" << std::endl; HRESULT hr = m_RealAudioClient.Initialize(ShareMode, StreamFlags, hnsBufferDuration, hnsPeriodicity, pFormat, AudioSessionGuid); DEBUG_PRINT_HR(hr); @@ -74,7 +74,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::Initialize(AUDCLNT_SHA template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetBufferSize(UINT32 *pNumBufferFrames) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.GetBufferSize(pNumBufferFrames); DEBUG_PRINT_HR(hr); @@ -90,7 +90,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetBufferSize(UINT32 * template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetStreamLatency(REFERENCE_TIME *phnsLatency) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.GetStreamLatency(phnsLatency); DEBUG_PRINT_HR(hr); @@ -117,7 +117,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetCurrentPadding(UINT template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::IsFormatSupported(AUDCLNT_SHAREMODE ShareMode, const WAVEFORMATEX *pFormat, WAVEFORMATEX **ppClosestMatch) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ " - ShareMode: " << ShareMode << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << " - ShareMode: " << ShareMode << std::endl; if (!pFormat) return E_POINTER; @@ -136,7 +136,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::IsFormatSupported(AUDC template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetMixFormat(WAVEFORMATEX **ppDeviceFormat) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.GetMixFormat(ppDeviceFormat); DEBUG_PRINT_HR(hr); @@ -147,7 +147,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetMixFormat(WAVEFORMA template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetDevicePeriod(REFERENCE_TIME *phnsDefaultDevicePeriod, REFERENCE_TIME *phnsMinimumDevicePeriod) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.GetDevicePeriod(phnsDefaultDevicePeriod, phnsMinimumDevicePeriod); DEBUG_PRINT_HR(hr); @@ -158,7 +158,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetDevicePeriod(REFERE template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::Start() { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.Start(); DEBUG_PRINT_HR(hr); @@ -169,7 +169,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::Start() template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::Stop() { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.Stop(); DEBUG_PRINT_HR(hr); @@ -180,7 +180,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::Stop() template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::Reset() { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.Reset(); DEBUG_PRINT_HR(hr); @@ -191,7 +191,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::Reset() template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::SetEventHandle(HANDLE eventHandle) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.SetEventHandle(eventHandle); DEBUG_PRINT_HR(hr); @@ -202,7 +202,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::SetEventHandle(HANDLE template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient::GetService(REFIID riid, void **ppv) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << " - riid: " << riid << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << " - riid: " << riid << std::endl; if (riid == __uuidof(IAudioCaptureClient)) { @@ -274,7 +274,7 @@ DebugWrapperAudioClient2::~DebugWrapperAudioClient2() template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient2::QueryInterface(REFIID riid, void **ppvObject) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << " riid: " << riid << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << " riid: " << riid << std::endl; if (!ppvObject) { @@ -297,7 +297,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient2::QueryInterface(REFIID template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient2::IsOffloadCapable(AUDIO_STREAM_CATEGORY Category, BOOL *pbOffloadCapable) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = this->m_RealAudioClient.IsOffloadCapable(Category, pbOffloadCapable); DEBUG_PRINT_HR(hr); @@ -308,7 +308,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient2::IsOffloadCapable(AUDI template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient2::SetClientProperties(const AudioClientProperties *pProperties) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = this->m_RealAudioClient.SetClientProperties(pProperties); DEBUG_PRINT_HR(hr); @@ -319,7 +319,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient2::SetClientProperties(c template HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient2::GetBufferSizeLimits(const WAVEFORMATEX *pFormat, BOOL bEventDriven, REFERENCE_TIME *phnsMinBufferDuration, REFERENCE_TIME *phnsMaxBufferDuration) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = this->m_RealAudioClient.GetBufferSizeLimits(pFormat, bEventDriven, phnsMinBufferDuration, phnsMaxBufferDuration); DEBUG_PRINT_HR(hr); @@ -345,7 +345,7 @@ DebugWrapperAudioClient3::~DebugWrapperAudioClient3() HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient3::QueryInterface(REFIID riid, void **ppvObject) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << " riid: " << riid << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << " riid: " << riid << std::endl; if (!ppvObject) { @@ -367,7 +367,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient3::QueryInterface(REFIID riid, HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient3::GetSharedModeEnginePeriod(const WAVEFORMATEX *pFormat, UINT32 *pDefaultPeriodInFrames, UINT32 *pFundamentalPeriodInFrames, UINT32 *pMinPeriodInFrames, UINT32 *pMaxPeriodInFrames) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.GetSharedModeEnginePeriod(pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames); DEBUG_PRINT_HR(hr); @@ -377,7 +377,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient3::GetSharedModeEnginePeriod(co HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient3::GetCurrentSharedModeEnginePeriod(WAVEFORMATEX **ppFormat, UINT32 *pCurrentPeriodInFrames) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.GetCurrentSharedModeEnginePeriod(ppFormat, pCurrentPeriodInFrames); DEBUG_PRINT_HR(hr); @@ -387,7 +387,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient3::GetCurrentSharedModeEnginePe HRESULT STDMETHODCALLTYPE DebugWrapperAudioClient3::InitializeSharedAudioStream(DWORD StreamFlags, UINT32 PeriodInFrames, const WAVEFORMATEX *pFormat, LPCGUID AudioSessionGuid) { - rslog::info_ts() << this->GetDeviceId() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << this->GetDeviceId() << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioClient.InitializeSharedAudioStream(StreamFlags, PeriodInFrames, pFormat, AudioSessionGuid); DEBUG_PRINT_HR(hr); diff --git a/RS_ASIO/DebugWrapperAudioEndpointVolume.cpp b/RS_ASIO/DebugWrapperAudioEndpointVolume.cpp index 070caef..6ad6632 100644 --- a/RS_ASIO/DebugWrapperAudioEndpointVolume.cpp +++ b/RS_ASIO/DebugWrapperAudioEndpointVolume.cpp @@ -17,7 +17,7 @@ DebugWrapperAudioEndpointVolume::~DebugWrapperAudioEndpointVolume() HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::RegisterControlChangeNotify(IAudioEndpointVolumeCallback *pNotify) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.RegisterControlChangeNotify(pNotify); DEBUG_PRINT_HR(hr); @@ -27,7 +27,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::RegisterControlChange HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::UnregisterControlChangeNotify(IAudioEndpointVolumeCallback *pNotify) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.UnregisterControlChangeNotify(pNotify); DEBUG_PRINT_HR(hr); @@ -37,7 +37,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::UnregisterControlChan HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetChannelCount(UINT *pnChannelCount) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.GetChannelCount(pnChannelCount); DEBUG_PRINT_HR(hr); @@ -47,7 +47,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetChannelCount(UINT HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetMasterVolumeLevel(float fLevelDB, LPCGUID pguidEventContext) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ "fLevelDB: " << fLevelDB << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << "fLevelDB: " << fLevelDB << std::endl; HRESULT hr = m_RealAudioEndpointVolume.SetMasterVolumeLevel(fLevelDB, pguidEventContext); DEBUG_PRINT_HR(hr); @@ -57,7 +57,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetMasterVolumeLevel( HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetMasterVolumeLevelScalar(float fLevel, LPCGUID pguidEventContext) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " fLevel: " << fLevel << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " fLevel: " << fLevel << std::endl; HRESULT hr = m_RealAudioEndpointVolume.SetMasterVolumeLevelScalar(fLevel, pguidEventContext); DEBUG_PRINT_HR(hr); @@ -67,7 +67,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetMasterVolumeLevelS HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetMasterVolumeLevel(float *pfLevelDB) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.GetMasterVolumeLevel(pfLevelDB); DEBUG_PRINT_HR(hr); @@ -77,7 +77,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetMasterVolumeLevel( HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetMasterVolumeLevelScalar(float *pfLevel) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.GetMasterVolumeLevelScalar(pfLevel); DEBUG_PRINT_HR(hr); @@ -87,7 +87,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetMasterVolumeLevelS HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetChannelVolumeLevel(UINT nChannel, float fLevelDB, LPCGUID pguidEventContext) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " nChannel: " << nChannel << " fLevelDB:" << fLevelDB << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " nChannel: " << nChannel << " fLevelDB:" << fLevelDB << std::endl; HRESULT hr = m_RealAudioEndpointVolume.SetChannelVolumeLevel(nChannel, fLevelDB, pguidEventContext); DEBUG_PRINT_HR(hr); @@ -97,7 +97,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetChannelVolumeLevel HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetChannelVolumeLevelScalar(UINT nChannel, float fLevel, LPCGUID pguidEventContext) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " nChannel: " << nChannel << " fLevel:" << fLevel << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " nChannel: " << nChannel << " fLevel:" << fLevel << std::endl; HRESULT hr = m_RealAudioEndpointVolume.SetChannelVolumeLevelScalar(nChannel, fLevel, pguidEventContext); DEBUG_PRINT_HR(hr); @@ -107,7 +107,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetChannelVolumeLevel HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetChannelVolumeLevel(UINT nChannel, float *pfLevelDB) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.GetChannelVolumeLevel(nChannel, pfLevelDB); DEBUG_PRINT_HR(hr); @@ -117,7 +117,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetChannelVolumeLevel HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetChannelVolumeLevelScalar(UINT nChannel, float *pfLevel) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.GetChannelVolumeLevelScalar(nChannel, pfLevel); DEBUG_PRINT_HR(hr); @@ -127,7 +127,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetChannelVolumeLevel HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetMute(BOOL bMute, LPCGUID pguidEventContext) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " bMute: " << bMute << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " bMute: " << bMute << std::endl; HRESULT hr = m_RealAudioEndpointVolume.SetMute(bMute, pguidEventContext); DEBUG_PRINT_HR(hr); @@ -137,7 +137,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::SetMute(BOOL bMute, L HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetMute(BOOL *pbMute) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.GetMute(pbMute); DEBUG_PRINT_HR(hr); @@ -147,7 +147,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetMute(BOOL *pbMute) HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetVolumeStepInfo(UINT *pnStep, UINT *pnStepCount) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.GetVolumeStepInfo(pnStep, pnStepCount); DEBUG_PRINT_HR(hr); @@ -157,7 +157,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetVolumeStepInfo(UIN HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::VolumeStepUp(LPCGUID pguidEventContext) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.VolumeStepUp(pguidEventContext); DEBUG_PRINT_HR(hr); @@ -167,7 +167,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::VolumeStepUp(LPCGUID HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::VolumeStepDown(LPCGUID pguidEventContext) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.VolumeStepDown(pguidEventContext); DEBUG_PRINT_HR(hr); @@ -177,7 +177,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::VolumeStepDown(LPCGUI HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::QueryHardwareSupport(DWORD *pdwHardwareSupportMask) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.QueryHardwareSupport(pdwHardwareSupportMask); DEBUG_PRINT_HR(hr); @@ -187,7 +187,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::QueryHardwareSupport( HRESULT STDMETHODCALLTYPE DebugWrapperAudioEndpointVolume::GetVolumeRange(float *pflVolumeMindB, float *pflVolumeMaxdB, float *pflVolumeIncrementdB) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealAudioEndpointVolume.GetVolumeRange(pflVolumeMindB, pflVolumeMaxdB, pflVolumeIncrementdB); DEBUG_PRINT_HR(hr); diff --git a/RS_ASIO/DebugWrapperCaptureClient.cpp b/RS_ASIO/DebugWrapperCaptureClient.cpp index cabfacd..001bf5c 100644 --- a/RS_ASIO/DebugWrapperCaptureClient.cpp +++ b/RS_ASIO/DebugWrapperCaptureClient.cpp @@ -21,7 +21,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperCaptureClient::GetBuffer(BYTE **ppData, UI if (m_GetCount < 3) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; hr = m_RealClient.GetBuffer(ppData, pNumFramesToRead, pdwFlags, pu64DevicePosition, pu64QPCPosition); } @@ -30,7 +30,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperCaptureClient::GetBuffer(BYTE **ppData, UI hr = m_RealClient.GetBuffer(ppData, pNumFramesToRead, pdwFlags, pu64DevicePosition, pu64QPCPosition); if (FAILED(hr)) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; } } @@ -45,7 +45,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperCaptureClient::ReleaseBuffer(UINT32 NumFra if (m_GetCount < 3) { ++m_GetCount; - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesRead: " << NumFramesRead << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " NumFramesRead: " << NumFramesRead << std::endl; hr = m_RealClient.ReleaseBuffer(NumFramesRead); } else @@ -53,7 +53,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperCaptureClient::ReleaseBuffer(UINT32 NumFra hr = m_RealClient.ReleaseBuffer(NumFramesRead); if (FAILED(hr)) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesRead: " << NumFramesRead << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " NumFramesRead: " << NumFramesRead << std::endl; } } @@ -68,7 +68,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperCaptureClient::GetNextPacketSize(UINT32 *p if (m_GetCount < 3) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; hr = m_RealClient.GetNextPacketSize(pNumFramesInNextPacket); if (SUCCEEDED(hr)) { @@ -80,7 +80,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperCaptureClient::GetNextPacketSize(UINT32 *p hr = m_RealClient.GetNextPacketSize(pNumFramesInNextPacket); if (FAILED(hr)) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; } } diff --git a/RS_ASIO/DebugWrapperDevice.cpp b/RS_ASIO/DebugWrapperDevice.cpp index f19ecf6..ed8d3b5 100644 --- a/RS_ASIO/DebugWrapperDevice.cpp +++ b/RS_ASIO/DebugWrapperDevice.cpp @@ -14,7 +14,7 @@ DebugWrapperDevice::DebugWrapperDevice(IMMDevice& realDevice) LPWSTR pStrId = NULL; realDevice.GetId(&pStrId); - m_Id = pStrId; + m_Id = ConvertToWstr(pStrId); CoTaskMemFree(pStrId); } @@ -25,7 +25,7 @@ DebugWrapperDevice::~DebugWrapperDevice() HRESULT STDMETHODCALLTYPE DebugWrapperDevice::QueryInterface(REFIID riid, void **ppvObject) { - rslog::info_ts() << m_Id << " " __FUNCTION__" - riid: " << riid << std::endl; + rslog::info_ts() << m_Id << " " << __FUNCTION__ << " - riid: " << riid << std::endl; HRESULT hr = m_RealDevice.QueryInterface(riid, ppvObject); DEBUG_PRINT_HR(hr); @@ -43,7 +43,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperDevice::QueryInterface(REFIID riid, void * HRESULT STDMETHODCALLTYPE DebugWrapperDevice::Activate(REFIID iid, DWORD dwClsCtx, PROPVARIANT *pActivationParams, void **ppInterface) { - rslog::info_ts() << m_Id << " " __FUNCTION__ " - Activate iid: " << iid << " dwClsCtx: " << std::hex << dwClsCtx << std::endl; + rslog::info_ts() << m_Id << " " << __FUNCTION__ << " - Activate iid: " << iid << " dwClsCtx: " << std::hex << dwClsCtx << std::endl; HRESULT hr = E_NOINTERFACE; @@ -113,7 +113,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperDevice::Activate(REFIID iid, DWORD dwClsCt HRESULT STDMETHODCALLTYPE DebugWrapperDevice::OpenPropertyStore(DWORD stgmAccess, IPropertyStore **ppProperties) { - rslog::info_ts() << m_Id << " " __FUNCTION__ " - stgmAccess: " << std::hex << stgmAccess << std::endl; + rslog::info_ts() << m_Id << " " << __FUNCTION__ << " - stgmAccess: " << std::hex << stgmAccess << std::endl; IPropertyStore* realPropStore = nullptr; HRESULT hr = m_RealDevice.OpenPropertyStore(stgmAccess, &realPropStore); diff --git a/RS_ASIO/DebugWrapperDevicePropertyStore.cpp b/RS_ASIO/DebugWrapperDevicePropertyStore.cpp index c78252f..07f9342 100644 --- a/RS_ASIO/DebugWrapperDevicePropertyStore.cpp +++ b/RS_ASIO/DebugWrapperDevicePropertyStore.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" #include "DebugWrapperDevicePropertyStore.h" +// This changes DEFINE_PROPERTYKEY to declare (on top of defined) +#include #include -#include // example: L"{1}.TUSBAUDIO_ENUM\\VID_1397&PID_0508&KS\\9&34A5FE73&4&4" DEFINE_PROPERTYKEY(PKEY_Device_DeviceIdHiddenKey1, 0xb3f8fa53, 0x0004, 0x438e, 0x90, 0x03, 0x51, 0xa4, 0x6e, 0x13, 0x9b, 0xfc, 2); @@ -27,7 +28,7 @@ DebugWrapperDevicePropertyStore::~DebugWrapperDevicePropertyStore() HRESULT STDMETHODCALLTYPE DebugWrapperDevicePropertyStore::GetCount(DWORD *cProps) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealPropertyStore.GetCount(cProps); @@ -88,7 +89,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperDevicePropertyStore::GetValue(REFPROPERTYK HRESULT STDMETHODCALLTYPE DebugWrapperDevicePropertyStore::SetValue(REFPROPERTYKEY key, REFPROPVARIANT propvar) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " - key: " << key << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " - key: " << key << std::endl; HRESULT hr = m_RealPropertyStore.SetValue(key, propvar); DEBUG_PRINT_HR(hr); @@ -98,7 +99,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperDevicePropertyStore::SetValue(REFPROPERTYK HRESULT STDMETHODCALLTYPE DebugWrapperDevicePropertyStore::Commit() { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealPropertyStore.Commit(); DEBUG_PRINT_HR(hr); diff --git a/RS_ASIO/DebugWrapperEndpoint.cpp b/RS_ASIO/DebugWrapperEndpoint.cpp index 84ecd25..5c76026 100644 --- a/RS_ASIO/DebugWrapperEndpoint.cpp +++ b/RS_ASIO/DebugWrapperEndpoint.cpp @@ -17,7 +17,7 @@ DebugWrapperEndpoint::~DebugWrapperEndpoint() HRESULT STDMETHODCALLTYPE DebugWrapperEndpoint::QueryInterface(REFIID riid, void **ppvObject) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " riid: " << riid << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " riid: " << riid << std::endl; HRESULT hr = m_RealEndpoint.QueryInterface(riid, ppvObject); DEBUG_PRINT_HR(hr); @@ -27,7 +27,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperEndpoint::QueryInterface(REFIID riid, void HRESULT STDMETHODCALLTYPE DebugWrapperEndpoint::GetDataFlow(EDataFlow *pDataFlow) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << std::endl; HRESULT hr = m_RealEndpoint.GetDataFlow(pDataFlow); DEBUG_PRINT_HR(hr); diff --git a/RS_ASIO/DebugWrapperRenderClient.cpp b/RS_ASIO/DebugWrapperRenderClient.cpp index 480ab21..c0f2f5f 100644 --- a/RS_ASIO/DebugWrapperRenderClient.cpp +++ b/RS_ASIO/DebugWrapperRenderClient.cpp @@ -21,7 +21,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperRenderClient::GetBuffer(UINT32 NumFramesRe if (m_GetCount < 3) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesRequested: " << NumFramesRequested << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " NumFramesRequested: " << NumFramesRequested << std::endl; hr = m_RealClient.GetBuffer(NumFramesRequested, ppData); } @@ -30,7 +30,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperRenderClient::GetBuffer(UINT32 NumFramesRe hr = m_RealClient.GetBuffer(NumFramesRequested, ppData); if (FAILED(hr)) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesRequested: " << NumFramesRequested << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " NumFramesRequested: " << NumFramesRequested << std::endl; } } @@ -45,7 +45,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperRenderClient::ReleaseBuffer(UINT32 NumFram if (m_GetCount < 3) { ++m_GetCount; - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesWritten: " << NumFramesWritten << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " NumFramesWritten: " << NumFramesWritten << std::endl; hr = m_RealClient.ReleaseBuffer(NumFramesWritten, dwFlags); } else @@ -53,7 +53,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperRenderClient::ReleaseBuffer(UINT32 NumFram hr = m_RealClient.ReleaseBuffer(NumFramesWritten, dwFlags); if (FAILED(hr)) { - rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesWritten: " << NumFramesWritten << std::endl; + rslog::info_ts() << m_DeviceId << " " << __FUNCTION__ << " NumFramesWritten: " << NumFramesWritten << std::endl; } } diff --git a/RS_ASIO/FunctionDiscoveryKeys_devpkey.h b/RS_ASIO/FunctionDiscoveryKeys_devpkey.h new file mode 100644 index 0000000..ee34e5a --- /dev/null +++ b/RS_ASIO/FunctionDiscoveryKeys_devpkey.h @@ -0,0 +1,3 @@ +#pragma once + +DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); // DEVPROP_TYPE_STRING diff --git a/RS_ASIO/MyUnknown.cpp b/RS_ASIO/MyUnknown.cpp new file mode 100644 index 0000000..497d855 --- /dev/null +++ b/RS_ASIO/MyUnknown.cpp @@ -0,0 +1,14 @@ +#include "MyUnknown.h" + +#ifdef __GNUC__ +// This changes DEFINE_PROPERTYKEY to declare (on top of defined) +#include + +// {F2D67F48-1977-4991-A3FC-A093835A7DC2} +DEFINE_GUID(IID_IMyUnknown , 0xf2d67f48, 0x1977, 0x4991, 0xa3, 0xfc, 0xa0, 0x93, 0x83, 0x5a, 0x7d, 0xc2); + +template<> struct __wine_uuidof { + static GUID uuid; +}; +GUID __wine_uuidof::uuid = IID_IMyUnknown; +#endif diff --git a/RS_ASIO/MyUnknown.h b/RS_ASIO/MyUnknown.h index 38722c5..ef8402d 100644 --- a/RS_ASIO/MyUnknown.h +++ b/RS_ASIO/MyUnknown.h @@ -5,7 +5,11 @@ // {F2D67F48-1977-4991-A3FC-A093835A7DC2} DEFINE_GUID(IID_IMyUnknown , 0xf2d67f48, 0x1977, 0x4991, 0xa3, 0xfc, 0xa0, 0x93, 0x83, 0x5a, 0x7d, 0xc2); +#ifdef __GNUC__ +class MyUnknown : public ComBaseUnknown +#else class __declspec(uuid("F2D67F48-1977-4991-A3FC-A093835A7DC2")) MyUnknown : public ComBaseUnknown +#endif { public: bool RefCountHackEnabled = false; diff --git a/RS_ASIO/Patcher.cpp b/RS_ASIO/Patcher.cpp index 94712d6..71191b0 100644 --- a/RS_ASIO/Patcher.cpp +++ b/RS_ASIO/Patcher.cpp @@ -86,7 +86,7 @@ std::vector FindBytesOffsets(const BYTE* bytes, size_t numBytes) void Patch_CallAbsoluteIndirectAddress(const std::vector& offsets, void* TargetFn, size_t numNopsFollowing) { - rslog::info_ts() << __FUNCTION__ " - num locations: " << offsets.size() << std::endl; + rslog::info_ts() << __FUNCTION__ << " - num locations: " << offsets.size() << std::endl; for (void* offset : offsets) { @@ -122,7 +122,7 @@ void Patch_CallAbsoluteIndirectAddress(const std::vector& offsets, void* void Patch_CallRelativeAddress(const std::vector& offsets, void* TargetFn) { - rslog::info_ts() << __FUNCTION__ " - num locations: " << offsets.size() << std::endl; + rslog::info_ts() << __FUNCTION__ << " - num locations: " << offsets.size() << std::endl; for (void* offset : offsets) { @@ -219,9 +219,8 @@ static bool LoadNtDllFileContents(std::vector& outBuffer) return false; } - FILE* file = nullptr; - fopen_s(&file, ntDllPath, "rb"); - if (file == nullptr) + HANDLE file = CreateFileA(ntDllPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + if (file == INVALID_HANDLE_VALUE) { rslog::error_ts() << "Failed to open ntdll.dll for read" << std::endl; return false; @@ -229,22 +228,17 @@ static bool LoadNtDllFileContents(std::vector& outBuffer) bool result = false; - if (fseek(file, 0, SEEK_END) != 0) { - rslog::error_ts() << "Failed to get ntdll.dll file size" << std::endl; - } - else - { - long fileSize = ftell(file); + long fileSize = GetFileSize(file, nullptr); if (fileSize > 0) { outBuffer.resize(fileSize); - fseek(file, 0, SEEK_SET); - - if (fread(outBuffer.data(), fileSize, 1, file) != 1) + DWORD numBytesRead = 0; + ReadFile(file, outBuffer.data(), fileSize, &numBytesRead, nullptr); + if (numBytesRead != fileSize) { - rslog::error_ts() << "Failed to get ntdll.dll file size" << std::endl; + rslog::error_ts() << "Failed to read " << fileSize << " bytes from ntdll.dll" << std::endl; } else { @@ -253,8 +247,7 @@ static bool LoadNtDllFileContents(std::vector& outBuffer) } } - fclose(file); - file = nullptr; + CloseHandle(file); return result; } @@ -310,7 +303,7 @@ void PatchOriginalCode() void* GetVirtualProtectFnPtr() { - return pfnNtProtectVirtualMemory; + return (void*)pfnNtProtectVirtualMemory; } void SetVirtualProtectFnPtr(void* fn) @@ -368,7 +361,7 @@ std::vector GetUntouchedVirtualProtectBytes(unsigned numBytes) if (untouchedMod) { - void* proc = GetProcAddress(untouchedMod, fnName); + void* proc = (void*)GetProcAddress(untouchedMod, fnName); if (!proc) { rslog::error_ts() << "Failed to get " << fnName << " proc" << std::endl; diff --git a/RS_ASIO/Patcher_21a8959a.cpp b/RS_ASIO/Patcher_21a8959a.cpp index 9418f14..fd038fb 100644 --- a/RS_ASIO/Patcher_21a8959a.cpp +++ b/RS_ASIO/Patcher_21a8959a.cpp @@ -75,15 +75,15 @@ void PatchOriginalCode_21a8959a() { // patch CoCreateInstance calls rslog::info_ts() << "Patching CoCreateInstance" << std::endl; - Patch_CallAbsoluteIndirectAddress(offsets_CoCreateInstance, &Patched_CoCreateInstance, 1); + Patch_CallAbsoluteIndirectAddress(offsets_CoCreateInstance, (void*)&Patched_CoCreateInstance, 1); // patch PortAudio MarshalStreamComPointers rslog::info_ts() << "Patching PortAudio MarshalStreamComPointers" << std::endl; - Patch_CallRelativeAddress(offsets_PaMarshalPointers, &Patched_PortAudio_MarshalStreamComPointers); + Patch_CallRelativeAddress(offsets_PaMarshalPointers, (void*)&Patched_PortAudio_MarshalStreamComPointers); // patch PortAudio UnmarshalStreamComPointers rslog::info_ts() << "Patching PortAudio UnmarshalStreamComPointers" << std::endl; - Patch_CallRelativeAddress(offsets_PaUnmarshalPointers, &Patched_PortAudio_UnmarshalStreamComPointers); + Patch_CallRelativeAddress(offsets_PaUnmarshalPointers, reinterpret_cast(&Patched_PortAudio_UnmarshalStreamComPointers)); Patch_ReplaceAssembly((LPVOID)location_TwoRealToneCablesMessageBox, (LPVOID)patchedBytes_TwoRealToneCablesMessageBox, sizeof(patchedBytes_TwoRealToneCablesMessageBox)); diff --git a/RS_ASIO/Patcher_6ea6d1ba.cpp b/RS_ASIO/Patcher_6ea6d1ba.cpp index ff8fd59..bebc784 100644 --- a/RS_ASIO/Patcher_6ea6d1ba.cpp +++ b/RS_ASIO/Patcher_6ea6d1ba.cpp @@ -139,15 +139,15 @@ void PatchOriginalCode_6ea6d1ba() { // patch CoCreateInstance calls rslog::info_ts() << "Patching CoCreateInstance" << std::endl; - Patch_CallAbsoluteIndirectAddress(offsets_CoCreateInstanceAbs, &Patched_CoCreateInstance, 1); + Patch_CallAbsoluteIndirectAddress(offsets_CoCreateInstanceAbs, (void*)&Patched_CoCreateInstance, 1); // patch PortAudio MarshalStreamComPointers rslog::info_ts() << "Patching PortAudio MarshalStreamComPointers" << std::endl; - Patch_CallRelativeAddress(offsets_PaMarshalPointers, &Patched_PortAudio_MarshalStreamComPointers); + Patch_CallRelativeAddress(offsets_PaMarshalPointers, (void*)&Patched_PortAudio_MarshalStreamComPointers); // patch PortAudio UnmarshalStreamComPointers rslog::info_ts() << "Patching PortAudio UnmarshalStreamComPointers" << std::endl; - Patch_CallRelativeAddress(offsets_PaUnmarshalPointers, &Patched_PortAudio_UnmarshalStreamComPointers); + Patch_CallRelativeAddress(offsets_PaUnmarshalPointers, (void*)&Patched_PortAudio_UnmarshalStreamComPointers); // patch two guitar cables connected message in single-player rslog::info_ts() << "Patching Two Guitar Tones Connected Message Box (starting menu) (num locations: " << offsets_TwoRealToneCablesMessageBoxStarting.size() << ")" << std::endl; diff --git a/RS_ASIO/Patcher_d1b38fcb.cpp b/RS_ASIO/Patcher_d1b38fcb.cpp index 852c311..8150ea4 100644 --- a/RS_ASIO/Patcher_d1b38fcb.cpp +++ b/RS_ASIO/Patcher_d1b38fcb.cpp @@ -109,16 +109,16 @@ void PatchOriginalCode_d1b38fcb() { // patch CoCreateInstance calls rslog::info_ts() << "Patching CoCreateInstance" << std::endl; - Patch_CallAbsoluteIndirectAddress(offsets_CoCreateInstanceAbs, &Patched_CoCreateInstance, 1); + Patch_CallAbsoluteIndirectAddress(offsets_CoCreateInstanceAbs, (void*)&Patched_CoCreateInstance, 1); //Patch_CallRelativeAddress<(void*)&Patched_CoCreateInstance>(offsets_CoCreateInstanceRel); // patch PortAudio MarshalStreamComPointers rslog::info_ts() << "Patching PortAudio MarshalStreamComPointers" << std::endl; - Patch_CallRelativeAddress(offsets_PaMarshalPointers, &Patched_PortAudio_MarshalStreamComPointers); + Patch_CallRelativeAddress(offsets_PaMarshalPointers, (void*)&Patched_PortAudio_MarshalStreamComPointers); // patch PortAudio UnmarshalStreamComPointers rslog::info_ts() << "Patching PortAudio UnmarshalStreamComPointers" << std::endl; - Patch_CallRelativeAddress(offsets_PaUnmarshalPointers, &Patched_PortAudio_UnmarshalStreamComPointers); + Patch_CallRelativeAddress(offsets_PaUnmarshalPointers, (void*)&Patched_PortAudio_UnmarshalStreamComPointers); // patch two guitar cables connected message in single-player rslog::info_ts() << "Patching Two Guitar Tones Connected Message Box (starting menu) (num locations: " << offsets_TwoRealToneCablesMessageBoxStarting.size() << ")" << std::endl; diff --git a/RS_ASIO/RSAsioAudioClient.cpp b/RS_ASIO/RSAsioAudioClient.cpp index 4f37764..db9e39f 100644 --- a/RS_ASIO/RSAsioAudioClient.cpp +++ b/RS_ASIO/RSAsioAudioClient.cpp @@ -1,4 +1,7 @@ #include "stdafx.h" + +#include + #include "AsioSharedHost.h" #include "RSAsioDevice.h" #include "RSAsioAudioClient.h" @@ -99,7 +102,7 @@ HRESULT RSAsioAudioClient::Initialize(AUDCLNT_SHAREMODE ShareMode, DWORD StreamF if (m_AsioSharedHost.SetSamplerate(pFormat->nSamplesPerSec) != ASE_OK) return E_FAIL; - rslog::info_ts() << std::dec << m_AsioDevice.GetIdRef() << " " << __FUNCTION__ " - host requested buffer duration: " << RefTimeToMilisecs(hnsBufferDuration) << "ms (" << std::dec << DurationToAudioFrames(hnsBufferDuration, pFormat->nSamplesPerSec) << " frames)" << std::endl; + rslog::info_ts() << std::dec << m_AsioDevice.GetIdRef() << " " << __FUNCTION__ << " - host requested buffer duration: " << RefTimeToMilisecs(hnsBufferDuration) << "ms (" << std::dec << DurationToAudioFrames(hnsBufferDuration, pFormat->nSamplesPerSec) << " frames)" << std::endl; rslog::info_ts() << m_AsioDevice.GetIdRef() << " " << (*pFormat); // calculate buffer duration @@ -133,7 +136,7 @@ HRESULT RSAsioAudioClient::Initialize(AUDCLNT_SHAREMODE ShareMode, DWORD StreamF } } - rslog::info_ts() << std::dec << m_AsioDevice.GetIdRef() << " " << __FUNCTION__ " - actual buffer duration: " << RefTimeToMilisecs(AudioFramesToDuration(bufferDurationFrames, pFormat->nSamplesPerSec)) << "ms (" << std::dec << bufferDurationFrames << " frames)" << std::endl; + rslog::info_ts() << std::dec << m_AsioDevice.GetIdRef() << " " << __FUNCTION__ << " - actual buffer duration: " << RefTimeToMilisecs(AudioFramesToDuration(bufferDurationFrames, pFormat->nSamplesPerSec)) << "ms (" << std::dec << bufferDurationFrames << " frames)" << std::endl; // setup ASIO streaming if (m_AsioSharedHost.Setup(*pFormat, bufferDurationFrames) != ASE_OK) @@ -495,7 +498,7 @@ void RSAsioAudioClient::SwapBuffers() m_BuffersWereSwapped = true; if (m_dbgNumBufferSwitches < 3) - rslog::info_ts() << m_AsioDevice.GetIdRef() << " " __FUNCTION__ << std::endl; + rslog::info_ts() << m_AsioDevice.GetIdRef() << " " << __FUNCTION__ << std::endl; } void RSAsioAudioClient::OnAsioBufferSwitch(unsigned buffIdx) @@ -506,7 +509,7 @@ void RSAsioAudioClient::OnAsioBufferSwitch(unsigned buffIdx) if (!m_bufferMutex.try_lock()) { - rslog::info_ts() << m_AsioDevice.GetIdRef() << " " __FUNCTION__ " - failed to get lock first time. This might be harmless, but if we freeze here this is likely related" << std::endl; + rslog::info_ts() << m_AsioDevice.GetIdRef() << " " << __FUNCTION__ << " - failed to get lock first time. This might be harmless, but if we freeze here this is likely related" << std::endl; m_bufferMutex.lock(); } diff --git a/RS_ASIO/RSAsioDeviceEnum.cpp b/RS_ASIO/RSAsioDeviceEnum.cpp index f81758f..16edb62 100644 --- a/RS_ASIO/RSAsioDeviceEnum.cpp +++ b/RS_ASIO/RSAsioDeviceEnum.cpp @@ -51,7 +51,7 @@ void RSAsioDeviceEnum::UpdateAvailableDevices() if (!m_Config.output.asioDriverName.empty()) { - rslog::info_ts() << __FUNCTION__ " - " << "output requesting ASIO driver: " << m_Config.output.asioDriverName << std::endl; + rslog::info_ts() << __FUNCTION__ << " - " << "output requesting ASIO driver: " << m_Config.output.asioDriverName << std::endl; AsioSharedHost* host = fnFindOrCreateAsioHost(m_Config.output.asioDriverName); if (host) @@ -73,12 +73,12 @@ void RSAsioDeviceEnum::UpdateAvailableDevices() device->Release(); device = nullptr; - rslog::info_ts() << __FUNCTION__ " - OK" << std::endl; + rslog::info_ts() << __FUNCTION__ << " - OK" << std::endl; host->Release(); } else { - rslog::error_ts() << __FUNCTION__ " - " << "failed." << std::endl; + rslog::error_ts() << __FUNCTION__ << " - " << "failed." << std::endl; } } @@ -87,7 +87,7 @@ void RSAsioDeviceEnum::UpdateAvailableDevices() { if (!inputCfg.asioDriverName.empty()) { - rslog::info_ts() << __FUNCTION__ " - " << "input[" << inputIdx << "] requesting ASIO driver: " << inputCfg.asioDriverName << std::endl; + rslog::info_ts() << __FUNCTION__ << " - " << "input[" << inputIdx << "] requesting ASIO driver: " << inputCfg.asioDriverName << std::endl; AsioSharedHost* host = fnFindOrCreateAsioHost(inputCfg.asioDriverName); if (host) @@ -112,12 +112,12 @@ void RSAsioDeviceEnum::UpdateAvailableDevices() device->Release(); device = nullptr; - rslog::info_ts() << __FUNCTION__ " - OK" << std::endl; + rslog::info_ts() << __FUNCTION__ << " - OK" << std::endl; host->Release(); } else { - rslog::error_ts() << __FUNCTION__ " - " << "failed." << std::endl; + rslog::error_ts() << __FUNCTION__ << " - " << "failed." << std::endl; } } diff --git a/RS_ASIO/RSAsioDevicePropertyStore.cpp b/RS_ASIO/RSAsioDevicePropertyStore.cpp index 1b85b9a..ed0fa61 100644 --- a/RS_ASIO/RSAsioDevicePropertyStore.cpp +++ b/RS_ASIO/RSAsioDevicePropertyStore.cpp @@ -1,9 +1,11 @@ #include "stdafx.h" + +#include + #include "RSAsioDevicePropertyStore.h" #include "RSAsioDevice.h" #include "AsioSharedHost.h" -#include RSAsioDevicePropertyStore::RSAsioDevicePropertyStore(RSAsioDevice& device) : m_AsioDevice(device) @@ -133,7 +135,7 @@ HRESULT STDMETHODCALLTYPE RSAsioDevicePropertyStore::GetValue(REFPROPERTYKEY key else if (key == PKEY_AudioEndpoint_FormFactor) { pv->vt = VT_UI4; - pv->uintVal = m_AsioDevice.GetConfig().isMicrophone ? Microphone : LineLevel; + pv->ulVal = m_AsioDevice.GetConfig().isMicrophone ? Microphone : LineLevel; } } diff --git a/RS_ASIO/RSBaseDeviceEnum.cpp b/RS_ASIO/RSBaseDeviceEnum.cpp index 9f5e42e..41425e1 100644 --- a/RS_ASIO/RSBaseDeviceEnum.cpp +++ b/RS_ASIO/RSBaseDeviceEnum.cpp @@ -3,6 +3,8 @@ RSBaseDeviceEnum::RSBaseDeviceEnum() { + m_DefaultRenderDevices.fill(nullptr); + m_DefaultCaptureDevices.fill(nullptr); } RSBaseDeviceEnum::~RSBaseDeviceEnum() diff --git a/RS_ASIO/RSDeviceCollection.cpp b/RS_ASIO/RSDeviceCollection.cpp index cb6a363..0720c0d 100644 --- a/RS_ASIO/RSDeviceCollection.cpp +++ b/RS_ASIO/RSDeviceCollection.cpp @@ -141,7 +141,7 @@ IMMDevice* RSDeviceCollection::FindById(LPCWSTR id) LPWSTR strId = nullptr; if (SUCCEEDED(dev->GetId(&strId))) { - bool match = (wcscmp(id, strId) == 0); + bool match = (lstrcmpW(id, strId) == 0); CoTaskMemFree(strId); if (match) { diff --git a/RS_ASIO/RS_ASIO.vcxproj b/RS_ASIO/RS_ASIO.vcxproj index 3ded978..7dd82b3 100644 --- a/RS_ASIO/RS_ASIO.vcxproj +++ b/RS_ASIO/RS_ASIO.vcxproj @@ -94,7 +94,7 @@ Level3 Disabled true - WIN32;_DEBUG;RSASIO_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;RSASIO_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreadedDebugDLL stdcpp17 @@ -127,7 +127,7 @@ true true true - WIN32;NDEBUG;RSASIO_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;RSASIO_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded stdcpp17 diff --git a/RS_ASIO/TrampolineToMethod.h b/RS_ASIO/TrampolineToMethod.h index b771c8a..237e182 100644 --- a/RS_ASIO/TrampolineToMethod.h +++ b/RS_ASIO/TrampolineToMethod.h @@ -80,7 +80,7 @@ class TrampolineToMethod template void* GenerateFuncPtr_Impl(TClass* obj, std::index_sequence) { - return (void*)&Redirector::type_list>::type...>; + return (void*)&Redirector::type_list>::type...>; } template @@ -94,4 +94,4 @@ class TrampolineToMethod }; #else #error TrampolineToMethod not supported in 64 bit -#endif \ No newline at end of file +#endif diff --git a/RS_ASIO/Utils.cpp b/RS_ASIO/Utils.cpp index 169353a..338e553 100644 --- a/RS_ASIO/Utils.cpp +++ b/RS_ASIO/Utils.cpp @@ -66,6 +66,23 @@ std::string ConvertWStrToStr(const std::wstring& wstr) return std::string(); } + +std::string ConvertWStrToStr(const wchar_t* keyName) +{ + std::wstring ws(keyName); + return ConvertWStrToStr(ws); +} + +std::string ConvertWStrToStr(const char* keyName) +{ + return std::string(keyName); +} + +std::wstring ConvertToWstr(LPWSTR str) +{ + return std::wstring((const wchar_t*)str); +} + std::string IID2String(REFIID iid) { std::string ret; @@ -76,7 +93,7 @@ std::string IID2String(REFIID iid) if (iidStr) { #if defined(_WIN32) && !defined(OLE2ANSI) - std::wstring wStr = iidStr; + std::wstring wStr( (wchar_t*) iidStr); ret = ConvertWStrToStr(wStr); #else ret = iidStr; @@ -160,7 +177,7 @@ std::ostream & operator<<(std::ostream & os, REFIID iid) return os; } - os << clsidStr; + os << reinterpret_cast(clsidStr); CoTaskMemFree(clsidStr); } @@ -193,7 +210,7 @@ std::ostream & operator<<(std::ostream & os, REFPROPERTYKEY key) else { wchar_t propNameW[128]; - HRESULT hr = PSStringFromPropertyKey(key, propNameW, 128); + HRESULT hr = PSStringFromPropertyKey(key, (WCHAR*)propNameW, 128); if (SUCCEEDED(hr)) { os << propNameW; diff --git a/RS_ASIO/Utils.h b/RS_ASIO/Utils.h index 5a1d765..5611417 100644 --- a/RS_ASIO/Utils.h +++ b/RS_ASIO/Utils.h @@ -30,6 +30,11 @@ struct TimeStamp }; std::string ConvertWStrToStr(const std::wstring& wstr); +// These overloads allow TCHAR to work both with and without unicode +std::string ConvertWStrToStr(const wchar_t* keyName); +std::string ConvertWStrToStr(const char* keyName); + +std::wstring ConvertToWstr(LPWSTR str); std::string IID2String(REFIID iid); const char* Dataflow2String(EDataFlow dataFlow); const char* Role2String(ERole role); diff --git a/RS_ASIO/crc32.cpp b/RS_ASIO/crc32.cpp index 5c5d0f9..4deac6b 100644 --- a/RS_ASIO/crc32.cpp +++ b/RS_ASIO/crc32.cpp @@ -55,9 +55,8 @@ static inline DWORD updateCRC32(unsigned char ch, DWORD crc) bool crc32file(char* name, DWORD& outCrc) { - FILE* f = nullptr; - fopen_s(&f, name, "rb"); - if (!f) + HANDLE f = CreateFileA(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + if (f == INVALID_HANDLE_VALUE) return false; bool ret = true; @@ -66,23 +65,24 @@ bool crc32file(char* name, DWORD& outCrc) outCrc = 0xffffffff; for(;;) { - const size_t numBytesRead = fread(buf, 1, sizeof(buf), f); + DWORD numBytesRead = 0; + auto re = ReadFile(f, buf, sizeof(buf), &numBytesRead, nullptr); for (size_t i = 0; i < numBytesRead; ++i) { outCrc = updateCRC32(buf[i], outCrc); } - if (feof(f)) + if (re && (numBytesRead == 0)) break; - if (ferror(f)) + if (re != TRUE) { ret = false; break; } } - fclose(f); + CloseHandle(f); outCrc = ~outCrc; return ret; diff --git a/RS_ASIO/dllmain.cpp b/RS_ASIO/dllmain.cpp index e1ae88b..18acddc 100644 --- a/RS_ASIO/dllmain.cpp +++ b/RS_ASIO/dllmain.cpp @@ -8,6 +8,9 @@ #define USE_STRUCTURED_PA 1 + +extern "C" { + BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -57,6 +60,8 @@ HRESULT STDAPICALLTYPE Patched_CoCreateInstance(REFCLSID rclsid, IUnknown *pUnkO return CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppOut); } + + #if USE_STRUCTURED_PA struct PaWasapiSubStream { @@ -307,3 +312,5 @@ HRESULT Patched_PortAudio_UnmarshalStreamComPointers(void* stream) return S_OK; } #endif + +} // Extern "C" diff --git a/RS_ASIO/dllmain.h b/RS_ASIO/dllmain.h index 43ede48..8284661 100644 --- a/RS_ASIO/dllmain.h +++ b/RS_ASIO/dllmain.h @@ -1,5 +1,7 @@ #pragma once +extern "C" { HRESULT STDAPICALLTYPE Patched_CoCreateInstance(REFCLSID rclsid, IUnknown *pUnkOuter, DWORD dwClsContext, REFIID riid, void **ppOut); HRESULT Patched_PortAudio_MarshalStreamComPointers(void*); -HRESULT Patched_PortAudio_UnmarshalStreamComPointers(void*); \ No newline at end of file +HRESULT Patched_PortAudio_UnmarshalStreamComPointers(void*); +} diff --git a/RS_ASIO/stdafx.cpp b/RS_ASIO/stdafx.cpp index 289f80a..81fbe5c 100644 --- a/RS_ASIO/stdafx.cpp +++ b/RS_ASIO/stdafx.cpp @@ -1,3 +1,11 @@ +// This forces instantiation of the GUIDS +#include + #include "stdafx.h" +#ifdef __GNUC__ +#include +__CRT_UUID_DECL(IUnknown, 0x00000000, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46) +#endif + #pragma comment(lib, "propsys.lib") diff --git a/RS_ASIO/stdafx.h b/RS_ASIO/stdafx.h index 194ab63..9fc5b31 100644 --- a/RS_ASIO/stdafx.h +++ b/RS_ASIO/stdafx.h @@ -5,19 +5,24 @@ #pragma once + #include "targetver.h" #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files #include #include -#include #include #include -#include +#include #include -#include +#include +#ifdef __GNUC__ +#include "FunctionDiscoveryKeys_devpkey.h" +#else +#include +#endif // reference additional headers your program requires here @@ -33,7 +38,8 @@ #include #include #include + #include "asio.h" #include "Utils.h" #include "Log.h" -#include "TrampolineToMethod.h" \ No newline at end of file +#include "TrampolineToMethod.h" diff --git a/RS_ASIO/targetver.h b/RS_ASIO/targetver.h index 90e767b..7a6df9a 100644 --- a/RS_ASIO/targetver.h +++ b/RS_ASIO/targetver.h @@ -5,4 +5,4 @@ // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. -#include +#include