interfaces for WINMM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this part is mainly intended to ease up the porting of Wine multimedia code to ReactOS. As Steven Edwards noted, OpenDriverW doesn't exist as export of WINMM, but is in fact called OpenDriver. Latest Windows version even drop the OpenDriverA form.
This patch takes care of this (keeping OpenDriverA internal to WINMM for upwardd compatibility issues, but forcing the use of OpenDriver (unicode form) for the other native DLLs (msacm and msvideo).
It also removes a few more wine-ism in winmm implementation (pure 32 bit part).


A+
--
Eric Pouech
Name:          ros_mm
ChangeLog:     
	- renamed winmm.OpenDriverW into winmm.OpenDriver
	- replaced all inter-DLL calls (msacm and msvideo) to OpenDriverA with OpenDriver (unicode form)
	- as a consequence, driver name handling in msacm is now mostly unicode
	- moved UserYield16 and UnMapLS call out of the 32bit part of winmm
License:       X11
GenDate:       2003/07/01 20:11:14 UTC
ModifiedFiles: dlls/winmm/winmm.spec dlls/winmm/mmio.c dlls/winmm/winmm.c dlls/winmm/mmsystem.c dlls/msacm/internal.c dlls/msacm/driver.c dlls/msacm/stream.c dlls/msacm/wineacm.h dlls/msvideo/msvideo_main.c include/mmsystem.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mmio.c,v
retrieving revision 1.38
diff -u -u -r1.38 mmio.c
--- dlls/winmm/mmio.c	31 Oct 2002 01:02:41 -0000	1.38
+++ dlls/winmm/mmio.c	30 Jun 2003 18:36:21 -0000
@@ -261,7 +261,7 @@
     struct IOProcList*  pListNode;
     struct IOProcList** ppListNode;
 
-    TRACE("(%ld, %p, %08lX, %i)\n", fccIOProc, pIOProc, dwFlags, type);
+    TRACE("(%08lx, %p, %08lX, %i)\n", fccIOProc, pIOProc, dwFlags, type);
 
     if (dwFlags & MMIO_GLOBALPROC)
 	FIXME("Global procedures not implemented\n");
@@ -529,14 +529,16 @@
     wm->info.pchEndRead = wm->info.pchBuffer;
     wm->info.pchEndWrite = wm->info.pchBuffer + wm->info.cchBuffer;
 
+    wm->bBufferLoaded = TRUE;
     if (for_read) {
 	size = send_message(wm->ioProc, &wm->info, MMIOM_READ, 
                             (LPARAM)wm->info.pchBuffer, size, MMIO_PROC_32A);
 	if (size > 0)
 	    wm->info.pchEndRead += size;
+        else
+            wm->bBufferLoaded = FALSE;
     }
 
-    wm->bBufferLoaded = TRUE;
     return size;
 }
 
@@ -560,13 +562,6 @@
         HeapFree(GetProcessHeap(), 0, wm->info.pchBuffer);
         wm->info.pchBuffer = NULL;
 	wm->info.dwFlags &= ~MMIO_ALLOCBUF;
-    }
-
-    /* free segmented ptr mapping, if any */
-    if (wm->info.dwReserved1 != 0L)
-    {
-        UnMapLS(wm->info.dwReserved1);
-        wm->info.dwReserved1 = 0L;
     }
 
     if (pchBuffer) {
Index: dlls/winmm/winmm.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/winmm.c,v
retrieving revision 1.17
diff -u -u -r1.17 winmm.c
--- dlls/winmm/winmm.c	30 Jun 2003 20:53:48 -0000	1.17
+++ dlls/winmm/winmm.c	1 Jul 2003 18:59:39 -0000
@@ -34,7 +34,7 @@
 #define NONAMELESSSTRUCT
 #include "mmsystem.h"
 #include "winbase.h"
-#include "wine/winuser16.h" /* FIXME: should be removed, only used for UserYield16 */
+#include "winuser.h"
 #include "heap.h"
 #include "winternl.h"
 #include "winemm.h"
@@ -43,6 +43,21 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(winmm);
 
+/******************************************************************
+ *		MyUserYield
+ *
+ * Internal wrapper to call USER.UserYield16 (in fact through a Wine only export from USER32).
+ */
+static void MyUserYield(void)
+{
+    HMODULE mod = GetModuleHandleA( "user32.dll" );
+    if (mod)
+    {
+        FARPROC proc = GetProcAddress( mod, "UserYield16" );
+        if (proc) proc();
+    }
+}
+
 /* ========================================================================
  *                   G L O B A L   S E T T I N G S
  * ========================================================================*/
@@ -812,7 +827,7 @@
 
     if ((HIWORD(data) != 0 && HWND_16(GetActiveWindow()) != HIWORD(data)) ||
 	(GetAsyncKeyState(LOWORD(data)) & 1) == 0) {
-	UserYield16();
+	MyUserYield();
 	ret = 0;
     } else {
 	MSG		msg;
@@ -906,7 +921,7 @@
     TRACE("(%04x)\n", uDeviceID);
 
     if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc || !wmd->bIs32) {
-	UserYield16();
+	MyUserYield();
     } else {
 	ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData);
     }
Index: dlls/winmm/mmsystem.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mmsystem.c,v
retrieving revision 1.92
diff -u -u -r1.92 mmsystem.c
--- dlls/winmm/mmsystem.c	30 Apr 2003 17:28:45 -0000	1.92
+++ dlls/winmm/mmsystem.c	30 Jun 2003 18:44:16 -0000
@@ -4,7 +4,7 @@
  * MMSYTEM functions
  *
  * Copyright 1993      Martin Ayotte
- *           1998-2002 Eric Pouech
+ *           1998-2003 Eric Pouech
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,10 +26,6 @@
  *  	99/4	added mmTask and mmThread functions support
  */
 
-/* FIXME: I think there are some segmented vs. linear pointer weirdnesses
- *        and long term pointers to 16 bit space in here
- */
-
 #include <string.h>
 
 #define NONAMELESSUNION
@@ -2690,12 +2686,13 @@
  *             MMIO_ResetSegmentedData
  *
  */
-static LRESULT     MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr)
+static LRESULT     MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr, BOOL release)
 {
     LPWINE_MMIO		wm;
 
     if ((wm = MMIO_Get(hmmio)) == NULL)
 	return MMSYSERR_INVALHANDLE;
+    if (release) UnMapLS(wm->segBuffer16);
     wm->segBuffer16 = ptr;
     return MMSYSERR_NOERROR;
 }
@@ -2727,7 +2724,7 @@
 	mmioinfo.adwInfo[3]  = lpmmioinfo16->adwInfo[3];
 
 	ret = MMIO_Open(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_16);
-        MMIO_SetSegmentedBuffer(mmioinfo.hmmio, (SEGPTR)lpmmioinfo16->pchBuffer);
+        MMIO_SetSegmentedBuffer(mmioinfo.hmmio, (SEGPTR)lpmmioinfo16->pchBuffer, FALSE);
 
 	lpmmioinfo16->wErrorRet = mmioinfo.wErrorRet;
         lpmmioinfo16->hmmio     = HMMIO_16(mmioinfo.hmmio);
@@ -2742,6 +2739,7 @@
  */
 MMRESULT16 WINAPI mmioClose16(HMMIO16 hmmio, UINT16 uFlags)
 {
+    MMIO_SetSegmentedBuffer(HMMIO_32(hmmio), (SEGPTR)NULL, TRUE);
     return mmioClose(HMMIO_32(hmmio), uFlags);
 }
 
@@ -2854,7 +2852,9 @@
                                     cchBuffer, uFlags);
 
     if (ret == MMSYSERR_NOERROR)
-        MMIO_SetSegmentedBuffer(HMMIO_32(hmmio), (DWORD)pchBuffer);
+        MMIO_SetSegmentedBuffer(HMMIO_32(hmmio), (DWORD)pchBuffer, TRUE);
+    else
+        UnMapLS((DWORD)pchBuffer);
     return ret;
 }
 
Index: dlls/msacm/internal.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/msacm/internal.c,v
retrieving revision 1.15
diff -u -u -r1.15 internal.c
--- dlls/msacm/internal.c	14 Jan 2003 23:43:42 -0000	1.15
+++ dlls/msacm/internal.c	29 Jun 2003 19:39:49 -0000
@@ -34,6 +34,7 @@
 #include "msacmdrv.h"
 #include "wineacm.h"
 #include "wine/debug.h"
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msacm);
 
@@ -112,7 +113,7 @@
     for (ntag = 0; ntag < add.cFormatTags; ntag++) {
 	aftd.dwFormatTagIndex = ntag;
 	if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, (LPARAM)&aftd, ACM_FORMATTAGDETAILSF_INDEX)) {
-	    TRACE("IIOs (%s)\n", padid->pszDriverAlias);
+	    TRACE("IIOs (%s)\n", debugstr_w(padid->pszDriverAlias));
 	    goto errCleanUp;
 	}
 	padid->aFormatTag[ntag].dwFormatTag = aftd.dwFormatTag;
@@ -133,23 +134,25 @@
 /***********************************************************************
  *           MSACM_GetRegistryKey
  */
-static	LPSTR	MSACM_GetRegistryKey(const WINE_ACMDRIVERID* padid)
+static	LPWSTR	MSACM_GetRegistryKey(const WINE_ACMDRIVERID* padid)
 {
-    static const char*	baseKey = "Software\\Microsoft\\AudioCompressionManager\\DriverCache\\";
-    LPSTR	ret;
+    static const WCHAR	baseKey[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
+                                     'A','u','d','i','o','C','o','m','p','r','e','s','s','i','o','n','M','a','n','a','g','e','r','\\',
+                                     'D','r','i','v','e','r','C','a','c','h','e','\\','\0'};
+    LPWSTR	ret;
     int		len;
 
     if (!padid->pszDriverAlias) {
 	ERR("No alias needed for registry entry\n");
 	return NULL;
     }
-    len = strlen(baseKey);
-    ret = HeapAlloc(MSACM_hHeap, 0, len + strlen(padid->pszDriverAlias) + 1);
+    len = strlenW(baseKey);
+    ret = HeapAlloc(MSACM_hHeap, 0, (len + strlenW(padid->pszDriverAlias) + 1) * sizeof(WCHAR));
     if (!ret) return NULL;
 
-    strcpy(ret, baseKey);
-    strcpy(ret + len, padid->pszDriverAlias);
-    CharLowerA(ret + len);
+    strcpyW(ret, baseKey);
+    strcpyW(ret + len, padid->pszDriverAlias);
+    CharLowerW(ret + len);
     return ret;
 }
 
@@ -158,7 +161,7 @@
  */
 static BOOL MSACM_ReadCache(PWINE_ACMDRIVERID padid)
 {
-    LPSTR	key = MSACM_GetRegistryKey(padid);
+    LPWSTR	key = MSACM_GetRegistryKey(padid);
     HKEY	hKey;
     DWORD	type, size;
 
@@ -166,7 +169,7 @@
 
     padid->aFormatTag = NULL;
 
-    if (RegCreateKeyA(HKEY_LOCAL_MACHINE, key, &hKey))
+    if (RegCreateKeyW(HKEY_LOCAL_MACHINE, key, &hKey))
 	goto errCleanUp;
 
     size = sizeof(padid->cFormatTags);
@@ -202,12 +205,12 @@
  */
 static	BOOL MSACM_WriteCache(PWINE_ACMDRIVERID padid)
 {
-    LPSTR	key = MSACM_GetRegistryKey(padid);
+    LPWSTR	key = MSACM_GetRegistryKey(padid);
     HKEY	hKey;
 
     if (!key) return FALSE;
 
-    if (RegCreateKeyA(HKEY_LOCAL_MACHINE, key, &hKey))
+    if (RegCreateKeyW(HKEY_LOCAL_MACHINE, key, &hKey))
 	goto errCleanUp;
 
     if (RegSetValueExA(hKey, "cFormatTags", 0, REG_DWORD, (void*)&padid->cFormatTags, sizeof(DWORD)))
@@ -231,12 +234,13 @@
 /***********************************************************************
  *           MSACM_RegisterDriver()
  */
-PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
+PWINE_ACMDRIVERID MSACM_RegisterDriver(LPWSTR pszDriverAlias, LPWSTR pszFileName,
 				       HINSTANCE hinstModule)
 {
     PWINE_ACMDRIVERID	padid;
 
-    TRACE("('%s', '%s', %p)\n", pszDriverAlias, pszFileName, hinstModule);
+    TRACE("(%s, %s, %p)\n", 
+          debugstr_w(pszDriverAlias), debugstr_w(pszFileName), hinstModule);
 
     padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
     padid->obj.dwType = WINE_ACMOBJ_DRIVERID;
@@ -244,14 +248,14 @@
     padid->pszDriverAlias = NULL;
     if (pszDriverAlias)
     {
-        padid->pszDriverAlias = HeapAlloc( MSACM_hHeap, 0, strlen(pszDriverAlias)+1 );
-        strcpy( padid->pszDriverAlias, pszDriverAlias );
+        padid->pszDriverAlias = HeapAlloc( MSACM_hHeap, 0, (strlenW(pszDriverAlias)+1) * sizeof(WCHAR) );
+        strcpyW( padid->pszDriverAlias, pszDriverAlias );
     }
     padid->pszFileName = NULL;
     if (pszFileName)
     {
-        padid->pszFileName = HeapAlloc( MSACM_hHeap, 0, strlen(pszFileName)+1 );
-        strcpy( padid->pszFileName, pszFileName );
+        padid->pszFileName = HeapAlloc( MSACM_hHeap, 0, (strlenW(pszFileName)+1) * sizeof(WCHAR) );
+        strcpyW( padid->pszFileName, pszFileName );
     }
     padid->hInstModule = hinstModule;
 
@@ -265,7 +269,7 @@
 	MSACM_pFirstACMDriverID = padid;
     /* disable the driver if we cannot load the cache */
     if (!MSACM_ReadCache(padid) && !MSACM_FillCache(padid)) {
-	WARN("Couldn't load cache for ACM driver (%s)\n", pszFileName);
+	WARN("Couldn't load cache for ACM driver (%s)\n", debugstr_w(pszFileName));
 	MSACM_UnregisterDriver(padid);
 	return NULL;
     }
@@ -277,8 +281,12 @@
  */
 void MSACM_RegisterAllDrivers(void)
 {
-    LPSTR pszBuffer;
+    LPWSTR pszBuffer;
     DWORD dwBufferLength;
+    static WCHAR msacm32[] = {'m','s','a','c','m','3','2','.','d','l','l','\0'};
+    static WCHAR msacmW[] = {'M','S','A','C','M','.'};
+    static WCHAR drv32[] = {'d','r','i','v','e','r','s','3','2','\0'};
+    static WCHAR sys[] = {'s','y','s','t','e','m','.','i','n','i','\0'};
 
     /* FIXME
      *  What if the user edits system.ini while the program is running?
@@ -291,26 +299,32 @@
     dwBufferLength = 1024;
 /* EPP 	GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
 
-    pszBuffer = (LPSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength);
-    if (GetPrivateProfileSectionA("drivers32", pszBuffer, dwBufferLength, "system.ini")) {
-	char* s = pszBuffer;
-	while (*s) {
-	    if (!strncasecmp("MSACM.", s, 6)) {
-		char *s2 = s;
+    pszBuffer = (LPWSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength * sizeof(WCHAR));
+    if (GetPrivateProfileSectionW(drv32, pszBuffer, dwBufferLength, sys))
+    {
+	LPWSTR s = pszBuffer, s2;
+
+	while (*s)
+        {
+            CharUpperBuffW(s, 6);
+            if (memcmp(s, msacmW, 6 * sizeof(WCHAR)) == 0)
+            {
+                s2 = s;
 		while (*s2 != '\0' && *s2 != '=') s2++;
-		if (*s2) {
+		if (*s2)
+                {
 		    *s2 = '\0';
 		    MSACM_RegisterDriver(s, s2 + 1, 0);
 		    *s2 = '=';
 		}
 	    }
-	    s += strlen(s) + 1; /* Either next char or \0 */
+	    s += strlenW(s) + 1; /* Either next char or \0 */
 	}
     }
 
     HeapFree(MSACM_hHeap, 0, pszBuffer);
 
-    MSACM_RegisterDriver("msacm32.dll", "msacm32.dll", 0);
+    MSACM_RegisterDriver(msacm32, msacm32, 0);
 }
 
 /***********************************************************************
Index: dlls/msacm/driver.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/msacm/driver.c,v
retrieving revision 1.21
diff -u -u -r1.21 driver.c
--- dlls/msacm/driver.c	22 Oct 2002 00:46:23 -0000	1.21
+++ dlls/msacm/driver.c	29 Jun 2003 19:03:24 -0000
@@ -292,15 +292,12 @@
         len = strlen("Drivers32") + 1;
         adod.pszSectionName = HeapAlloc(MSACM_hHeap, 0, len * sizeof(WCHAR));
         MultiByteToWideChar(CP_ACP, 0, "Drivers32", -1, (LPWSTR)adod.pszSectionName, len);
-        len = strlen(padid->pszDriverAlias) + 1;
-        adod.pszAliasName = HeapAlloc(MSACM_hHeap, 0, len * sizeof(WCHAR));
-        MultiByteToWideChar(CP_ACP, 0, padid->pszDriverAlias, -1, (LPWSTR)adod.pszAliasName, len);
+        adod.pszAliasName = padid->pszDriverAlias;
         adod.dnDevNode = 0;
 
-        pad->hDrvr = OpenDriverA(padid->pszDriverAlias, NULL, (DWORD)&adod);
+        pad->hDrvr = OpenDriver(padid->pszDriverAlias, NULL, (DWORD)&adod);
 
         HeapFree(MSACM_hHeap, 0, (LPWSTR)adod.pszSectionName);
-        HeapFree(MSACM_hHeap, 0, (LPWSTR)adod.pszAliasName);
         if (!pad->hDrvr)
         {
             ret = adod.dwError;
@@ -314,7 +311,7 @@
 
     /* FIXME: Create a WINE_ACMDRIVER32 */
     *phad = (HACMDRIVER)pad;
-    TRACE("'%s' => %08lx\n", padid->pszDriverAlias, (DWORD)pad);
+    TRACE("'%s' => %08lx\n", debugstr_w(padid->pszDriverAlias), (DWORD)pad);
 
     return MMSYSERR_NOERROR;
  gotError:
Index: dlls/msacm/stream.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/msacm/stream.c,v
retrieving revision 1.13
diff -u -u -r1.13 stream.c
--- dlls/msacm/stream.c	23 Jan 2003 21:21:02 -0000	1.13
+++ dlls/msacm/stream.c	1 Jul 2003 19:28:55 -0000
@@ -216,7 +216,7 @@
 		was->hAcmDriver = had;
 
 		ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
-		TRACE("%s => %08x\n", wadi->pszDriverAlias, ret);
+		TRACE("%s => %08x\n", debugstr_w(wadi->pszDriverAlias), ret);
 		if (ret == MMSYSERR_NOERROR) {
 		    if (fdwOpen & ACM_STREAMOPENF_QUERY) {
 			acmDriverClose(had, 0L);
Index: dlls/msacm/wineacm.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/msacm/wineacm.h,v
retrieving revision 1.10
diff -u -u -r1.10 wineacm.h
--- dlls/msacm/wineacm.h	31 May 2002 23:25:48 -0000	1.10
+++ dlls/msacm/wineacm.h	29 Jun 2003 19:03:31 -0000
@@ -317,8 +317,8 @@
 typedef struct _WINE_ACMDRIVERID
 {
     WINE_ACMOBJ		obj;
-    LPSTR		pszDriverAlias;
-    LPSTR               pszFileName;
+    LPWSTR		pszDriverAlias;
+    LPWSTR              pszFileName;
     HINSTANCE		hInstModule;          /* NULL if global */
     PWINE_ACMDRIVER     pACMDriverList;
     PWINE_ACMDRIVERID   pNextACMDriverID;
@@ -337,7 +337,7 @@
 extern HANDLE MSACM_hHeap;
 extern PWINE_ACMDRIVERID MSACM_pFirstACMDriverID;
 extern PWINE_ACMDRIVERID MSACM_pLastACMDriverID;
-extern PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
+extern PWINE_ACMDRIVERID MSACM_RegisterDriver(LPWSTR pszDriverAlias, LPWSTR pszFileName,
 					      HINSTANCE hinstModule);
 extern void MSACM_RegisterAllDrivers(void);
 extern PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p);
Index: dlls/msvideo/msvideo_main.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/msvideo/msvideo_main.c,v
retrieving revision 1.50
diff -u -u -r1.50 msvideo_main.c
--- dlls/msvideo/msvideo_main.c	30 Jun 2003 02:04:26 -0000	1.50
+++ dlls/msvideo/msvideo_main.c	1 Jul 2003 19:23:44 -0000
@@ -48,12 +48,13 @@
 static WINE_HIC*        MSVIDEO_FirstHic /* = NULL */;
 
 typedef struct _reg_driver reg_driver;
-struct _reg_driver{
-	DWORD fccType;
-	DWORD fccHandler;
-	DRIVERPROC proc;
-	char* name;
-	reg_driver* next;
+struct _reg_driver
+{
+    DWORD       fccType;
+    DWORD       fccHandler;
+    DRIVERPROC  proc;
+    LPWSTR      name;
+    reg_driver* next;
 };
 
 static reg_driver* reg_driver_list = NULL;
@@ -164,34 +165,37 @@
 BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags) 
 {
     reg_driver* driver;
+    unsigned len;
 
     TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags);
 
     /* Check if a driver is already registered */
-    driver = reg_driver_list;
-    while(driver)
+    for (driver = reg_driver_list; driver; driver = driver->next)
+    {
         if (!compare_fourcc(fccType, driver->fccType) &&
             !compare_fourcc(fccHandler, driver->fccHandler))
             break;
-        else
-            driver = driver->next;
-    if (driver)
-        return FALSE;
+    }
+    if (driver) return FALSE;
 
     /* Register the driver */
     driver = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(reg_driver));
+    if (!driver) goto oom;
     driver->fccType = fccType;
     driver->fccHandler = fccHandler;
 
-    switch(wFlags) {
+    switch(wFlags)
+    {
     case ICINSTALL_FUNCTION:
         driver->proc = (DRIVERPROC)lParam;
 	driver->name = NULL;
         break;
     case ICINSTALL_DRIVER:
 	driver->proc = NULL;
-	driver->name = HeapAlloc(GetProcessHeap(), 0, strlen((char*)lParam));
-	strcpy(driver->name, (char*) lParam);
+        len = MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, NULL, 0);
+        driver->name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+        if (!driver->name) goto oom;
+        MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, driver->name, len);
 	break;
     default:
 	ERR("Invalid flags!\n");
@@ -204,6 +208,9 @@
    reg_driver_list = driver;
     
    return TRUE;
+ oom:
+   if (driver) HeapFree(GetProcessHeap(), 0, driver);
+   return FALSE;
 }
 
 /***********************************************************************
@@ -211,30 +218,25 @@
  */
 BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags) 
 {
-    reg_driver* driver;
-    reg_driver** previous;
+    reg_driver** pdriver;
     
     TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags);
 
     /* Check if a driver is already registered */
-    driver = reg_driver_list;
-    previous = &reg_driver_list;
-    while(driver)
-        if (!compare_fourcc(fccType, driver->fccType) &&
-            !compare_fourcc(fccHandler, driver->fccHandler))
+    for (pdriver = &reg_driver_list; *pdriver; pdriver = &(*pdriver)->next)
+    {
+        if (!compare_fourcc(fccType, (*pdriver)->fccType) &&
+            !compare_fourcc(fccHandler, (*pdriver)->fccHandler))
             break;
-        else {
-            previous = &(driver->next);
-            driver = driver->next;
-        }
-    if (!driver)
+    }
+    if (!*pdriver)
         return FALSE;
 
     /* Remove the driver from the list */
-    *previous = driver->next;
-    if (driver->name)
-        HeapFree(GetProcessHeap(), 0, driver->name);
-    HeapFree(GetProcessHeap(), 0, driver);
+    *pdriver = (*pdriver)->next;
+    if ((*pdriver)->name)
+        HeapFree(GetProcessHeap(), 0, (*pdriver)->name);
+    HeapFree(GetProcessHeap(), 0, *pdriver);
     
     return TRUE;  
 }
@@ -246,11 +248,12 @@
  */
 HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) 
 {
-    char		codecname[10];
+    WCHAR		codecname[10];
     ICOPEN		icopen;
     HDRVR		hdrv;
     WINE_HIC*           whic;
     BOOL                bIs16;
+    static WCHAR        drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'};
     reg_driver*         driver;
 
     TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode);
@@ -294,7 +297,7 @@
         codecname[8] = HIBYTE(HIWORD(fccHandler));
         codecname[9] = '\0';
 
-        hdrv = OpenDriverA(codecname, "drivers32", (LPARAM)&icopen);
+        hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
         if (!hdrv) 
         {
             if (fccType == streamtypeVIDEO) 
@@ -305,14 +308,14 @@
                 codecname[3] = 'c';
 
 		fccType = ICTYPE_VIDEO;
-                hdrv = OpenDriverA(codecname, "drivers32", (LPARAM)&icopen);   
+                hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
 	    }
             if (!hdrv)
                 return 0;
 	}
     } else {
         /* The driver has been registered at runtime with its name */
-        hdrv = OpenDriverA(driver->name, NULL, (LPARAM)&icopen);
+        hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen);
         if (!hdrv) 
             return 0; 
     }
Index: include/mmsystem.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/include/mmsystem.h,v
retrieving revision 1.63
diff -u -u -r1.63 mmsystem.h
--- include/mmsystem.h	13 Apr 2003 01:05:17 -0000	1.63
+++ include/mmsystem.h	29 Jun 2003 18:55:55 -0000
@@ -220,11 +220,13 @@
 
 LRESULT WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hdrvr,
 			     UINT Msg, LPARAM lParam1, LPARAM lParam2);
+/* this sounds odd, but it's the way it is. OpenDriverA even disapeared
+ * from latest SDK
+ */
 HDRVR 	WINAPI OpenDriverA(LPCSTR szDriverName, LPCSTR szSectionName,
 			   LPARAM lParam2);
-HDRVR 	WINAPI OpenDriverW(LPCWSTR szDriverName, LPCWSTR szSectionName,
-			   LPARAM lParam2);
-#define OpenDriver WINELIB_NAME_AW(OpenDriver)
+HDRVR 	WINAPI OpenDriver(LPCWSTR szDriverName, LPCWSTR szSectionName,
+                          LPARAM lParam2);
 LRESULT WINAPI CloseDriver(HDRVR hDriver, LPARAM lParam1, LPARAM lParam2);
 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
 				 LPARAM lParam1, LPARAM lParam2);

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux