[MPlayer-dev-eng] [PATCH] Support thread handles in WaitForSingleObject

Steinar H. Gunderson sgunderson at bigfoot.com
Tue Mar 2 12:42:01 CET 2010


Some codecs need this for clean shutdown (as opposed to a crash); we don't
really support timed wait since POSIX doesn't, but it doesn't seem necessary.

--- a/loader/win32.c	2010-03-02 12:04:17.000000000 +0100
+++ b/loader/win32.c	2010-03-02 12:34:57.000000000 +0100
@@ -786,6 +786,7 @@ static void* WINAPI expWaitForSingleObje
     // FIXME FIXME FIXME - this value is sometime unititialize !!!
     int ret = WAIT_FAILED;
     mutex_list* pp=mlist;
+    th_list* tp=list;
     if(object == (void*)0xcfcf9898)
     {
 	/**
@@ -801,6 +802,17 @@ static void* WINAPI expWaitForSingleObje
     }
     dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration);
 
+    // See if this is a thread.
+    while (tp && (tp->thread != object))
+        tp = tp->prev;
+    if (tp) {
+        if (pthread_join(*(pthread_t*)object, NULL) == 0) {
+            return (void*)WAIT_OBJECT_0;
+        } else {
+            return (void*)WAIT_FAILED;
+        }
+    }
+    
     // loop below was slightly fixed - its used just for checking if
     // this object really exists in our list
     if (!ml)


-- 
Homepage: http://www.sesse.net/



More information about the MPlayer-dev-eng mailing list