GetNextPacketSize returns either 0 or one period worth of frames whereas GetCurrentPadding grows when input is not consumed.
84{
92
93 hr = IAudioClient_GetService(ac, &IID_IAudioCaptureClient, (
void**)&acc);
94 ok(
hr ==
S_OK,
"IAudioClient_GetService(IID_IAudioCaptureClient) returns %08x\n",
hr);
96 return;
97
98 frames = 0xabadcafe;
99 data = (
void*)0xdeadf00d;
101 pos = qpc = 0xdeadbeef;
102 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
103 ok(
hr == AUDCLNT_S_BUFFER_EMPTY,
"Initial IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
104
105
107 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
108 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
110
111 frames = 0xabadcafe;
112 data = (
void*)0xdeadf00d;
114 pos = qpc = 0xdeadbeef;
115 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
116 ok(
hr == AUDCLNT_S_BUFFER_EMPTY,
"Initial IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
117 }
118
119 if(
hr == AUDCLNT_S_BUFFER_EMPTY){
120 ok(!frames,
"frames changed to %u\n", frames);
121 ok(
data == (
void*)0xdeadf00d,
"data changed to %p\n",
data);
122 ok(
flags == 0xabadcafe,
"flags changed to %x\n",
flags);
123 ok(
pos == 0xdeadbeef,
"position changed to %u\n", (
UINT)
pos);
124 ok(qpc == 0xdeadbeef,
"timer changed to %u\n", (
UINT)qpc);
125
126
127
128 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
129 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
131 }
132
133 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
134 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
136
138
139 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
140 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
141
142 hr = IAudioClient_GetCurrentPadding(ac, &pad);
143 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
144 ok(
next == pad,
"GetNextPacketSize %u vs. GCP %u\n",
next, pad);
145
146
147 hr = IAudioCaptureClient_GetNextPacketSize(acc,
NULL);
148 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetNextPacketSize(NULL) returns %08x\n",
hr);
149
150 data = (
void*)0xdeadf00d;
151 frames = 0xdeadbeef;
154 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetBuffer(data, NULL, NULL) returns %08x\n",
hr);
155
157 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetBuffer(NULL, &frames, NULL) returns %08x\n",
hr);
158
160 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetBuffer(NULL, NULL, &flags) returns %08x\n",
hr);
161
163 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetBuffer(&ata, &frames, NULL) returns %08x\n",
hr);
165 ok(frames == 0xdeadbeef,
"frames is reset to %08x\n", frames);
166 ok(
flags == 0xabadcafe,
"flags is reset to %08x\n",
flags);
167
168 hr = IAudioClient_GetDevicePeriod(ac, &period,
NULL);
169 ok(
hr ==
S_OK,
"GetDevicePeriod failed: %08x\n",
hr);
171
173
174 data = (
void*)0xdeadf00d;
175 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
176 ok(
hr ==
S_OK ||
hr == AUDCLNT_S_BUFFER_EMPTY,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
178 ok(frames,
"Amount of frames locked is 0!\n");
179
180
184 }
else if (
hr == AUDCLNT_S_BUFFER_EMPTY){
185 ok(!frames,
"Amount of frames locked with empty buffer is %u!\n", frames);
186 ok(
data == (
void*)0xdeadf00d,
"No data changed to %p\n",
data);
187 }
188
189 trace(
"Wait'ed position %d pad %u flags %x, amount of frames locked: %u\n",
191
192 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
193 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
194 ok(
next == frames,
"GetNextPacketSize %u vs. GetBuffer %u\n",
next, frames);
195
196 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
197 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
198
199 hr = IAudioCaptureClient_ReleaseBuffer(acc, 0);
200 ok(
hr ==
S_OK,
"Releasing 0 returns %08x\n",
hr);
201
202 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
203 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
204
205 if (frames) {
206 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
207 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"Releasing buffer twice returns %08x\n",
hr);
209 }
210
212
213 hr = IAudioClient_GetCurrentPadding(ac, &pad);
214 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
215
219 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
220 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
221 ok(
next < pad,
"GetNextPacketSize %u vs. GCP %u\n",
next, pad);
222
223 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
224 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
225 ok(
next == frames,
"GetNextPacketSize %u vs. GetBuffer %u\n",
next, frames);
226
230 ok(frames,
"Amount of frames locked is 0!\n");
232
233 hr = IAudioCaptureClient_ReleaseBuffer(acc, 0);
234 ok(
hr ==
S_OK,
"Releasing 0 returns %08x\n",
hr);
235
236
237 hr = IAudioClient_GetCurrentPadding(ac, &frames);
238 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
239 ok(frames == pad || frames == pad +
next ,
240 "GCP %u past ReleaseBuffer(0) initially %u\n", frames, pad);
241
242
243 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &pos2, &qpc2);
244 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
245 ok(frames2 == frames,
"GetBuffer after ReleaseBuffer(0) %u/%u\n", frames2, frames);
246 ok(pos2 ==
pos,
"Position after ReleaseBuffer(0) %u/%u\n", (
UINT)pos2, (
UINT)
pos);
248
249 ok(qpc2 == qpc,
"HPC after ReleaseBuffer(0) %u vs. %u\n", (
UINT)qpc2, (
UINT)qpc);
250 }
251
252
253 trace(
"Sleep.1 position %d pad %u flags %x, amount of frames locked: %u\n",
255
257 UINT32 frames2 = 0xabadcafe;
260
262
263 pos = qpc = 0xdeadbeef;
264 hr = IAudioCaptureClient_GetBuffer(acc, &
data2, &frames2, &
flags, &
pos, &qpc);
265 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"Out of order IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
266 ok(frames2 == 0xabadcafe,
"Out of order frames changed to %x\n", frames2);
267 ok(
data2 == (
void*)0xdeadf00d,
"Out of order data changed to %p\n",
data2);
268 ok(
flags == 0xabadcafe,
"Out of order flags changed to %x\n",
flags);
269 ok(
pos == 0xdeadbeef,
"Out of order position changed to %x\n", (
UINT)
pos);
270 ok(qpc == 0xdeadbeef,
"Out of order timer changed to %x\n", (
UINT)qpc);
271
272 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames+1);
273 ok(
hr == AUDCLNT_E_INVALID_SIZE,
"Releasing buffer+1 returns %08x\n",
hr);
274
275 hr = IAudioCaptureClient_ReleaseBuffer(acc, 1);
276 ok(
hr == AUDCLNT_E_INVALID_SIZE,
"Releasing 1 returns %08x\n",
hr);
277
278 hr = IAudioClient_Reset(ac);
279 ok(
hr == AUDCLNT_E_NOT_STOPPED,
"Reset failed: %08x\n",
hr);
280 }
281
282 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
283 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
284
285 if (frames) {
287 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
288 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"Releasing buffer twice returns %08x\n",
hr);
289 }
290
291 frames = period;
292 ok(
next == frames,
"GetNextPacketSize %u vs. GetDevicePeriod %u\n",
next, frames);
293
294
295 hr = IAudioClient_GetBufferSize(ac, &
next);
296 ok(
hr ==
S_OK,
"GetBufferSize failed: %08x\n",
hr);
297 trace(
"GetBufferSize %u period size %u\n",
next, frames);
298
300
301 hr = IAudioClient_GetCurrentPadding(ac, &pad);
302 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
303
304 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
305 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
306
307 trace(
"Overrun position %d pad %u flags %x, amount of frames locked: %u\n",
309
312
313
314
317 }else{
319 }
320
322 }
323
324 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
325 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
327
328 hr = IAudioClient_GetCurrentPadding(ac, &pad);
329 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
330
331 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
332 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
333
334 trace(
"Cont'ed position %d pad %u flags %x, amount of frames locked: %u\n",
336
340
341 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
342 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
344 }
345
346 hr = IAudioClient_Stop(ac);
347 ok(
hr ==
S_OK,
"Stop on a started stream returns %08x\n",
hr);
348
349 hr = IAudioClient_Start(ac);
350 ok(
hr ==
S_OK,
"Start on a stopped stream returns %08x\n",
hr);
351
352 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
353 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
354
355 hr = IAudioClient_GetCurrentPadding(ac, &pad);
356 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
357
358 trace(
"Restart position %d pad %u flags %x, amount of frames locked: %u\n",
360 ok(pad >
sum,
"restarted GCP %u\n", pad);
361
362 if(frames){
365
366 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
367 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
369 }
370
371 hr = IAudioClient_Stop(ac);
372 ok(
hr ==
S_OK,
"Stop on a started stream returns %08x\n",
hr);
373
374 hr = IAudioClient_Reset(ac);
375 ok(
hr ==
S_OK,
"Reset on a stopped stream returns %08x\n",
hr);
377
378 hr = IAudioClient_Start(ac);
379 ok(
hr ==
S_OK,
"Start on a stopped stream returns %08x\n",
hr);
380
381 hr = IAudioClient_GetCurrentPadding(ac, &pad);
382 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
383
385 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
386 ok(
hr == AUDCLNT_S_BUFFER_EMPTY ||
hr ==
S_OK,
387 "Initial IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
388
389 trace(
"Reset position %d pad %u flags %x, amount of frames locked: %u\n",
391
393
394
395 trace(
"Test marked todo: only PulseAudio gets here\n");
397
399
400
401 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
402 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
404 }
405 else if(
hr == AUDCLNT_S_BUFFER_EMPTY){
406 ok(!pad,
"reset GCP %u\n", pad);
408 }
409
410 hr = IAudioClient_GetCurrentPadding(ac, &pad);
411 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
412
413 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
414 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
415 trace(
"Running position %d pad %u flags %x, amount of frames locked: %u\n",
417
419
420
422 IAudioCaptureClient_ReleaseBuffer(acc, frames);
423 }
424
425 IAudioCaptureClient_Release(acc);
426}
unsigned long long UINT64
@ AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
#define todo_wine_if(is_todo)
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
static int sum(int x_, int y_)
static unsigned __int64 next
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)