Changeset 522 for trunk/Utilities/EnumerateAudioDevices/MainDialog.h
- Timestamp:
- Oct 9, 2015, 11:59:26 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/EnumerateAudioDevices/MainDialog.h
r351 r522 6 6 7 7 #include <mmdeviceapi.h> 8 #include <mmreg.h> 8 9 #include <functiondiscoverykeys.h> 9 10 #include <propkey.h> … … 40 41 public: 41 42 // CMainDialog 43 static BOOL IsWaveFormatExKey(const PROPERTYKEY& Key) 44 { 45 if(Key == PKEY_AudioEngine_DeviceFormat) 46 return TRUE; 47 if(Key == PKEY_AudioEngine_OEMFormat) 48 return TRUE; 49 class __declspec(uuid("{3D6E1656-2E50-4C4C-8D85-D0ACAE3C6C68}")) A; 50 if(Key.fmtid == __uuidof(A) && (Key.pid == 2 || Key.pid == 3)) 51 return TRUE; 52 class __declspec(uuid("{E4870E26-3CC5-4CD2-BA46-CA0A9A70ED04}")) B; 53 if(Key.fmtid == __uuidof(B) && Key.pid == 0) // PKEY_AudioEngine_??? endpointkeys.h 54 return TRUE; 55 class __declspec(uuid("{624F56DE-FD24-473E-814A-DE40AACAED16}")) C; 56 if(Key.fmtid == __uuidof(C) && Key.pid == 3) 57 return TRUE; 58 return FALSE; 59 } 42 60 43 61 // Window message handelrs … … 73 91 __C(pMmDevice->GetId(&pszIdentifier)); 74 92 sText.AppendFormat(_T("\t") _T("Identifier\t%ls\r\n"), pszIdentifier); 93 #pragma region State 75 94 DWORD nState = 0; 76 95 __C(pMmDevice->GetState(&nState)); 77 CRoArrayT<CString> StateStringArray; 78 #pragma region State Strings 79 const DWORD& nValue = nState; 80 static const struct 96 static const CFlagNameT<DWORD> g_pDeviceStateMap[] = 81 97 { 82 DWORD nValue; 83 LPCTSTR pszName; 84 } g_pMap[] = 85 { 86 { DEVICE_STATE_ACTIVE, _T("DEVICE_STATE_ACTIVE") }, 87 { DEVICE_STATE_DISABLED, _T("DEVICE_STATE_DISABLED") }, 88 { DEVICE_STATE_NOTPRESENT, _T("DEVICE_STATE_NOTPRESENT") }, 89 { DEVICE_STATE_UNPLUGGED, _T("DEVICE_STATE_UNPLUGGED") }, 98 #define A(x) { x, #x }, 99 A(DEVICE_STATE_ACTIVE) 100 A(DEVICE_STATE_DISABLED) 101 A(DEVICE_STATE_NOTPRESENT) 102 A(DEVICE_STATE_UNPLUGGED) 103 #undef A 90 104 }; 91 DWORD nMask = 0; 92 for(SIZE_T nIndex = 0; nIndex < DIM(g_pMap); nIndex++) 93 { 94 if(nValue & g_pMap[nIndex].nValue) 95 _W(StateStringArray.Add(g_pMap[nIndex].pszName) >= 0); 96 nMask |= g_pMap[nIndex].nValue; 97 } 98 if(nValue & ~nMask) 99 _W(StateStringArray.Add(AtlFormatString(_T("0x%x"), nValue & ~nMask)) >= 0); 100 #pragma endregion 101 sText.AppendFormat(_T("\t") _T("State\t%s\t0x%02x\r\n"), _StringHelper::Join(StateStringArray, _T(" | ")), nState); 105 sText.AppendFormat(_T("\t") _T("State\t%s\t0x%02X\r\n"), FormatFlagsT(g_pDeviceStateMap, nState), nState); 106 #pragma endregion State 102 107 #pragma region Property Store 103 108 sText.AppendFormat(_T("\t") _T("Properties:\r\n")); … … 119 124 // NOTE: This is brought to you by regexp .+{PKEY_[^,]+}.+ -> A(\1) 120 125 #pragma region Named SDK constants 121 #define A(x) { &x, #x }, 122 #define B(x) { &reinterpret_cast<const PROPERTYKEY&>(x), #x }, 123 static const struct { const PROPERTYKEY* pKey; LPCSTR pszName; } g_pMap[] = { 126 #define A(x) { &x, #x }, 127 #define B(x) { &reinterpret_cast<const PROPERTYKEY&>(x), #x }, 128 static const struct 129 { 130 const PROPERTYKEY* pKey; 131 LPCSTR pszName; 132 } g_pMap[] = 133 { 124 134 #pragma region functiondiscoverykeys.h 125 135 A(PKEY_NAME) … … 1144 1154 #pragma endregion 1145 1155 }; 1146 #undef A1147 #undef B1156 #undef A 1157 #undef B 1148 1158 #pragma endregion 1149 1159 for(SIZE_T nIndex = 0; nIndex < DIM(g_pMap); nIndex++) … … 1209 1219 #pragma endregion 1210 1220 #pragma endregion 1221 #pragma region Variant Type 1211 1222 static const CEnumerationNameT<VARTYPE> g_pVarTypeMap[] = 1212 1223 { … … 1258 1269 #undef A 1259 1270 }; 1260 sText.Append(_StringHelper::Join<CString>(5, _T("\t"), 1271 #pragma endregion 1272 #pragma region Detail 1273 CString sDetail; 1274 if(Key == PKEY_AudioEndpoint_FormFactor && Value.vt == VT_UI4) 1275 { 1276 static const CEnumerationNameT<UINT32> g_pMap[] = 1277 { 1278 #define A(x) { x, #x }, 1279 A(RemoteNetworkDevice) 1280 A(Speakers) 1281 A(LineLevel) 1282 A(Headphones) 1283 A(Microphone) 1284 A(Headset) 1285 A(Handset) 1286 A(UnknownDigitalPassthrough) 1287 A(SPDIF) 1288 A(DigitalAudioDisplayDevice) 1289 A(UnknownFormFactor) 1290 #undef A 1291 }; 1292 sDetail = FormatEnumerationT(g_pMap, Value.uintVal); 1293 } else 1294 if(IsWaveFormatExKey(Key) && Value.vt == VT_BLOB && Value.blob.cbSize >= sizeof (WAVEFORMATEX)) 1295 { 1296 const WAVEFORMATEX* pWaveFormatEx = (const WAVEFORMATEX*) Value.blob.pBlobData; 1297 CRoArrayT<CString> Array; 1298 Array.Add(AtlFormatString(_T("wFormatTag 0x%02X"), pWaveFormatEx->wFormatTag)); 1299 Array.Add(AtlFormatString(_T("nChannels %d"), pWaveFormatEx->nChannels)); 1300 Array.Add(AtlFormatString(_T("nSamplesPerSec %d"), pWaveFormatEx->nSamplesPerSec)); 1301 Array.Add(AtlFormatString(_T("nAvgBytesPerSec %d"), pWaveFormatEx->nAvgBytesPerSec)); 1302 Array.Add(AtlFormatString(_T("nBlockAlign %d"), pWaveFormatEx->nBlockAlign)); 1303 Array.Add(AtlFormatString(_T("wBitsPerSample %d"), pWaveFormatEx->wBitsPerSample)); 1304 Array.Add(AtlFormatString(_T("cbSize %d"), pWaveFormatEx->cbSize)); 1305 if(Value.blob.cbSize >= sizeof (WAVEFORMATEXTENSIBLE) && pWaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) 1306 { 1307 const WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = (const WAVEFORMATEXTENSIBLE*) pWaveFormatEx; 1308 Array.Add(AtlFormatString(_T("wValidBitsPerSample %d"), pWaveFormatExtensible->Samples.wValidBitsPerSample)); 1309 Array.Add(AtlFormatString(_T("dwChannelMask 0x%02X"), pWaveFormatExtensible->dwChannelMask)); 1310 Array.Add(AtlFormatString(_T("SubFormat %ls"), _PersistHelper::StringFromIdentifier(pWaveFormatExtensible->SubFormat))); 1311 } 1312 sDetail = _StringHelper::Join(Array, _T("; ")); 1313 } 1314 #pragma endregion 1315 sText.Append(_StringHelper::Join<CString>(6, _T("\t"), 1261 1316 _T(""), 1262 1317 _T(""), … … 1264 1319 sValue, 1265 1320 FormatEnumerationT(g_pVarTypeMap, Value.vt), 1321 sDetail, 1266 1322 0) + _T("\r\n")); 1267 1323 } … … 1276 1332 { 1277 1333 _Z_ATLEXCEPTION(Exception); 1278 sText.AppendFormat(_T("\t\t") _T("Error 0x%08 x\r\n"), (HRESULT) Exception);1334 sText.AppendFormat(_T("\t\t") _T("Error 0x%08X\r\n"), (HRESULT) Exception); 1279 1335 } 1280 1336 #pragma endregion … … 1283 1339 { 1284 1340 _Z_ATLEXCEPTION(Exception); 1285 sText.AppendFormat(_T("\t") _T("Error 0x%08 x\r\n"), (HRESULT) Exception);1341 sText.AppendFormat(_T("\t") _T("Error 0x%08X\r\n"), (HRESULT) Exception); 1286 1342 } 1287 1343 } … … 1289 1345 { 1290 1346 _Z_ATLEXCEPTION(Exception); 1291 sText.AppendFormat(_T("Error 0x%08 x\r\n"), (HRESULT) Exception);1347 sText.AppendFormat(_T("Error 0x%08X\r\n"), (HRESULT) Exception); 1292 1348 } 1293 1349 #pragma endregion
Note: See TracChangeset
for help on using the changeset viewer.