blob: d54c7640214c0f39d0f933f6542b40df54537367 [file] [log] [blame]
Eric Pouech1ddce711999-10-31 18:29:16 +00001/* -*- tab-width: 8; c-basic-offset: 4 -*- */
2
Patrik Stridvall29c08dd1998-10-11 17:00:29 +00003/*
4 * MSACM32 library
5 *
6 * Copyright 1998 Patrik Stridvall
Eric Pouech1ddce711999-10-31 18:29:16 +00007 * 1999 Eric Pouech
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00008 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Patrik Stridvall29c08dd1998-10-11 17:00:29 +000022 */
23
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000024#include <stdarg.h>
Patrik Stridvallf4fca7c1999-09-11 16:27:20 +000025#include <string.h>
26
Jeremy Whited3e22d92000-02-10 19:03:02 +000027#include "windef.h"
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000028#include "winbase.h"
Jeremy Whited3e22d92000-02-10 19:03:02 +000029#include "wingdi.h"
Marcus Meissner317af321999-02-17 13:51:06 +000030#include "winuser.h"
Patrik Stridvall29c08dd1998-10-11 17:00:29 +000031#include "winerror.h"
Eric Pouechfaa35942001-04-23 18:14:41 +000032#include "winreg.h"
Patrik Stridvall29c08dd1998-10-11 17:00:29 +000033#include "mmsystem.h"
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000034#include "mmreg.h"
Patrik Stridvall29c08dd1998-10-11 17:00:29 +000035#include "msacm.h"
36#include "msacmdrv.h"
Eric Pouech1ddce711999-10-31 18:29:16 +000037#include "wineacm.h"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000038#include "wine/debug.h"
Eric Pouech5061d3a2003-07-02 00:40:14 +000039#include "wine/unicode.h"
Patrik Stridvall29c08dd1998-10-11 17:00:29 +000040
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000041WINE_DEFAULT_DEBUG_CHANNEL(msacm);
Eric Pouech1ddce711999-10-31 18:29:16 +000042
Patrik Stridvall29c08dd1998-10-11 17:00:29 +000043/**********************************************************************/
44
Francois Gouget9b0b1e02003-01-14 23:43:41 +000045HANDLE MSACM_hHeap = NULL;
Alexandre Julliarda3960291999-02-26 11:11:13 +000046PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
47PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
Patrik Stridvall29c08dd1998-10-11 17:00:29 +000048
Eric Pouechfaa35942001-04-23 18:14:41 +000049#if 0
50/***********************************************************************
51 * MSACM_DumpCache
52 */
Vincent Béron9a624912002-05-31 23:06:46 +000053static void MSACM_DumpCache(PWINE_ACMDRIVERID padid)
Eric Pouechfaa35942001-04-23 18:14:41 +000054{
55 unsigned i;
56
57 TRACE("cFilterTags=%lu cFormatTags=%lu fdwSupport=%08lx\n",
58 padid->cFilterTags, padid->cFormatTags, padid->fdwSupport);
59 for (i = 0; i < padid->cache->cFormatTags; i++) {
Vincent Béron9a624912002-05-31 23:06:46 +000060 TRACE("\tdwFormatTag=%lu cbwfx=%lu\n",
Eric Pouechfaa35942001-04-23 18:14:41 +000061 padid->aFormatTag[i].dwFormatTag, padid->aFormatTag[i].cbwfx);
62 }
63}
64#endif
65
66/***********************************************************************
67 * MSACM_FindFormatTagInCache [internal]
Vincent Béron9a624912002-05-31 23:06:46 +000068 *
Eric Pouechfaa35942001-04-23 18:14:41 +000069 * Returns TRUE is the format tag fmtTag is present in the cache.
70 * If so, idx is set to its index.
71 */
72BOOL MSACM_FindFormatTagInCache(WINE_ACMDRIVERID* padid, DWORD fmtTag, LPDWORD idx)
73{
74 unsigned i;
75
76 for (i = 0; i < padid->cFormatTags; i++) {
77 if (padid->aFormatTag[i].dwFormatTag == fmtTag) {
78 if (idx) *idx = i;
79 return TRUE;
80 }
81 }
82 return FALSE;
83}
84
85/***********************************************************************
86 * MSACM_FillCache
87 */
Vincent Béron9a624912002-05-31 23:06:46 +000088static BOOL MSACM_FillCache(PWINE_ACMDRIVERID padid)
Eric Pouechfaa35942001-04-23 18:14:41 +000089{
Eric Pouech91f3fc72002-02-08 17:11:22 +000090 HACMDRIVER had = 0;
91 int ntag;
92 ACMDRIVERDETAILSW add;
93 ACMFORMATTAGDETAILSW aftd;
Eric Pouechfaa35942001-04-23 18:14:41 +000094
95 if (acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != 0)
96 return FALSE;
97
98 padid->aFormatTag = NULL;
99 add.cbStruct = sizeof(add);
100 if (MSACM_Message(had, ACMDM_DRIVER_DETAILS, (LPARAM)&add, 0))
101 goto errCleanUp;
102
103 if (add.cFormatTags > 0) {
Vincent Béron9a624912002-05-31 23:06:46 +0000104 padid->aFormatTag = HeapAlloc(MSACM_hHeap, HEAP_ZERO_MEMORY,
Eric Pouechfaa35942001-04-23 18:14:41 +0000105 add.cFormatTags * sizeof(padid->aFormatTag[0]));
106 if (!padid->aFormatTag) goto errCleanUp;
107 }
108
109 padid->cFormatTags = add.cFormatTags;
110 padid->cFilterTags = add.cFilterTags;
111 padid->fdwSupport = add.fdwSupport;
112
113 aftd.cbStruct = sizeof(aftd);
Vincent Béron9a624912002-05-31 23:06:46 +0000114
Eric Pouechfaa35942001-04-23 18:14:41 +0000115 for (ntag = 0; ntag < add.cFormatTags; ntag++) {
Eric Pouech91f3fc72002-02-08 17:11:22 +0000116 aftd.dwFormatTagIndex = ntag;
117 if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, (LPARAM)&aftd, ACM_FORMATTAGDETAILSF_INDEX)) {
Eric Pouech5061d3a2003-07-02 00:40:14 +0000118 TRACE("IIOs (%s)\n", debugstr_w(padid->pszDriverAlias));
Eric Pouechfaa35942001-04-23 18:14:41 +0000119 goto errCleanUp;
120 }
121 padid->aFormatTag[ntag].dwFormatTag = aftd.dwFormatTag;
Eric Pouech91f3fc72002-02-08 17:11:22 +0000122 padid->aFormatTag[ntag].cbwfx = aftd.cbFormatSize;
Eric Pouechfaa35942001-04-23 18:14:41 +0000123 }
Eric Pouech91f3fc72002-02-08 17:11:22 +0000124
Eric Pouechfaa35942001-04-23 18:14:41 +0000125 acmDriverClose(had, 0);
126
127 return TRUE;
128
129errCleanUp:
130 if (had) acmDriverClose(had, 0);
131 HeapFree(MSACM_hHeap, 0, padid->aFormatTag);
132 padid->aFormatTag = NULL;
133 return FALSE;
134}
135
136/***********************************************************************
137 * MSACM_GetRegistryKey
138 */
Eric Pouech5061d3a2003-07-02 00:40:14 +0000139static LPWSTR MSACM_GetRegistryKey(const WINE_ACMDRIVERID* padid)
Eric Pouechfaa35942001-04-23 18:14:41 +0000140{
Eric Pouech5061d3a2003-07-02 00:40:14 +0000141 static const WCHAR baseKey[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
142 'A','u','d','i','o','C','o','m','p','r','e','s','s','i','o','n','M','a','n','a','g','e','r','\\',
143 'D','r','i','v','e','r','C','a','c','h','e','\\','\0'};
144 LPWSTR ret;
Eric Pouechfaa35942001-04-23 18:14:41 +0000145 int len;
146
147 if (!padid->pszDriverAlias) {
148 ERR("No alias needed for registry entry\n");
149 return NULL;
150 }
Eric Pouech5061d3a2003-07-02 00:40:14 +0000151 len = strlenW(baseKey);
152 ret = HeapAlloc(MSACM_hHeap, 0, (len + strlenW(padid->pszDriverAlias) + 1) * sizeof(WCHAR));
Eric Pouechfaa35942001-04-23 18:14:41 +0000153 if (!ret) return NULL;
154
Eric Pouech5061d3a2003-07-02 00:40:14 +0000155 strcpyW(ret, baseKey);
156 strcpyW(ret + len, padid->pszDriverAlias);
157 CharLowerW(ret + len);
Eric Pouechfaa35942001-04-23 18:14:41 +0000158 return ret;
159}
160
161/***********************************************************************
162 * MSACM_ReadCache
163 */
164static BOOL MSACM_ReadCache(PWINE_ACMDRIVERID padid)
165{
Eric Pouech5061d3a2003-07-02 00:40:14 +0000166 LPWSTR key = MSACM_GetRegistryKey(padid);
Eric Pouechfaa35942001-04-23 18:14:41 +0000167 HKEY hKey;
168 DWORD type, size;
169
170 if (!key) return FALSE;
171
172 padid->aFormatTag = NULL;
173
Eric Pouech5061d3a2003-07-02 00:40:14 +0000174 if (RegCreateKeyW(HKEY_LOCAL_MACHINE, key, &hKey))
Eric Pouechfaa35942001-04-23 18:14:41 +0000175 goto errCleanUp;
176
177 size = sizeof(padid->cFormatTags);
178 if (RegQueryValueExA(hKey, "cFormatTags", 0, &type, (void*)&padid->cFormatTags, &size))
179 goto errCleanUp;
180 size = sizeof(padid->cFilterTags);
181 if (RegQueryValueExA(hKey, "cFilterTags", 0, &type, (void*)&padid->cFilterTags, &size))
182 goto errCleanUp;
183 size = sizeof(padid->fdwSupport);
184 if (RegQueryValueExA(hKey, "fdwSupport", 0, &type, (void*)&padid->fdwSupport, &size))
185 goto errCleanUp;
186
187 if (padid->cFormatTags > 0) {
188 size = padid->cFormatTags * sizeof(padid->aFormatTag[0]);
189 padid->aFormatTag = HeapAlloc(MSACM_hHeap, HEAP_ZERO_MEMORY, size);
190 if (!padid->aFormatTag) goto errCleanUp;
191 if (RegQueryValueExA(hKey, "aFormatTagCache", 0, &type, (void*)padid->aFormatTag, &size))
192 goto errCleanUp;
193 }
194 HeapFree(MSACM_hHeap, 0, key);
195 return TRUE;
196
197 errCleanUp:
198 HeapFree(MSACM_hHeap, 0, key);
199 HeapFree(MSACM_hHeap, 0, padid->aFormatTag);
200 padid->aFormatTag = NULL;
201 RegCloseKey(hKey);
202 return FALSE;
203}
204
205/***********************************************************************
206 * MSACM_WriteCache
207 */
208static BOOL MSACM_WriteCache(PWINE_ACMDRIVERID padid)
209{
Eric Pouech5061d3a2003-07-02 00:40:14 +0000210 LPWSTR key = MSACM_GetRegistryKey(padid);
Eric Pouechfaa35942001-04-23 18:14:41 +0000211 HKEY hKey;
212
213 if (!key) return FALSE;
214
Eric Pouech5061d3a2003-07-02 00:40:14 +0000215 if (RegCreateKeyW(HKEY_LOCAL_MACHINE, key, &hKey))
Eric Pouechfaa35942001-04-23 18:14:41 +0000216 goto errCleanUp;
217
218 if (RegSetValueExA(hKey, "cFormatTags", 0, REG_DWORD, (void*)&padid->cFormatTags, sizeof(DWORD)))
219 goto errCleanUp;
220 if (RegSetValueExA(hKey, "cFilterTags", 0, REG_DWORD, (void*)&padid->cFilterTags, sizeof(DWORD)))
221 goto errCleanUp;
222 if (RegSetValueExA(hKey, "fdwSupport", 0, REG_DWORD, (void*)&padid->fdwSupport, sizeof(DWORD)))
223 goto errCleanUp;
Vincent Béron9a624912002-05-31 23:06:46 +0000224 if (RegSetValueExA(hKey, "aFormatTagCache", 0, REG_BINARY,
225 (void*)padid->aFormatTag,
Eric Pouechfaa35942001-04-23 18:14:41 +0000226 padid->cFormatTags * sizeof(padid->aFormatTag[0])))
227 goto errCleanUp;
228 HeapFree(MSACM_hHeap, 0, key);
229 return TRUE;
230
231 errCleanUp:
232 HeapFree(MSACM_hHeap, 0, key);
233 return FALSE;
234}
235
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000236/***********************************************************************
Vincent Béron9a624912002-05-31 23:06:46 +0000237 * MSACM_RegisterDriver()
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000238 */
Eric Pouech5061d3a2003-07-02 00:40:14 +0000239PWINE_ACMDRIVERID MSACM_RegisterDriver(LPWSTR pszDriverAlias, LPWSTR pszFileName,
Eric Pouech1ddce711999-10-31 18:29:16 +0000240 HINSTANCE hinstModule)
Vincent Béron9a624912002-05-31 23:06:46 +0000241{
Eric Pouechf051db32001-05-22 19:21:16 +0000242 PWINE_ACMDRIVERID padid;
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000243
Eric Pouech5061d3a2003-07-02 00:40:14 +0000244 TRACE("(%s, %s, %p)\n",
245 debugstr_w(pszDriverAlias), debugstr_w(pszFileName), hinstModule);
Eric Pouech1ddce711999-10-31 18:29:16 +0000246
247 padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
Eric Pouechb8ba8452000-08-26 04:33:00 +0000248 padid->obj.dwType = WINE_ACMOBJ_DRIVERID;
249 padid->obj.pACMDriverID = padid;
Alexandre Julliard8c540c62000-11-13 04:16:05 +0000250 padid->pszDriverAlias = NULL;
251 if (pszDriverAlias)
252 {
Eric Pouech5061d3a2003-07-02 00:40:14 +0000253 padid->pszDriverAlias = HeapAlloc( MSACM_hHeap, 0, (strlenW(pszDriverAlias)+1) * sizeof(WCHAR) );
254 strcpyW( padid->pszDriverAlias, pszDriverAlias );
Alexandre Julliard8c540c62000-11-13 04:16:05 +0000255 }
256 padid->pszFileName = NULL;
257 if (pszFileName)
258 {
Eric Pouech5061d3a2003-07-02 00:40:14 +0000259 padid->pszFileName = HeapAlloc( MSACM_hHeap, 0, (strlenW(pszFileName)+1) * sizeof(WCHAR) );
260 strcpyW( padid->pszFileName, pszFileName );
Alexandre Julliard8c540c62000-11-13 04:16:05 +0000261 }
Eric Pouech1ddce711999-10-31 18:29:16 +0000262 padid->hInstModule = hinstModule;
Vincent Béron9a624912002-05-31 23:06:46 +0000263
Eric Pouech5c7f1ab1999-12-12 21:28:09 +0000264 padid->pACMDriverList = NULL;
Eric Pouech1ddce711999-10-31 18:29:16 +0000265 padid->pNextACMDriverID = NULL;
Eric Pouech5c7f1ab1999-12-12 21:28:09 +0000266 padid->pPrevACMDriverID = MSACM_pLastACMDriverID;
Eric Pouech1ddce711999-10-31 18:29:16 +0000267 if (MSACM_pLastACMDriverID)
268 MSACM_pLastACMDriverID->pNextACMDriverID = padid;
269 MSACM_pLastACMDriverID = padid;
270 if (!MSACM_pFirstACMDriverID)
271 MSACM_pFirstACMDriverID = padid;
Eric Pouechfaa35942001-04-23 18:14:41 +0000272 /* disable the driver if we cannot load the cache */
273 if (!MSACM_ReadCache(padid) && !MSACM_FillCache(padid)) {
Eric Pouech5061d3a2003-07-02 00:40:14 +0000274 WARN("Couldn't load cache for ACM driver (%s)\n", debugstr_w(pszFileName));
Eric Pouechfaa35942001-04-23 18:14:41 +0000275 MSACM_UnregisterDriver(padid);
276 return NULL;
277 }
Eric Pouech1ddce711999-10-31 18:29:16 +0000278 return padid;
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000279}
280
281/***********************************************************************
Vincent Béron9a624912002-05-31 23:06:46 +0000282 * MSACM_RegisterAllDrivers()
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000283 */
Eric Pouech1ddce711999-10-31 18:29:16 +0000284void MSACM_RegisterAllDrivers(void)
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000285{
Eric Pouech5061d3a2003-07-02 00:40:14 +0000286 LPWSTR pszBuffer;
Eric Pouech1ddce711999-10-31 18:29:16 +0000287 DWORD dwBufferLength;
Eric Pouech5061d3a2003-07-02 00:40:14 +0000288 static WCHAR msacm32[] = {'m','s','a','c','m','3','2','.','d','l','l','\0'};
289 static WCHAR msacmW[] = {'M','S','A','C','M','.'};
290 static WCHAR drv32[] = {'d','r','i','v','e','r','s','3','2','\0'};
291 static WCHAR sys[] = {'s','y','s','t','e','m','.','i','n','i','\0'};
Eric Pouech140d8cd2000-10-12 20:46:49 +0000292
Vincent Béron9a624912002-05-31 23:06:46 +0000293 /* FIXME
Eric Pouech1ddce711999-10-31 18:29:16 +0000294 * What if the user edits system.ini while the program is running?
295 * Does Windows handle that?
296 */
297 if (MSACM_pFirstACMDriverID)
298 return;
Vincent Béron9a624912002-05-31 23:06:46 +0000299
Eric Pouechfaa35942001-04-23 18:14:41 +0000300 /* FIXME: Does not work! How do I determine the section length? */
Eric Pouech1ddce711999-10-31 18:29:16 +0000301 dwBufferLength = 1024;
302/* EPP GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
Vincent Béron9a624912002-05-31 23:06:46 +0000303
Eric Pouech5061d3a2003-07-02 00:40:14 +0000304 pszBuffer = (LPWSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength * sizeof(WCHAR));
305 if (GetPrivateProfileSectionW(drv32, pszBuffer, dwBufferLength, sys))
306 {
307 LPWSTR s = pszBuffer, s2;
308
309 while (*s)
310 {
311 CharUpperBuffW(s, 6);
312 if (memcmp(s, msacmW, 6 * sizeof(WCHAR)) == 0)
313 {
314 s2 = s;
Eric Pouech1ddce711999-10-31 18:29:16 +0000315 while (*s2 != '\0' && *s2 != '=') s2++;
Eric Pouech5061d3a2003-07-02 00:40:14 +0000316 if (*s2)
317 {
Eric Pouech140d8cd2000-10-12 20:46:49 +0000318 *s2 = '\0';
319 MSACM_RegisterDriver(s, s2 + 1, 0);
320 *s2 = '=';
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000321 }
Vincent Béron9a624912002-05-31 23:06:46 +0000322 }
Eric Pouech5061d3a2003-07-02 00:40:14 +0000323 s += strlenW(s) + 1; /* Either next char or \0 */
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000324 }
325 }
Vincent Béron9a624912002-05-31 23:06:46 +0000326
Eric Pouech1ddce711999-10-31 18:29:16 +0000327 HeapFree(MSACM_hHeap, 0, pszBuffer);
Eric Pouech140d8cd2000-10-12 20:46:49 +0000328
Eric Pouech5061d3a2003-07-02 00:40:14 +0000329 MSACM_RegisterDriver(msacm32, msacm32, 0);
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000330}
331
332/***********************************************************************
Eric Pouechb8ba8452000-08-26 04:33:00 +0000333 * MSACM_UnregisterDriver()
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000334 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000335PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000336{
Eric Pouech1ddce711999-10-31 18:29:16 +0000337 PWINE_ACMDRIVERID pNextACMDriverID;
Vincent Béron9a624912002-05-31 23:06:46 +0000338
Eric Pouech5c7f1ab1999-12-12 21:28:09 +0000339 while (p->pACMDriverList)
340 acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
Vincent Béron9a624912002-05-31 23:06:46 +0000341
Eric Pouech1ddce711999-10-31 18:29:16 +0000342 if (p->pszDriverAlias)
343 HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
344 if (p->pszFileName)
345 HeapFree(MSACM_hHeap, 0, p->pszFileName);
Eric Pouechfaa35942001-04-23 18:14:41 +0000346 HeapFree(MSACM_hHeap, 0, p->aFormatTag);
347
Eric Pouech1ddce711999-10-31 18:29:16 +0000348 if (p == MSACM_pFirstACMDriverID)
349 MSACM_pFirstACMDriverID = p->pNextACMDriverID;
350 if (p == MSACM_pLastACMDriverID)
Eric Pouech5c7f1ab1999-12-12 21:28:09 +0000351 MSACM_pLastACMDriverID = p->pPrevACMDriverID;
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000352
Eric Pouech5c7f1ab1999-12-12 21:28:09 +0000353 if (p->pPrevACMDriverID)
354 p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
Eric Pouech1ddce711999-10-31 18:29:16 +0000355 if (p->pNextACMDriverID)
Eric Pouech5c7f1ab1999-12-12 21:28:09 +0000356 p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
Vincent Béron9a624912002-05-31 23:06:46 +0000357
Eric Pouech1ddce711999-10-31 18:29:16 +0000358 pNextACMDriverID = p->pNextACMDriverID;
Vincent Béron9a624912002-05-31 23:06:46 +0000359
Eric Pouech1ddce711999-10-31 18:29:16 +0000360 HeapFree(MSACM_hHeap, 0, p);
Vincent Béron9a624912002-05-31 23:06:46 +0000361
Eric Pouech1ddce711999-10-31 18:29:16 +0000362 return pNextACMDriverID;
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000363}
364
365/***********************************************************************
Eric Pouechb8ba8452000-08-26 04:33:00 +0000366 * MSACM_UnregisterAllDrivers()
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000367 */
Eric Pouech1ddce711999-10-31 18:29:16 +0000368void MSACM_UnregisterAllDrivers(void)
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000369{
Vincent Béron9a624912002-05-31 23:06:46 +0000370 PWINE_ACMDRIVERID p = MSACM_pFirstACMDriverID;
Eric Pouech1ddce711999-10-31 18:29:16 +0000371
Eric Pouechfaa35942001-04-23 18:14:41 +0000372 while (p) {
373 MSACM_WriteCache(p);
374 p = MSACM_UnregisterDriver(p);
375 }
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000376}
377
378/***********************************************************************
Eric Pouechb8ba8452000-08-26 04:33:00 +0000379 * MSACM_GetObj()
380 */
381PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj, DWORD type)
382{
383 PWINE_ACMOBJ pao = (PWINE_ACMOBJ)hObj;
384
James Hatheway23b320e2000-10-02 03:33:20 +0000385 if (pao == NULL || IsBadReadPtr(pao, sizeof(WINE_ACMOBJ)) ||
Eric Pouechb8ba8452000-08-26 04:33:00 +0000386 ((type != WINE_ACMOBJ_DONTCARE) && (type != pao->dwType)))
387 return NULL;
388 return pao;
389}
390
391/***********************************************************************
Vincent Béron9a624912002-05-31 23:06:46 +0000392 * MSACM_GetDriverID()
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000393 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000394PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000395{
Eric Pouechb8ba8452000-08-26 04:33:00 +0000396 return (PWINE_ACMDRIVERID)MSACM_GetObj((HACMOBJ)hDriverID, WINE_ACMOBJ_DRIVERID);
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000397}
398
399/***********************************************************************
Eric Pouechb8ba8452000-08-26 04:33:00 +0000400 * MSACM_GetDriver()
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000401 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000402PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000403{
Eric Pouechb8ba8452000-08-26 04:33:00 +0000404 return (PWINE_ACMDRIVER)MSACM_GetObj((HACMOBJ)hDriver, WINE_ACMOBJ_DRIVER);
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000405}
406
407/***********************************************************************
Eric Pouechb8ba8452000-08-26 04:33:00 +0000408 * MSACM_Message()
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000409 */
Eric Pouechb8ba8452000-08-26 04:33:00 +0000410MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000411{
Eric Pouechb8ba8452000-08-26 04:33:00 +0000412 PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
413
414 return pad ? SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2) : MMSYSERR_INVALHANDLE;
Patrik Stridvall29c08dd1998-10-11 17:00:29 +0000415}