diff options
author | George Hazan <george.hazan@gmail.com> | 2015-09-10 13:46:01 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-09-10 13:46:01 +0000 |
commit | 9e585c126abc93e335aa30e7393325e8e418449a (patch) | |
tree | d7cb37f2b30c8b005bc7d320ef03f362492a48e2 | |
parent | 9cbcc4a1234b3ad61110eb733ed8b154f8e3ff68 (diff) |
- fix for the chaos in memory allocation;
- CComPtr used instead of home brewed macro;
- dialog lauout slightly straightened
git-svn-id: http://svn.miranda-ng.org/main/trunk@15318 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Tox/res/resource.rc | 19 | ||||
-rw-r--r-- | protocols/Tox/src/resource.h | 4 | ||||
-rw-r--r-- | protocols/Tox/src/stdafx.h | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 77 |
4 files changed, 47 insertions, 56 deletions
diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc index 7550a65f43..151a9163f6 100644 --- a/protocols/Tox/res/resource.rc +++ b/protocols/Tox/res/resource.rc @@ -180,11 +180,11 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN
GROUPBOX "Multimedia",-1,7,7,296,89
LTEXT "Audio input device",-1,12,17,60,8
- COMBOBOX IDC_AUDIOINPUT,12,26,138,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_AUDIOINPUT,12,26,286,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Audio output device",-1,12,42,65,8
- COMBOBOX IDC_AUDIOOUTPUT,12,52,138,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_AUDIOOUTPUT,12,52,286,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Video input device",-1,15,68,59,8,NOT WS_VISIBLE
- COMBOBOX IDC_COMBO_VIDEOINPUT,12,78,138,30,CBS_DROPDOWN | CBS_SORT | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_COMBO_VIDEOINPUT,12,78,286,30,CBS_DROPDOWN | CBS_SORT | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
END
IDD_CHATROOM_INVITE DIALOGEX 0, 0, 190, 179
@@ -312,8 +312,6 @@ BEGIN RIGHTMARGIN, 303
VERTGUIDE, 12
VERTGUIDE, 81
- VERTGUIDE, 276
- VERTGUIDE, 282
VERTGUIDE, 298
TOPMARGIN, 7
BOTTOMMARGIN, 228
@@ -355,6 +353,17 @@ BEGIN END
#endif // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPTIONS_MULTIMEDIA AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // English resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h index 593c8dec7a..5f21b0905b 100644 --- a/protocols/Tox/src/resource.h +++ b/protocols/Tox/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by e:\Projects\C++\MirandaNG\protocols\Tox\res\resource.rc
+// Used by w:\miranda-ng\protocols\Tox\res\resource.rc
//
#define IDI_TOX 100
#define IDD_USER_INFO 101
@@ -60,7 +60,7 @@ //
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 115
+#define _APS_NEXT_RESOURCE_VALUE 116
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1025
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index fed628c81b..72fdb9cfd4 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -5,12 +5,13 @@ #include <windns.h>
#include <time.h>
#include <commctrl.h>
+#include <msapi/comptr.h>
#include <mmreg.h>
#include <MMDeviceAPI.h>
#define EXIT_ON_ERROR(hres) if (FAILED(hres)) { goto Exit; }
-#define SAFE_RELEASE(punk) if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
+
DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14);
#include <vector>
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index 8ce1da4526..a547cb3871 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -195,82 +195,63 @@ CToxOptionsMultimedia::CToxOptionsMultimedia(CToxProto *proto) void CToxOptionsMultimedia::EnumDevices(CCtrlCombo &combo, IMMDeviceEnumerator *pEnumerator, EDataFlow dataFlow, const char* setting)
{
- HRESULT hr;
- UINT count;
- DBVARIANT dbv;
- LPWSTR pwszID = NULL,
- pwszDefID = NULL;
- IMMDevice *pDevice = NULL;
- IMMDeviceCollection *pDevices = NULL;
- PROPVARIANT varName;
- IPropertyStore *pProperties = NULL;
-
- if (!m_proto->getWString(setting, &dbv))
+ LPWSTR pwszDefID = NULL;
+ ptrW wszDefID(m_proto->getWStringA(setting));
+ if (wszDefID != NULL)
{
- int len = mir_wstrlen(dbv.pwszVal) * 2;
- pwszDefID = (LPWSTR)CoTaskMemAlloc(len + 1);
- mir_wstrncpy(pwszDefID, dbv.pwszVal, len);
- db_free(&dbv);
+ size_t len = mir_wstrlen(wszDefID) + 1;
+ pwszDefID = (LPWSTR)CoTaskMemAlloc(len*2);
+ mir_wstrncpy(pwszDefID, wszDefID, len);
}
else
{
- hr = pEnumerator->GetDefaultAudioEndpoint(dataFlow, eConsole, &pDevice);
- EXIT_ON_ERROR(hr);
- hr = pDevice->GetId(&pwszDefID);
- EXIT_ON_ERROR(hr);
+ CComPtr<IMMDevice> pDevice = NULL;
+ if (FAILED(pEnumerator->GetDefaultAudioEndpoint(dataFlow, eConsole, &pDevice))) return;
+ if (FAILED(pDevice->GetId(&pwszDefID))) return;
}
- hr = pEnumerator->EnumAudioEndpoints(dataFlow, DEVICE_STATE_ACTIVE, &pDevices);
- EXIT_ON_ERROR(hr);
- hr = pDevices->GetCount(&count);
- EXIT_ON_ERROR(hr);
+ CComPtr<IMMDeviceCollection> pDevices = NULL;
+ EXIT_ON_ERROR(pEnumerator->EnumAudioEndpoints(dataFlow, DEVICE_STATE_ACTIVE, &pDevices));
+
+ UINT count;
+ EXIT_ON_ERROR(pDevices->GetCount(&count));
for (UINT i = 0; i < count; i++)
{
- hr = pDevices->Item(i, &pDevice);
- EXIT_ON_ERROR(hr);
- hr = pDevice->OpenPropertyStore(STGM_READ, &pProperties);
- EXIT_ON_ERROR(hr);
+ CComPtr<IMMDevice> pDevice = NULL;
+ EXIT_ON_ERROR(pDevices->Item(i, &pDevice));
+
+ CComPtr<IPropertyStore> pProperties = NULL;
+ EXIT_ON_ERROR(pDevice->OpenPropertyStore(STGM_READ, &pProperties));
+
+ PROPVARIANT varName;
PropVariantInit(&varName);
- hr = pProperties->GetValue(PKEY_Device_FriendlyName, &varName);
- EXIT_ON_ERROR(hr);
- hr = pDevice->GetId(&pwszID);
- EXIT_ON_ERROR(hr);
+ EXIT_ON_ERROR(pProperties->GetValue(PKEY_Device_FriendlyName, &varName));
+
+ LPWSTR pwszID = NULL;
+ EXIT_ON_ERROR(pDevice->GetId(&pwszID));
combo.InsertString(varName.pwszVal, i, (LPARAM)mir_wstrdup(pwszID));
if (mir_wstrcmpi(pwszID, pwszDefID) == 0)
combo.SetCurSel(i);
CoTaskMemFree(pwszID);
- CoTaskMemFree(pwszDefID);
+
PropVariantClear(&varName);
- SAFE_RELEASE(pDevice);
- SAFE_RELEASE(pProperties);
}
- SAFE_RELEASE(pDevices);
- return;
-
Exit:
- CoTaskMemFree(pwszID);
CoTaskMemFree(pwszDefID);
- SAFE_RELEASE(pDevices);
- SAFE_RELEASE(pDevice);
- SAFE_RELEASE(pProperties);
}
void CToxOptionsMultimedia::OnInitDialog()
{
CToxDlgBase::OnInitDialog();
- IMMDeviceEnumerator *pEnumerator = NULL;
- HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pEnumerator);
- EXIT_ON_ERROR(hr);
+ CComPtr<IMMDeviceEnumerator> pEnumerator = NULL;
+ if (FAILED(CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pEnumerator)))
+ return;
EnumDevices(m_audioInput, pEnumerator, eCapture, "AudioInputDeviceID");
EnumDevices(m_audioOutput, pEnumerator, eRender, "AudioOutputDeviceID");
- return;
-
-Exit:
- SAFE_RELEASE(pEnumerator);
}
void CToxOptionsMultimedia::OnApply()
|