/
apoenum.cpp
46 lines (36 loc) · 1.15 KB
/
apoenum.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// apoenum.cpp
#include <windows.h>
#include <audioenginebaseapo.h>
#include <stdio.h>
#include "apoenum.h"
#include "details.h"
#include "log.h"
HRESULT myEnumerateAPOsCallback(
PAPO_REG_PROPERTIES pProperties,
PVOID pvRefData
);
HRESULT EnumerateAudioProcessingObjects() {
UINT32 nCount = 0;
HRESULT hr = EnumerateAPOs(myEnumerateAPOsCallback, &nCount);
if (FAILED(hr)) {
ERR(L"EnumerateAPOs failed: hr = 0x%08x", hr);
return hr;
}
LOG(L"APOs found: %u", nCount);
return S_OK;
}
// note that APO_REG_PROPERTIES is a variable-sized structure so beware of slicing
// also note that it's only valid for the life of the callback;
// if you want to store the info for use later, make a deep copy
HRESULT myEnumerateAPOsCallback(
PAPO_REG_PROPERTIES pProperties,
PVOID pvRefData
) {
UINT32 *pnCount = reinterpret_cast<UINT32 *>(pvRefData);
if (NULL == pnCount) {
ERR(L"myEnumerateAPOsCallback got a NULL pvRefData");
return E_POINTER;
}
(*pnCount)++;
return LogDetails(pProperties); // LogDetails logs its own failures
}