msvfw32: When no fccHandler is specified return the first valid codec

Bruno Jesus 00cpxxx at gmail.com
Thu Oct 22 11:04:13 CDT 2015


Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>

When not properly configured CamStudio will call ICOpen with
fccHandler = 0, which means it is not important which codec is
returned. Currently wine fails in this case because 0x0 is not a valid
handler.

Fixes bug https://bugs.winehq.org/show_bug.cgi?id=22907
-------------- next part --------------
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index c48479d..4f1a2bf 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -436,6 +436,27 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
 
     TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode);
 
+    if (!fccHandler) /* No specific handler, return the first valid for wMode */
+    {
+        HIC local;
+        ICINFO info;
+        DWORD loop = 0;
+        info.dwSize = sizeof(info);
+        while(ICInfo(fccType, loop++, &info))
+        {
+            /* Ensure fccHandler is not 0x0 because we will recurse on ICOpen */
+            if(!info.fccHandler)
+                continue;
+            local = ICOpen(fccType, info.fccHandler, wMode);
+            if (local != 0)
+            {
+                TRACE("Returning %s as defult handler for %s\n",
+                      wine_dbgstr_fcc(info.fccHandler), wine_dbgstr_fcc(fccType));
+                return local;
+            }
+        }
+    }
+
     /* Check if there is a registered driver that matches */
     driver = reg_driver_list;
     while(driver)
@@ -448,7 +469,7 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
             driver = driver->next;
 
     if (driver && driver->proc)
-	/* The driver has been registered at runtime with its driverproc */
+        /* The driver has been registered at runtime with its driverproc */
         return ICOpenFunction(fccType, fccHandler, wMode, driver->proc);
   
     /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
@@ -478,7 +499,7 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
         codecname[9] = '\0';
 
         hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
-        if (!hdrv) 
+        if (!hdrv)
             return 0;
     } else {
         /* The driver has been registered at runtime with its name */
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c
index a9c4053..95f28f3 100644
--- a/dlls/msvfw32/tests/msvfw.c
+++ b/dlls/msvfw32/tests/msvfw.c
@@ -31,7 +31,6 @@ static void test_OpenCase(void)
     ICINFO info;
     /* Check if default handler works */
     h = ICOpen(mmioFOURCC('v','i','d','c'),0,ICMODE_DECOMPRESS);
-todo_wine
     ok(0!=h,"ICOpen(vidc.0) failed\n");
     if (h) {
         info.dwSize = sizeof(info);
@@ -41,7 +40,6 @@ todo_wine
         ok(ICClose(h)==ICERR_OK,"ICClose failed\n");
     }
     h = ICOpen(mmioFOURCC('v','i','d','c'),0,ICMODE_COMPRESS);
-todo_wine
     ok(0!=h || broken(h == 0),"ICOpen(vidc.0) failed\n");  /* Not present in Win8 */
     if (h) {
         info.dwSize = sizeof(info);


More information about the wine-patches mailing list