diff options
author | Alex Marsev <alex.marsev@gmail.com> | 2014-12-21 13:40:10 +0300 |
---|---|---|
committer | Alex Marsev <alex.marsev@gmail.com> | 2014-12-21 13:40:46 +0300 |
commit | 06121ba188ec27aadb0b8b0fa631ba681a4aeca1 (patch) | |
tree | b3e23fbb247163a96e6e7cb1971aa99bb8156bf9 /src/Settings.cpp | |
parent | aeec5047f34c2f995ae11d4b67c97c306449d2ff (diff) |
Don't ignore output device setting
Initial settings injection interface should be now fully implemented.
Diffstat (limited to 'src/Settings.cpp')
-rw-r--r-- | src/Settings.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/Settings.cpp b/src/Settings.cpp index 7d9aeed..fde09da 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -24,10 +24,20 @@ namespace SaneAudioRenderer {
CAutoLock lock(this);
- if (m_exclusive != bExclusive)
+ if (m_exclusive != bExclusive ||
+ (pDeviceName && wcscmp(pDeviceName, m_device.c_str())) ||
+ (!pDeviceName && !m_device.empty()))
{
- m_exclusive = bExclusive;
- m_serial++;
+ try
+ {
+ m_device = pDeviceName ? pDeviceName : L"";
+ m_exclusive = bExclusive;
+ m_serial++;
+ }
+ catch (std::bad_alloc&)
+ {
+ return E_OUTOFMEMORY;
+ }
}
return S_OK;
@@ -37,12 +47,21 @@ namespace SaneAudioRenderer {
CAutoLock lock(this);
- if (ppDeviceName)
- *ppDeviceName = nullptr;
-
if (pbExclusive)
*pbExclusive = m_exclusive;
+ if (ppDeviceName)
+ {
+ size_t size = sizeof(wchar_t) * (m_device.length() + 1);
+
+ *ppDeviceName = static_cast<LPWSTR>(CoTaskMemAlloc(size));
+
+ if (!*ppDeviceName)
+ return E_OUTOFMEMORY;
+
+ memcpy(*ppDeviceName, m_device.c_str(), size);
+ }
+
return S_OK;
}
|