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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
// ------------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File Name:
//
// KsPosTestTaef.cpp
//
// Abstract:
//
// Implementation file for KsPosTestTaef
//
// -------------------------------------------------------------------------------
#include "PreComp.h"
#include "KsPosTestTaef.h"
#include "tests.h"
using namespace WEX::Common;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
#define RUN_TEST_CASE(testfn) \
{ \
SetVerifyOutput verifySettings(VerifyOutputSettings::LogOnlyFailures); \
testfn(); \
}
IBasicLog * g_pBasicLog = NULL;
WDMAudio::KsPosTest* g_pKsPosTst = NULL;
TIMER_MECHANISM g_Timer =
{
tpQPC, "QueryPerformanceCounter"
};
void LogWaveFormat(WAVEFORMATEX* pwfx)
{
WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)pwfx;
switch (pwfx->wFormatTag)
{
case WAVE_FORMAT_PCM:
LOG(g_pBasicLog, L" wFormatTag = WAVE_FORMAT_PCM");
break;
case WAVE_FORMAT_IEEE_FLOAT:
LOG(g_pBasicLog, L" wFormatTag = WAVE_FORMAT_IEEE_FLOAT");
break;
case WAVE_FORMAT_EXTENSIBLE:
LOG(g_pBasicLog, L" wFormatTag = WAVE_FORMAT_EXTENSIBLE");
if (wfex->SubFormat.Data1 == WAVE_FORMAT_PCM)
LOG(g_pBasicLog, L" SubFormat = WAVE_FORMAT_PCM");
if (wfex->SubFormat.Data1 == WAVE_FORMAT_IEEE_FLOAT)
LOG(g_pBasicLog, L" SubFormat = WAVE_FORMAT_IEEE_FLOAT");
break;
default:
LOG(g_pBasicLog, L" wFormatTag = UNKNOWN!");
}
LOG(g_pBasicLog, L" nChannel = %d", pwfx->nChannels);
LOG(g_pBasicLog, L" nSamplesPerSec = %d", pwfx->nSamplesPerSec);
LOG(g_pBasicLog, L" nAvgBytesPerSe = %d", pwfx->nAvgBytesPerSec);
LOG(g_pBasicLog, L" nBlockAlign = %d", pwfx->nBlockAlign);
LOG(g_pBasicLog, L" wBitsPerSample = %d", pwfx->wBitsPerSample);
if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{
LOG(g_pBasicLog, L" wValidBitsPerSample = %d", wfex->Samples.wValidBitsPerSample);
LOG(g_pBasicLog, L" dwChannelMask = %hd", wfex->dwChannelMask);
}
}
// -------------------------------------------------------------------------------
namespace WDMAudio
{
BEGIN_MODULE()
MODULE_PROPERTY(L"Feature", L"PortCls HCK Tests")
MODULE_PROPERTY(L"TestResourceDependent", L"true")
END_MODULE()
// Create WEXBasicLog, Coinitialize Etc
MODULE_SETUP(WDMAudioSetup)
// Release stuff acquired in WDMAudioSetup
MODULE_CLEANUP(WDMAudioCleanup)
};
bool WDMAudio::WDMAudioSetup()
{
if (NULL == g_pBasicLog)
{
if (!(VERIFY_SUCCEEDED(CreateWexBasicLog(&g_pBasicLog))))
{
return false;
}
}
return true;
}
bool WDMAudio::WDMAudioCleanup()
{
if (g_pBasicLog)
{
g_pBasicLog->Release();
}
return true;
}
// -------------------------------------------------------------------------------
bool WDMAudio::KsPosTest::KsPosTestSetup()
{
g_pKsPosTst = this;
m_pTimer = &g_Timer;
// The histograms can be displayed by using the command line parameter checked below
// If the parameter is not specified, the default is to not log anything
bool param = true;
WEX::TestExecution::RuntimeParameters::TryGetValue(L"logHistograms", param);
m_fLogHistograms = param;
return true;
}
bool WDMAudio::KsPosTest::KsPosTestCleanUp()
{
g_pKsPosTst = NULL;
return true;
}
// -------------------------------------------------------------------------------
bool WDMAudio::KsPosTest::TestCaseSetup()
{
CComPtr<ITestResource> spResource;
CComQIPtr<IHalfAppContainer> spHalfContainer;
SetVerifyOutput verifySettings(VerifyOutputSettings::LogOnlyFailures);
Log::Comment(L"");
Log::Comment(L"------------------------------------------------------");
Log::Comment(L"Running test case setup");
size_t count = Resources::Count();
if (!VERIFY_ARE_EQUAL(count, (size_t)1)) { return false; }
if (!VERIFY_SUCCEEDED(Resources::Item(0, &spResource))) { return false; }
// 1. Assign m_pHalf
spHalfContainer = spResource;
if (!VERIFY_IS_NOT_NULL(spHalfContainer)) { return false; }
if (!VERIFY_SUCCEEDED(spHalfContainer->GetHalfApp(&m_pHalf))) { return false; }
// 2. Check if this is a loopback pin. If so, assign the host pin's HalfApp
if (m_pHalf->m_ConnectorType == eLoopbackConnector)
{
VERIFY_SUCCEEDED(m_pHalf->GetHostHalfApp(&m_pHostHalf));
}
else
{
m_pHostHalf = NULL;
}
Log::Comment(L"The test will run on the following format:");
if (m_pHostHalf != NULL)
{
LogWaveFormat(m_pHostHalf->m_pCurrentFormat.get());
}
else
{
LogWaveFormat(m_pHalf->m_pCurrentFormat.get());
}
return true;
}
bool WDMAudio::KsPosTest::TestCaseCleanUp()
{
// Stop the timer here, in case any latency test fails
NtSetTimerResolution(0, FALSE, &actualTimerResolution);
if (!CompareWaveFormat(m_pHalf->m_pCurrentFormat.get(), m_pHalf->m_pPreferredFormat.get())) {
CloneWaveFormat(m_pHalf->m_pPreferredFormat.get(), wil::out_param(m_pHalf->m_pCurrentFormat));
m_pHalf->m_u32CurrentDefaultPeriodicityInFrames = m_pHalf->m_u32DefaultPeriodicityInFrames;
m_pHalf->m_u32CurrentFundamentalPeriodicityInFrames = m_pHalf->m_u32FundamentalPeriodicityInFrames;
m_pHalf->m_u32CurrentMinPeriodicityInFrames = m_pHalf->m_u32MinPeriodicityInFrames;
m_pHalf->m_u32CurrentMaxPeriodicityInFrames = m_pHalf->m_u32MaxPeriodicityInFrames;
}
if (m_pHostHalf != NULL) {
if (!VERIFY_SUCCEEDED(m_pHostHalf->CleanupStream())) { return false; }
if (!VERIFY_SUCCEEDED(m_pHostHalf->ReleaseEndpoint())) { return false; }
if (!VERIFY_SUCCEEDED(m_pHostHalf->ReleaseSineToneDataBuffer())) { return false; }
delete m_pHostHalf;
m_pHostHalf = NULL;
}
if (m_pHalf != NULL) {
if (!VERIFY_SUCCEEDED(m_pHalf->CleanupStream())) { return false; }
if (!VERIFY_SUCCEEDED(m_pHalf->ReleaseEndpoint())) { return false; }
if (!VERIFY_SUCCEEDED(m_pHalf->ReleaseSineToneDataBuffer())) { return false; }
m_pHalf = NULL;
}
return true;
}
// -------------------------------------------------------------------------------
void WDMAudio::KsPosTest::TAEF_DriftAndJitter()
{
RUN_TEST_CASE(Test_DriftAndJitter_Default);
}
void WDMAudio::KsPosTest::TAEF_Latency()
{
RUN_TEST_CASE(Test_Latency_Default);
}
|