Nikolay Sivov : evr/allocator: Implement GetFreeSampleCount().

Alexandre Julliard julliard at winehq.org
Thu Oct 8 15:20:05 CDT 2020


Module: wine
Branch: master
Commit: d136c7554cc5f78bfefb5da9559bcec78030247d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d136c7554cc5f78bfefb5da9559bcec78030247d

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Oct  8 14:44:18 2020 +0300

evr/allocator: Implement GetFreeSampleCount().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/evr/sample.c    | 12 ++++++++++--
 dlls/evr/tests/evr.c | 14 ++++++++------
 dlls/mf/tests/mf.c   |  1 -
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/dlls/evr/sample.c b/dlls/evr/sample.c
index 31e3ff4333..2887a37e8d 100644
--- a/dlls/evr/sample.c
+++ b/dlls/evr/sample.c
@@ -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 =
diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c
index 3951b813a0..7ad011d2a0 100644
--- a/dlls/evr/tests/evr.c
+++ b/dlls/evr/tests/evr.c
@@ -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);
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c
index bd6e66a513..a63c353a4b 100644
--- a/dlls/mf/tests/mf.c
+++ b/dlls/mf/tests/mf.c
@@ -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);
 




More information about the wine-cvs mailing list