[QUARTZ] System clock fixes + misc

Christian Costa titan.costa at wanadoo.fr
Wed Dec 15 08:46:10 CST 2004


Hi,

Changelog:
Many fixes to the system clock implementation.
Ensure there is a clock before doing any AddRef or Release in the AVI 
splitter.
Improved tests a bit.
Misc fixes and traces clean-up.

Christian Costa   titan.costa at wanadoo.fr

-------------- next part --------------
Index: avisplit.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/avisplit.c,v
retrieving revision 1.7
diff -u -r1.7 avisplit.c
--- avisplit.c	30 Nov 2004 21:38:59 -0000	1.7
+++ avisplit.c	15 Dec 2004 11:30:11 -0000
@@ -224,7 +224,8 @@
         ULONG i;
 
         DeleteCriticalSection(&This->csFilter);
-        IReferenceClock_Release(This->pClock);
+        if (This->pClock)
+            IReferenceClock_Release(This->pClock);
         
         for (i = 0; i < This->cStreams + 1; i++)
             IPin_Release(This->ppPins[i]);
@@ -385,7 +386,8 @@
     EnterCriticalSection(&This->csFilter);
     {
         *ppClock = This->pClock;
-        IReferenceClock_AddRef(This->pClock);
+        if (This->pClock)
+            IReferenceClock_AddRef(This->pClock);
     }
     LeaveCriticalSection(&This->csFilter);
     
Index: filtergraph.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/filtergraph.c,v
retrieving revision 1.19
diff -u -r1.19 filtergraph.c
--- filtergraph.c	6 Dec 2004 11:47:13 -0000	1.19
+++ filtergraph.c	15 Dec 2004 11:30:20 -0000
@@ -495,7 +495,7 @@
     static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
     IPropertyBag * pPropBagCat = NULL;
     HRESULT hr;
-    
+
     VariantInit(pvar);
     V_VT(pvar) = VT_BSTR;
 
@@ -524,7 +524,7 @@
     HRESULT hr;
     ULONG nb = 0;
 
-    TRACE("\n");
+    TRACE("(%p, %p, %p, %p)\n");
     hr = IPin_QueryInternalConnections(poutputpin, NULL, &nb);
     if (hr == S_OK) {
         /* Rendered input */
@@ -1167,7 +1167,7 @@
 
     ResetEvent(This->hEventCompletion);
 
-    return S_OK;
+    return S_FALSE;
 }
 
 static HRESULT WINAPI Mediacontrol_Pause(IMediaControl *iface) {
Index: pin.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/pin.c,v
retrieving revision 1.8
diff -u -r1.8 pin.c
--- pin.c	8 Sep 2004 01:50:37 -0000	1.8
+++ pin.c	15 Dec 2004 11:30:25 -0000
@@ -730,7 +730,7 @@
     } /* if succeeded */
     LeaveCriticalSection(This->pin.pCritSec);
 
-    FIXME(" -- %lx\n", hr);
+    TRACE(" -- %lx\n", hr);
     return hr;
 }
 
Index: systemclock.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/systemclock.c,v
retrieving revision 1.7
diff -u -r1.7 systemclock.c
--- systemclock.c	9 Dec 2004 14:07:59 -0000	1.7
+++ systemclock.c	15 Dec 2004 11:30:25 -0000
@@ -111,16 +111,16 @@
       timeOut = INFINITE;
       goto outrefresh;
     }
-    
+
     /** First SingleShots Advice: sorted list */
-    for (it = This->pSingleShotAdvise; NULL != it && it->rtBaseTime <= curTime; it = it->next) {
+    for (it = This->pSingleShotAdvise; NULL != it && (it->rtBaseTime + it->rtIntervalTime) <= curTime; it = it->next) {
       /** send event ... */
       SetEvent((HANDLE) it->hEvent);
       /** ... and Release it */
       QUARTZ_RemoveAviseEntryFromQueue(This, it);
       HeapFree(GetProcessHeap(), 0, it);
     }
-    if (NULL != it) timeOut = (DWORD) (curTime - (it->rtBaseTime + it->rtIntervalTime));
+    if (NULL != it) timeOut = (DWORD) ((it->rtBaseTime + it->rtIntervalTime) - curTime) / (REFERENCE_TIME)10000;
 
     /** Now Periodics Advice: semi sorted list (sort cannot be used) */
     for (it = This->pPeriodicAdvise; NULL != it; it = it->next) {
@@ -129,10 +129,10 @@
 	/** Release the semaphore ... */
 	ReleaseSemaphore((HANDLE) it->hEvent, nPeriods, NULL);
 	/** ... and refresh time */
-	it->rtBaseTime += it->rtIntervalTime;
+	it->rtBaseTime += nPeriods * it->rtIntervalTime;
 	/*assert( it->rtBaseTime + it->rtIntervalTime < curTime );*/
       }
-      tmpTimeOut = (DWORD) (curTime - (it->rtBaseTime + it->rtIntervalTime));
+      tmpTimeOut = (DWORD) ((it->rtBaseTime + it->rtIntervalTime) - curTime) / (REFERENCE_TIME)10000;
       if (timeOut > tmpTimeOut) timeOut = tmpTimeOut; 
     }
 
@@ -175,10 +175,20 @@
 
 static BOOL SystemClockPostMessageToAdviseThread(SystemClockImpl* This, UINT iMsg) {
   if (FALSE == This->adviseThreadActive) {
+    BOOL res;
     This->adviseThread = CreateThread(NULL, 0, SystemClockAdviseThread, This, 0, &This->adviseThreadId);
     if (NULL == This->adviseThread) return FALSE;
     SetThreadPriority(This->adviseThread, THREAD_PRIORITY_TIME_CRITICAL);
     This->adviseThreadActive = TRUE;
+    while(1) {
+      res = PostThreadMessageA(This->adviseThreadId, iMsg, 0, 0);
+      /* Let the thread creates its message queue (with MsgWaitForMultipleObjects call) by yielding and retrying */
+      if (!res && (GetLastError() == ERROR_INVALID_THREAD_ID))
+	Sleep(0);
+      else
+	break;
+    }
+    return res;
   }
   return PostThreadMessageA(This->adviseThreadId, iMsg, 0, 0);
 }
Index: tests/filtergraph.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/tests/filtergraph.c,v
retrieving revision 1.3
diff -u -r1.3 filtergraph.c
--- tests/filtergraph.c	29 Nov 2004 17:01:21 -0000	1.3
+++ tests/filtergraph.c	15 Dec 2004 11:30:25 -0000
@@ -27,6 +27,8 @@
 #include "dshow.h"
 #include "control.h"
 
+WCHAR file[] = {'t','e','s','t','.','a','v','i',0};
+
 IGraphBuilder* pgraph;
 
 static void createfiltergraph()
@@ -37,10 +39,8 @@
     ok(hr==S_OK, "Creating filtergraph returned: %lx\n", hr);
 }
 
-#if 0
 static void renderfile()
 {
-    WCHAR file[] = {'t','e','s','t','.','a','v','i',0};
     HRESULT hr;
 
     hr = IGraphBuilder_RenderFile(pgraph, file, NULL);
@@ -56,27 +56,38 @@
     ok(hr==S_OK, "Cannot get IMediaControl interface returned: %lx\n", hr);
 
     hr = IMediaControl_Run(pmc);
-    ok(hr==S_OK, "Cannot run the graph returned: %lx\n", hr);
+    ok(hr==S_FALSE, "Cannot run the graph returned: %lx\n", hr);
+
+    Sleep(20000);
 
-    Sleep(20000); 
+    hr = IMediaControl_Stop(pmc);
+    ok(hr==S_OK, "Cannot stop the graph returned: %lx\n", hr);
+    
+    hr = IMediaControl_Release(pmc);
+    ok(hr==1, "Releasing mediacontrol returned: %lx\n", hr);     
 }
-#endif
 
 static void releasefiltergraph()
 {
     HRESULT hr;
 
     hr = IGraphBuilder_Release(pgraph);
-    ok(hr==S_OK, "Releasing filtergraph returned: %lx\n", hr);
+    ok(hr==0, "Releasing filtergraph returned: %lx\n", hr);
 }
 
 START_TEST(filtergraph)
 {
+    HANDLE h;
+	
     CoInitialize(NULL);
     createfiltergraph();
-#if 0
-    renderfile();
-    rungraph();
-#endif
+
+    h = CreateFileW(file, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+    if (h != INVALID_HANDLE_VALUE) {
+	CloseHandle(h);
+	renderfile();
+	rungraph();
+    }
+
     releasefiltergraph();
 }


More information about the wine-patches mailing list