1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
4 * MMSYTEM low level drivers handling functions
6 * Copyright 1999 Eric Pouech
12 #include "user.h" /* should be removed asap; used in MMDRV_(Get|Alloc|Free) */
13 #include "selectors.h"
17 #include "debugtools.h"
19 DEFAULT_DEBUG_CHANNEL(mmsys
)
21 typedef DWORD
CALLBACK (*WINEMM_msgFunc16
)(UINT16
, WORD
, DWORD
, DWORD
, DWORD
);
22 typedef DWORD
CALLBACK (*WINEMM_msgFunc32
)(UINT
, UINT
, DWORD
, DWORD
, DWORD
);
24 /* for each loaded driver and each known type of driver, this structure contains
25 * the information needed to access it
27 typedef struct tagWINE_MM_DRIVER_PART
{
28 int nIDMin
; /* lower bound of global indexes for this type */
29 int nIDMax
; /* hhigher bound of global indexes for this type */
31 WINEMM_msgFunc32 fnMessage32
; /* pointer to fonction */
32 WINEMM_msgFunc16 fnMessage16
;
34 } WINE_MM_DRIVER_PART
;
36 /* each low-level .drv will be associated with an instance of this structure */
37 typedef struct tagWINE_MM_DRIVER
{
38 HDRVR hDrvr
; /* handle of loader driver */
39 LPSTR name
; /* name of the driver */
40 BOOL bIs32
: 1, /* TRUE if 32 bit driver, FALSE for 16 */
41 bIsMapper
: 1; /* TRUE if mapper */
42 WINE_MM_DRIVER_PART parts
[MMDRV_MAX
];/* Information for all known types */
43 } WINE_MM_DRIVER
, *LPWINE_MM_DRIVER
;
46 MMDRV_MAP_NOMEM
, /* ko, memory problem */
47 MMDRV_MAP_MSGERROR
, /* ko, unknown message */
48 MMDRV_MAP_OK
, /* ok, no memory allocated. to be sent to the proc. */
49 MMDRV_MAP_OKMEM
, /* ok, some memory allocated, need to call UnMapMsg. to be sent to the proc. */
50 MMDRV_MAP_PASS
/* not handled (no memory allocated) to be sent to the driver */
53 typedef MMDRV_MapType (*MMDRV_MAPFUNC
)(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
);
55 /* each known type of driver has an instance of this structure */
56 typedef struct tagWINE_LLTYPE
{
57 /* those attributes depend on the specification of the type */
58 LPSTR name
; /* name (for debugging) */
59 BOOL bSupportMapper
; /* if type is allowed to support mapper */
60 MMDRV_MAPFUNC Map16To32A
; /* those are function pointers to handle */
61 MMDRV_MAPFUNC UnMap16To32A
; /* the parameter conversion (16 vs 32 bit) */
62 MMDRV_MAPFUNC Map32ATo16
; /* when hi-func (in mmsystem or winmm) and */
63 MMDRV_MAPFUNC UnMap32ATo16
; /* low-func (in .drv) do not match */
64 LPDRVCALLBACK Callback
; /* handles callback for a specified type */
65 /* those attributes reflect the loaded/current situation for the type */
66 UINT wMaxId
; /* number of loaded devices (sum across all loaded drivers */
67 LPWINE_MLD lpMlds
; /* "static" mlds to access the part though device IDs */
68 int nMapper
; /* index to mapper */
71 static WINE_MM_DRIVER MMDrvs
[3];
73 /* ### start build ### */
74 extern WORD CALLBACK
MMDRV_CallTo16_word_wwlll(FARPROC16
,WORD
,WORD
,LONG
,LONG
,LONG
);
75 /* ### stop build ### */
77 /**************************************************************************
78 * MMDRV_GetDescription16 [internal]
80 static BOOL
MMDRV_GetDescription16(const char* fname
, char* buf
, int buflen
)
88 if ((hFile
= OpenFile(fname
, &ofs
, OF_READ
| OF_SHARE_DENY_WRITE
)) == HFILE_ERROR
) {
89 ERR("Can't open file %s\n", fname
);
93 #define E(_x) do {TRACE _x;goto theEnd;} while(0)
95 if (_lread(hFile
, &w
, 2) != 2) E(("Can't read sig\n"));
96 if (w
!= ('Z' * 256 + 'M')) E(("Bad sig %04x\n", w
));
97 if (_llseek(hFile
, 0x3C, SEEK_SET
) < 0) E(("Can't seek to ext header offset\n"));
98 if (_lread(hFile
, &dw
, 4) != 4) E(("Can't read ext header offset\n"));
99 if (_llseek(hFile
, dw
+ 0x2C, SEEK_SET
) < 0) E(("Can't seek to ext header.nr table %lu\n", dw
+0x2C));
100 if (_lread(hFile
, &dw
, 4) != 4) E(("Can't read nr table offset\n"));
101 if (_llseek(hFile
, dw
, SEEK_SET
) < 0) E(("Can't seek to nr table %lu\n", dw
));
102 if (_lread(hFile
, buf
, 1) != 1) E(("Can't read descr length\n"));
103 buflen
= min((BYTE
)buf
[0], buflen
- 1);
104 if (_lread(hFile
, buf
, buflen
) != buflen
) E(("Can't read descr (%d)\n", buflen
));
107 TRACE("Got '%s' [%d]\n", buf
, buflen
);
113 /**************************************************************************
114 * MMDRV_GetDescription32 [internal]
116 static BOOL
MMDRV_GetDescription32(const char* fname
, char* buf
, int buflen
)
125 FARPROC pGetFileVersionInfoSizeA
;
126 FARPROC pGetFileVersionInfoA
;
127 FARPROC pVerQueryValueA
;
130 #define E(_x) do {TRACE _x;goto theEnd;} while(0)
132 if (OpenFile(fname
, &ofs
, OF_EXIST
)==HFILE_ERROR
) E(("Can't find file %s\n", fname
));
134 if (!(hmodule
= LoadLibraryA( "version.dll" ))) goto theEnd
;
135 if (!(pGetFileVersionInfoSizeA
= GetProcAddress( hmodule
, "GetFileVersionInfoSizeA" )))
137 if (!(pGetFileVersionInfoA
= GetProcAddress( hmodule
, "GetFileVersionInfoA" )))
139 if (!(pVerQueryValueA
= GetProcAddress( hmodule
, "pVerQueryValueA" )))
142 if (!(dw
= pGetFileVersionInfoSizeA(ofs
.szPathName
, &h
))) E(("Can't get FVIS\n"));
143 if (!(ptr
= HeapAlloc(GetProcessHeap(), 0, dw
))) E(("OOM\n"));
144 if (!pGetFileVersionInfoA(ofs
.szPathName
, h
, dw
, ptr
)) E(("Can't get FVI\n"));
146 #define A(_x) if (pVerQueryValueA(ptr, "\\StringFileInfo\\040904B0\\" #_x, &val, &u)) \
147 TRACE(#_x " => %s\n", (LPSTR)val); else TRACE(#_x " @\n")
163 if (!pVerQueryValueA(ptr
, "\\StringFileInfo\\040904B0\\ProductName", &val
, &u
)) E(("Can't get product name\n"));
164 lstrcpynA(buf
, val
, buflen
);
169 HeapFree(GetProcessHeap(), 0, ptr
);
170 if (hmodule
) FreeLibrary( hmodule
);
174 /**************************************************************************
175 * MMDRV_Callback [internal]
177 static void MMDRV_Callback(LPWINE_MLD mld
, HDRVR hDev
, UINT uMsg
, DWORD dwParam1
, DWORD dwParam2
)
179 TRACE("CB (*%08lx)(%08x %08x %08lx %08lx %08lx\n",
180 mld
->dwCallback
, hDev
, uMsg
, mld
->dwClientInstance
, dwParam1
, dwParam2
);
182 if (!mld
->bFrom32
&& (mld
->dwFlags
& DCB_TYPEMASK
) == DCB_FUNCTION
) {
183 /* 16 bit func, call it */
184 TRACE("Function (16 bit) !\n");
185 MMDRV_CallTo16_word_wwlll((FARPROC16
)mld
->dwCallback
, hDev
, uMsg
,
186 mld
->dwClientInstance
, dwParam1
, dwParam2
);
188 DriverCallback(mld
->dwCallback
, mld
->dwFlags
, hDev
, uMsg
,
189 mld
->dwClientInstance
, dwParam1
, dwParam2
);
193 /* =================================
194 * A U X M A P P E R S
195 * ================================= */
197 /**************************************************************************
198 * MMDRV_Aux_Map16To32A [internal]
200 static MMDRV_MapType
MMDRV_Aux_Map16To32A (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
202 return MMDRV_MAP_MSGERROR
;
205 /**************************************************************************
206 * MMDRV_Aux_UnMap16To32A [internal]
208 static MMDRV_MapType
MMDRV_Aux_UnMap16To32A(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
210 return MMDRV_MAP_MSGERROR
;
213 /**************************************************************************
214 * MMDRV_Aux_Map32ATo16 [internal]
216 static MMDRV_MapType
MMDRV_Aux_Map32ATo16 (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
218 return MMDRV_MAP_MSGERROR
;
221 /**************************************************************************
222 * MMDRV_Aux_UnMap32ATo16 [internal]
224 static MMDRV_MapType
MMDRV_Aux_UnMap32ATo16(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
227 case AUXDM_GETDEVCAPS
:
228 lpCaps
->wMid
= ac16
.wMid
;
229 lpCaps
->wPid
= ac16
.wPid
;
230 lpCaps
->vDriverVersion
= ac16
.vDriverVersion
;
231 strcpy(lpCaps
->szPname
, ac16
.szPname
);
232 lpCaps
->wTechnology
= ac16
.wTechnology
;
233 lpCaps
->dwSupport
= ac16
.dwSupport
;
235 return MMDRV_MAP_MSGERROR
;
238 /**************************************************************************
239 * MMDRV_Aux_Callback [internal]
241 static void CALLBACK
MMDRV_Aux_Callback(HDRVR hDev
, UINT uMsg
, DWORD dwInstance
, DWORD dwParam1
, DWORD dwParam2
)
243 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
246 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
249 /* =================================
250 * M I X E R M A P P E R S
251 * ================================= */
253 /**************************************************************************
254 * xMMDRV_Mixer_Map16To32A [internal]
256 static MMDRV_MapType
MMDRV_Mixer_Map16To32A (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
258 return MMDRV_MAP_MSGERROR
;
261 /**************************************************************************
262 * MMDRV_Mixer_UnMap16To32A [internal]
264 static MMDRV_MapType
MMDRV_Mixer_UnMap16To32A(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
268 UINT ret
= mixerGetDevCapsA(devid
, &micA
, sizeof(micA
));
270 if (ret
== MMSYSERR_NOERROR
) {
271 mixcaps
->wMid
= micA
.wMid
;
272 mixcaps
->wPid
= micA
.wPid
;
273 mixcaps
->vDriverVersion
= micA
.vDriverVersion
;
274 strcpy(mixcaps
->szPname
, micA
.szPname
);
275 mixcaps
->fdwSupport
= micA
.fdwSupport
;
276 mixcaps
->cDestinations
= micA
.cDestinations
;
280 return MMDRV_MAP_MSGERROR
;
283 /**************************************************************************
284 * MMDRV_Mixer_Map32ATo16 [internal]
286 static MMDRV_MapType
MMDRV_Mixer_Map32ATo16 (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
288 return MMDRV_MAP_MSGERROR
;
291 /**************************************************************************
292 * MMDRV_Mixer_UnMap32ATo16 [internal]
294 static MMDRV_MapType
MMDRV_Mixer_UnMap32ATo16(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
296 return MMDRV_MAP_MSGERROR
;
299 /**************************************************************************
300 * MMDRV_Mixer_Callback [internal]
302 static void CALLBACK
MMDRV_Mixer_Callback(HDRVR hDev
, UINT uMsg
, DWORD dwInstance
, DWORD dwParam1
, DWORD dwParam2
)
304 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
307 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
310 /* =================================
311 * M I D I I N M A P P E R S
312 * ================================= */
314 /**************************************************************************
315 * MMDRV_MidiIn_Map16To32A [internal]
317 static MMDRV_MapType
MMDRV_MidiIn_Map16To32A (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
319 return MMDRV_MAP_MSGERROR
;
322 /**************************************************************************
323 * MMDRV_MidiIn_UnMap16To32A [internal]
325 static MMDRV_MapType
MMDRV_MidiIn_UnMap16To32A(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
327 return MMDRV_MAP_MSGERROR
;
330 /**************************************************************************
331 * MMDRV_MidiIn_Map32ATo16 [internal]
333 static MMDRV_MapType
MMDRV_MidiIn_Map32ATo16 (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
335 return MMDRV_MAP_MSGERROR
;
338 /**************************************************************************
339 * MMDRV_MidiIn_UnMap32ATo16 [internal]
341 static MMDRV_MapType
MMDRV_MidiIn_UnMap32ATo16(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
343 return MMDRV_MAP_MSGERROR
;
346 /**************************************************************************
347 * MMDRV_MidiIn_Callback [internal]
349 static void CALLBACK
MMDRV_MidiIn_Callback(HDRVR hDev
, UINT uMsg
, DWORD dwInstance
, DWORD dwParam1
, DWORD dwParam2
)
351 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
356 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
361 /* dwParam1 & dwParam2 are are data, nothing to do */
365 /* dwParam1 points to a MidiHdr, work to be done !!! */
366 if (mld
->bFrom32
&& !MMDrvs
[mld
->mmdIndex
].bIs32
) {
367 /* initial map is: 32 => 16 */
368 LPMIDIHDR mh16
= (LPMIDIHDR
)PTR_SEG_TO_LIN(dwParam1
);
369 LPMIDIHDR mh32
= *(LPMIDIHDR
*)((LPSTR
)mh16
- sizeof(LPMIDIHDR
));
371 dwParam1
= (DWORD
)mh32
;
372 mh32
->dwFlags
= mh16
->dwFlags
;
373 mh32
->dwBytesRecorded
= mh16
->dwBytesRecorded
;
374 if (mh32
->reserved
>= sizeof(MIDIHDR
))
375 mh32
->dwOffset
= mh16
->dwOffset
;
376 } else if (!mld
->bFrom32
&& MMDrvs
[mld
->mmdIndex
].bIs32
) {
377 /* initial map is: 16 => 32 */
378 LPMIDIHDR mh32
= (LPMIDIHDR
)(dwParam1
);
379 LPMIDIHDR segmh16
= *(LPMIDIHDR
*)((LPSTR
)mh32
- sizeof(LPMIDIHDR
));
380 LPMIDIHDR mh16
= PTR_SEG_TO_LIN(segmh16
);
382 dwParam1
= (DWORD
)segmh16
;
383 mh16
->dwFlags
= mh32
->dwFlags
;
384 mh16
->dwBytesRecorded
= mh32
->dwBytesRecorded
;
385 if (mh16
->reserved
>= sizeof(MIDIHDR
))
386 mh16
->dwOffset
= mh32
->dwOffset
;
388 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
390 /* case MOM_POSITIONCB: */
392 ERR("Unknown msg %u\n", uMsg
);
395 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
398 /* =================================
399 * M I D I O U T M A P P E R S
400 * ================================= */
402 /**************************************************************************
403 * MMDRV_MidiOut_Map16To32A [internal]
405 static MMDRV_MapType
MMDRV_MidiOut_Map16To32A (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
407 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
410 case MODM_GETNUMDEVS
:
420 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
423 case MODM_GETDEVCAPS
:
425 LPMIDIOUTCAPSA moc32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPS16
) + sizeof(MIDIOUTCAPSA
));
426 LPMIDIOUTCAPS16 moc16
= PTR_SEG_TO_LIN(*lpParam1
);
429 *(LPMIDIOUTCAPS16
*)moc32
= moc16
;
430 moc32
= (LPMIDIOUTCAPSA
)((LPSTR
)moc32
+ sizeof(LPMIDIOUTCAPS16
));
431 *lpParam1
= (DWORD
)moc32
;
432 *lpParam2
= sizeof(MIDIOUTCAPSA
);
434 ret
= MMDRV_MAP_OKMEM
;
436 ret
= MMDRV_MAP_NOMEM
;
442 LPMIDIHDR mh32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIHDR
) + sizeof(MIDIHDR
));
443 LPMIDIHDR mh16
= PTR_SEG_TO_LIN(*lpParam1
);
446 *(LPMIDIHDR
*)mh32
= (LPMIDIHDR
)*lpParam1
;
447 mh32
= (LPMIDIHDR
)((LPSTR
)mh32
+ sizeof(LPMIDIHDR
));
448 mh32
->lpData
= PTR_SEG_TO_LIN(mh16
->lpData
);
449 mh32
->dwBufferLength
= mh16
->dwBufferLength
;
450 mh32
->dwBytesRecorded
= mh16
->dwBytesRecorded
;
451 mh32
->dwUser
= mh16
->dwUser
;
452 mh32
->dwFlags
= mh16
->dwFlags
;
453 /* FIXME: nothing on mh32->lpNext */
454 /* could link the mh32->lpNext at this level for memory house keeping */
455 mh32
->dwOffset
= (*lpParam2
>= sizeof(MIDIHDR
)) ? ((LPMIDIHDR
)mh16
)->dwOffset
: 0;
456 mh16
->lpNext
= mh32
; /* for reuse in unprepare and write */
457 /* store size of passed MIDIHDR?? structure to know if dwOffset is available or not */
458 mh16
->reserved
= *lpParam2
;
459 *lpParam1
= (DWORD
)mh32
;
460 *lpParam2
= sizeof(MIDIHDR
);
462 ret
= MMDRV_MAP_OKMEM
;
464 ret
= MMDRV_MAP_NOMEM
;
471 LPMIDIHDR mh16
= PTR_SEG_TO_LIN(*lpParam1
);
472 LPMIDIHDR mh32
= (LPMIDIHDR
)mh16
->lpNext
;
474 *lpParam1
= (DWORD
)mh32
;
475 *lpParam2
= sizeof(MIDIHDR
);
476 /* dwBufferLength can be reduced between prepare & write */
477 if (mh32
->dwBufferLength
< mh16
->dwBufferLength
) {
478 ERR("Size of buffer has been increased (%ld, %ld)\n",
479 mh32
->dwBufferLength
, mh16
->dwBufferLength
);
480 return MMDRV_MAP_MSGERROR
;
482 mh32
->dwBufferLength
= mh16
->dwBufferLength
;
483 ret
= MMDRV_MAP_OKMEM
;
487 case MODM_CACHEPATCHES
:
488 case MODM_CACHEDRUMPATCHES
:
490 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
496 /**************************************************************************
497 * MMDRV_MidiOut_UnMap16To32A [internal]
499 static MMDRV_MapType
MMDRV_MidiOut_UnMap16To32A(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
501 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
504 case MODM_GETNUMDEVS
:
514 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
517 case MODM_GETDEVCAPS
:
519 LPMIDIOUTCAPSA moc32
= (LPMIDIOUTCAPSA
)(*lpParam1
);
520 LPMIDIOUTCAPS16 moc16
= *(LPMIDIOUTCAPS16
*)((LPSTR
)moc32
- sizeof(LPMIDIOUTCAPS16
));
522 moc16
->wMid
= moc32
->wMid
;
523 moc16
->wPid
= moc32
->wPid
;
524 moc16
->vDriverVersion
= moc32
->vDriverVersion
;
525 strcpy(moc16
->szPname
, moc32
->szPname
);
526 moc16
->wTechnology
= moc32
->wTechnology
;
527 moc16
->wVoices
= moc32
->wVoices
;
528 moc16
->wNotes
= moc32
->wNotes
;
529 moc16
->wChannelMask
= moc32
->wChannelMask
;
530 moc16
->dwSupport
= moc32
->dwSupport
;
531 HeapFree(GetProcessHeap(), 0, (LPSTR
)moc32
- sizeof(LPMIDIOUTCAPS16
));
539 LPMIDIHDR mh32
= (LPMIDIHDR
)(*lpParam1
);
540 LPMIDIHDR mh16
= PTR_SEG_TO_LIN(*(LPMIDIHDR
*)((LPSTR
)mh32
- sizeof(LPMIDIHDR
)));
542 assert(mh16
->lpNext
== mh32
);
543 mh16
->dwBufferLength
= mh32
->dwBufferLength
;
544 mh16
->dwBytesRecorded
= mh32
->dwBytesRecorded
;
545 mh16
->dwUser
= mh32
->dwUser
;
546 mh16
->dwFlags
= mh32
->dwFlags
;
547 if (mh16
->reserved
>= sizeof(MIDIHDR
))
548 mh16
->dwOffset
= mh32
->dwOffset
;
550 if (wMsg
== MODM_UNPREPARE
) {
551 HeapFree(GetProcessHeap(), 0, (LPSTR
)mh32
- sizeof(LPMIDIHDR
));
558 case MODM_CACHEPATCHES
:
559 case MODM_CACHEDRUMPATCHES
:
561 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
567 /**************************************************************************
568 * MMDRV_MidiOut_Map32ATo16 [internal]
570 static MMDRV_MapType
MMDRV_MidiOut_Map32ATo16 (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
572 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
576 case MODM_GETNUMDEVS
:
582 case MODM_GETDEVCAPS
:
584 LPMIDIOUTCAPSA moc32
= (LPMIDIOUTCAPSA
)*lpParam1
;
585 LPSTR ptr
= SEGPTR_ALLOC(sizeof(LPMIDIOUTCAPSA
) + sizeof(MIDIOUTCAPS16
));
588 *(LPMIDIOUTCAPSA
*)ptr
= moc32
;
589 ret
= MMDRV_MAP_OKMEM
;
591 ret
= MMDRV_MAP_NOMEM
;
593 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMIDIOUTCAPSA
);
594 *lpParam2
= sizeof(MIDIOUTCAPS16
);
599 LPMIDIHDR mh32
= (LPMIDIHDR
)*lpParam1
;
601 LPVOID ptr
= SEGPTR_ALLOC(sizeof(LPMIDIHDR
) + sizeof(MIDIHDR
) + mh32
->dwBufferLength
);
604 *(LPMIDIHDR
*)ptr
= mh32
;
605 mh16
= (LPMIDIHDR
)((LPSTR
)ptr
+ sizeof(LPMIDIHDR
));
606 mh16
->lpData
= (LPSTR
)SEGPTR_GET(ptr
) + sizeof(LPMIDIHDR
) + sizeof(MIDIHDR
);
607 /* data will be copied on WODM_WRITE */
608 mh16
->dwBufferLength
= mh32
->dwBufferLength
;
609 mh16
->dwBytesRecorded
= mh32
->dwBytesRecorded
;
610 mh16
->dwUser
= mh32
->dwUser
;
611 mh16
->dwFlags
= mh32
->dwFlags
;
612 /* FIXME: nothing on mh32->lpNext */
613 /* could link the mh32->lpNext at this level for memory house keeping */
614 mh16
->dwOffset
= (*lpParam2
>= sizeof(MIDIHDR
)) ? mh32
->dwOffset
: 0;
616 mh32
->lpNext
= (LPMIDIHDR
)mh16
; /* for reuse in unprepare and write */
617 mh32
->reserved
= *lpParam2
;
619 TRACE("mh16=%08lx mh16->lpData=%08lx mh32->buflen=%lu mh32->lpData=%08lx\n",
620 (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMIDIHDR
), (DWORD
)mh16
->lpData
,
621 mh32
->dwBufferLength
, (DWORD
)mh32
->lpData
);
622 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMIDIHDR
);
623 *lpParam2
= sizeof(MIDIHDR
);
625 ret
= MMDRV_MAP_OKMEM
;
627 ret
= MMDRV_MAP_NOMEM
;
634 LPMIDIHDR mh32
= (LPMIDIHDR
)(*lpParam1
);
635 LPMIDIHDR mh16
= (LPMIDIHDR
)mh32
->lpNext
;
636 LPSTR ptr
= (LPSTR
)mh16
- sizeof(LPMIDIHDR
);
638 assert(*(LPMIDIHDR
*)ptr
== mh32
);
640 TRACE("mh16=%08lx mh16->lpData=%08lx mh32->buflen=%lu mh32->lpData=%08lx\n",
641 (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMIDIHDR
), (DWORD
)mh16
->lpData
,
642 mh32
->dwBufferLength
, (DWORD
)mh32
->lpData
);
644 if (wMsg
== MODM_LONGDATA
)
645 memcpy((LPSTR
)mh16
+ sizeof(MIDIHDR
), mh32
->lpData
, mh32
->dwBufferLength
);
647 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMIDIHDR
);
648 *lpParam2
= sizeof(MIDIHDR
);
649 /* dwBufferLength can be reduced between prepare & write */
650 if (mh16
->dwBufferLength
< mh32
->dwBufferLength
) {
651 ERR("Size of buffer has been increased (%ld, %ld)\n",
652 mh16
->dwBufferLength
, mh32
->dwBufferLength
);
653 return MMDRV_MAP_MSGERROR
;
655 mh16
->dwBufferLength
= mh32
->dwBufferLength
;
656 ret
= MMDRV_MAP_OKMEM
;
661 LPMIDIOPENDESC mod32
= (LPMIDIOPENDESC
)*lpParam1
;
663 LPMIDIOPENDESC16 mod16
;
665 /* allocated data are mapped as follows:
666 LPMIDIOPENDESC ptr to orig lParam1
667 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
668 DWORD dwUser passed to driver
669 MIDIOPENDESC16 mod16: openDesc passed to driver
672 ptr
= SEGPTR_ALLOC(sizeof(LPMIDIOPENDESC
) + 2*sizeof(DWORD
) + sizeof(MIDIOPENDESC16
) +
673 mod32
->cIds
? (mod32
->cIds
- 1) * sizeof(MIDIOPENSTRMID
) : 0);
676 *(LPMIDIOPENDESC
*)ptr
= mod32
;
677 *(LPDWORD
)(ptr
+ sizeof(LPMIDIOPENDESC
)) = *lpdwUser
;
678 mod16
= (LPMIDIOPENDESC16
)((LPSTR
)ptr
+ sizeof(LPMIDIOPENDESC
) + 2*sizeof(DWORD
));
680 mod16
->hMidi
= mod32
->hMidi
;
681 mod16
->dwCallback
= mod32
->dwCallback
;
682 mod16
->dwInstance
= mod32
->dwInstance
;
683 mod16
->dnDevNode
= mod32
->dnDevNode
;
684 mod16
->cIds
= mod32
->cIds
;
685 memcpy(&mod16
->rgIds
, &mod32
->rgIds
, mod32
->cIds
* sizeof(MIDIOPENSTRMID
));
687 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMIDIOPENDESC
) + 2*sizeof(DWORD
);
688 *lpdwUser
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMIDIOPENDESC
) + sizeof(DWORD
);
690 ret
= MMDRV_MAP_OKMEM
;
692 ret
= MMDRV_MAP_NOMEM
;
697 case MODM_CACHEPATCHES
:
698 case MODM_CACHEDRUMPATCHES
:
700 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
706 /**************************************************************************
707 * MMDRV_MidiOut_UnMap32ATo16 [internal]
709 static MMDRV_MapType
MMDRV_MidiOut_UnMap32ATo16(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
711 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
715 case MODM_GETNUMDEVS
:
721 case MODM_GETDEVCAPS
:
723 LPMIDIOUTCAPS16 moc16
= (LPMIDIOUTCAPS16
)PTR_SEG_TO_LIN(*lpParam1
);
724 LPSTR ptr
= (LPSTR
)moc16
- sizeof(LPMIDIOUTCAPSA
);
725 LPMIDIOUTCAPSA moc32
= *(LPMIDIOUTCAPSA
*)ptr
;
727 moc32
->wMid
= moc16
->wMid
;
728 moc32
->wPid
= moc16
->wPid
;
729 moc32
->vDriverVersion
= moc16
->vDriverVersion
;
730 strcpy(moc32
->szPname
, moc16
->szPname
);
731 moc32
->wTechnology
= moc16
->wTechnology
;
732 moc32
->wVoices
= moc16
->wVoices
;
733 moc32
->wNotes
= moc16
->wNotes
;
734 moc32
->wChannelMask
= moc16
->wChannelMask
;
735 moc32
->dwSupport
= moc16
->dwSupport
;
737 if (!SEGPTR_FREE(ptr
))
738 FIXME("bad free line=%d\n", __LINE__
);
746 LPMIDIHDR mh16
= (LPMIDIHDR
)PTR_SEG_TO_LIN(*lpParam1
);
747 LPSTR ptr
= (LPSTR
)mh16
- sizeof(LPMIDIHDR
);
748 LPMIDIHDR mh32
= *(LPMIDIHDR
*)ptr
;
750 assert(mh32
->lpNext
== (LPMIDIHDR
)mh16
);
751 mh32
->dwBytesRecorded
= mh16
->dwBytesRecorded
;
752 mh32
->dwUser
= mh16
->dwUser
;
753 mh32
->dwFlags
= mh16
->dwFlags
;
755 if (wMsg
== MODM_UNPREPARE
) {
756 if (!SEGPTR_FREE(ptr
))
757 FIXME("bad free line=%d\n", __LINE__
);
765 LPMIDIOPENDESC16 mod16
= (LPMIDIOPENDESC16
)PTR_SEG_TO_LIN(*lpParam1
);
766 LPSTR ptr
= (LPSTR
)mod16
- sizeof(LPMIDIOPENDESC
) - 2*sizeof(DWORD
);
768 **(DWORD
**)(ptr
+ sizeof(LPMIDIOPENDESC
)) = *(LPDWORD
)(ptr
+ sizeof(LPMIDIOPENDESC
) + sizeof(DWORD
));
770 if (!SEGPTR_FREE(ptr
))
771 FIXME("bad free line=%d\n", __LINE__
);
777 case MODM_CACHEPATCHES
:
778 case MODM_CACHEDRUMPATCHES
:
780 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
786 /**************************************************************************
787 * MMDRV_MidiOut_Callback [internal]
789 static void CALLBACK
MMDRV_MidiOut_Callback(HDRVR hDev
, UINT uMsg
, DWORD dwInstance
, DWORD dwParam1
, DWORD dwParam2
)
791 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
796 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
799 if (mld
->bFrom32
&& !MMDrvs
[mld
->mmdIndex
].bIs32
) {
800 /* initial map is: 32 => 16 */
801 LPMIDIHDR mh16
= (LPMIDIHDR
)PTR_SEG_TO_LIN(dwParam1
);
802 LPMIDIHDR mh32
= *(LPMIDIHDR
*)((LPSTR
)mh16
- sizeof(LPMIDIHDR
));
804 dwParam1
= (DWORD
)mh32
;
805 mh32
->dwFlags
= mh16
->dwFlags
;
806 mh32
->dwOffset
= mh16
->dwOffset
;
807 if (mh32
->reserved
>= sizeof(MIDIHDR
))
808 mh32
->dwOffset
= mh16
->dwOffset
;
809 } else if (!mld
->bFrom32
&& MMDrvs
[mld
->mmdIndex
].bIs32
) {
810 /* initial map is: 16 => 32 */
811 LPMIDIHDR mh32
= (LPMIDIHDR
)(dwParam1
);
812 LPMIDIHDR segmh16
= *(LPMIDIHDR
*)((LPSTR
)mh32
- sizeof(LPMIDIHDR
));
813 LPMIDIHDR mh16
= PTR_SEG_TO_LIN(segmh16
);
815 dwParam1
= (DWORD
)segmh16
;
816 mh16
->dwFlags
= mh32
->dwFlags
;
817 if (mh16
->reserved
>= sizeof(MIDIHDR
))
818 mh16
->dwOffset
= mh32
->dwOffset
;
820 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
822 /* case MOM_POSITIONCB: */
824 ERR("Unknown msg %u\n", uMsg
);
827 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
830 /* =================================
831 * W A V E I N M A P P E R S
832 * ================================= */
834 /**************************************************************************
835 * MMDRV_WaveIn_Map16To32A [internal]
837 static MMDRV_MapType
MMDRV_WaveIn_Map16To32A (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
839 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
842 case WIDM_GETNUMDEVS
:
850 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
852 case WIDM_GETDEVCAPS
:
854 LPWAVEINCAPSA wic32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEINCAPS16
) + sizeof(WAVEINCAPSA
));
855 LPWAVEINCAPS16 wic16
= PTR_SEG_TO_LIN(*lpParam1
);
858 *(LPWAVEINCAPS16
*)wic32
= wic16
;
859 wic32
= (LPWAVEINCAPSA
)((LPSTR
)wic32
+ sizeof(LPWAVEINCAPS16
));
860 *lpParam1
= (DWORD
)wic32
;
861 *lpParam2
= sizeof(WAVEINCAPSA
);
863 ret
= MMDRV_MAP_OKMEM
;
865 ret
= MMDRV_MAP_NOMEM
;
871 LPMMTIME mmt32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16
) + sizeof(MMTIME
));
872 LPMMTIME16 mmt16
= PTR_SEG_TO_LIN(*lpParam1
);
875 *(LPMMTIME16
*)mmt32
= mmt16
;
876 mmt32
= (LPMMTIME
)((LPSTR
)mmt32
+ sizeof(LPMMTIME16
));
878 mmt32
->wType
= mmt16
->wType
;
879 *lpParam1
= (DWORD
)mmt32
;
880 *lpParam2
= sizeof(MMTIME
);
882 ret
= MMDRV_MAP_OKMEM
;
884 ret
= MMDRV_MAP_NOMEM
;
890 LPWAVEHDR wh32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
));
891 LPWAVEHDR wh16
= PTR_SEG_TO_LIN(*lpParam1
);
894 *(LPWAVEHDR
*)wh32
= (LPWAVEHDR
)*lpParam1
;
895 wh32
= (LPWAVEHDR
)((LPSTR
)wh32
+ sizeof(LPWAVEHDR
));
896 wh32
->lpData
= PTR_SEG_TO_LIN(wh16
->lpData
);
897 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
898 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
899 wh32
->dwUser
= wh16
->dwUser
;
900 wh32
->dwFlags
= wh16
->dwFlags
;
901 wh32
->dwLoops
= wh16
->dwLoops
;
902 /* FIXME: nothing on wh32->lpNext */
903 /* could link the wh32->lpNext at this level for memory house keeping */
904 wh16
->lpNext
= wh32
; /* for reuse in unprepare and write */
905 *lpParam1
= (DWORD
)wh32
;
906 *lpParam2
= sizeof(WAVEHDR
);
908 ret
= MMDRV_MAP_OKMEM
;
910 ret
= MMDRV_MAP_NOMEM
;
917 LPWAVEHDR wh16
= PTR_SEG_TO_LIN(*lpParam1
);
918 LPWAVEHDR wh32
= (LPWAVEHDR
)wh16
->lpNext
;
920 *lpParam1
= (DWORD
)wh32
;
921 *lpParam2
= sizeof(WAVEHDR
);
922 /* dwBufferLength can be reduced between prepare & write */
923 if (wh32
->dwBufferLength
< wh16
->dwBufferLength
) {
924 ERR("Size of buffer has been increased (%ld, %ld)\n",
925 wh32
->dwBufferLength
, wh16
->dwBufferLength
);
926 return MMDRV_MAP_MSGERROR
;
928 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
929 ret
= MMDRV_MAP_OKMEM
;
933 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
934 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
940 /**************************************************************************
941 * MMDRV_WaveIn_UnMap16To32A [internal]
943 static MMDRV_MapType
MMDRV_WaveIn_UnMap16To32A(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
945 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
948 case WIDM_GETNUMDEVS
:
956 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
958 case WIDM_GETDEVCAPS
:
960 LPWAVEINCAPSA wic32
= (LPWAVEINCAPSA
)(*lpParam1
);
961 LPWAVEINCAPS16 wic16
= *(LPWAVEINCAPS16
*)((LPSTR
)wic32
- sizeof(LPWAVEINCAPS16
));
963 wic16
->wMid
= wic32
->wMid
;
964 wic16
->wPid
= wic32
->wPid
;
965 wic16
->vDriverVersion
= wic32
->vDriverVersion
;
966 strcpy(wic16
->szPname
, wic32
->szPname
);
967 wic16
->dwFormats
= wic32
->dwFormats
;
968 wic16
->wChannels
= wic32
->wChannels
;
969 HeapFree(GetProcessHeap(), 0, (LPSTR
)wic32
- sizeof(LPWAVEINCAPS16
));
975 LPMMTIME mmt32
= (LPMMTIME
)(*lpParam1
);
976 LPMMTIME16 mmt16
= *(LPMMTIME16
*)((LPSTR
)mmt32
- sizeof(LPMMTIME16
));
978 MMSYSTEM_MMTIME32to16(mmt16
, mmt32
);
979 HeapFree(GetProcessHeap(), 0, (LPSTR
)mmt32
- sizeof(LPMMTIME16
));
987 LPWAVEHDR wh32
= (LPWAVEHDR
)(*lpParam1
);
988 LPWAVEHDR wh16
= PTR_SEG_TO_LIN(*(LPWAVEHDR
*)((LPSTR
)wh32
- sizeof(LPWAVEHDR
)));
990 assert(wh16
->lpNext
== wh32
);
991 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
992 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
993 wh16
->dwUser
= wh32
->dwUser
;
994 wh16
->dwFlags
= wh32
->dwFlags
;
995 wh16
->dwLoops
= wh32
->dwLoops
;
997 if (wMsg
== WIDM_UNPREPARE
) {
998 HeapFree(GetProcessHeap(), 0, (LPSTR
)wh32
- sizeof(LPWAVEHDR
));
1005 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1011 /**************************************************************************
1012 * MMDRV_WaveIn_Map32ATo16 [internal]
1014 static MMDRV_MapType
MMDRV_WaveIn_Map32ATo16 (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
1016 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
1020 case WIDM_GETNUMDEVS
:
1029 LPWAVEOPENDESC wod32
= (LPWAVEOPENDESC
)*lpParam1
;
1030 int sz
= sizeof(WAVEFORMATEX
);
1032 LPWAVEOPENDESC16 wod16
;
1034 /* allocated data are mapped as follows:
1035 LPWAVEOPENDESC ptr to orig lParam1
1036 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
1037 DWORD dwUser passed to driver
1038 WAVEOPENDESC16 wod16: openDesc passed to driver
1039 WAVEFORMATEX openDesc->lpFormat passed to driver
1040 xxx extra bytes to WAVEFORMATEX
1042 if (wod32
->lpFormat
->wFormatTag
!= WAVE_FORMAT_PCM
) {
1043 TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX
)wod32
->lpFormat
)->cbSize
, wod32
->lpFormat
->wFormatTag
);
1044 sz
+= ((LPWAVEFORMATEX
)wod32
->lpFormat
)->cbSize
;
1047 ptr
= SEGPTR_ALLOC(sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
) + sizeof(WAVEOPENDESC16
) + sz
);
1050 *(LPWAVEOPENDESC
*)ptr
= wod32
;
1051 *(LPDWORD
)(ptr
+ sizeof(LPWAVEOPENDESC
)) = *lpdwUser
;
1052 wod16
= (LPWAVEOPENDESC16
)((LPSTR
)ptr
+ sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
));
1054 wod16
->hWave
= wod32
->hWave
;
1055 wod16
->lpFormat
= (LPWAVEFORMATEX
)((DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
) + sizeof(WAVEOPENDESC16
));
1056 memcpy(wod16
+ 1, wod32
->lpFormat
, sz
);
1058 wod16
->dwCallback
= wod32
->dwCallback
;
1059 wod16
->dwInstance
= wod32
->dwInstance
;
1060 wod16
->uMappedDeviceID
= wod32
->uMappedDeviceID
;
1061 wod16
->dnDevNode
= wod32
->dnDevNode
;
1063 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
);
1064 *lpdwUser
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEOPENDESC
) + sizeof(DWORD
);
1066 ret
= MMDRV_MAP_OKMEM
;
1068 ret
= MMDRV_MAP_NOMEM
;
1074 LPWAVEHDR wh32
= (LPWAVEHDR
)*lpParam1
;
1076 LPVOID ptr
= SEGPTR_ALLOC(sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
) + wh32
->dwBufferLength
);
1079 *(LPWAVEHDR
*)ptr
= wh32
;
1080 wh16
= (LPWAVEHDR
)((LPSTR
)ptr
+ sizeof(LPWAVEHDR
));
1081 wh16
->lpData
= (LPSTR
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
);
1082 /* data will be copied on WODM_WRITE */
1083 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
1084 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
1085 wh16
->dwUser
= wh32
->dwUser
;
1086 wh16
->dwFlags
= wh32
->dwFlags
;
1087 wh16
->dwLoops
= wh32
->dwLoops
;
1088 /* FIXME: nothing on wh32->lpNext */
1089 /* could link the wh32->lpNext at this level for memory house keeping */
1090 wh32
->lpNext
= wh16
; /* for reuse in unprepare and write */
1091 TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n",
1092 (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
), (DWORD
)wh16
->lpData
,
1093 wh32
->dwBufferLength
, (DWORD
)wh32
->lpData
);
1094 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
);
1095 *lpParam2
= sizeof(WAVEHDR
);
1097 ret
= MMDRV_MAP_OKMEM
;
1099 ret
= MMDRV_MAP_NOMEM
;
1103 case WIDM_ADDBUFFER
:
1104 case WIDM_UNPREPARE
:
1106 LPWAVEHDR wh32
= (LPWAVEHDR
)(*lpParam1
);
1107 LPWAVEHDR wh16
= wh32
->lpNext
;
1108 LPSTR ptr
= (LPSTR
)wh16
- sizeof(LPWAVEHDR
);
1110 assert(*(LPWAVEHDR
*)ptr
== wh32
);
1112 TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n",
1113 (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
), (DWORD
)wh16
->lpData
,
1114 wh32
->dwBufferLength
, (DWORD
)wh32
->lpData
);
1116 if (wMsg
== WIDM_ADDBUFFER
)
1117 memcpy((LPSTR
)wh16
+ sizeof(WAVEHDR
), wh32
->lpData
, wh32
->dwBufferLength
);
1119 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
);
1120 *lpParam2
= sizeof(WAVEHDR
);
1121 /* dwBufferLength can be reduced between prepare & write */
1122 if (wh32
->dwBufferLength
< wh16
->dwBufferLength
) {
1123 ERR("Size of buffer has been increased (%ld, %ld)\n",
1124 wh32
->dwBufferLength
, wh16
->dwBufferLength
);
1125 return MMDRV_MAP_MSGERROR
;
1127 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
1128 ret
= MMDRV_MAP_OKMEM
;
1131 case WIDM_GETDEVCAPS
:
1133 LPWAVEINCAPSA wic32
= (LPWAVEINCAPSA
)*lpParam1
;
1134 LPSTR ptr
= SEGPTR_ALLOC(sizeof(LPWAVEINCAPSA
) + sizeof(WAVEINCAPS16
));
1137 *(LPWAVEINCAPSA
*)ptr
= wic32
;
1138 ret
= MMDRV_MAP_OKMEM
;
1140 ret
= MMDRV_MAP_NOMEM
;
1142 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEINCAPSA
);
1143 *lpParam2
= sizeof(WAVEINCAPS16
);
1148 LPMMTIME mmt32
= (LPMMTIME
)*lpParam1
;
1149 LPSTR ptr
= SEGPTR_ALLOC(sizeof(LPMMTIME
) + sizeof(MMTIME16
));
1150 LPMMTIME16 mmt16
= (LPMMTIME16
)(ptr
+ sizeof(LPMMTIME
));
1153 *(LPMMTIME
*)ptr
= mmt32
;
1154 mmt16
->wType
= mmt32
->wType
;
1155 ret
= MMDRV_MAP_OKMEM
;
1157 ret
= MMDRV_MAP_NOMEM
;
1159 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMMTIME
);
1160 *lpParam2
= sizeof(MMTIME16
);
1164 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1170 /**************************************************************************
1171 * MMDRV_WaveIn_UnMap32ATo16 [internal]
1173 static MMDRV_MapType
MMDRV_WaveIn_UnMap32ATo16(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
1175 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
1179 case WIDM_GETNUMDEVS
:
1188 LPWAVEOPENDESC16 wod16
= (LPWAVEOPENDESC16
)PTR_SEG_TO_LIN(*lpParam1
);
1189 LPSTR ptr
= (LPSTR
)wod16
- sizeof(LPWAVEOPENDESC
) - 2*sizeof(DWORD
);
1190 LPWAVEOPENDESC wod32
= *(LPWAVEOPENDESC
*)ptr
;
1192 wod32
->uMappedDeviceID
= wod16
->uMappedDeviceID
;
1193 **(DWORD
**)(ptr
+ sizeof(LPWAVEOPENDESC
)) = *(LPDWORD
)(ptr
+ sizeof(LPWAVEOPENDESC
) + sizeof(DWORD
));
1195 if (!SEGPTR_FREE(ptr
))
1196 FIXME("bad free line=%d\n", __LINE__
);
1202 case WIDM_ADDBUFFER
:
1204 case WIDM_UNPREPARE
:
1206 LPWAVEHDR wh16
= (LPWAVEHDR
)PTR_SEG_TO_LIN(*lpParam1
);
1207 LPSTR ptr
= (LPSTR
)wh16
- sizeof(LPWAVEHDR
);
1208 LPWAVEHDR wh32
= *(LPWAVEHDR
*)ptr
;
1210 assert(wh32
->lpNext
== wh16
);
1211 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
1212 wh32
->dwUser
= wh16
->dwUser
;
1213 wh32
->dwFlags
= wh16
->dwFlags
;
1214 wh32
->dwLoops
= wh16
->dwLoops
;
1216 if (wMsg
== WIDM_UNPREPARE
) {
1217 if (!SEGPTR_FREE(ptr
))
1218 FIXME("bad free line=%d\n", __LINE__
);
1224 case WIDM_GETDEVCAPS
:
1226 LPWAVEINCAPS16 wic16
= (LPWAVEINCAPS16
)PTR_SEG_TO_LIN(*lpParam1
);
1227 LPSTR ptr
= (LPSTR
)wic16
- sizeof(LPWAVEINCAPSA
);
1228 LPWAVEINCAPSA wic32
= *(LPWAVEINCAPSA
*)ptr
;
1230 wic32
->wMid
= wic16
->wMid
;
1231 wic32
->wPid
= wic16
->wPid
;
1232 wic32
->vDriverVersion
= wic16
->vDriverVersion
;
1233 strcpy(wic32
->szPname
, wic16
->szPname
);
1234 wic32
->dwFormats
= wic16
->dwFormats
;
1235 wic32
->wChannels
= wic16
->wChannels
;
1236 if (!SEGPTR_FREE(ptr
))
1237 FIXME("bad free line=%d\n", __LINE__
);
1243 LPMMTIME16 mmt16
= (LPMMTIME16
)PTR_SEG_TO_LIN(*lpParam1
);
1244 LPSTR ptr
= (LPSTR
)mmt16
- sizeof(LPMMTIME
);
1245 LPMMTIME mmt32
= *(LPMMTIME
*)ptr
;
1247 MMSYSTEM_MMTIME16to32(mmt32
, mmt16
);
1249 if (!SEGPTR_FREE(ptr
))
1250 FIXME("bad free line=%d\n", __LINE__
);
1256 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1262 /**************************************************************************
1263 * MMDRV_WaveIn_Callback [internal]
1265 static void CALLBACK
MMDRV_WaveIn_Callback(HDRVR hDev
, UINT uMsg
, DWORD dwInstance
, DWORD dwParam1
, DWORD dwParam2
)
1267 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
1272 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
1275 if (mld
->bFrom32
&& !MMDrvs
[mld
->mmdIndex
].bIs32
) {
1276 /* initial map is: 32 => 16 */
1277 LPWAVEHDR wh16
= (LPWAVEHDR
)PTR_SEG_TO_LIN(dwParam1
);
1278 LPWAVEHDR wh32
= *(LPWAVEHDR
*)((LPSTR
)wh16
- sizeof(LPWAVEHDR
));
1280 dwParam1
= (DWORD
)wh32
;
1281 wh32
->dwFlags
= wh16
->dwFlags
;
1282 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
1283 } else if (!mld
->bFrom32
&& MMDrvs
[mld
->mmdIndex
].bIs32
) {
1284 /* initial map is: 16 => 32 */
1285 LPWAVEHDR wh32
= (LPWAVEHDR
)(dwParam1
);
1286 LPWAVEHDR segwh16
= *(LPWAVEHDR
*)((LPSTR
)wh32
- sizeof(LPWAVEHDR
));
1287 LPWAVEHDR wh16
= PTR_SEG_TO_LIN(segwh16
);
1289 dwParam1
= (DWORD
)segwh16
;
1290 wh16
->dwFlags
= wh32
->dwFlags
;
1291 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
1293 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
1296 ERR("Unknown msg %u\n", uMsg
);
1299 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
1302 /* =================================
1303 * W A V E O U T M A P P E R S
1304 * ================================= */
1306 /**************************************************************************
1307 * MMDRV_WaveOut_Map16To32A [internal]
1309 static MMDRV_MapType
MMDRV_WaveOut_Map16To32A (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
1311 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
1315 case WODM_BREAKLOOP
:
1317 case WODM_GETNUMDEVS
:
1322 case WODM_SETPLAYBACKRATE
:
1323 case WODM_SETVOLUME
:
1328 case WODM_GETPLAYBACKRATE
:
1329 case WODM_GETVOLUME
:
1331 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
1334 case WODM_GETDEVCAPS
:
1336 LPWAVEOUTCAPSA woc32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEOUTCAPS16
) + sizeof(WAVEOUTCAPSA
));
1337 LPWAVEOUTCAPS16 woc16
= PTR_SEG_TO_LIN(*lpParam1
);
1340 *(LPWAVEOUTCAPS16
*)woc32
= woc16
;
1341 woc32
= (LPWAVEOUTCAPSA
)((LPSTR
)woc32
+ sizeof(LPWAVEOUTCAPS16
));
1342 *lpParam1
= (DWORD
)woc32
;
1343 *lpParam2
= sizeof(WAVEOUTCAPSA
);
1345 ret
= MMDRV_MAP_OKMEM
;
1347 ret
= MMDRV_MAP_NOMEM
;
1353 LPMMTIME mmt32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16
) + sizeof(MMTIME
));
1354 LPMMTIME16 mmt16
= PTR_SEG_TO_LIN(*lpParam1
);
1357 *(LPMMTIME16
*)mmt32
= mmt16
;
1358 mmt32
= (LPMMTIME
)((LPSTR
)mmt32
+ sizeof(LPMMTIME16
));
1360 mmt32
->wType
= mmt16
->wType
;
1361 *lpParam1
= (DWORD
)mmt32
;
1362 *lpParam2
= sizeof(MMTIME
);
1364 ret
= MMDRV_MAP_OKMEM
;
1366 ret
= MMDRV_MAP_NOMEM
;
1372 LPWAVEHDR wh32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
));
1373 LPWAVEHDR wh16
= PTR_SEG_TO_LIN(*lpParam1
);
1376 *(LPWAVEHDR
*)wh32
= (LPWAVEHDR
)*lpParam1
;
1377 wh32
= (LPWAVEHDR
)((LPSTR
)wh32
+ sizeof(LPWAVEHDR
));
1378 wh32
->lpData
= PTR_SEG_TO_LIN(wh16
->lpData
);
1379 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
1380 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
1381 wh32
->dwUser
= wh16
->dwUser
;
1382 wh32
->dwFlags
= wh16
->dwFlags
;
1383 wh32
->dwLoops
= wh16
->dwLoops
;
1384 /* FIXME: nothing on wh32->lpNext */
1385 /* could link the wh32->lpNext at this level for memory house keeping */
1386 wh16
->lpNext
= wh32
; /* for reuse in unprepare and write */
1387 *lpParam1
= (DWORD
)wh32
;
1388 *lpParam2
= sizeof(WAVEHDR
);
1390 ret
= MMDRV_MAP_OKMEM
;
1392 ret
= MMDRV_MAP_NOMEM
;
1396 case WODM_UNPREPARE
:
1399 LPWAVEHDR wh16
= PTR_SEG_TO_LIN(*lpParam1
);
1400 LPWAVEHDR wh32
= (LPWAVEHDR
)wh16
->lpNext
;
1402 *lpParam1
= (DWORD
)wh32
;
1403 *lpParam2
= sizeof(WAVEHDR
);
1404 /* dwBufferLength can be reduced between prepare & write */
1405 if (wh32
->dwBufferLength
< wh16
->dwBufferLength
) {
1406 ERR("Size of buffer has been increased (%ld, %ld)\n",
1407 wh32
->dwBufferLength
, wh16
->dwBufferLength
);
1408 return MMDRV_MAP_MSGERROR
;
1410 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
1411 ret
= MMDRV_MAP_OKMEM
;
1415 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1421 /**************************************************************************
1422 * MMDRV_WaveOut_UnMap16To32A [internal]
1424 static MMDRV_MapType
MMDRV_WaveOut_UnMap16To32A(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
1426 MMDRV_MapType ret
= MMDRV_MAP_MSGERROR
;
1430 case WODM_BREAKLOOP
:
1432 case WODM_GETNUMDEVS
:
1437 case WODM_SETPLAYBACKRATE
:
1438 case WODM_SETVOLUME
:
1443 case WODM_GETPLAYBACKRATE
:
1444 case WODM_GETVOLUME
:
1446 FIXME("Shouldn't be used: those 16 bit functions use the 32 bit interface\n");
1449 case WODM_GETDEVCAPS
:
1451 LPWAVEOUTCAPSA woc32
= (LPWAVEOUTCAPSA
)(*lpParam1
);
1452 LPWAVEOUTCAPS16 woc16
= *(LPWAVEOUTCAPS16
*)((LPSTR
)woc32
- sizeof(LPWAVEOUTCAPS16
));
1454 woc16
->wMid
= woc32
->wMid
;
1455 woc16
->wPid
= woc32
->wPid
;
1456 woc16
->vDriverVersion
= woc32
->vDriverVersion
;
1457 strcpy(woc16
->szPname
, woc32
->szPname
);
1458 woc16
->dwFormats
= woc32
->dwFormats
;
1459 woc16
->wChannels
= woc32
->wChannels
;
1460 woc16
->dwSupport
= woc32
->dwSupport
;
1461 HeapFree(GetProcessHeap(), 0, (LPSTR
)woc32
- sizeof(LPWAVEOUTCAPS16
));
1467 LPMMTIME mmt32
= (LPMMTIME
)(*lpParam1
);
1468 LPMMTIME16 mmt16
= *(LPMMTIME16
*)((LPSTR
)mmt32
- sizeof(LPMMTIME16
));
1470 MMSYSTEM_MMTIME32to16(mmt16
, mmt32
);
1471 HeapFree(GetProcessHeap(), 0, (LPSTR
)mmt32
- sizeof(LPMMTIME16
));
1476 case WODM_UNPREPARE
:
1479 LPWAVEHDR wh32
= (LPWAVEHDR
)(*lpParam1
);
1480 LPWAVEHDR wh16
= PTR_SEG_TO_LIN(*(LPWAVEHDR
*)((LPSTR
)wh32
- sizeof(LPWAVEHDR
)));
1482 assert(wh16
->lpNext
== wh32
);
1483 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
1484 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
1485 wh16
->dwUser
= wh32
->dwUser
;
1486 wh16
->dwFlags
= wh32
->dwFlags
;
1487 wh16
->dwLoops
= wh32
->dwLoops
;
1489 if (wMsg
== WODM_UNPREPARE
) {
1490 HeapFree(GetProcessHeap(), 0, (LPSTR
)wh32
- sizeof(LPWAVEHDR
));
1497 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1503 /**************************************************************************
1504 * MMDRV_WaveOut_Map32ATo16 [internal]
1506 static MMDRV_MapType
MMDRV_WaveOut_Map32ATo16 (UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
1512 case WODM_BREAKLOOP
:
1514 case WODM_GETNUMDEVS
:
1519 case WODM_SETPLAYBACKRATE
:
1520 case WODM_SETVOLUME
:
1524 case WODM_GETDEVCAPS
:
1526 LPWAVEOUTCAPSA woc32
= (LPWAVEOUTCAPSA
)*lpParam1
;
1527 LPSTR ptr
= SEGPTR_ALLOC(sizeof(LPWAVEOUTCAPSA
) + sizeof(WAVEOUTCAPS16
));
1530 *(LPWAVEOUTCAPSA
*)ptr
= woc32
;
1531 ret
= MMDRV_MAP_OKMEM
;
1533 ret
= MMDRV_MAP_NOMEM
;
1535 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEOUTCAPSA
);
1536 *lpParam2
= sizeof(WAVEOUTCAPS16
);
1540 FIXME("NIY: no conversion yet\n");
1541 ret
= MMDRV_MAP_MSGERROR
;
1543 case WODM_GETPLAYBACKRATE
:
1544 FIXME("NIY: no conversion yet\n");
1545 ret
= MMDRV_MAP_MSGERROR
;
1549 LPMMTIME mmt32
= (LPMMTIME
)*lpParam1
;
1550 LPSTR ptr
= SEGPTR_ALLOC(sizeof(LPMMTIME
) + sizeof(MMTIME16
));
1551 LPMMTIME16 mmt16
= (LPMMTIME16
)(ptr
+ sizeof(LPMMTIME
));
1554 *(LPMMTIME
*)ptr
= mmt32
;
1555 mmt16
->wType
= mmt32
->wType
;
1556 ret
= MMDRV_MAP_OKMEM
;
1558 ret
= MMDRV_MAP_NOMEM
;
1560 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPMMTIME
);
1561 *lpParam2
= sizeof(MMTIME16
);
1564 case WODM_GETVOLUME
:
1565 FIXME("NIY: no conversion yet\n");
1566 ret
= MMDRV_MAP_MSGERROR
;
1570 LPWAVEOPENDESC wod32
= (LPWAVEOPENDESC
)*lpParam1
;
1571 int sz
= sizeof(WAVEFORMATEX
);
1573 LPWAVEOPENDESC16 wod16
;
1575 /* allocated data are mapped as follows:
1576 LPWAVEOPENDESC ptr to orig lParam1
1577 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
1578 DWORD dwUser passed to driver
1579 WAVEOPENDESC16 wod16: openDesc passed to driver
1580 WAVEFORMATEX openDesc->lpFormat passed to driver
1581 xxx extra bytes to WAVEFORMATEX
1583 if (wod32
->lpFormat
->wFormatTag
!= WAVE_FORMAT_PCM
) {
1584 TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX
)wod32
->lpFormat
)->cbSize
, wod32
->lpFormat
->wFormatTag
);
1585 sz
+= ((LPWAVEFORMATEX
)wod32
->lpFormat
)->cbSize
;
1588 ptr
= SEGPTR_ALLOC(sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
) + sizeof(WAVEOPENDESC16
) + sz
);
1591 *(LPWAVEOPENDESC
*)ptr
= wod32
;
1592 *(LPDWORD
)(ptr
+ sizeof(LPWAVEOPENDESC
)) = *lpdwUser
;
1593 wod16
= (LPWAVEOPENDESC16
)((LPSTR
)ptr
+ sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
));
1595 wod16
->hWave
= wod32
->hWave
;
1596 wod16
->lpFormat
= (LPWAVEFORMATEX
)((DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
) + sizeof(WAVEOPENDESC16
));
1597 memcpy(wod16
+ 1, wod32
->lpFormat
, sz
);
1599 wod16
->dwCallback
= wod32
->dwCallback
;
1600 wod16
->dwInstance
= wod32
->dwInstance
;
1601 wod16
->uMappedDeviceID
= wod32
->uMappedDeviceID
;
1602 wod16
->dnDevNode
= wod32
->dnDevNode
;
1604 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
);
1605 *lpdwUser
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEOPENDESC
) + sizeof(DWORD
);
1607 ret
= MMDRV_MAP_OKMEM
;
1609 ret
= MMDRV_MAP_NOMEM
;
1615 LPWAVEHDR wh32
= (LPWAVEHDR
)*lpParam1
;
1617 LPVOID ptr
= SEGPTR_ALLOC(sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
) + wh32
->dwBufferLength
);
1620 *(LPWAVEHDR
*)ptr
= wh32
;
1621 wh16
= (LPWAVEHDR
)((LPSTR
)ptr
+ sizeof(LPWAVEHDR
));
1622 wh16
->lpData
= (LPSTR
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
);
1623 /* data will be copied on WODM_WRITE */
1624 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
1625 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
1626 wh16
->dwUser
= wh32
->dwUser
;
1627 wh16
->dwFlags
= wh32
->dwFlags
;
1628 wh16
->dwLoops
= wh32
->dwLoops
;
1629 /* FIXME: nothing on wh32->lpNext */
1630 /* could link the wh32->lpNext at this level for memory house keeping */
1631 wh32
->lpNext
= wh16
; /* for reuse in unprepare and write */
1632 TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n",
1633 (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
), (DWORD
)wh16
->lpData
,
1634 wh32
->dwBufferLength
, (DWORD
)wh32
->lpData
);
1635 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
);
1636 *lpParam2
= sizeof(WAVEHDR
);
1638 ret
= MMDRV_MAP_OKMEM
;
1640 ret
= MMDRV_MAP_NOMEM
;
1644 case WODM_UNPREPARE
:
1647 LPWAVEHDR wh32
= (LPWAVEHDR
)(*lpParam1
);
1648 LPWAVEHDR wh16
= wh32
->lpNext
;
1649 LPSTR ptr
= (LPSTR
)wh16
- sizeof(LPWAVEHDR
);
1651 assert(*(LPWAVEHDR
*)ptr
== wh32
);
1653 TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n",
1654 (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
), (DWORD
)wh16
->lpData
,
1655 wh32
->dwBufferLength
, (DWORD
)wh32
->lpData
);
1657 if (wMsg
== WODM_WRITE
)
1658 memcpy((LPSTR
)wh16
+ sizeof(WAVEHDR
), wh32
->lpData
, wh32
->dwBufferLength
);
1660 *lpParam1
= (DWORD
)SEGPTR_GET(ptr
) + sizeof(LPWAVEHDR
);
1661 *lpParam2
= sizeof(WAVEHDR
);
1662 /* dwBufferLength can be reduced between prepare & write */
1663 if (wh16
->dwBufferLength
< wh32
->dwBufferLength
) {
1664 ERR("Size of buffer has been increased (%ld, %ld)\n",
1665 wh16
->dwBufferLength
, wh32
->dwBufferLength
);
1666 return MMDRV_MAP_MSGERROR
;
1668 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
1669 ret
= MMDRV_MAP_OKMEM
;
1673 FIXME("NIY: no conversion yet\n");
1674 ret
= MMDRV_MAP_MSGERROR
;
1680 /**************************************************************************
1681 * MMDRV_WaveOut_UnMap32ATo16 [internal]
1683 static MMDRV_MapType
MMDRV_WaveOut_UnMap32ATo16(UINT wMsg
, LPDWORD lpdwUser
, LPDWORD lpParam1
, LPDWORD lpParam2
)
1689 case WODM_BREAKLOOP
:
1691 case WODM_GETNUMDEVS
:
1696 case WODM_SETPLAYBACKRATE
:
1697 case WODM_SETVOLUME
:
1701 case WODM_GETDEVCAPS
:
1703 LPWAVEOUTCAPS16 woc16
= (LPWAVEOUTCAPS16
)PTR_SEG_TO_LIN(*lpParam1
);
1704 LPSTR ptr
= (LPSTR
)woc16
- sizeof(LPWAVEOUTCAPSA
);
1705 LPWAVEOUTCAPSA woc32
= *(LPWAVEOUTCAPSA
*)ptr
;
1707 woc32
->wMid
= woc16
->wMid
;
1708 woc32
->wPid
= woc16
->wPid
;
1709 woc32
->vDriverVersion
= woc16
->vDriverVersion
;
1710 strcpy(woc32
->szPname
, woc16
->szPname
);
1711 woc32
->dwFormats
= woc16
->dwFormats
;
1712 woc32
->wChannels
= woc16
->wChannels
;
1713 woc32
->dwSupport
= woc16
->dwSupport
;
1714 if (!SEGPTR_FREE(ptr
))
1715 FIXME("bad free line=%d\n", __LINE__
);
1720 FIXME("NIY: no conversion yet\n");
1721 ret
= MMDRV_MAP_MSGERROR
;
1723 case WODM_GETPLAYBACKRATE
:
1724 FIXME("NIY: no conversion yet\n");
1725 ret
= MMDRV_MAP_MSGERROR
;
1729 LPMMTIME16 mmt16
= (LPMMTIME16
)PTR_SEG_TO_LIN(*lpParam1
);
1730 LPSTR ptr
= (LPSTR
)mmt16
- sizeof(LPMMTIME
);
1731 LPMMTIME mmt32
= *(LPMMTIME
*)ptr
;
1733 MMSYSTEM_MMTIME16to32(mmt32
, mmt16
);
1735 if (!SEGPTR_FREE(ptr
))
1736 FIXME("bad free line=%d\n", __LINE__
);
1743 LPWAVEOPENDESC16 wod16
= (LPWAVEOPENDESC16
)PTR_SEG_TO_LIN(*lpParam1
);
1744 LPSTR ptr
= (LPSTR
)wod16
- sizeof(LPWAVEOPENDESC
) - 2*sizeof(DWORD
);
1745 LPWAVEOPENDESC wod32
= *(LPWAVEOPENDESC
*)ptr
;
1747 wod32
->uMappedDeviceID
= wod16
->uMappedDeviceID
;
1748 **(DWORD
**)(ptr
+ sizeof(LPWAVEOPENDESC
)) = *(LPDWORD
)(ptr
+ sizeof(LPWAVEOPENDESC
) + sizeof(DWORD
));
1750 if (!SEGPTR_FREE(ptr
))
1751 FIXME("bad free line=%d\n", __LINE__
);
1757 case WODM_UNPREPARE
:
1760 LPWAVEHDR wh16
= (LPWAVEHDR
)PTR_SEG_TO_LIN(*lpParam1
);
1761 LPSTR ptr
= (LPSTR
)wh16
- sizeof(LPWAVEHDR
);
1762 LPWAVEHDR wh32
= *(LPWAVEHDR
*)ptr
;
1764 assert(wh32
->lpNext
== wh16
);
1765 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
1766 wh32
->dwUser
= wh16
->dwUser
;
1767 wh32
->dwFlags
= wh16
->dwFlags
;
1768 wh32
->dwLoops
= wh16
->dwLoops
;
1770 if (wMsg
== WODM_UNPREPARE
) {
1771 if (!SEGPTR_FREE(ptr
))
1772 FIXME("bad free line=%d\n", __LINE__
);
1778 case WODM_GETVOLUME
:
1779 FIXME("NIY: no conversion yet\n");
1780 ret
= MMDRV_MAP_MSGERROR
;
1783 FIXME("NIY: no conversion yet\n");
1784 ret
= MMDRV_MAP_MSGERROR
;
1790 /**************************************************************************
1791 * MMDRV_WaveOut_Callback [internal]
1793 static void CALLBACK
MMDRV_WaveOut_Callback(HDRVR hDev
, UINT uMsg
, DWORD dwInstance
, DWORD dwParam1
, DWORD dwParam2
)
1795 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
1800 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
1803 if (mld
->bFrom32
&& !MMDrvs
[mld
->mmdIndex
].bIs32
) {
1804 /* initial map is: 32 => 16 */
1805 LPWAVEHDR wh16
= (LPWAVEHDR
)PTR_SEG_TO_LIN(dwParam1
);
1806 LPWAVEHDR wh32
= *(LPWAVEHDR
*)((LPSTR
)wh16
- sizeof(LPWAVEHDR
));
1808 dwParam1
= (DWORD
)wh32
;
1809 wh32
->dwFlags
= wh16
->dwFlags
;
1810 } else if (!mld
->bFrom32
&& MMDrvs
[mld
->mmdIndex
].bIs32
) {
1811 /* initial map is: 16 => 32 */
1812 LPWAVEHDR wh32
= (LPWAVEHDR
)(dwParam1
);
1813 LPWAVEHDR segwh16
= *(LPWAVEHDR
*)((LPSTR
)wh32
- sizeof(LPWAVEHDR
));
1814 LPWAVEHDR wh16
= PTR_SEG_TO_LIN(segwh16
);
1816 dwParam1
= (DWORD
)segwh16
;
1817 wh16
->dwFlags
= wh32
->dwFlags
;
1819 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
1822 ERR("Unknown msg %u\n", uMsg
);
1825 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
1828 #define A(_x,_y) {#_y, _x, \
1829 MMDRV_##_y##_Map16To32A, MMDRV_##_y##_UnMap16To32A, \
1830 MMDRV_##_y##_Map32ATo16, MMDRV_##_y##_UnMap32ATo16, \
1831 MMDRV_##_y##_Callback, 0, NULL, -1}
1833 /* Note: the indices of this array must match the definitions
1834 * of the MMDRV_???? manifest constants
1836 static WINE_LLTYPE llTypes
[MMDRV_MAX
] = {
1846 /**************************************************************************
1847 * MMDRV_GetNum [internal]
1849 UINT
MMDRV_GetNum(UINT type
)
1851 assert(type
< MMDRV_MAX
);
1852 return llTypes
[type
].wMaxId
;
1855 /**************************************************************************
1856 * WINE_Message [internal]
1858 DWORD
MMDRV_Message(LPWINE_MLD mld
, WORD wMsg
, DWORD dwParam1
,
1859 DWORD dwParam2
, BOOL bFrom32
)
1861 LPWINE_MM_DRIVER lpDrv
;
1863 WINE_MM_DRIVER_PART
* part
;
1864 WINE_LLTYPE
* llType
= &llTypes
[mld
->type
];
1868 TRACE("(%s %u %u 0x%08lx 0x%08lx 0x%08lx %c)!\n",
1869 llTypes
[mld
->type
].name
, mld
->uDeviceID
, wMsg
,
1870 mld
->dwDriverInstance
, dwParam1
, dwParam2
, bFrom32
?'Y':'N');
1872 if (mld
->uDeviceID
== (UINT16
)-1) {
1873 if (!llType
->bSupportMapper
) {
1874 WARN("uDev=-1 requested on non-mappable ll type %s\n",
1875 llTypes
[mld
->type
].name
);
1876 return MMSYSERR_BADDEVICEID
;
1880 if (mld
->uDeviceID
>= llType
->wMaxId
) {
1881 WARN("uDev(%u) requested >= max (%d)\n", mld
->uDeviceID
, llType
->wMaxId
);
1882 return MMSYSERR_BADDEVICEID
;
1884 devID
= mld
->uDeviceID
;
1887 lpDrv
= &MMDrvs
[mld
->mmdIndex
];
1888 part
= &lpDrv
->parts
[mld
->type
];
1891 /* some sanity checks */
1892 if (!(part
->nIDMin
<= devID
))
1893 ERR("!(part->nIDMin(%d) <= devID(%d))\n", part
->nIDMin
, devID
);
1894 if (!(devID
< part
->nIDMax
))
1895 ERR("!(devID(%d) < part->nIDMax(%d))\n", devID
, part
->nIDMax
);
1899 assert(part
->u
.fnMessage32
);
1902 TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n",
1903 mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
1904 ret
= part
->u
.fnMessage32(mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
1905 TRACE("=> %lu\n", ret
);
1907 map
= llType
->Map16To32A(wMsg
, &mld
->dwDriverInstance
, &dwParam1
, &dwParam2
);
1909 case MMDRV_MAP_NOMEM
:
1910 ret
= MMSYSERR_NOMEM
;
1912 case MMDRV_MAP_MSGERROR
:
1913 FIXME("NIY: no conversion yet 16->32 (%u)\n", wMsg
);
1914 ret
= MMSYSERR_ERROR
;
1917 case MMDRV_MAP_OKMEM
:
1918 TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n",
1919 mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
1920 ret
= part
->u
.fnMessage32(mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
,
1921 dwParam1
, dwParam2
);
1922 TRACE("=> %lu\n", ret
);
1923 if (map
== MMDRV_MAP_OKMEM
)
1924 llType
->UnMap16To32A(wMsg
, &mld
->dwDriverInstance
, &dwParam1
, &dwParam2
);
1927 case MMDRV_MAP_PASS
:
1928 FIXME("NIY: pass used ?\n");
1929 ret
= MMSYSERR_NOTSUPPORTED
;
1934 assert(part
->u
.fnMessage16
);
1937 map
= llType
->Map32ATo16(wMsg
, &mld
->dwDriverInstance
, &dwParam1
, &dwParam2
);
1939 case MMDRV_MAP_NOMEM
:
1940 ret
= MMSYSERR_NOMEM
;
1942 case MMDRV_MAP_MSGERROR
:
1943 FIXME("NIY: no conversion yet 32->16 (%u)\n", wMsg
);
1944 ret
= MMSYSERR_ERROR
;
1947 case MMDRV_MAP_OKMEM
:
1948 TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n",
1949 mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
1950 ret
= MMDRV_CallTo16_word_wwlll((FARPROC16
)part
->u
.fnMessage16
, mld
->uDeviceID
,
1951 wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
1952 TRACE("=> %lu\n", ret
);
1953 if (map
== MMDRV_MAP_OKMEM
)
1954 llType
->UnMap32ATo16(wMsg
, &mld
->dwDriverInstance
, &dwParam1
, &dwParam2
);
1957 case MMDRV_MAP_PASS
:
1958 FIXME("NIY: pass used ?\n");
1959 ret
= MMSYSERR_NOTSUPPORTED
;
1963 TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n",
1964 mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
1965 ret
= MMDRV_CallTo16_word_wwlll((FARPROC16
)part
->u
.fnMessage16
, mld
->uDeviceID
,
1966 wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
1967 TRACE("=> %lu\n", ret
);
1973 /**************************************************************************
1974 * MMDRV_Alloc [internal]
1976 LPWINE_MLD
MMDRV_Alloc(UINT size
, UINT type
, LPHANDLE hndl
, DWORD
* dwFlags
,
1977 DWORD
* dwCallback
, DWORD
* dwInstance
, BOOL bFrom32
)
1981 if ((*hndl
= USER_HEAP_ALLOC(size
)) == 0)
1984 mld
= (LPWINE_MLD
) USER_HEAP_LIN_ADDR(*hndl
);
1985 if (!mld
) return NULL
;
1987 if ((UINT
)*hndl
< MMDRV_GetNum(type
) || HIWORD(*hndl
) != 0) {
1988 /* FIXME: those conditions must be fulfilled so that:
1989 * - we can distinguish between device IDs and handles
1990 * - we can use handles as 16 or 32 bit entities
1992 ERR("Shouldn't happen. Bad allocation scheme\n");
1995 mld
->bFrom32
= bFrom32
;
1996 mld
->dwFlags
= HIWORD(*dwFlags
);
1997 mld
->dwCallback
= *dwCallback
;
1998 mld
->dwClientInstance
= *dwInstance
;
2000 *dwFlags
= LOWORD(*dwFlags
) | CALLBACK_FUNCTION
;
2001 *dwCallback
= (DWORD
)llTypes
[type
].Callback
;
2002 *dwInstance
= (DWORD
)mld
; /* FIXME: wouldn't some 16 bit drivers only use the loword ? */
2007 /**************************************************************************
2008 * MMDRV_Free [internal]
2010 void MMDRV_Free(HANDLE hndl
, LPWINE_MLD mld
)
2012 USER_HEAP_FREE(hndl
);
2015 /**************************************************************************
2016 * MMDRV_Open [internal]
2018 DWORD
MMDRV_Open(LPWINE_MLD mld
, UINT wMsg
, DWORD dwParam1
, DWORD dwFlags
)
2020 DWORD dwRet
= MMSYSERR_BADDEVICEID
;
2022 WINE_LLTYPE
* llType
= &llTypes
[mld
->type
];
2024 mld
->dwDriverInstance
= (DWORD
)&dwInstance
;
2026 if (mld
->uDeviceID
== (UINT
)-1 || mld
->uDeviceID
== (UINT16
)-1) {
2027 TRACE("MAPPER mode requested !\n");
2028 /* check if mapper is supported by type */
2029 if (llType
->bSupportMapper
) {
2030 if (llType
->nMapper
== -1) {
2031 /* no driver for mapper has been loaded, try a dumb implementation */
2032 TRACE("No mapper loaded, doing it by hand\n");
2033 for (mld
->uDeviceID
= 0; mld
->uDeviceID
< llType
->wMaxId
; mld
->uDeviceID
++) {
2034 if ((dwRet
= MMDRV_Open(mld
, wMsg
, dwParam1
, dwFlags
)) == MMSYSERR_NOERROR
) {
2035 /* to share this function epilog */
2036 dwInstance
= mld
->dwDriverInstance
;
2041 mld
->uDeviceID
= (UINT16
)-1;
2042 mld
->mmdIndex
= llType
->lpMlds
[-1].mmdIndex
;
2043 TRACE("Setting mmdIndex to %u\n", mld
->mmdIndex
);
2044 dwRet
= MMDRV_Message(mld
, wMsg
, dwParam1
, dwFlags
, TRUE
);
2048 if (mld
->uDeviceID
< llType
->wMaxId
) {
2049 mld
->mmdIndex
= llType
->lpMlds
[mld
->uDeviceID
].mmdIndex
;
2050 TRACE("Setting mmdIndex to %u\n", mld
->mmdIndex
);
2051 dwRet
= MMDRV_Message(mld
, wMsg
, dwParam1
, dwFlags
, TRUE
);
2054 if (dwRet
== MMSYSERR_NOERROR
)
2055 mld
->dwDriverInstance
= dwInstance
;
2059 /**************************************************************************
2060 * MMDRV_Close [internal]
2062 DWORD
MMDRV_Close(LPWINE_MLD mld
, UINT wMsg
)
2064 return MMDRV_Message(mld
, wMsg
, 0L, 0L, TRUE
);
2067 /**************************************************************************
2068 * MMDRV_GetByID [internal]
2070 LPWINE_MLD
MMDRV_GetByID(UINT uDevID
, UINT type
)
2072 if (uDevID
< llTypes
[type
].wMaxId
)
2073 return &llTypes
[type
].lpMlds
[uDevID
];
2074 if ((uDevID
== (UINT16
)-1 || uDevID
== (UINT
)-1) && llTypes
[type
].nMapper
!= -1)
2075 return &llTypes
[type
].lpMlds
[-1];
2079 /**************************************************************************
2080 * MMDRV_Get [internal]
2082 LPWINE_MLD
MMDRV_Get(HANDLE hndl
, UINT type
, BOOL bCanBeID
)
2084 LPWINE_MLD mld
= NULL
;
2086 assert(type
< MMDRV_MAX
);
2088 if ((UINT
)hndl
>= llTypes
[type
].wMaxId
) {
2089 mld
= (LPWINE_MLD
)USER_HEAP_LIN_ADDR(hndl
);
2091 if (!IsBadWritePtr(mld
, sizeof(*mld
)) && mld
->type
!= type
) mld
= NULL
;
2093 if (mld
== NULL
&& bCanBeID
) {
2094 mld
= MMDRV_GetByID((UINT
)hndl
, type
);
2099 /**************************************************************************
2100 * MMDRV_GetRelated [internal]
2102 LPWINE_MLD
MMDRV_GetRelated(HANDLE hndl
, UINT srcType
,
2103 BOOL bSrcCanBeID
, UINT dstType
)
2107 if ((mld
= MMDRV_Get(hndl
, srcType
, bSrcCanBeID
)) != NULL
) {
2108 WINE_MM_DRIVER_PART
* part
= &MMDrvs
[mld
->mmdIndex
].parts
[dstType
];
2109 if (part
->nIDMin
< part
->nIDMax
)
2110 return MMDRV_GetByID(part
->nIDMin
, dstType
);
2115 /**************************************************************************
2116 * MMDRV_PhysicalFeatures [internal]
2118 UINT
MMDRV_PhysicalFeatures(LPWINE_MLD mld
, UINT uMsg
, DWORD dwParam1
,
2121 WINE_MM_DRIVER
* lpDrv
= &MMDrvs
[mld
->mmdIndex
];
2123 TRACE("(%p, %04x, %08lx, %08lx)\n", mld
, uMsg
, dwParam1
, dwParam2
);
2125 /* all those function calls are undocumented */
2127 case 0x801: /* DRV_QUERYDRVENTRY */
2128 lstrcpynA((LPSTR
)dwParam1
, lpDrv
->name
, LOWORD(dwParam2
));
2130 case 0x802: /* DRV_QUERYDEVNODE */
2131 *(LPDWORD
)dwParam1
= 0L; /* should be DevNode */
2133 case 0x803: /* DRV_QUERYNAME */
2134 WARN("NIY 0x803\n");
2136 case 0x804: /* DRV_QUERYDRIVERIDS */
2137 WARN("NIY call VxD\n");
2138 /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts
2139 * dwParam1 is buffer and dwParam2 is sizeof buffer
2140 * I don't know where the result is stored though
2143 case 0x805: /* DRV_QUERYMAPPABLE */
2144 return (lpDrv
->bIsMapper
) ? 2 : 0;
2146 case 0x810: /* Wine-specific: Retrieve DirectSound interface */
2147 return MMDRV_Message(mld
, uMsg
, dwParam1
, dwParam2
, TRUE
);
2150 WARN("Unknown call %04x\n", uMsg
);
2151 return MMSYSERR_INVALPARAM
;
2156 /**************************************************************************
2157 * MMDRV_InitPerType [internal]
2159 static BOOL
MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv
, UINT num
,
2160 UINT type
, UINT wMsg
)
2162 WINE_MM_DRIVER_PART
* part
= &lpDrv
->parts
[type
];
2167 part
->nIDMin
= part
->nIDMax
= 0;
2169 /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */
2170 /* the DRVM_ENABLE is only required when the PnP node is non zero */
2172 if (lpDrv
->bIs32
&& part
->u
.fnMessage32
) {
2173 ret
= part
->u
.fnMessage32(0, DRVM_INIT
, 0L, 0L, 0L);
2174 TRACE("DRVM_INIT => %08lx\n", ret
);
2176 ret
= part
->u
.fnMessage32(0, DRVM_ENABLE
, 0L, 0L, 0L);
2177 TRACE("DRVM_ENABLE => %08lx\n", ret
);
2179 count
= part
->u
.fnMessage32(0, wMsg
, 0L, 0L, 0L);
2182 if (!lpDrv
->bIs32
&& part
->u
.fnMessage16
) {
2183 ret
= MMDRV_CallTo16_word_wwlll((FARPROC16
)part
->u
.fnMessage16
,
2184 0, DRVM_INIT
, 0L, 0L, 0L);
2185 TRACE("DRVM_INIT => %08lx\n", ret
);
2187 ret
= MMDRV_CallTo16_word_wwlll((FARPROC16
)part
->u
.fnMessage16
,
2188 0, DRVM_ENABLE
, 0L, 0L, 0L);
2189 TRACE("DRVM_ENABLE => %08lx\n", ret
);
2191 count
= MMDRV_CallTo16_word_wwlll((FARPROC16
)part
->u
.fnMessage16
,
2192 0, wMsg
, 0L, 0L, 0L);
2195 TRACE("Got %u dev for (%s:%s)\n", count
, lpDrv
->name
, llTypes
[type
].name
);
2199 /* got some drivers */
2200 if (lpDrv
->bIsMapper
) {
2201 if (llTypes
[type
].nMapper
!= -1)
2202 ERR("Two mappers for type %s (%d, %s)\n",
2203 llTypes
[type
].name
, llTypes
[type
].nMapper
, lpDrv
->name
);
2205 ERR("Strange: mapper with %d > 1 devices\n", count
);
2206 llTypes
[type
].nMapper
= num
;
2208 part
->nIDMin
= llTypes
[type
].wMaxId
;
2209 llTypes
[type
].wMaxId
+= count
;
2210 part
->nIDMax
= llTypes
[type
].wMaxId
;
2212 TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n",
2213 part
->nIDMin
, part
->nIDMax
, llTypes
[type
].wMaxId
,
2214 lpDrv
->name
, llTypes
[type
].name
);
2215 /* realloc translation table */
2216 llTypes
[type
].lpMlds
= (LPWINE_MLD
)
2217 HeapReAlloc(GetProcessHeap(), 0, (llTypes
[type
].lpMlds
) ? llTypes
[type
].lpMlds
- 1 : NULL
,
2218 sizeof(WINE_MLD
) * (llTypes
[type
].wMaxId
+ 1)) + 1;
2219 /* re-build the translation table */
2220 if (llTypes
[type
].nMapper
!= -1) {
2221 TRACE("%s:Trans[%d] -> %s\n", llTypes
[type
].name
, -1, MMDrvs
[llTypes
[type
].nMapper
].name
);
2222 llTypes
[type
].lpMlds
[-1].uDeviceID
= (UINT16
)-1;
2223 llTypes
[type
].lpMlds
[-1].type
= type
;
2224 llTypes
[type
].lpMlds
[-1].mmdIndex
= llTypes
[type
].nMapper
;
2225 llTypes
[type
].lpMlds
[-1].dwDriverInstance
= 0;
2227 for (i
= k
= 0; i
<= num
; i
++) {
2228 while (MMDrvs
[i
].parts
[type
].nIDMin
<= k
&& k
< MMDrvs
[i
].parts
[type
].nIDMax
) {
2229 TRACE("%s:Trans[%d] -> %s\n", llTypes
[type
].name
, k
, MMDrvs
[i
].name
);
2230 llTypes
[type
].lpMlds
[k
].uDeviceID
= k
;
2231 llTypes
[type
].lpMlds
[k
].type
= type
;
2232 llTypes
[type
].lpMlds
[k
].mmdIndex
= i
;
2233 llTypes
[type
].lpMlds
[k
].dwDriverInstance
= 0;
2240 /**************************************************************************
2241 * MMDRV_Install [internal]
2243 static BOOL
MMDRV_Install(LPCSTR name
, int num
, BOOL bIsMapper
)
2248 LPWINE_MM_DRIVER lpDrv
= &MMDrvs
[num
];
2250 TRACE("('%s');\n", name
);
2252 memset(lpDrv
, 0, sizeof(*lpDrv
));
2254 /* First load driver */
2255 if ((lpDrv
->hDrvr
= OpenDriverA(name
, 0, 0)) == 0) {
2256 WARN("Couldn't open driver '%s'\n", name
);
2260 /* Then look for xxxMessage functions */
2261 #define AA(_w,_x,_y,_z) \
2262 func = (WINEMM_msgFunc##_y) _z (hModule, #_x); \
2264 { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \
2265 TRACE("Got %d bit func '%s'\n", _y, #_x); }
2267 if ((GetDriverFlags(lpDrv
->hDrvr
) & (WINE_GDF_EXIST
|WINE_GDF_16BIT
)) == WINE_GDF_EXIST
) {
2268 WINEMM_msgFunc32 func
;
2270 lpDrv
->bIs32
= TRUE
;
2271 if ((hModule
= GetDriverModuleHandle(lpDrv
->hDrvr
))) {
2272 #define A(_x,_y) AA(_x,_y,32,GetProcAddress)
2273 A(MMDRV_AUX
, auxMessage
);
2274 A(MMDRV_MIXER
, mixMessage
);
2275 A(MMDRV_MIDIIN
, midMessage
);
2276 A(MMDRV_MIDIOUT
, modMessage
);
2277 A(MMDRV_WAVEIN
, widMessage
);
2278 A(MMDRV_WAVEOUT
, wodMessage
);
2282 WINEMM_msgFunc16 func
;
2285 * DESCRIPTION 'wave,aux,mixer:Creative Labs Sound Blaster 16 Driver'
2286 * The beginning of the module description indicates the driver supports
2287 * waveform, auxiliary, and mixer devices. Use one of the following
2288 * device-type names, followed by a colon (:) to indicate the type of
2289 * device your driver supports. If the driver supports more than one
2290 * type of device, separate each device-type name with a comma (,).
2292 * wave for waveform audio devices
2293 * wavemapper for wave mappers
2294 * midi for MIDI audio devices
2295 * midimapper for midi mappers
2296 * aux for auxiliary audio devices
2297 * mixer for mixer devices
2300 lpDrv
->bIs32
= FALSE
;
2301 if ((hModule
= GetDriverModuleHandle16(lpDrv
->hDrvr
))) {
2302 #define A(_x,_y) AA(_x,_y,16,WIN32_GetProcAddress16)
2303 A(MMDRV_AUX
, auxMessage
);
2304 A(MMDRV_MIXER
, mixMessage
);
2305 A(MMDRV_MIDIIN
, midMessage
);
2306 A(MMDRV_MIDIOUT
, modMessage
);
2307 A(MMDRV_WAVEIN
, widMessage
);
2308 A(MMDRV_WAVEOUT
, wodMessage
);
2314 if (TRACE_ON(mmsys
)) {
2315 if ((lpDrv
->bIs32
) ? MMDRV_GetDescription32(name
, buffer
, sizeof(buffer
)) :
2316 MMDRV_GetDescription16(name
, buffer
, sizeof(buffer
)))
2317 TRACE("%s => %s\n", name
, buffer
);
2319 TRACE("%s => No description\n", name
);
2323 CloseDriver(lpDrv
->hDrvr
, 0, 0);
2324 WARN("No message functions found\n");
2328 /* FIXME: being a mapper or not should be known by another way */
2329 /* it's known for NE drvs (the description is of the form '*mapper: *'
2330 * I don't have any clue for PE drvs
2331 * on Win 9x, the value is gotten from the key mappable under
2332 * HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\MediaResources\
2334 lpDrv
->bIsMapper
= bIsMapper
;
2335 lpDrv
->name
= HEAP_strdupA(GetProcessHeap(), 0, name
);
2337 /* Finish init and get the count of the devices */
2338 MMDRV_InitPerType(lpDrv
, num
, MMDRV_AUX
, AUXDM_GETNUMDEVS
);
2339 MMDRV_InitPerType(lpDrv
, num
, MMDRV_MIXER
, MXDM_GETNUMDEVS
);
2340 MMDRV_InitPerType(lpDrv
, num
, MMDRV_MIDIIN
, MIDM_GETNUMDEVS
);
2341 MMDRV_InitPerType(lpDrv
, num
, MMDRV_MIDIOUT
, MODM_GETNUMDEVS
);
2342 MMDRV_InitPerType(lpDrv
, num
, MMDRV_WAVEIN
, WIDM_GETNUMDEVS
);
2343 MMDRV_InitPerType(lpDrv
, num
, MMDRV_WAVEOUT
, WODM_GETNUMDEVS
);
2344 /* FIXME: if all those func calls return FALSE, then the driver must be unloaded */
2348 /**************************************************************************
2349 * MMDRV_Init [internal]
2351 BOOL
MMDRV_Init(void)
2355 /* FIXME: this should be moved to init files;
2356 * - either .winerc/wine.conf
2357 * - or made of registry keys
2358 * this is a temporary hack, shall be removed anytime now
2360 /* first load hardware drivers */
2361 if (MMDRV_Install("wineoss.drv", num
, FALSE
)) num
++;
2363 /* finish with mappers */
2364 if (MMDRV_Install("msacm.drv", num
, TRUE
)) num
++;
2365 if (MMDRV_Install("midimap.drv", num
, TRUE
)) num
++;
2367 /* be sure that size of MMDrvs matches the max number of loadable drivers !!
2368 * if not just increase size of MMDrvs */
2369 assert(num
<= sizeof(MMDrvs
)/sizeof(MMDrvs
[0]));