4 * Copyright 1998 Patrik Stridvall
17 /**********************************************************************/
19 HANDLE32 MSACM_hHeap32
= (HANDLE32
) NULL
;
20 PWINE_ACMDRIVERID32 MSACM_pFirstACMDriverID32
= NULL
;
21 PWINE_ACMDRIVERID32 MSACM_pLastACMDriverID32
= NULL
;
23 /***********************************************************************
24 * MSACM_RegisterDriver32()
26 PWINE_ACMDRIVERID32
MSACM_RegisterDriver32(
27 LPSTR pszDriverAlias
, LPSTR pszFileName
,
28 PWINE_ACMLOCALDRIVER32 pLocalDriver
)
30 PWINE_ACMDRIVERID32 padid
;
31 padid
= (PWINE_ACMDRIVERID32
) HeapAlloc(
32 MSACM_hHeap32
, 0, sizeof(WINE_ACMDRIVERID32
)
34 padid
->pszDriverAlias
=
35 HEAP_strdupA(MSACM_hHeap32
, 0, pszDriverAlias
);
37 HEAP_strdupA(MSACM_hHeap32
, 0, pszFileName
);
38 padid
->pACMLocalDriver
= pLocalDriver
;
39 padid
->bEnabled
= TRUE
;
40 padid
->pACMDriver
= NULL
;
41 padid
->pNextACMDriverID
= NULL
;
42 padid
->pPreviousACMDriverID
=
43 MSACM_pLastACMDriverID32
;
44 MSACM_pLastACMDriverID32
= padid
;
45 if(!MSACM_pFirstACMDriverID32
)
46 MSACM_pFirstACMDriverID32
= padid
;
51 /***********************************************************************
52 * MSACM_RegisterAllDrivers32()
54 void MSACM_RegisterAllDrivers32()
56 PWINE_ACMBUILTINDRIVER32 pbd
;
61 * What if the user edits system.ini while the program is running?
62 * Does Windows handle that?
64 if(!MSACM_pFirstACMDriverID32
)
67 /* FIXME: Do not work! How do I determine the section length? */
69 GetPrivateProfileSection32A("drivers32", NULL
, 0, "system.ini");
71 pszBuffer
= (LPSTR
) HeapAlloc(
72 MSACM_hHeap32
, 0, dwBufferLength
74 if(GetPrivateProfileSection32A(
75 "drivers32", pszBuffer
, dwBufferLength
, "system.ini"))
80 if(!lstrncmpi32A("MSACM.", s
, 6))
83 while(*s2
!= '\0' && *s2
!= '=') s2
++;
87 MSACM_RegisterDriver32(s
, s2
, NULL
);
90 s
+= lstrlen32A(s
) + 1; /* Either next char or \0 */
95 * Check if any of the builtin driver was added
96 * when the external drivers was.
99 pbd
= MSACM_BuiltinDrivers32
;
100 while(pbd
->pszDriverAlias
)
102 PWINE_ACMLOCALDRIVER32 pld
;
103 pld
= HeapAlloc(MSACM_hHeap32
, 0, sizeof(WINE_ACMLOCALDRIVER32
));
104 pld
->pfnDriverProc
= pbd
->pfnDriverProc
;
105 MSACM_RegisterDriver32(pbd
->pszDriverAlias
, NULL
, pld
);
108 HeapFree(MSACM_hHeap32
, 0, pszBuffer
);
111 /***********************************************************************
112 * MSACM_UnregisterDriver32()
114 PWINE_ACMDRIVERID32
MSACM_UnregisterDriver32(PWINE_ACMDRIVERID32 p
)
116 PWINE_ACMDRIVERID32 pNextACMDriverID
;
119 acmDriverClose32((HACMDRIVER32
) p
->pACMDriver
, 0);
121 if(p
->pszDriverAlias
)
122 HeapFree(MSACM_hHeap32
, 0, p
->pszDriverAlias
);
124 HeapFree(MSACM_hHeap32
, 0, p
->pszFileName
);
125 if(p
->pACMLocalDriver
)
126 HeapFree(MSACM_hHeap32
, 0, p
->pACMLocalDriver
);
128 if(p
->pPreviousACMDriverID
)
129 p
->pPreviousACMDriverID
->pNextACMDriverID
= p
->pNextACMDriverID
;
130 if(p
->pNextACMDriverID
)
131 p
->pNextACMDriverID
->pPreviousACMDriverID
= p
->pPreviousACMDriverID
;
133 pNextACMDriverID
= p
->pNextACMDriverID
;
135 HeapFree(MSACM_hHeap32
, 0, p
);
137 return pNextACMDriverID
;
140 /***********************************************************************
141 * MSACM_UnregisterAllDrivers32()
143 * Where should this function be called?
145 void MSACM_UnregisterAllDrivers32()
147 PWINE_ACMDRIVERID32 p
= MSACM_pFirstACMDriverID32
;
148 while(p
) p
= MSACM_UnregisterDriver32(p
);
151 /***********************************************************************
152 * MSACM_GetDriverID32()
154 PWINE_ACMDRIVERID32
MSACM_GetDriverID32(HACMDRIVERID32 hDriverID
)
156 return (PWINE_ACMDRIVERID32
) hDriverID
;
159 /***********************************************************************
160 * MSACM_GetDriver32()
162 PWINE_ACMDRIVER32
MSACM_GetDriver32(HACMDRIVER32 hDriver
)
164 return (PWINE_ACMDRIVER32
) hDriver
;
167 /***********************************************************************
170 PWINE_ACMOBJ32
MSACM_GetObj32(HACMOBJ32 hObj
)
172 return (PWINE_ACMOBJ32
) hObj
;
175 /***********************************************************************
176 * MSACM_OpenDriverProc32
178 * This function should be integrated with OpenDriver,
179 * renamed and moved there.
181 HDRVR32
MSACM_OpenDriverProc32(DRIVERPROC32 pfnDriverProc
)
183 LPDRIVERITEM32A pDrvr
;
185 /* FIXME: This is a very bad solution */
186 pDrvr
= (LPDRIVERITEM32A
) HeapAlloc(MSACM_hHeap32
, HEAP_ZERO_MEMORY
, sizeof(DRIVERITEM32A
));
188 pDrvr
->driverproc
= pfnDriverProc
;
190 /* FIXME: Send DRV_OPEN among others to DriverProc */
192 return (HDRVR32
) pDrvr
;