Skip to content

Commit 5736d99

Browse files
committed
Constify TCHARToUTF8, dump IMMNotificationClient callback params
1 parent b202489 commit 5736d99

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

SarAsio/sarclient.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,21 +522,31 @@ HRESULT STDMETHODCALLTYPE SarClient::NotificationClient::OnDeviceStateChanged(
522522
_In_ LPCWSTR pwstrDeviceId,
523523
_In_ DWORD dwNewState)
524524
{
525-
OutputDebugString(_T("OnDeviceStateChanged"));
525+
std::ostringstream os;
526+
527+
os << "OnDeviceStateChanged(" << TCHARToUTF8(pwstrDeviceId)
528+
<< ", " << dwNewState << ")";
529+
OutputDebugStringA(os.str().c_str());
526530
return S_OK;
527531
}
528532

529533
HRESULT STDMETHODCALLTYPE SarClient::NotificationClient::OnDeviceAdded(
530534
_In_ LPCWSTR pwstrDeviceId)
531535
{
532-
OutputDebugString(_T("OnDeviceAdded"));
536+
std::ostringstream os;
537+
538+
os << "OnDeviceAdded(" << TCHARToUTF8(pwstrDeviceId) << ")";
539+
OutputDebugStringA(os.str().c_str());
533540
return S_OK;
534541
}
535542

536543
HRESULT STDMETHODCALLTYPE SarClient::NotificationClient::OnDeviceRemoved(
537544
_In_ LPCWSTR pwstrDeviceId)
538545
{
539-
OutputDebugString(_T("OnDeviceRemoved"));
546+
std::ostringstream os;
547+
548+
os << "OnDeviceRemoved(" << TCHARToUTF8(pwstrDeviceId) << ")";
549+
OutputDebugStringA(os.str().c_str());
540550
return S_OK;
541551
}
542552

@@ -545,15 +555,25 @@ HRESULT STDMETHODCALLTYPE SarClient::NotificationClient::OnDefaultDeviceChanged(
545555
_In_ ERole role,
546556
_In_ LPCWSTR pwstrDefaultDeviceId)
547557
{
548-
OutputDebugString(_T("OnDefaultDeviceChanged"));
558+
std::ostringstream os;
559+
560+
os << "OnDefaultDeviceChanged(" << flow << ", " << role << ", "
561+
<< TCHARToUTF8(pwstrDefaultDeviceId) << ")";
562+
OutputDebugStringA(os.str().c_str());
549563
return S_OK;
550564
}
551565

552566
HRESULT STDMETHODCALLTYPE SarClient::NotificationClient::OnPropertyValueChanged(
553567
_In_ LPCWSTR pwstrDeviceId,
554568
_In_ const PROPERTYKEY key)
555569
{
556-
OutputDebugString(_T("OnPropertyValueChanged"));
570+
std::ostringstream os;
571+
CComBSTR bstr(key.fmtid);
572+
std::wstring wstr(bstr);
573+
574+
os << "OnPropertyValueChanged(" << TCHARToUTF8(pwstrDeviceId)
575+
<< ", " << TCHARToUTF8(wstr.c_str()) << ")";
576+
OutputDebugStringA(os.str().c_str());
557577
return S_OK;
558578
}
559579

SarAsio/utility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace Sar {
2121

22-
std::string TCHARToUTF8(TCHAR *ptr)
22+
std::string TCHARToUTF8(const TCHAR *ptr)
2323
{
2424
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
2525

SarAsio/utility.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Sar {
2323
#error "SarAsio must be built with unicode"
2424
#endif
2525

26-
std::string TCHARToUTF8(TCHAR *ptr);
26+
std::string TCHARToUTF8(const TCHAR *ptr);
2727
std::string ConfigurationPath(const std::string& name);
2828
std::wstring UTF8ToWide(const std::string& str);
2929

0 commit comments

Comments
 (0)