evr/allocator: Implement GetFreeSampleCount().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-10-08 14:44:18 +03:00 committed by Alexandre Julliard
parent 4fa62d40dc
commit d136c7554c
3 changed files with 18 additions and 9 deletions

View File

@ -32,6 +32,7 @@ struct sample_allocator
LONG refcount;
IMFVideoSampleAllocatorNotify *callback;
unsigned int free_samples;
CRITICAL_SECTION cs;
};
@ -180,9 +181,16 @@ static HRESULT WINAPI sample_allocator_callback_SetCallback(IMFVideoSampleAlloca
static HRESULT WINAPI sample_allocator_callback_GetFreeSampleCount(IMFVideoSampleAllocatorCallback *iface,
LONG *count)
{
FIXME("%p, %p.\n", iface, count);
struct sample_allocator *allocator = impl_from_IMFVideoSampleAllocatorCallback(iface);
return E_NOTIMPL;
TRACE("%p, %p.\n", iface, count);
EnterCriticalSection(&allocator->cs);
if (count)
*count = allocator->free_samples;
LeaveCriticalSection(&allocator->cs);
return S_OK;
}
static const IMFVideoSampleAllocatorCallbackVtbl sample_allocator_callback_vtbl =

View File

@ -1219,12 +1219,14 @@ static void test_MFCreateVideoSampleAllocator(void)
hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, NULL);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, NULL);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
count = 10;
hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!count, "Unexpected count %d.\n", count);
}
hr = IMFVideoSampleAllocator_UninitializeSampleAllocator(allocator);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
@ -1256,10 +1258,10 @@ todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
todo_wine
ok(count == 1, "Unexpected count %d.\n", count);
}
sample = NULL;
hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
todo_wine
@ -1279,10 +1281,10 @@ todo_wine
ok(get_refcount(sample) == 3, "Unexpected refcount %u.\n", get_refcount(sample));
hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
todo_wine
ok(count == 4, "Unexpected count %d.\n", count);
}
if (sample)
{
hr = IMFSample_QueryInterface(sample, &IID_IMFDesiredSample, (void **)&unk);

View File

@ -3308,7 +3308,6 @@ static void test_evr(void)
sample_count = 0;
hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_callback, &sample_count);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!sample_count, "Unexpected sample count %d.\n", sample_count);