4 * Copyright 1998 Patrik Stridvall
17 #include "debugtools.h"
19 /**********************************************************************/
21 HANDLE MSACM_hHeap = (HANDLE) NULL;
22 PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
23 PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
25 /***********************************************************************
26 * MSACM_RegisterDriver32()
28 PWINE_ACMDRIVERID MSACM_RegisterDriver(
29 LPSTR pszDriverAlias, LPSTR pszFileName,
30 PWINE_ACMLOCALDRIVER pLocalDriver)
32 PWINE_ACMDRIVERID padid;
33 padid = (PWINE_ACMDRIVERID) HeapAlloc(
34 MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID)
36 padid->pszDriverAlias =
37 HEAP_strdupA(MSACM_hHeap, 0, pszDriverAlias);
39 HEAP_strdupA(MSACM_hHeap, 0, pszFileName);
40 padid->pACMLocalDriver = pLocalDriver;
41 padid->bEnabled = TRUE;
42 padid->pACMDriver = NULL;
43 padid->pNextACMDriverID = NULL;
44 padid->pPreviousACMDriverID =
45 MSACM_pLastACMDriverID;
46 MSACM_pLastACMDriverID = padid;
47 if(!MSACM_pFirstACMDriverID)
48 MSACM_pFirstACMDriverID = padid;
53 /***********************************************************************
54 * MSACM_RegisterAllDrivers32()
56 void MSACM_RegisterAllDrivers()
58 PWINE_ACMBUILTINDRIVER pbd;
63 * What if the user edits system.ini while the program is running?
64 * Does Windows handle that?
66 if(!MSACM_pFirstACMDriverID)
69 /* FIXME: Do not work! How do I determine the section length? */
71 GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini");
73 pszBuffer = (LPSTR) HeapAlloc(
74 MSACM_hHeap, 0, dwBufferLength
76 if(GetPrivateProfileSectionA(
77 "drivers32", pszBuffer, dwBufferLength, "system.ini"))
82 if(!lstrncmpiA("MSACM.", s, 6))
85 while(*s2 != '\0' && *s2 != '=') s2++;
89 MSACM_RegisterDriver(s, s2, NULL);
92 s += lstrlenA(s) + 1; /* Either next char or \0 */
97 * Check if any of the builtin driver was added
98 * when the external drivers was.
101 pbd = MSACM_BuiltinDrivers;
102 while(pbd->pszDriverAlias)
104 PWINE_ACMLOCALDRIVER pld;
105 pld = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVER));
106 pld->pfnDriverProc = pbd->pfnDriverProc;
107 MSACM_RegisterDriver(pbd->pszDriverAlias, NULL, pld);
110 HeapFree(MSACM_hHeap, 0, pszBuffer);
113 /***********************************************************************
114 * MSACM_UnregisterDriver32()
116 PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
118 PWINE_ACMDRIVERID pNextACMDriverID;
121 acmDriverClose((HACMDRIVER) p->pACMDriver, 0);
123 if(p->pszDriverAlias)
124 HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
126 HeapFree(MSACM_hHeap, 0, p->pszFileName);
127 if(p->pACMLocalDriver)
128 HeapFree(MSACM_hHeap, 0, p->pACMLocalDriver);
130 if(p->pPreviousACMDriverID)
131 p->pPreviousACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
132 if(p->pNextACMDriverID)
133 p->pNextACMDriverID->pPreviousACMDriverID = p->pPreviousACMDriverID;
135 pNextACMDriverID = p->pNextACMDriverID;
137 HeapFree(MSACM_hHeap, 0, p);
139 return pNextACMDriverID;
142 /***********************************************************************
143 * MSACM_UnregisterAllDrivers32()
145 * Where should this function be called?
147 void MSACM_UnregisterAllDrivers()
149 PWINE_ACMDRIVERID p = MSACM_pFirstACMDriverID;
150 while(p) p = MSACM_UnregisterDriver(p);
153 /***********************************************************************
154 * MSACM_GetDriverID32()
156 PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
158 return (PWINE_ACMDRIVERID) hDriverID;
161 /***********************************************************************
162 * MSACM_GetDriver32()
164 PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
166 return (PWINE_ACMDRIVER) hDriver;
169 /***********************************************************************
172 PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj)
174 return (PWINE_ACMOBJ) hObj;
177 /***********************************************************************
178 * MSACM_OpenDriverProc32
180 * This function should be integrated with OpenDriver,
181 * renamed and moved there.
183 HDRVR MSACM_OpenDriverProc(DRIVERPROC pfnDriverProc)
188 /* FIXME: This is a very bad solution */
189 pDrvr = (LPDRIVERITEMA) HeapAlloc(MSACM_hHeap, HEAP_ZERO_MEMORY, sizeof(DRIVERITEMA));
191 pDrvr->driverproc = pfnDriverProc;
193 /* FIXME: Send DRV_OPEN among others to DriverProc */
195 return (HDRVR) pDrvr;