[MPlayer-dev-eng] [PATCH] Support CineForm DirectShow codec

Steinar H. Gunderson sgunderson at bigfoot.com
Sun Jan 10 16:17:45 CET 2010


On Sun, Jan 10, 2010 at 04:07:05PM +0100, Reimar Döffinger wrote:
> I strongly suggest you split this and submit the "obvious" bug fixes and
> implementations of simple new stub functions separately.
> They have a good chance of being accepted reasonably fast and makes the rest of
> the patch much easier to review without all the "clutter"

OK. How about this patch? Nothing CineForm-specific, no new stub functions.

/* Steinar */


diff -Nur orig/mplayer-export-2010-01-02/loader/dshow/interfaces.h mplayer-export-2010-01-02/loader/dshow/interfaces.h
--- orig/mplayer-export-2010-01-02/loader/dshow/interfaces.h	2008-02-23 15:50:55.000000000 +0100
+++ mplayer-export-2010-01-02/loader/dshow/interfaces.h	2010-01-06 01:07:14.000000000 +0100
diff -Nur orig/mplayer-export-2010-01-02/loader/registry.c mplayer-export-2010-01-02/loader/registry.c
--- orig/mplayer-export-2010-01-02/loader/registry.c	2009-05-04 19:35:26.000000000 +0200
+++ mplayer-export-2010-01-02/loader/registry.c	2010-01-06 21:09:22.000000000 +0100
@@ -385,7 +385,7 @@
     if(handle==head)
 	head=head->prev;
     free(handle);
-    return 1;
+    return 0;
 }
 
 long __stdcall RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
diff -Nur orig/mplayer-export-2010-01-02/loader/win32.c mplayer-export-2010-01-02/loader/win32.c
--- orig/mplayer-export-2010-01-02/loader/win32.c	2009-10-10 11:27:22.000000000 +0200
+++ mplayer-export-2010-01-02/loader/win32.c	2010-01-10 14:00:54.000000000 +0100
@@ -208,8 +208,8 @@
 	vprintf(fmt, va);
 //	mp_dbg(MSGT_WIN32, MSGL_DBG3, fmt, va);
 	va_end(va);
+        fflush(stdout);
     }
-  fflush(stdout);
 }
 
 
@@ -344,9 +344,7 @@
 /* -- critical sections -- */
 struct CRITSECT
 {
-    pthread_t id;
     pthread_mutex_t mutex;
-    int locked;
     long deadbeef;
 };
 
@@ -436,9 +434,8 @@
 
     alccnt--;
 
-    if (last_alloc)
-	pthread_mutex_unlock(&memmut);
-    else
+    pthread_mutex_unlock(&memmut);
+    if (!last_alloc)
 	pthread_mutex_destroy(&memmut);
 
     //if (alccnt < 40000) printf("MY_RELEASE: %p\t%ld    (%d)\n", header, header->size, alccnt);
@@ -639,9 +637,11 @@
 };
 typedef struct mutex_list_t mutex_list;
 static mutex_list* mlist=NULL;
+static pthread_mutex_t mlist_lock = PTHREAD_MUTEX_INITIALIZER;
 
 void destroy_event(void* event)
 {
+    pthread_mutex_lock(&mlist_lock);
     mutex_list* pp=mlist;
     //    printf("garbage collector: destroy_event(%x)\n", event);
     while(pp)
@@ -663,10 +663,12 @@
 	     }
 	     printf("0\n");
 	     */
+            pthread_mutex_unlock(&mlist_lock);
 	    return;
 	}
 	pp=pp->prev;
     }
+    pthread_mutex_unlock(&mlist_lock);
 }
 
 static void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
@@ -674,6 +676,7 @@
 {
     pthread_mutex_t *pm;
     pthread_cond_t  *pc;
+    void *ret;
     /*
      mutex_list* pp;
      pp=mlist;
@@ -684,6 +687,7 @@
      }
      printf("0\n");
      */
+    pthread_mutex_lock(&mlist_lock);
     if(mlist!=NULL)
     {
 	mutex_list* pp=mlist;
@@ -694,6 +698,7 @@
 	    {
 		dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
 			  pSecAttr, bManualReset, bInitialState, name, name, pp->pm);
+                pthread_mutex_unlock(&mlist_lock);
 		return pp->pm;
 	    }
 	}while((pp=pp->prev) != NULL);
@@ -718,7 +723,7 @@
     mlist->pm=pm;
     mlist->pc=pc;
     mlist->state=bInitialState;
-    mlist->reset=bManualReset;
+    mlist->reset=!bManualReset;
     if(name)
 	strncpy(mlist->name, name, 127);
     else
@@ -735,7 +740,9 @@
     else
 	dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, NULL) => 0x%x\n",
 		  pSecAttr, bManualReset, bInitialState, mlist);
-    return mlist;
+    ret = mlist;
+    pthread_mutex_unlock(&mlist_lock);
+    return ret;
 }
 
 static void* WINAPI expSetEvent(void* event)
@@ -767,7 +774,9 @@
     mutex_list *ml = (mutex_list *)object;
     // FIXME FIXME FIXME - this value is sometime unititialize !!!
     int ret = WAIT_FAILED;
+    pthread_mutex_lock(&mlist_lock);
     mutex_list* pp=mlist;
+    pthread_mutex_unlock(&mlist_lock);
     if(object == (void*)0xcfcf9898)
     {
 	/**
@@ -1308,8 +1321,10 @@
 	    printf("InitializeCriticalSection(%p) - out of memory\n", c);
 	    return;
 	}
-	pthread_mutex_init(&cs->mutex, NULL);
-	cs->locked = 0;
+        pthread_mutexattr_t mutex_attr;
+	pthread_mutexattr_init(&mutex_attr);
+	pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_NP);
+	pthread_mutex_init(&cs->mutex, &mutex_attr);
 	critsecs_list[i].cs_win = c;
 	critsecs_list[i].cs_unix = cs;
 	dbgprintf("InitializeCriticalSection -> itemno=%d, cs_win=%p, cs_unix=%p\n",
@@ -1319,8 +1334,10 @@
     {
 	struct CRITSECT* cs = mreq_private(sizeof(struct CRITSECT) + sizeof(CRITICAL_SECTION),
 					   0, AREATYPE_CRITSECT);
-	pthread_mutex_init(&cs->mutex, NULL);
-	cs->locked=0;
+        pthread_mutexattr_t mutex_attr;
+	pthread_mutexattr_init(&mutex_attr);
+	pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_NP);
+	pthread_mutex_init(&cs->mutex, &mutex_attr);
         cs->deadbeef = 0xdeadbeef;
 	*(void**)c = cs;
     }
@@ -1347,12 +1364,7 @@
 #endif
 	dbgprintf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
     }
-    if(cs->locked)
-	if(cs->id==pthread_self())
-	    return;
     pthread_mutex_lock(&(cs->mutex));
-    cs->locked=1;
-    cs->id=pthread_self();
     return;
 }
 static void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
@@ -1369,13 +1381,7 @@
 	dbgprintf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c);
 	return;
     }
-    if (cs->locked)
-    {
-	cs->locked=0;
-	pthread_mutex_unlock(&(cs->mutex));
-    }
-    else
-	dbgprintf("Win32 Warning: Unlocking unlocked Critical Section %p!!\n", c);
+    pthread_mutex_unlock(&(cs->mutex));
     return;
 }
 
@@ -1397,12 +1403,6 @@
 	return;
     }
 
-    if (cs->locked)
-    {
-	dbgprintf("Win32 Warning: Deleting unlocked Critical Section %p!!\n", c);
-	pthread_mutex_unlock(&(cs->mutex));
-    }
-
 #ifndef GARBAGE
     pthread_mutex_destroy(&(cs->mutex));
     // released by GarbageCollector in my_relase otherwise
@@ -1735,6 +1735,7 @@
 {
     pthread_mutex_t *pm;
     pthread_cond_t  *pc;
+    HANDLE ret;
     /*
     mutex_list* pp;
      printf("CreateSemaphoreA(%p = %s)\n", name, (name ? name : "<null>"));
@@ -1746,6 +1747,7 @@
      }
      printf("0\n");
      */
+    pthread_mutex_lock(&mlist_lock);
     if(mlist!=NULL)
     {
 	mutex_list* pp=mlist;
@@ -1756,7 +1758,9 @@
 	    {
 		dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x\n",
 			  v1, init_count, max_count, name, name, mlist);
-		return (HANDLE)mlist;
+		ret = (HANDLE)mlist;
+                pthread_mutex_unlock(&mlist_lock);
+                return ret;
 	    }
 	}while((pp=pp->prev) != NULL);
     }
@@ -1795,7 +1799,9 @@
     else
 	dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0) => 0x%x\n",
 		  v1, init_count, max_count, mlist);
-    return (HANDLE)mlist;
+    ret = (HANDLE)mlist;
+    pthread_mutex_unlock(&mlist_lock);
+    return ret;
 }
 
 static long WINAPI expReleaseSemaphore(long hsem, long increment, long* prev_count)

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



More information about the MPlayer-dev-eng mailing list