ReactOS 0.4.17-dev-966-gf06eace
memallocator.c
Go to the documentation of this file.
1/*
2 * Memory allocator unit tests
3 *
4 * Copyright (C) 2005 Christian Costa
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#define COBJMACROS
22#include "dshow.h"
23#include "wine/test.h"
24
26{
28 HRESULT hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER,
29 &IID_IMemAllocator, (void **)&allocator);
30 ok(hr == S_OK, "Got hr %#lx.\n", hr);
31 return allocator;
32}
33
34static void test_properties(void)
35{
36 ALLOCATOR_PROPERTIES req_props = {0}, ret_props;
40 unsigned int i;
41 HRESULT hr;
42
43 static const ALLOCATOR_PROPERTIES tests[] =
44 {
45 {0, 0, 1, 0},
46 {1, 0, 1, 0},
47 {1, 1, 1, 0},
48 {1, 1, 4, 0},
49 {2, 1, 1, 0},
50 {1, 2, 4, 0},
51 {1, 1, 16, 0},
52 {1, 16, 16, 0},
53 {1, 17, 16, 0},
54 {1, 32, 16, 0},
55 {1, 1, 16, 1},
56 {1, 15, 16, 1},
57 {1, 16, 16, 1},
58 {1, 17, 16, 1},
59 {1, 0, 16, 16},
60 {1, 1, 16, 16},
61 {1, 16, 16, 16},
62 };
63
64 memset(&ret_props, 0xcc, sizeof(ret_props));
65 hr = IMemAllocator_GetProperties(allocator, &ret_props);
66 ok(hr == S_OK, "Got hr %#lx.\n", hr);
67 ok(!ret_props.cBuffers, "Got %ld buffers.\n", ret_props.cBuffers);
68 ok(!ret_props.cbBuffer, "Got size %ld.\n", ret_props.cbBuffer);
69 ok(!ret_props.cbAlign, "Got align %ld.\n", ret_props.cbAlign);
70 ok(!ret_props.cbPrefix, "Got prefix %ld.\n", ret_props.cbPrefix);
71
72 hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
73 ok(hr == VFW_E_BADALIGN, "Got hr %#lx.\n", hr);
74
75 for (i = 0; i < ARRAY_SIZE(tests); i++)
76 {
77 req_props = tests[i];
78 hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
79 ok(hr == S_OK, "Test %u: Got hr %#lx.\n", i, hr);
80 ok(!memcmp(&req_props, &tests[i], sizeof(req_props)), "Test %u: Requested props should not be changed.\n", i);
81 ok(ret_props.cBuffers == req_props.cBuffers, "Test %u: Got %ld buffers.\n", i, ret_props.cBuffers);
82 ok(ret_props.cbBuffer >= req_props.cbBuffer, "Test %u: Got size %ld.\n", i, ret_props.cbBuffer);
83 ok(ret_props.cbAlign == req_props.cbAlign, "Test %u: Got alignment %ld.\n", i, ret_props.cbAlign);
84 ok(ret_props.cbPrefix == req_props.cbPrefix, "Test %u: Got prefix %ld.\n", i, ret_props.cbPrefix);
85 ret_size = ret_props.cbBuffer;
86
87 hr = IMemAllocator_GetProperties(allocator, &ret_props);
88 ok(hr == S_OK, "Test %u: Got hr %#lx.\n", i, hr);
89 ok(ret_props.cBuffers == req_props.cBuffers, "Test %u: Got %ld buffers.\n", i, ret_props.cBuffers);
90 ok(ret_props.cbBuffer == ret_size, "Test %u: Got size %ld.\n", i, ret_props.cbBuffer);
91 ok(ret_props.cbAlign == req_props.cbAlign, "Test %u: Got alignment %ld.\n", i, ret_props.cbAlign);
92 ok(ret_props.cbPrefix == req_props.cbPrefix, "Test %u: Got prefix %ld.\n", i, ret_props.cbPrefix);
93
94 hr = IMemAllocator_Commit(allocator);
95 if (!req_props.cbBuffer)
96 {
97 ok(hr == VFW_E_SIZENOTSET, "Test %u: Got hr %#lx.\n", i, hr);
98 continue;
99 }
100 ok(hr == S_OK, "Test %u: Got hr %#lx.\n", i, hr);
101
102 hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
103 ok(hr == VFW_E_ALREADY_COMMITTED, "Test %u: Got hr %#lx.\n", i, hr);
104
105 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
106 ok(hr == S_OK, "Test %u: Got hr %#lx.\n", i, hr);
107
108 size = IMediaSample_GetSize(sample);
109 ok(size == ret_size, "Test %u: Got size %ld.\n", i, size);
110
111 hr = IMemAllocator_Decommit(allocator);
112 ok(hr == S_OK, "Test %u: Got hr %#lx.\n", i, hr);
113
114 hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
115 ok(hr == VFW_E_BUFFERS_OUTSTANDING, "Test %u: Got hr %#lx.\n", i, hr);
116
117 hr = IMediaSample_Release(sample);
118 ok(hr == S_OK, "Test %u: Got hr %#lx.\n", i, hr);
119 }
120
121 IMemAllocator_Release(allocator);
122}
123
124static void test_commit(void)
125{
126 ALLOCATOR_PROPERTIES req_props = {2, 65536, 1, 0}, ret_props;
128 IMediaSample *sample, *sample2;
129 HRESULT hr;
130 BYTE *data;
131
132 hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
133 ok(hr == S_OK, "Got hr %#lx.\n", hr);
134
135 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
136 ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#lx.\n", hr);
137
138 hr = IMemAllocator_Commit(allocator);
139 ok(hr == S_OK, "Got hr %#lx.\n", hr);
140 hr = IMemAllocator_Commit(allocator);
141 ok(hr == S_OK, "Got hr %#lx.\n", hr);
142
143 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
144 ok(hr == S_OK, "Got hr %#lx.\n", hr);
145 IMediaSample_Release(sample);
146
147 hr = IMemAllocator_Decommit(allocator);
148 ok(hr == S_OK, "Got hr %#lx.\n", hr);
149 hr = IMemAllocator_Decommit(allocator);
150 ok(hr == S_OK, "Got hr %#lx.\n", hr);
151
152 /* Extant samples remain valid even after Decommit() is called. */
153 hr = IMemAllocator_Commit(allocator);
154 ok(hr == S_OK, "Got hr %#lx.\n", hr);
155
156 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
157 ok(hr == S_OK, "Got hr %#lx.\n", hr);
158
159 hr = IMediaSample_GetPointer(sample, &data);
160 ok(hr == S_OK, "Got hr %#lx.\n", hr);
161
162 hr = IMemAllocator_Decommit(allocator);
163 ok(hr == S_OK, "Got hr %#lx.\n", hr);
164
165 memset(data, 0xcc, 65536);
166
167 hr = IMemAllocator_GetBuffer(allocator, &sample2, NULL, NULL, 0);
168 ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#lx.\n", hr);
169
170 IMediaSample_Release(sample);
171 IMemAllocator_Release(allocator);
172}
173
174static void test_sample_time(void)
175{
176 ALLOCATOR_PROPERTIES req_props = {1, 65536, 1, 0}, ret_props;
180 IMediaSample2 *sample2;
182 HRESULT hr;
183
184 hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
185 ok(hr == S_OK, "Got hr %#lx.\n", hr);
186 hr = IMemAllocator_Commit(allocator);
187 ok(hr == S_OK, "Got hr %#lx.\n", hr);
188 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
189 ok(hr == S_OK, "Got hr %#lx.\n", hr);
190 hr = IMediaSample_QueryInterface(sample, &IID_IMediaSample2, (void **)&sample2);
191 ok(hr == S_OK, "Got hr %#lx.\n", hr);
192
193 start = 0xdeadbeef;
194 end = 0xdeadf00d;
195 hr = IMediaSample_GetTime(sample, &start, &end);
196 ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#lx.\n", hr);
197 ok(start == 0xdeadbeef, "Got start %s.\n", wine_dbgstr_longlong(start));
198 ok(end == 0xdeadf00d, "Got end %s.\n", wine_dbgstr_longlong(end));
199
200 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
201 ok(hr == S_OK, "Got hr %#lx.\n", hr);
202 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
203
204 hr = IMediaSample_SetTime(sample, NULL, NULL);
205 ok(hr == S_OK, "Got hr %#lx.\n", hr);
206
207 hr = IMediaSample_GetTime(sample, &start, &end);
208 ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#lx.\n", hr);
209
210 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
211 ok(hr == S_OK, "Got hr %#lx.\n", hr);
212 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
213
214 start = 0x123;
215 hr = IMediaSample_SetTime(sample, &start, NULL);
216 ok(hr == S_OK, "Got hr %#lx.\n", hr);
217
218 start = end = 0;
219 hr = IMediaSample_GetTime(sample, &start, &end);
220 ok(hr == VFW_S_NO_STOP_TIME, "Got hr %#lx.\n", hr);
221 ok(start == 0x123, "Got start %s.\n", wine_dbgstr_longlong(start));
222 ok(end == 0x124, "Got end %s.\n", wine_dbgstr_longlong(end));
223
224 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
225 ok(hr == S_OK, "Got hr %#lx.\n", hr);
226 ok(props.dwSampleFlags == AM_SAMPLE_TIMEVALID, "Got flags %#lx.\n", props.dwSampleFlags);
227 ok(props.tStart == 0x123, "Got start %s.\n", wine_dbgstr_longlong(props.tStart));
228
229 hr = IMediaSample_SetTime(sample, NULL, NULL);
230 ok(hr == S_OK, "Got hr %#lx.\n", hr);
231
232 hr = IMediaSample_GetTime(sample, &start, &end);
233 ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#lx.\n", hr);
234
235 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
236 ok(hr == S_OK, "Got hr %#lx.\n", hr);
237 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
238
239 end = 0x321;
240 hr = IMediaSample_SetTime(sample, NULL, &end);
241 ok(hr == S_OK, "Got hr %#lx.\n", hr);
242
243 hr = IMediaSample_GetTime(sample, &start, &end);
244 ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#lx.\n", hr);
245
246 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
247 ok(hr == S_OK, "Got hr %#lx.\n", hr);
248 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
249
250 start = 0x123;
251 end = 0x321;
252 hr = IMediaSample_SetTime(sample, &start, &end);
253 ok(hr == S_OK, "Got hr %#lx.\n", hr);
254
255 start = end = 0;
256 hr = IMediaSample_GetTime(sample, &start, &end);
257 ok(hr == S_OK, "Got hr %#lx.\n", hr);
258 ok(start == 0x123, "Got start %s.\n", wine_dbgstr_longlong(start));
259 ok(end == 0x321, "Got end %s.\n", wine_dbgstr_longlong(end));
260
261 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
262 ok(hr == S_OK, "Got hr %#lx.\n", hr);
263 ok(props.dwSampleFlags == (AM_SAMPLE_TIMEVALID | AM_SAMPLE_STOPVALID),
264 "Got flags %#lx.\n", props.dwSampleFlags);
265 ok(props.tStart == 0x123, "Got start %s.\n", wine_dbgstr_longlong(props.tStart));
266 ok(props.tStop == 0x321, "Got end %s.\n", wine_dbgstr_longlong(props.tStop));
267
268 props.dwSampleFlags = 0;
269 hr = IMediaSample2_SetProperties(sample2, sizeof(props), (BYTE *)&props);
270 ok(hr == S_OK, "Got hr %#lx.\n", hr);
271
272 hr = IMediaSample_GetTime(sample, &start, &end);
273 ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#lx.\n", hr);
274
275 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
276 ok(hr == S_OK, "Got hr %#lx.\n", hr);
277 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
278
279 props.dwSampleFlags = AM_SAMPLE_TIMEVALID;
280 props.tStart = 0x123;
281 hr = IMediaSample2_SetProperties(sample2, sizeof(props), (BYTE *)&props);
282 ok(hr == S_OK, "Got hr %#lx.\n", hr);
283
284 start = end = 0;
285 hr = IMediaSample_GetTime(sample, &start, &end);
286 ok(hr == VFW_S_NO_STOP_TIME, "Got hr %#lx.\n", hr);
287 ok(start == 0x123, "Got start %s.\n", wine_dbgstr_longlong(start));
288 ok(end == 0x124, "Got end %s.\n", wine_dbgstr_longlong(end));
289
290 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
291 ok(hr == S_OK, "Got hr %#lx.\n", hr);
292 ok(props.dwSampleFlags == AM_SAMPLE_TIMEVALID, "Got flags %#lx.\n", props.dwSampleFlags);
293 ok(props.tStart == 0x123, "Got start %s.\n", wine_dbgstr_longlong(props.tStart));
294
296 props.tStart = 0x1234;
297 props.tStop = 0x4321;
298 hr = IMediaSample2_SetProperties(sample2, sizeof(props), (BYTE *)&props);
299 ok(hr == S_OK, "Got hr %#lx.\n", hr);
300
301 start = end = 0;
302 hr = IMediaSample_GetTime(sample, &start, &end);
303 ok(hr == S_OK, "Got hr %#lx.\n", hr);
304 ok(start == 0x1234, "Got start %s.\n", wine_dbgstr_longlong(start));
305 ok(end == 0x4321, "Got end %s.\n", wine_dbgstr_longlong(end));
306
307 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
308 ok(hr == S_OK, "Got hr %#lx.\n", hr);
309 ok(props.dwSampleFlags == (AM_SAMPLE_TIMEVALID | AM_SAMPLE_STOPVALID),
310 "Got flags %#lx.\n", props.dwSampleFlags);
311 ok(props.tStart == 0x1234, "Got start %s.\n", wine_dbgstr_longlong(props.tStart));
312 ok(props.tStop == 0x4321, "Got end %s.\n", wine_dbgstr_longlong(props.tStop));
313
314 IMediaSample2_Release(sample2);
315 IMediaSample_Release(sample);
316
317 start = 0x123;
318 end = 0x321;
319 hr = IMemAllocator_GetBuffer(allocator, &sample, &start, &end, 0);
320 ok(hr == S_OK, "Got hr %#lx.\n", hr);
321 hr = IMediaSample_QueryInterface(sample, &IID_IMediaSample2, (void **)&sample2);
322 ok(hr == S_OK, "Got hr %#lx.\n", hr);
323
324 start = 0xdeadbeef;
325 end = 0xdeadf00d;
326 hr = IMediaSample_GetTime(sample, &start, &end);
327 ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#lx.\n", hr);
328 ok(start == 0xdeadbeef, "Got start %s.\n", wine_dbgstr_longlong(start));
329 ok(end == 0xdeadf00d, "Got end %s.\n", wine_dbgstr_longlong(end));
330
331 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
332 ok(hr == S_OK, "Got hr %#lx.\n", hr);
333 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
334
335 start = 0x123;
336 end = 0x321;
337 hr = IMediaSample_SetMediaTime(sample, &start, &end);
338 ok(hr == S_OK, "Got hr %#lx.\n", hr);
339
340 hr = IMediaSample_GetTime(sample, &start, &end);
341 ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#lx.\n", hr);
342
343 IMediaSample2_Release(sample2);
344 IMediaSample_Release(sample);
345 IMemAllocator_Release(allocator);
346}
347
348static void test_media_time(void)
349{
350 ALLOCATOR_PROPERTIES req_props = {1, 65536, 1, 0}, ret_props;
355 HRESULT hr;
356
357 hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
358 ok(hr == S_OK, "Got hr %#lx.\n", hr);
359 hr = IMemAllocator_Commit(allocator);
360 ok(hr == S_OK, "Got hr %#lx.\n", hr);
361 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
362 ok(hr == S_OK, "Got hr %#lx.\n", hr);
363
364 start = 0xdeadbeef;
365 end = 0xdeadf00d;
366 hr = IMediaSample_GetMediaTime(sample, &start, &end);
367 ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#lx.\n", hr);
368 ok(start == 0xdeadbeef, "Got start %s.\n", wine_dbgstr_longlong(start));
369 ok(end == 0xdeadf00d, "Got end %s.\n", wine_dbgstr_longlong(end));
370
371 hr = IMediaSample_SetMediaTime(sample, NULL, NULL);
372 ok(hr == S_OK, "Got hr %#lx.\n", hr);
373
374 hr = IMediaSample_GetMediaTime(sample, &start, &end);
375 ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#lx.\n", hr);
376
377 /* This crashes on quartz.dll < 6.6. */
378 if (0)
379 {
380 start = 0x123;
381 hr = IMediaSample_SetMediaTime(sample, &start, NULL);
382 ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
383 }
384
385 end = 0x321;
386 hr = IMediaSample_SetMediaTime(sample, NULL, &end);
387 ok(hr == S_OK, "Got hr %#lx.\n", hr);
388
389 hr = IMediaSample_GetMediaTime(sample, &start, &end);
390 ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#lx.\n", hr);
391
392 start = 0x123;
393 end = 0x321;
394 hr = IMediaSample_SetMediaTime(sample, &start, &end);
395 ok(hr == S_OK, "Got hr %#lx.\n", hr);
396
397 start = end = 0;
398 hr = IMediaSample_GetMediaTime(sample, &start, &end);
399 ok(hr == S_OK, "Got hr %#lx.\n", hr);
400 ok(start == 0x123, "Got start %s.\n", wine_dbgstr_longlong(start));
401 ok(end == 0x321, "Got end %s.\n", wine_dbgstr_longlong(end));
402
403 IMediaSample_Release(sample);
404
405 start = 0x123;
406 end = 0x321;
407 hr = IMemAllocator_GetBuffer(allocator, &sample, &start, &end, 0);
408 ok(hr == S_OK, "Got hr %#lx.\n", hr);
409
410 start = 0xdeadbeef;
411 end = 0xdeadf00d;
412 hr = IMediaSample_GetMediaTime(sample, &start, &end);
413 ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#lx.\n", hr);
414 ok(start == 0xdeadbeef, "Got start %s.\n", wine_dbgstr_longlong(start));
415 ok(end == 0xdeadf00d, "Got end %s.\n", wine_dbgstr_longlong(end));
416
417 start = 0x123;
418 end = 0x321;
419 hr = IMediaSample_SetTime(sample, &start, &end);
420 ok(hr == S_OK, "Got hr %#lx.\n", hr);
421
422 hr = IMediaSample_GetMediaTime(sample, &start, &end);
423 ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#lx.\n", hr);
424
425 start = 0x123;
426 end = 0x321;
427 hr = IMediaSample_SetMediaTime(sample, &start, &end);
428 ok(hr == S_OK, "Got hr %#lx.\n", hr);
429
430 IMediaSample_Release(sample);
431
432 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
433 ok(hr == S_OK, "Got hr %#lx.\n", hr);
434
435 hr = IMediaSample_GetMediaTime(sample, &start, &end);
436 ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#lx.\n", hr);
437
438 IMediaSample_Release(sample);
439 IMemAllocator_Release(allocator);
440}
441
442static void test_sample_properties(void)
443{
444 ALLOCATOR_PROPERTIES req_props = {1, 65536, 1, 0}, ret_props;
447 AM_MEDIA_TYPE *mt, expect_mt;
448 IMediaSample2 *sample2;
450 HRESULT hr;
451 BYTE *data;
452 LONG len;
453
454 memset(&expect_mt, 0xcc, sizeof(expect_mt));
455 expect_mt.pUnk = NULL;
456 expect_mt.cbFormat = 0;
457 expect_mt.pbFormat = NULL;
458
459 hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
460 ok(hr == S_OK, "Got hr %#lx.\n", hr);
461 hr = IMemAllocator_Commit(allocator);
462 ok(hr == S_OK, "Got hr %#lx.\n", hr);
463 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
464 ok(hr == S_OK, "Got hr %#lx.\n", hr);
465 hr = IMediaSample_QueryInterface(sample, &IID_IMediaSample2, (void **)&sample2);
466 ok(hr == S_OK, "Got hr %#lx.\n", hr);
467
468 hr = IMediaSample_GetPointer(sample, &data);
469 ok(hr == S_OK, "Got hr %#lx.\n", hr);
470
471 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
472 ok(hr == S_OK, "Got hr %#lx.\n", hr);
473 ok(!props.dwTypeSpecificFlags, "Got type-specific flags %#lx.\n", props.dwTypeSpecificFlags);
474 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
475 ok(props.lActual == 65536, "Got actual length %ld.\n", props.lActual);
476 ok(!props.tStart, "Got sample start %s.\n", wine_dbgstr_longlong(props.tStart));
477 ok(!props.dwStreamId, "Got stream ID %#lx.\n", props.dwStreamId);
478 ok(!props.pMediaType, "Got media type %p.\n", props.pMediaType);
479 ok(props.pbBuffer == data, "Expected pointer %p, got %p.\n", data, props.pbBuffer);
480 ok(props.cbBuffer == 65536, "Got buffer length %ld.\n", props.cbBuffer);
481
482 /* media type */
483
484 mt = (AM_MEDIA_TYPE *)0xdeadbeef;
485 hr = IMediaSample_GetMediaType(sample, &mt);
486 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
487 ok(!mt, "Got media type %p.\n", mt);
488
489 hr = IMediaSample_SetMediaType(sample, NULL);
490 ok(hr == S_OK, "Got hr %#lx.\n", hr);
491
492 mt = (AM_MEDIA_TYPE *)0xdeadbeef;
493 hr = IMediaSample_GetMediaType(sample, &mt);
494 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
495 ok(!mt, "Got media type %p.\n", mt);
496
497 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
498 ok(hr == S_OK, "Got hr %#lx.\n", hr);
499 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
500 ok(!props.pMediaType, "Got media type %p.\n", props.pMediaType);
501
502 hr = IMediaSample_SetMediaType(sample, &expect_mt);
503 ok(hr == S_OK, "Got hr %#lx.\n", hr);
504
505 hr = IMediaSample_GetMediaType(sample, &mt);
506 ok(hr == S_OK, "Got hr %#lx.\n", hr);
507 ok(!memcmp(mt, &expect_mt, sizeof(AM_MEDIA_TYPE)), "Media types didn't match.\n");
508 CoTaskMemFree(mt);
509
510 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
511 ok(hr == S_OK, "Got hr %#lx.\n", hr);
512 ok(props.dwSampleFlags == AM_SAMPLE_TYPECHANGED, "Got flags %#lx.\n", props.dwSampleFlags);
513 ok(!memcmp(props.pMediaType, &expect_mt, sizeof(AM_MEDIA_TYPE)), "Media types didn't match.\n");
514
515 hr = IMediaSample_SetMediaType(sample, NULL);
516 ok(hr == S_OK, "Got hr %#lx.\n", hr);
517
518 mt = (AM_MEDIA_TYPE *)0xdeadbeef;
519 hr = IMediaSample_GetMediaType(sample, &mt);
520 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
521 ok(!mt, "Got media type %p.\n", mt);
522
523 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
524 ok(hr == S_OK, "Got hr %#lx.\n", hr);
525 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
526 ok(!props.pMediaType, "Got media type %p.\n", props.pMediaType);
527
528 /* actual length */
529
530 len = IMediaSample_GetActualDataLength(sample);
531 ok(len == 65536, "Got length %ld.\n", len);
532
533 hr = IMediaSample_SetActualDataLength(sample, 65537);
534 ok(hr == VFW_E_BUFFER_OVERFLOW, "Got hr %#lx.\n", hr);
535 hr = IMediaSample_SetActualDataLength(sample, -1);
536 ok(hr == VFW_E_BUFFER_OVERFLOW || broken(hr == S_OK), "Got hr %#lx.\n", hr);
537 hr = IMediaSample_SetActualDataLength(sample, 65536);
538 ok(hr == S_OK, "Got hr %#lx.\n", hr);
539 hr = IMediaSample_SetActualDataLength(sample, 0);
540 ok(hr == S_OK, "Got hr %#lx.\n", hr);
541
542 len = IMediaSample_GetActualDataLength(sample);
543 ok(len == 0, "Got length %ld.\n", len);
544
545 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
546 ok(hr == S_OK, "Got hr %#lx.\n", hr);
547 ok(props.lActual == 0, "Got actual length %ld.\n", props.lActual);
548
549 props.lActual = 123;
550 hr = IMediaSample2_SetProperties(sample2, sizeof(props), (BYTE *)&props);
551 ok(hr == S_OK, "Got hr %#lx.\n", hr);
552
553 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
554 ok(hr == S_OK, "Got hr %#lx.\n", hr);
555 ok(props.lActual == 123, "Got actual length %ld.\n", props.lActual);
556
557 len = IMediaSample_GetActualDataLength(sample);
558 ok(len == 123, "Got length %ld.\n", len);
559
560 /* boolean flags */
561
562 hr = IMediaSample_IsPreroll(sample);
563 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
564 hr = IMediaSample_SetPreroll(sample, TRUE);
565 ok(hr == S_OK, "Got hr %#lx.\n", hr);
566 hr = IMediaSample_IsPreroll(sample);
567 ok(hr == S_OK, "Got hr %#lx.\n", hr);
568 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
569 ok(hr == S_OK, "Got hr %#lx.\n", hr);
570 ok(props.dwSampleFlags == AM_SAMPLE_PREROLL, "Got flags %#lx.\n", props.dwSampleFlags);
571 hr = IMediaSample_SetPreroll(sample, FALSE);
572 ok(hr == S_OK, "Got hr %#lx.\n", hr);
573 hr = IMediaSample_IsPreroll(sample);
574 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
575 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
576 ok(hr == S_OK, "Got hr %#lx.\n", hr);
577 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
578
579 hr = IMediaSample_IsDiscontinuity(sample);
580 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
581 hr = IMediaSample_SetDiscontinuity(sample, TRUE);
582 ok(hr == S_OK, "Got hr %#lx.\n", hr);
583 hr = IMediaSample_IsDiscontinuity(sample);
584 ok(hr == S_OK, "Got hr %#lx.\n", hr);
585 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
586 ok(hr == S_OK, "Got hr %#lx.\n", hr);
587 ok(props.dwSampleFlags == AM_SAMPLE_DATADISCONTINUITY, "Got flags %#lx.\n", props.dwSampleFlags);
588 hr = IMediaSample_SetDiscontinuity(sample, FALSE);
589 ok(hr == S_OK, "Got hr %#lx.\n", hr);
590 hr = IMediaSample_IsDiscontinuity(sample);
591 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
592 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
593 ok(hr == S_OK, "Got hr %#lx.\n", hr);
594 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
595
596 hr = IMediaSample_IsSyncPoint(sample);
597 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
598 hr = IMediaSample_SetSyncPoint(sample, TRUE);
599 ok(hr == S_OK, "Got hr %#lx.\n", hr);
600 hr = IMediaSample_IsSyncPoint(sample);
601 ok(hr == S_OK, "Got hr %#lx.\n", hr);
602 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
603 ok(hr == S_OK, "Got hr %#lx.\n", hr);
604 ok(props.dwSampleFlags == AM_SAMPLE_SPLICEPOINT, "Got flags %#lx.\n", props.dwSampleFlags);
605 hr = IMediaSample_SetSyncPoint(sample, FALSE);
606 ok(hr == S_OK, "Got hr %#lx.\n", hr);
607 hr = IMediaSample_IsSyncPoint(sample);
608 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
609 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
610 ok(hr == S_OK, "Got hr %#lx.\n", hr);
611 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
612
614 hr = IMediaSample2_SetProperties(sample2, sizeof(props), (BYTE *)&props);
615 ok(hr == S_OK, "Got hr %#lx.\n", hr);
616 hr = IMediaSample_IsPreroll(sample);
617 ok(hr == S_OK, "Got hr %#lx.\n", hr);
618 hr = IMediaSample_IsDiscontinuity(sample);
619 ok(hr == S_OK, "Got hr %#lx.\n", hr);
620 hr = IMediaSample_IsSyncPoint(sample);
621 ok(hr == S_OK, "Got hr %#lx.\n", hr);
622 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
623 ok(hr == S_OK, "Got hr %#lx.\n", hr);
625 "Got flags %#lx.\n", props.dwSampleFlags);
626
627 hr = IMediaSample_SetMediaType(sample, &expect_mt);
628 ok(hr == S_OK, "Got hr %#lx.\n", hr);
629
630 IMediaSample2_Release(sample2);
631 IMediaSample_Release(sample);
632
633 hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
634 ok(hr == S_OK, "Got hr %#lx.\n", hr);
635 hr = IMediaSample_QueryInterface(sample, &IID_IMediaSample2, (void **)&sample2);
636 ok(hr == S_OK, "Got hr %#lx.\n", hr);
637
638 hr = IMediaSample2_GetProperties(sample2, sizeof(props), (BYTE *)&props);
639 ok(hr == S_OK, "Got hr %#lx.\n", hr);
640 ok(!props.dwTypeSpecificFlags, "Got type-specific flags %#lx.\n", props.dwTypeSpecificFlags);
641 ok(!props.dwSampleFlags, "Got flags %#lx.\n", props.dwSampleFlags);
642 ok(props.lActual == 123, "Got actual length %ld.\n", props.lActual);
643 ok(!props.tStart, "Got sample start %s.\n", wine_dbgstr_longlong(props.tStart));
644 ok(!props.dwStreamId, "Got stream ID %#lx.\n", props.dwStreamId);
645 ok(!props.pMediaType, "Got media type %p.\n", props.pMediaType);
646 ok(props.cbBuffer == 65536, "Got buffer length %ld.\n", props.cbBuffer);
647
648 IMediaSample2_Release(sample2);
649 IMediaSample_Release(sample);
650 IMemAllocator_Release(allocator);
651}
652
653START_TEST(memallocator)
654{
656
658 test_commit();
662
664}
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
@ AM_SAMPLE_TIMEVALID
Definition: axcore.idl:441
@ AM_SAMPLE_STOPVALID
Definition: axcore.idl:444
@ AM_SAMPLE_DATADISCONTINUITY
Definition: axcore.idl:439
@ AM_SAMPLE_TYPECHANGED
Definition: axcore.idl:440
@ AM_SAMPLE_PREROLL
Definition: axcore.idl:438
@ AM_SAMPLE_SPLICEPOINT
Definition: axcore.idl:437
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_OK
Definition: intsafe.h:52
static struct test_info tests[]
static void ULONG ULONG * ret_size
Definition: time.c:40
static void test_media_time(void)
Definition: memallocator.c:348
static void test_sample_properties(void)
Definition: memallocator.c:442
static void test_sample_time(void)
Definition: memallocator.c:174
static void test_commit(void)
Definition: memallocator.c:124
static IMemAllocator * create_allocator(void)
Definition: memallocator.c:25
static void test_properties(void)
Definition: memallocator.c:34
long LONG
Definition: pedump.c:60
#define memset(x, y, z)
Definition: compat.h:39
Definition: wave.c:25
int64_t LONGLONG
Definition: typedefs.h:68
#define VFW_E_BADALIGN
Definition: vfwmsgs.h:53
#define VFW_E_SAMPLE_TIME_NOT_SET
Definition: vfwmsgs.h:104
#define VFW_E_MEDIA_TIME_NOT_SET
Definition: vfwmsgs.h:105
#define VFW_E_NOT_COMMITTED
Definition: vfwmsgs.h:56
#define VFW_E_BUFFERS_OUTSTANDING
Definition: vfwmsgs.h:55
#define VFW_S_NO_STOP_TIME
Definition: vfwmsgs.h:34
#define VFW_E_BUFFER_OVERFLOW
Definition: vfwmsgs.h:52
#define VFW_E_ALREADY_COMMITTED
Definition: vfwmsgs.h:54
#define VFW_E_SIZENOTSET
Definition: vfwmsgs.h:57
static const WCHAR props[]
Definition: wbemdisp.c:288
#define S_FALSE
Definition: winerror.h:3451
#define E_POINTER
Definition: winerror.h:3480
unsigned char BYTE
Definition: xxhash.c:193