Maarten Lankhorst : quartz: Add some more tests and fix wine to pass them.

Alexandre Julliard julliard at winehq.org
Mon Apr 21 07:46:37 CDT 2008


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

Author: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date:   Sat Apr 19 15:19:32 2008 -0700

quartz: Add some more tests and fix wine to pass them.

---

 dlls/quartz/dsoundrender.c        |    3 +-
 dlls/quartz/enumpins.c            |   13 +++++++-
 dlls/quartz/nullrenderer.c        |    3 +-
 dlls/quartz/tests/filtergraph.c   |   15 +++++++-
 dlls/quartz/tests/videorenderer.c |   64 +++++++++++++++++++++++++++++++++++++
 dlls/quartz/transform.c           |    3 +-
 dlls/quartz/videorenderer.c       |    3 +-
 7 files changed, 97 insertions(+), 7 deletions(-)

diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c
index 4a90bb3..c20c5e8 100644
--- a/dlls/quartz/dsoundrender.c
+++ b/dlls/quartz/dsoundrender.c
@@ -599,7 +599,8 @@ static HRESULT WINAPI DSoundRender_GetSyncSource(IBaseFilter * iface, IReference
     EnterCriticalSection(&This->csFilter);
     {
         *ppClock = This->pClock;
-        IReferenceClock_AddRef(This->pClock);
+        if (This->pClock)
+            IReferenceClock_AddRef(This->pClock);
     }
     LeaveCriticalSection(&This->csFilter);
     
diff --git a/dlls/quartz/enumpins.c b/dlls/quartz/enumpins.c
index 61e42b0..675ef5c 100644
--- a/dlls/quartz/enumpins.c
+++ b/dlls/quartz/enumpins.c
@@ -36,7 +36,12 @@ static const struct IEnumPinsVtbl IEnumPinsImpl_Vtbl;
 
 HRESULT IEnumPinsImpl_Construct(const ENUMPINDETAILS * pDetails, IEnumPins ** ppEnum)
 {
-    IEnumPinsImpl * pEnumPins = CoTaskMemAlloc(sizeof(IEnumPinsImpl));
+    IEnumPinsImpl * pEnumPins;
+
+    if (!ppEnum)
+        return E_POINTER;
+
+    pEnumPins = CoTaskMemAlloc(sizeof(IEnumPinsImpl));
     if (!pEnumPins)
     {
         *ppEnum = NULL;
@@ -109,6 +114,12 @@ static HRESULT WINAPI IEnumPinsImpl_Next(IEnumPins * iface, ULONG cPins, IPin **
 
     TRACE("(%u, %p, %p)\n", cPins, ppPins, pcFetched);
 
+    if (!ppPins)
+        return E_POINTER;
+
+    if (cPins > 1 && !pcFetched)
+        return E_INVALIDARG;
+
     if (cFetched > 0)
     {
         ULONG i;
diff --git a/dlls/quartz/nullrenderer.c b/dlls/quartz/nullrenderer.c
index d871e67..f511a7b 100644
--- a/dlls/quartz/nullrenderer.c
+++ b/dlls/quartz/nullrenderer.c
@@ -463,7 +463,8 @@ static HRESULT WINAPI NullRenderer_GetSyncSource(IBaseFilter * iface, IReference
     EnterCriticalSection(&This->csFilter);
     {
         *ppClock = This->pClock;
-        IReferenceClock_AddRef(This->pClock);
+        if (This->pClock)
+            IReferenceClock_AddRef(This->pClock);
     }
     LeaveCriticalSection(&This->csFilter);
 
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index d72b7b3..98be4b5 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -50,11 +50,21 @@ static void rungraph(void)
     HRESULT hr;
     IMediaControl* pmc;
     IMediaEvent* pme;
+    IMediaFilter* pmf;
     HANDLE hEvent;
 
     hr = IGraphBuilder_QueryInterface(pgraph, &IID_IMediaControl, (LPVOID*)&pmc);
     ok(hr==S_OK, "Cannot get IMediaControl interface returned: %x\n", hr);
 
+    hr = IGraphBuilder_QueryInterface(pgraph, &IID_IMediaFilter, (LPVOID*)&pmf);
+    ok(hr==S_OK, "Cannot get IMediaFilter interface returned: %x\n", hr);
+
+    IMediaControl_Stop(pmc);
+
+    IMediaFilter_SetSyncSource(pmf, NULL);
+
+    IMediaFilter_Release(pmf);
+
     hr = IMediaControl_Run(pmc);
     ok(hr==S_FALSE, "Cannot run the graph returned: %x\n", hr);
 
@@ -64,6 +74,8 @@ static void rungraph(void)
     hr = IMediaControl_Stop(pmc);
     ok(hr==S_OK || hr == S_FALSE, "Cannot stop the graph returned: %x\n", hr);
 
+    IGraphBuilder_SetDefaultSyncSource(pgraph);
+
     Sleep(10);
     trace("stop -> pause\n");
     hr = IMediaControl_Pause(pmc);
@@ -97,7 +109,6 @@ static void rungraph(void)
     hr = IMediaControl_Run(pmc);
     ok(hr==S_OK || hr == S_FALSE, "Cannot start the graph returned: %x\n", hr);
 
-
     hr = IGraphBuilder_QueryInterface(pgraph, &IID_IMediaEvent, (LPVOID*)&pme);
     ok(hr==S_OK, "Cannot get IMediaEvent interface returned: %x\n", hr);
 
@@ -107,7 +118,7 @@ static void rungraph(void)
     /* WaitForSingleObject(hEvent, INFINITE); */
     Sleep(20000);
 
-    hr = IMediaControl_Release(pme);
+    hr = IMediaEvent_Release(pme);
     ok(hr==2, "Releasing mediaevent returned: %x\n", hr);
 
     hr = IMediaControl_Stop(pmc);
diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c
index ca119e7..378e019 100644
--- a/dlls/quartz/tests/videorenderer.c
+++ b/dlls/quartz/tests/videorenderer.c
@@ -86,6 +86,69 @@ static void test_query_interface(void)
     RELEASE_EXPECT(pVideoWindow, 1);
 }
 
+static void test_pin(IPin *pin)
+{
+    IMemInputPin *mpin = NULL;
+
+    IPin_QueryInterface(pin, &IID_IMemInputPin, (void **)&mpin);
+
+    ok(mpin != NULL, "No IMemInputPin found!\n");
+    if (mpin)
+    {
+        ok(IMemInputPin_ReceiveCanBlock(mpin) == S_OK, "Receive can't block for pin!\n");
+        IMemInputPin_Release(mpin);
+    }
+    /* TODO */
+}
+
+static void test_basefilter(void)
+{
+    IEnumPins *pin_enum = NULL;
+    IBaseFilter *base = NULL;
+    IPin *pins[2];
+    ULONG ref;
+    HRESULT hr;
+
+    IUnknown_QueryInterface(pVideoRenderer, &IID_IBaseFilter, (void *)&base);
+    if (base == NULL)
+    {
+        /* test_query_interface handles this case */
+        skip("No IBaseFilter\n");
+        return;
+    }
+
+    hr = IBaseFilter_EnumPins(base, NULL);
+    ok(hr == E_POINTER, "hr = %08x and not E_POINTER\n", hr);
+
+    hr= IBaseFilter_EnumPins(base, &pin_enum);
+    ok(hr == S_OK, "hr = %08x and not S_OK\n", hr);
+
+    hr = IEnumPins_Next(pin_enum, 1, NULL, NULL);
+    ok(hr == E_POINTER, "hr = %08x and not E_POINTER\n", hr);
+
+    hr = IEnumPins_Next(pin_enum, 2, pins, NULL);
+    ok(hr == E_INVALIDARG, "hr = %08x and not E_INVALIDARG\n", hr);
+
+    pins[0] = (void *)0xdead;
+    pins[1] = (void *)0xdeed;
+
+    hr = IEnumPins_Next(pin_enum, 2, pins, &ref);
+    ok(hr == S_FALSE, "hr = %08x instead of S_FALSE\n", hr);
+    ok(pins[0] != (void *)0xdead && pins[0] != NULL, "pins[0] = %p\n", pins[0]);
+    if (pins[0] != (void *)0xdead && pins[0] != NULL)
+    {
+        test_pin(pins[0]);
+        IPin_Release(pins[0]);
+    }
+
+    ok(pins[1] == (void *)0xdeed, "pins[1] = %p\n", pins[1]);
+
+    ref = IEnumPins_Release(pin_enum);
+    ok(ref == 0, "ref is %u and not 0!\n", ref);
+
+    IBaseFilter_Release(base);
+}
+
 START_TEST(videorenderer)
 {
     CoInitialize(NULL);
@@ -93,6 +156,7 @@ START_TEST(videorenderer)
         return;
 
     test_query_interface();
+    test_basefilter();
 
     release_video_renderer();
 }
diff --git a/dlls/quartz/transform.c b/dlls/quartz/transform.c
index b090e5b..2596f63 100644
--- a/dlls/quartz/transform.c
+++ b/dlls/quartz/transform.c
@@ -424,7 +424,8 @@ static HRESULT WINAPI TransformFilter_GetSyncSource(IBaseFilter * iface, IRefere
     EnterCriticalSection(&This->csFilter);
     {
         *ppClock = This->pClock;
-        IReferenceClock_AddRef(This->pClock);
+        if (This->pClock)
+            IReferenceClock_AddRef(This->pClock);
     }
     LeaveCriticalSection(&This->csFilter);
 
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c
index 5179bd0..f49f8fb 100644
--- a/dlls/quartz/videorenderer.c
+++ b/dlls/quartz/videorenderer.c
@@ -754,7 +754,8 @@ static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenc
     EnterCriticalSection(&This->csFilter);
     {
         *ppClock = This->pClock;
-        IReferenceClock_AddRef(This->pClock);
+        if (This->pClock)
+            IReferenceClock_AddRef(This->pClock);
     }
     LeaveCriticalSection(&This->csFilter);
     




More information about the wine-cvs mailing list