gdiplus: Implement GdipSetPathGradientBlend, with tests.
[wine/multimedia.git] / dlls / winmm / lolvldrv.c
blob7081a86823591f08831b1d063f3559b3ad94b5e2
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 /*
4 * MMSYSTEM low level drivers handling functions
6 * Copyright 1999 Eric Pouech
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
28 #define COBJMACROS
29 #include <string.h>
30 #include <stdarg.h>
31 #include <stdio.h>
32 #include <assert.h>
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winreg.h"
36 #include "winnls.h"
37 #include "winemm.h"
38 #include "wine/debug.h"
39 #include "wine/exception.h"
41 #include "wingdi.h"
42 #include "ole2.h"
43 #include "devpkey.h"
44 #include "mmdeviceapi.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(winmm);
48 /* each known type of driver has an instance of this structure */
49 typedef struct tagWINE_LLTYPE {
50 /* those attributes depend on the specification of the type */
51 LPCSTR typestr; /* name (for debugging) */
52 /* those attributes reflect the loaded/current situation for the type */
53 UINT wMaxId; /* number of loaded devices (sum across all loaded drivers) */
54 LPWINE_MLD lpMlds; /* "static" mlds to access the part though device IDs */
55 int nMapper; /* index to mapper */
56 } WINE_LLTYPE;
58 static WINE_LLTYPE llTypes[MMDRV_MAX] = {
59 { "Aux", 0, 0, -1 },
60 { "Mixer", 0, 0, -1 },
61 { "MidiIn", 0, 0, -1 },
62 { "MidiOut", 0, 0, -1 },
63 { "WaveIn", 0, 0, -1 },
64 { "WaveOut", 0, 0, -1 }
67 static int drivers_loaded, MMDrvsHi;
68 static WINE_MM_DRIVER MMDrvs[8];
69 static LPWINE_MLD MM_MLDrvs[40];
70 #define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]))
72 static void MMDRV_Init(void);
74 static void MMDRV_InitSingleType(UINT type) {
75 if (!drivers_loaded) {
76 drivers_loaded = 1;
77 MMDRV_Init();
81 /**************************************************************************
82 * MMDRV_GetNum [internal]
84 UINT MMDRV_GetNum(UINT type)
86 TRACE("(%04x)\n", type);
87 assert(type < MMDRV_MAX);
88 MMDRV_InitSingleType(type);
89 return llTypes[type].wMaxId;
92 /**************************************************************************
93 * MMDRV_Message [internal]
95 DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1,
96 DWORD_PTR dwParam2)
98 LPWINE_MM_DRIVER lpDrv;
99 DWORD ret;
100 WINE_MM_DRIVER_PART* part;
101 WINE_LLTYPE* llType = &llTypes[mld->type];
103 TRACE("(%s %d %u 0x%08lx 0x%08lx 0x%08lx)\n",
104 llTypes[mld->type].typestr, mld->uDeviceID, wMsg,
105 mld->dwDriverInstance, dwParam1, dwParam2);
107 if ((UINT16)mld->uDeviceID == (UINT16)-1) {
108 if (llType->nMapper == -1) {
109 WARN("uDev=-1 requested on non-mapped ll type %s\n",
110 llTypes[mld->type].typestr);
111 return MMSYSERR_BADDEVICEID;
113 } else {
114 if (mld->uDeviceID >= llType->wMaxId) {
115 WARN("uDev(%u) requested >= max (%d)\n", mld->uDeviceID, llType->wMaxId);
116 return MMSYSERR_BADDEVICEID;
120 lpDrv = &MMDrvs[mld->mmdIndex];
121 part = &lpDrv->parts[mld->type];
123 assert(part->fnMessage32);
125 TRACE("Calling message(dev=%d msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx)\n",
126 mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2);
127 ret = part->fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2);
128 TRACE("=> %s\n", WINMM_ErrorToString(ret));
130 return ret;
133 /**************************************************************************
134 * MMDRV_Alloc [internal]
136 LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
137 DWORD_PTR* dwCallback, DWORD_PTR* dwInstance)
139 LPWINE_MLD mld;
140 UINT_PTR i;
141 TRACE("(%d, %04x, %p, %p, %p, %p)\n",
142 size, type, hndl, dwFlags, dwCallback, dwInstance);
144 mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
145 if (!mld) return NULL;
147 /* find an empty slot in MM_MLDrvs table */
148 for (i = 0; i < MAX_MM_MLDRVS; i++) if (!MM_MLDrvs[i]) break;
150 if (i == MAX_MM_MLDRVS) {
151 /* the MM_MLDrvs table could be made growable in the future if needed */
152 ERR("Too many open drivers\n");
153 HeapFree(GetProcessHeap(), 0, mld);
154 return NULL;
156 MM_MLDrvs[i] = mld;
157 *hndl = (HANDLE)(i | 0x8000);
159 mld->type = type;
160 if ((UINT_PTR)*hndl < MMDRV_GetNum(type) || ((UINT_PTR)*hndl >> 16)) {
161 /* FIXME: those conditions must be fulfilled so that:
162 * - we can distinguish between device IDs and handles
163 * - we can use handles as 16 or 32 bit entities
165 ERR("Shouldn't happen. Bad allocation scheme\n");
168 mld->dwFlags = HIWORD(*dwFlags);
169 mld->dwCallback = *dwCallback;
170 mld->dwClientInstance = *dwInstance;
172 return mld;
175 /**************************************************************************
176 * MMDRV_Free [internal]
178 void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
180 TRACE("(%p, %p)\n", hndl, mld);
182 if ((UINT_PTR)hndl & 0x8000) {
183 UINT_PTR idx = (UINT_PTR)hndl & ~0x8000;
184 if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
185 MM_MLDrvs[idx] = NULL;
186 HeapFree(GetProcessHeap(), 0, mld);
187 return;
190 ERR("Bad Handle %p at %p (not freed)\n", hndl, mld);
193 /**************************************************************************
194 * MMDRV_Open [internal]
196 DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD dwFlags)
198 DWORD dwRet = MMSYSERR_BADDEVICEID;
199 DWORD_PTR dwInstance;
200 WINE_LLTYPE* llType = &llTypes[mld->type];
201 TRACE("(%p, %04x, 0x%08lx, 0x%08x)\n", mld, wMsg, dwParam1, dwFlags);
203 mld->dwDriverInstance = (DWORD_PTR)&dwInstance;
205 if (mld->uDeviceID == (UINT)-1 || mld->uDeviceID == (UINT16)-1) {
206 TRACE("MAPPER mode requested !\n");
207 if (llType->nMapper == -1) {
208 WARN("Mapper not supported for type %s\n", llTypes[mld->type].typestr);
209 return MMSYSERR_BADDEVICEID;
211 mld->mmdIndex = llType->lpMlds[-1].mmdIndex;
212 TRACE("Setting mmdIndex to %u\n", mld->mmdIndex);
213 dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags);
214 } else {
215 if (mld->uDeviceID < llType->wMaxId) {
216 mld->mmdIndex = llType->lpMlds[mld->uDeviceID].mmdIndex;
217 TRACE("Setting mmdIndex to %u\n", mld->mmdIndex);
218 dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags);
221 if (dwRet == MMSYSERR_NOERROR)
222 mld->dwDriverInstance = dwInstance;
223 return dwRet;
226 /**************************************************************************
227 * MMDRV_Close [internal]
229 DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg)
231 TRACE("(%p, %04x)\n", mld, wMsg);
232 return MMDRV_Message(mld, wMsg, 0L, 0L);
235 /**************************************************************************
236 * MMDRV_GetByID [internal]
238 static LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type)
240 TRACE("(%04x, %04x)\n", uDevID, type);
241 if (uDevID < llTypes[type].wMaxId)
242 return &llTypes[type].lpMlds[uDevID];
243 if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1)
244 return &llTypes[type].lpMlds[-1];
245 return NULL;
248 /**************************************************************************
249 * MMDRV_Get [internal]
251 LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID)
253 LPWINE_MLD mld = NULL;
254 UINT_PTR hndl = (UINT_PTR)_hndl;
255 TRACE("(%p, %04x, %c)\n", _hndl, type, bCanBeID ? 'Y' : 'N');
257 assert(type < MMDRV_MAX);
258 MMDRV_InitSingleType(type);
260 if (hndl >= llTypes[type].wMaxId &&
261 hndl != (UINT16)-1 && hndl != (UINT)-1) {
262 if (hndl & 0x8000) {
263 UINT idx = hndl & ~0x8000;
264 if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
265 __TRY
267 mld = MM_MLDrvs[idx];
268 if (mld && mld->type != type) mld = NULL;
270 __EXCEPT_PAGE_FAULT
272 mld = NULL;
274 __ENDTRY;
278 if (mld == NULL && bCanBeID) {
279 mld = MMDRV_GetByID(hndl, type);
281 return mld;
284 /**************************************************************************
285 * MMDRV_GetRelated [internal]
287 LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType,
288 BOOL bSrcCanBeID, UINT dstType)
290 LPWINE_MLD mld;
291 TRACE("(%p, %04x, %c, %04x)\n",
292 hndl, srcType, bSrcCanBeID ? 'Y' : 'N', dstType);
294 if ((mld = MMDRV_Get(hndl, srcType, bSrcCanBeID)) != NULL) {
295 WINE_MM_DRIVER_PART* part = &MMDrvs[mld->mmdIndex].parts[dstType];
296 if (part->nIDMin < part->nIDMax)
297 return MMDRV_GetByID(part->nIDMin, dstType);
299 return NULL;
302 /**************************************************************************
303 * MMDRV_PhysicalFeatures [internal]
305 UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg,
306 DWORD_PTR dwParam1, DWORD_PTR dwParam2)
308 WINE_MM_DRIVER* lpDrv = &MMDrvs[mld->mmdIndex];
310 TRACE("(%p, %04x, %08lx, %08lx)\n", mld, uMsg, dwParam1, dwParam2);
312 /* all those function calls are undocumented */
313 switch (uMsg) {
314 case DRV_QUERYDRVENTRY:
315 lstrcpynA((LPSTR)dwParam1, lpDrv->drvname, LOWORD(dwParam2));
316 break;
317 case DRV_QUERYDEVNODE:
318 *(LPDWORD)dwParam1 = 0L; /* should be DevNode */
319 break;
320 case DRV_QUERYNAME:
321 WARN("NIY QueryName\n");
322 break;
323 case DRV_QUERYDRIVERIDS:
324 WARN("NIY call VxD\n");
325 /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts
326 * dwParam1 is buffer and dwParam2 is sizeof(buffer)
327 * I don't know where the result is stored though
329 break;
330 case DRV_QUERYMAPPABLE:
331 return (lpDrv->bIsMapper) ? 2 : 0;
333 case DRVM_MAPPER_PREFERRED_GET:
334 /* FIXME: get from registry someday */
335 *((LPDWORD)dwParam1) = -1; /* No preferred device */
336 *((LPDWORD)dwParam2) = 0;
337 break;
339 case DRV_QUERYDEVICEINTERFACE:
340 case DRV_QUERYDEVICEINTERFACESIZE:
341 return MMDRV_Message(mld, uMsg, dwParam1, dwParam2);
343 default:
344 WARN("Unknown call %04x\n", uMsg);
345 return MMSYSERR_INVALPARAM;
347 return 0L;
350 /**************************************************************************
351 * MMDRV_InitPerType [internal]
353 static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg)
355 WINE_MM_DRIVER_PART* part = &lpDrv->parts[type];
356 DWORD ret;
357 UINT count = 0;
358 int i, k;
359 TRACE("(%p, %04x, %04x)\n", lpDrv, type, wMsg);
361 part->nIDMin = part->nIDMax = 0;
363 /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */
364 /* the DRVM_ENABLE is only required when the PnP node is non zero */
365 if (part->fnMessage32) {
366 ret = part->fnMessage32(0, DRVM_INIT, 0L, 0L, 0L);
367 TRACE("DRVM_INIT => %s\n", WINMM_ErrorToString(ret));
368 #if 0
369 ret = part->fnMessage32(0, DRVM_ENABLE, 0L, 0L, 0L);
370 TRACE("DRVM_ENABLE => %08lx\n", ret);
371 #endif
372 count = part->fnMessage32(0, wMsg, 0L, 0L, 0L);
374 else return FALSE;
376 TRACE("Got %u dev for (%s:%s)\n", count, lpDrv->drvname, llTypes[type].typestr);
378 if (HIWORD(count))
379 return FALSE;
381 /* got some drivers */
382 if (lpDrv->bIsMapper) {
383 llTypes[type].nMapper = MMDrvsHi;
384 } else {
385 if (count == 0)
386 return FALSE;
387 part->nIDMin = llTypes[type].wMaxId;
388 llTypes[type].wMaxId += count;
389 part->nIDMax = llTypes[type].wMaxId;
391 TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n",
392 part->nIDMin, part->nIDMax, llTypes[type].wMaxId,
393 lpDrv->drvname, llTypes[type].typestr);
394 /* realloc translation table */
395 if (llTypes[type].lpMlds)
396 llTypes[type].lpMlds = (LPWINE_MLD)
397 HeapReAlloc(GetProcessHeap(), 0, llTypes[type].lpMlds - 1,
398 sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1;
399 else
400 llTypes[type].lpMlds = (LPWINE_MLD)
401 HeapAlloc(GetProcessHeap(), 0,
402 sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1;
404 /* re-build the translation table */
405 if (lpDrv->bIsMapper) {
406 TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, -1, MMDrvs[llTypes[type].nMapper].drvname);
407 llTypes[type].lpMlds[-1].uDeviceID = (UINT)-1;
408 llTypes[type].lpMlds[-1].type = type;
409 llTypes[type].lpMlds[-1].mmdIndex = llTypes[type].nMapper;
410 llTypes[type].lpMlds[-1].dwDriverInstance = 0;
412 for (i = k = 0; i <= MMDrvsHi; i++) {
413 while (MMDrvs[i].parts[type].nIDMin <= k && k < MMDrvs[i].parts[type].nIDMax) {
414 TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, k, MMDrvs[i].drvname);
415 llTypes[type].lpMlds[k].uDeviceID = k;
416 llTypes[type].lpMlds[k].type = type;
417 llTypes[type].lpMlds[k].mmdIndex = i;
418 llTypes[type].lpMlds[k].dwDriverInstance = 0;
419 k++;
422 return TRUE;
425 /**************************************************************************
426 * MMDRV_Install [internal]
428 static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
430 int i, count = 0;
431 LPWINE_MM_DRIVER lpDrv = &MMDrvs[MMDrvsHi];
432 LPWINE_DRIVER d;
433 WINEMM_msgFunc32 func;
435 TRACE("('%s', '%s', mapper=%c);\n", drvRegName, drvFileName, bIsMapper ? 'Y' : 'N');
437 for (i = 0; i < MMDrvsHi; i++) {
438 if (!strcmp(drvRegName, MMDrvs[i].drvname)) return FALSE;
441 /* Be sure that size of MMDrvs matches the max number of loadable
442 * drivers !!
443 * If not just increase size of MMDrvs
445 assert(MMDrvsHi <= sizeof(MMDrvs)/sizeof(MMDrvs[0]));
447 memset(lpDrv, 0, sizeof(*lpDrv));
449 if (!(lpDrv->hDriver = OpenDriverA(drvFileName, 0, 0))) {
450 WARN("Couldn't open driver '%s'\n", drvFileName);
451 return FALSE;
454 d = DRIVER_FindFromHDrvr(lpDrv->hDriver);
456 /* Then look for xxxMessage functions */
457 #define AA(_h,_w,_x,_y,_z) \
458 func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
459 if (func != NULL) \
460 { lpDrv->parts[_w].fnMessage##_y = func; count++; \
461 TRACE("Got %d bit func '%s'\n", _y, #_x); }
463 if (d->hModule) {
464 #define A(_x,_y) AA(d->hModule,_x,_y,32,GetProcAddress)
465 A(MMDRV_AUX, auxMessage);
466 A(MMDRV_MIXER, mxdMessage);
467 A(MMDRV_MIDIIN, midMessage);
468 A(MMDRV_MIDIOUT, modMessage);
469 A(MMDRV_WAVEIN, widMessage);
470 A(MMDRV_WAVEOUT, wodMessage);
471 #undef A
473 #undef AA
475 if (!count) {
476 CloseDriver(lpDrv->hDriver, 0, 0);
477 WARN("No message functions found\n");
478 return FALSE;
481 /* FIXME: being a mapper or not should be known by another way */
482 /* it's known for NE drvs (the description is of the form '*mapper: *'
483 * I don't have any clue for PE drvs
485 lpDrv->bIsMapper = bIsMapper;
486 lpDrv->drvname = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName) + 1), drvRegName);
488 /* Finish init and get the count of the devices */
489 i = 0;
490 if (MMDRV_InitPerType(lpDrv, MMDRV_AUX, AUXDM_GETNUMDEVS)) i = 1;
491 if (MMDRV_InitPerType(lpDrv, MMDRV_MIXER, MXDM_GETNUMDEVS)) i = 1;
492 if (MMDRV_InitPerType(lpDrv, MMDRV_MIDIIN, MIDM_GETNUMDEVS)) i = 1;
493 if (MMDRV_InitPerType(lpDrv, MMDRV_MIDIOUT, MODM_GETNUMDEVS)) i = 1;
494 if (MMDRV_InitPerType(lpDrv, MMDRV_WAVEIN, WIDM_GETNUMDEVS)) i = 1;
495 if (MMDRV_InitPerType(lpDrv, MMDRV_WAVEOUT, WODM_GETNUMDEVS)) i = 1;
496 /* if all those func calls return FALSE, then the driver must be unloaded */
497 if (!i) {
498 CloseDriver(lpDrv->hDriver, 0, 0);
499 HeapFree(GetProcessHeap(), 0, lpDrv->drvname);
500 WARN("Driver initialization failed\n");
501 return FALSE;
504 MMDrvsHi++;
506 return TRUE;
509 /**************************************************************************
510 * MMDRV_Init
512 static void MMDRV_Init(void)
514 IMMDeviceEnumerator *devenum;
515 IMMDevice *device;
516 IPropertyStore *ps;
517 PROPVARIANT pv;
518 DWORD size;
519 char *drvA;
520 HRESULT init_hr, hr;
522 static const WCHAR wine_info_deviceW[] = {'W','i','n','e',' ',
523 'i','n','f','o',' ','d','e','v','i','c','e',0};
525 TRACE("()\n");
527 init_hr = CoInitialize(NULL);
529 hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
530 CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&devenum);
531 if(FAILED(hr)){
532 ERR("CoCreateInstance failed: %08x\n", hr);
533 goto exit;
536 hr = IMMDeviceEnumerator_GetDevice(devenum, wine_info_deviceW, &device);
537 IMMDeviceEnumerator_Release(devenum);
538 if(FAILED(hr)){
539 ERR("GetDevice failed: %08x\n", hr);
540 goto exit;
543 hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps);
544 if(FAILED(hr)){
545 ERR("OpenPropertyStore failed: %08x\n", hr);
546 IMMDevice_Release(device);
547 goto exit;
550 hr = IPropertyStore_GetValue(ps,
551 (const PROPERTYKEY *)&DEVPKEY_Device_Driver, &pv);
552 IPropertyStore_Release(ps);
553 IMMDevice_Release(device);
554 if(FAILED(hr)){
555 ERR("GetValue failed: %08x\n", hr);
556 goto exit;
559 size = WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1,
560 NULL, 0, NULL, NULL);
561 drvA = HeapAlloc(GetProcessHeap(), 0, size);
562 WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1, drvA, size, NULL, NULL);
564 MMDRV_Install(drvA, drvA, FALSE);
566 HeapFree(GetProcessHeap(), 0, drvA);
567 PropVariantClear(&pv);
569 MMDRV_Install("wavemapper", "msacm32.drv", TRUE);
570 MMDRV_Install("midimapper", "midimap.dll", TRUE);
572 exit:
573 if(SUCCEEDED(init_hr))
574 CoUninitialize();
577 /******************************************************************
578 * ExitPerType
582 static BOOL MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv, UINT type)
584 WINE_MM_DRIVER_PART* part = &lpDrv->parts[type];
585 DWORD ret;
586 TRACE("(%p, %04x)\n", lpDrv, type);
588 if (part->fnMessage32) {
589 #if 0
590 ret = part->fnMessage32(0, DRVM_DISABLE, 0L, 0L, 0L);
591 TRACE("DRVM_DISABLE => %08lx\n", ret);
592 #endif
593 ret = part->fnMessage32(0, DRVM_EXIT, 0L, 0L, 0L);
594 TRACE("DRVM_EXIT => %s\n", WINMM_ErrorToString(ret));
597 return TRUE;
600 /******************************************************************
601 * Exit
605 void MMDRV_Exit(void)
607 unsigned int i;
608 TRACE("()\n");
610 for (i = 0; i < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]); i++)
612 if (MM_MLDrvs[i] != NULL)
614 FIXME("Closing while ll-driver open\n");
615 #if 0
616 /* FIXME: should generate a message depending on type */
617 MMDRV_Free((HANDLE)(i | 0x8000), MM_MLDrvs[i]);
618 #endif
622 /* unload driver, in reverse order of loading */
623 i = sizeof(MMDrvs) / sizeof(MMDrvs[0]);
624 while (i-- > 0)
626 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_AUX);
627 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_MIXER);
628 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_MIDIIN);
629 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_MIDIOUT);
630 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_WAVEIN);
631 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_WAVEOUT);
632 CloseDriver(MMDrvs[i].hDriver, 0, 0);
634 if (llTypes[MMDRV_AUX].lpMlds)
635 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_AUX].lpMlds - 1);
636 if (llTypes[MMDRV_MIXER].lpMlds)
637 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIXER].lpMlds - 1);
638 if (llTypes[MMDRV_MIDIIN].lpMlds)
639 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIIN].lpMlds - 1);
640 if (llTypes[MMDRV_MIDIOUT].lpMlds)
641 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIOUT].lpMlds - 1);
642 if (llTypes[MMDRV_WAVEIN].lpMlds)
643 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEIN].lpMlds - 1);
644 if (llTypes[MMDRV_WAVEOUT].lpMlds)
645 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEOUT].lpMlds - 1);