Devenum fixes

Maarten Lankhorst m.b.lankhorst at gmail.com
Thu May 5 04:53:26 CDT 2005


Well, multiple fixes meant to fix broken behaviour, with these patches i 
can finally make a seperation between the vfw capture devices in a 
microsoft compliant (TM/puke) way

- Makes the video input category use devenum/video%d, so if you have 
multiple devices with the same name you can still use both
- Writes a vfwindex value
- Makes mediacatenum use ipersistpropertybag if available, so vfwcapture 
can initialise properly..
-------------- next part --------------
? config.log
Index: Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/devenum/Makefile.in,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile.in
--- Makefile.in	27 Apr 2005 11:07:55 -0000	1.10
+++ Makefile.in	5 May 2005 09:45:03 -0000
@@ -4,7 +4,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = devenum.dll
 IMPORTS   = ole32 oleaut32 avicap32 winmm user32 advapi32 kernel32
-EXTRALIBS = -lstrmiids -luuid
+EXTRALIBS = -lstrmiids -luuid $(LIBUNICODE)
 
 C_SRCS = \
 	createdevenum.c \
Index: createdevenum.c
===================================================================
RCS file: /home/wine/wine/dlls/devenum/createdevenum.c,v
retrieving revision 1.10
diff -u -p -r1.10 createdevenum.c
--- createdevenum.c	27 Apr 2005 11:07:55 -0000	1.10
+++ createdevenum.c	5 May 2005 09:45:03 -0000
@@ -30,6 +30,7 @@
 #include "vfw.h"
 
 #include "wine/debug.h"
+#include "wine/unicode.h"
 #include "mmddk.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(devenum);
@@ -420,13 +421,17 @@ static HRESULT DEVENUM_CreateSpecialCate
         if (SUCCEEDED(res))
             for (i = 0; i < 10; i++)
             {
-                WCHAR szDeviceName[80], szDeviceVersion[80];
+                WCHAR szDeviceName[32], szDeviceVersion[32], szDevicePath[10];
 
                 if (capGetDriverDescriptionW ((WORD) i,
                                               szDeviceName, sizeof(szDeviceName)/sizeof(WCHAR),
                                               szDeviceVersion, sizeof(szDeviceVersion)/sizeof(WCHAR)))
                 {
                     IMoniker * pMoniker = NULL;
+                    IPropertyBag * pPropBag = NULL;
+                    WCHAR dprintf[] = { 'v','i','d','e','o','%','d',0 };
+                    snprintfW(szDevicePath, sizeof(szDevicePath)/sizeof(WCHAR), dprintf, i);
+                    /* The above code prevents 1 device with a different ID overwriting another */
 
                     rfp2.nMediaTypes = 1;
                     pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES));
@@ -436,7 +441,7 @@ static HRESULT DEVENUM_CreateSpecialCate
                     }
 
                     pTypes[0].clsMajorType = &MEDIATYPE_Video;
-                    pTypes[0].clsMinorType = &MEDIASUBTYPE_RGB24;
+                    pTypes[0].clsMinorType = &MEDIASUBTYPE_None;
 
                     rfp2.lpMediaType = pTypes;
 
@@ -445,11 +450,19 @@ static HRESULT DEVENUM_CreateSpecialCate
                                                         szDeviceName,
                                                         &pMoniker,
                                                         &CLSID_VideoInputDeviceCategory,
-                                                        szDeviceName,
+                                                        szDevicePath,
                                                         &rf2);
 
-                    /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */
-                    if (pMoniker) IMoniker_Release(pMoniker);
+                    if (pMoniker) {
+                       OLECHAR wszVfwIndex[] = { 'V','F','W','I','n','d','e','x',0 };
+                       VARIANT var;
+                       V_VT(&var) = VT_I4;
+                       V_UNION(&var, ulVal) = (ULONG)i;
+                       res = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID)&pPropBag);
+                       if (SUCCEEDED(res))
+                          res = IPropertyBag_Write(pPropBag, wszVfwIndex, &var);
+                       IMoniker_Release(pMoniker);
+                    }
 
                     if (i == iDefaultDevice) FIXME("Default device\n");
                     CoTaskMemFree(pTypes);
Index: mediacatenum.c
===================================================================
RCS file: /home/wine/wine/dlls/devenum/mediacatenum.c,v
retrieving revision 1.15
diff -u -p -r1.15 mediacatenum.c
--- mediacatenum.c	26 Apr 2005 08:15:38 -0000	1.15
+++ mediacatenum.c	5 May 2005 09:45:04 -0000
@@ -25,6 +25,7 @@
 #include "devenum_private.h"
 #include "vfwmsgs.h"
 #include "oleauto.h"
+#include "ocidl.h"
 
 #include "wine/debug.h"
 
@@ -432,6 +433,16 @@ static HRESULT WINAPI DEVENUM_IMediaCatM
     {
         /* get the requested interface from the loaded class */
         res= IUnknown_QueryInterface(pObj,riidResult,ppvResult);
+        if (pProp) {
+           HRESULT res2;
+           LPVOID ppv = NULL;
+           res2 = IUnknown_QueryInterface(pObj, &IID_IPersistPropertyBag, &ppv);
+           if (SUCCEEDED(res2)) {
+              res = IPersistPropertyBag_Load((IPersistPropertyBag *) ppv, pProp, NULL);
+              IPersistPropertyBag_Release((IPersistPropertyBag *) ppv);
+              if (FAILED(res)) IUnknown_Release((IUnknown *)ppvResult);
+           }
+        }
         IUnknown_Release(pObj);
     }
 


More information about the wine-patches mailing list