summaryrefslogtreecommitdiff
path: root/audio/tests/HLK/ThirdPartyApoTests/Wrappers.h
blob: 82ceedc0c3032a949f75b20e377ccaa67f03925f (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// Wrappers.h -- Copyright (c) Microsoft Corporation
//
// Author: zaneh
//
// Description:
//
//   Wrapper methods for APIs which can throw
//

// Collects exception data and sends it to Watson without crashing Audio DG.
// This method can only be called from inside the __except condition statement
// as a filter function.
inline DWORD CollectExceptionDataAndContinue(LPEXCEPTION_POINTERS exceptionInfo)
{
    LONG lResult;
    DWORD dwType, dwVal, dwSize=sizeof(DWORD);

    // Check to see if we should allow the process create a crash dump
    lResult = RegGetValue(HKEY_LOCAL_MACHINE, REGKEY_AUDIO_SOFTWARE, PREVENT_APOTEST_CRASH_OR_REPORT_ON_APO_EXCEPTION, RRF_RT_DWORD, &dwType, &dwVal, &dwSize);

    // If we are allowing dumps, report an exception to Watson before continuing
    if ((lResult != ERROR_SUCCESS) || (dwVal == 0))
    {
        RtlReportException(exceptionInfo->ExceptionRecord, exceptionInfo->ContextRecord, RTL_WER_NO_DEBUG | RTL_WER_NON_FATAL);
    }

    return EXCEPTION_EXECUTE_HANDLER;
}

HRESULT QIInternal(IAudioProcessingObject* pIAPO, _In_ REFIID riid, _COM_Outptr_ void** ppvObject)
{
    __try
    {
        return pIAPO->QueryInterface(riid, ppvObject);
    }
    __except (CollectExceptionDataAndContinue(GetExceptionInformation()))
    {
        return __HRESULT_FROM_WIN32(GetExceptionCode());
    }
}

HRESULT UnknownQIInternal(IUnknown* pIAPO, _In_ REFIID riid, _COM_Outptr_ void** ppvObject)
{
    __try
    {
        return pIAPO->QueryInterface(riid, ppvObject);
    }
    __except (CollectExceptionDataAndContinue(GetExceptionInformation()))
    {
        return __HRESULT_FROM_WIN32(GetExceptionCode());
    }
}

HRESULT IsOutputFormatSupported(IAudioProcessingObject* pIAPO, IAudioMediaType* pInputFormat, IAudioMediaType* pRequestedOutputFormat, IAudioMediaType** ppSupportedOutputFormat)
{
    __try
    {
        return pIAPO->IsOutputFormatSupported(pInputFormat, pRequestedOutputFormat, ppSupportedOutputFormat);
    }
    __except (CollectExceptionDataAndContinue(GetExceptionInformation()))
    {
        return __HRESULT_FROM_WIN32(GetExceptionCode());
    }
}

HRESULT LockForProcess(IAudioProcessingObjectConfiguration* pIAPOConfig,
        _In_ UINT32 u32NumInputConnections, 
        _In_reads_(u32NumInputConnections) APO_CONNECTION_DESCRIPTOR** ppInputConnections,
        _In_ UINT32 u32NumOutputConnections, 
        _In_reads_(u32NumOutputConnections) APO_CONNECTION_DESCRIPTOR** ppOutputConnections)
{
    __try
    {
        return pIAPOConfig->LockForProcess(u32NumInputConnections, ppInputConnections, u32NumOutputConnections, ppOutputConnections);
    }
    __except (CollectExceptionDataAndContinue(GetExceptionInformation()))
    {
        return __HRESULT_FROM_WIN32(GetExceptionCode());
    }
}

HRESULT UnlockForProcess(IAudioProcessingObjectConfiguration* pIAPOConfig)
{
    __try
    {
        return pIAPOConfig->UnlockForProcess();
    }
    __except (CollectExceptionDataAndContinue(GetExceptionInformation()))
    {
        return __HRESULT_FROM_WIN32(GetExceptionCode());
    }
}

void APOProcess(IAudioProcessingObjectRT* pIAPORT,
        _In_ UINT32 u32NumInputConnections,
        _In_reads_(u32NumInputConnections) APO_CONNECTION_PROPERTY** ppInputConnections,
        _In_ UINT32 u32NumOutputConnections,
        _Inout_updates_(u32NumOutputConnections) APO_CONNECTION_PROPERTY** ppOutputConnections)
{
    __try
    {
        pIAPORT->APOProcess(u32NumInputConnections, ppInputConnections, u32NumOutputConnections, ppOutputConnections);
    }
    __except (CollectExceptionDataAndContinue(GetExceptionInformation()))
    {
        return;
    }
}

HRESULT GetRegistrationProperties(IAudioProcessingObject* pIAPO, APO_REG_PROPERTIES** ppRegProps)
{
    __try
    {
        return pIAPO->GetRegistrationProperties(ppRegProps);
    }
    __except (CollectExceptionDataAndContinue(GetExceptionInformation()))
    {
        return __HRESULT_FROM_WIN32(GetExceptionCode());
    }
}