2 * MMSYSTEM MCI and low level mapping functions
4 * Copyright 1999 Eric Pouech
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/winbase16.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(winmm
);
37 /**************************************************************************
38 * MMDRV_Callback [internal]
40 static void MMDRV_Callback(LPWINE_MLD mld
, HDRVR hDev
, UINT uMsg
, DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
42 TRACE("CB (*%08lx)(%p %08x %08lx %08lx %08lx\n",
43 mld
->dwCallback
, hDev
, uMsg
, mld
->dwClientInstance
, dwParam1
, dwParam2
);
45 if (!mld
->bFrom32
&& (mld
->dwFlags
& DCB_TYPEMASK
) == DCB_FUNCTION
)
48 /* 16 bit func, call it */
49 TRACE("Function (16 bit) !\n");
51 args
[7] = HDRVR_16(hDev
);
53 args
[5] = HIWORD(mld
->dwClientInstance
);
54 args
[4] = LOWORD(mld
->dwClientInstance
);
55 args
[3] = HIWORD(dwParam1
);
56 args
[2] = LOWORD(dwParam1
);
57 args
[1] = HIWORD(dwParam2
);
58 args
[0] = LOWORD(dwParam2
);
59 WOWCallback16Ex( mld
->dwCallback
, WCB16_PASCAL
, sizeof(args
), args
, NULL
);
61 DriverCallback(mld
->dwCallback
, mld
->dwFlags
, hDev
, uMsg
,
62 mld
->dwClientInstance
, dwParam1
, dwParam2
);
66 /* =================================
68 * ================================= */
70 /**************************************************************************
71 * MMDRV_Aux_Map16To32W [internal]
73 static WINMM_MapType
MMDRV_Aux_Map16To32W (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
75 return WINMM_MAP_MSGERROR
;
78 /**************************************************************************
79 * MMDRV_Aux_UnMap16To32W [internal]
81 static WINMM_MapType
MMDRV_Aux_UnMap16To32W(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
83 return WINMM_MAP_MSGERROR
;
86 /**************************************************************************
87 * MMDRV_Aux_Map32WTo16 [internal]
89 static WINMM_MapType
MMDRV_Aux_Map32WTo16 (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
91 return WINMM_MAP_MSGERROR
;
94 /**************************************************************************
95 * MMDRV_Aux_UnMap32WTo16 [internal]
97 static WINMM_MapType
MMDRV_Aux_UnMap32WTo16(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
100 case AUXDM_GETDEVCAPS
:
101 lpCaps
->wMid
= ac16
.wMid
;
102 lpCaps
->wPid
= ac16
.wPid
;
103 lpCaps
->vDriverVersion
= ac16
.vDriverVersion
;
104 strcpy(lpCaps
->szPname
, ac16
.szPname
);
105 lpCaps
->wTechnology
= ac16
.wTechnology
;
106 lpCaps
->dwSupport
= ac16
.dwSupport
;
108 return WINMM_MAP_MSGERROR
;
111 /**************************************************************************
112 * MMDRV_Aux_Callback [internal]
114 static void CALLBACK
MMDRV_Aux_Callback(HDRVR hDev
, UINT uMsg
, DWORD_PTR dwInstance
, DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
116 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
119 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
122 /* =================================
123 * M I X E R M A P P E R S
124 * ================================= */
126 /**************************************************************************
127 * xMMDRV_Mixer_Map16To32W [internal]
129 static WINMM_MapType
MMDRV_Mixer_Map16To32W (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
131 return WINMM_MAP_MSGERROR
;
134 /**************************************************************************
135 * MMDRV_Mixer_UnMap16To32W [internal]
137 static WINMM_MapType
MMDRV_Mixer_UnMap16To32W(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
141 UINT ret
= mixerGetDevCapsA(devid
, &micA
, sizeof(micA
));
143 if (ret
== MMSYSERR_NOERROR
) {
144 mixcaps
->wMid
= micA
.wMid
;
145 mixcaps
->wPid
= micA
.wPid
;
146 mixcaps
->vDriverVersion
= micA
.vDriverVersion
;
147 strcpy(mixcaps
->szPname
, micA
.szPname
);
148 mixcaps
->fdwSupport
= micA
.fdwSupport
;
149 mixcaps
->cDestinations
= micA
.cDestinations
;
153 return WINMM_MAP_MSGERROR
;
156 /**************************************************************************
157 * MMDRV_Mixer_Map32WTo16 [internal]
159 static WINMM_MapType
MMDRV_Mixer_Map32WTo16 (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
161 return WINMM_MAP_MSGERROR
;
164 /**************************************************************************
165 * MMDRV_Mixer_UnMap32WTo16 [internal]
167 static WINMM_MapType
MMDRV_Mixer_UnMap32WTo16(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
169 return WINMM_MAP_MSGERROR
;
172 /**************************************************************************
173 * MMDRV_Mixer_Callback [internal]
175 static void CALLBACK
MMDRV_Mixer_Callback(HDRVR hDev
, UINT uMsg
, DWORD_PTR dwInstance
, DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
177 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
180 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
183 /* =================================
184 * M I D I I N M A P P E R S
185 * ================================= */
187 /**************************************************************************
188 * MMDRV_MidiIn_Map16To32W [internal]
190 static WINMM_MapType
MMDRV_MidiIn_Map16To32W (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
192 return WINMM_MAP_MSGERROR
;
195 /**************************************************************************
196 * MMDRV_MidiIn_UnMap16To32W [internal]
198 static WINMM_MapType
MMDRV_MidiIn_UnMap16To32W(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
200 return WINMM_MAP_MSGERROR
;
203 /**************************************************************************
204 * MMDRV_MidiIn_Map32WTo16 [internal]
206 static WINMM_MapType
MMDRV_MidiIn_Map32WTo16 (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
208 return WINMM_MAP_MSGERROR
;
211 /**************************************************************************
212 * MMDRV_MidiIn_UnMap32WTo16 [internal]
214 static WINMM_MapType
MMDRV_MidiIn_UnMap32WTo16(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
216 return WINMM_MAP_MSGERROR
;
219 /**************************************************************************
220 * MMDRV_MidiIn_Callback [internal]
222 static void CALLBACK
MMDRV_MidiIn_Callback(HDRVR hDev
, UINT uMsg
, DWORD_PTR dwInstance
, DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
224 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
229 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
234 /* dwParam1 & dwParam2 are data, nothing to do */
238 /* dwParam1 points to a MidiHdr, work to be done !!! */
239 if (mld
->bFrom32
&& !MMDRV_Is32(mld
->mmdIndex
)) {
240 /* initial map is: 32 => 16 */
241 LPMIDIHDR mh16
= MapSL(dwParam1
);
242 LPMIDIHDR mh32
= *(LPMIDIHDR
*)((LPSTR
)mh16
- sizeof(LPMIDIHDR
));
244 dwParam1
= (DWORD
)mh32
;
245 mh32
->dwFlags
= mh16
->dwFlags
;
246 mh32
->dwBytesRecorded
= mh16
->dwBytesRecorded
;
247 if (mh32
->reserved
>= sizeof(MIDIHDR
))
248 mh32
->dwOffset
= mh16
->dwOffset
;
249 } else if (!mld
->bFrom32
&& MMDRV_Is32(mld
->mmdIndex
)) {
250 /* initial map is: 16 => 32 */
251 LPMIDIHDR mh32
= (LPMIDIHDR
)(dwParam1
);
252 SEGPTR segmh16
= *(SEGPTR
*)((LPSTR
)mh32
- sizeof(LPMIDIHDR
));
253 LPMIDIHDR mh16
= MapSL(segmh16
);
255 dwParam1
= (DWORD
)segmh16
;
256 mh16
->dwFlags
= mh32
->dwFlags
;
257 mh16
->dwBytesRecorded
= mh32
->dwBytesRecorded
;
258 if (mh16
->reserved
>= sizeof(MIDIHDR
))
259 mh16
->dwOffset
= mh32
->dwOffset
;
261 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
263 /* case MOM_POSITIONCB: */
265 ERR("Unknown msg %u\n", uMsg
);
268 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
271 /* =================================
272 * M I D I O U T M A P P E R S
273 * ================================= */
275 /**************************************************************************
276 * MMDRV_MidiOut_Map16To32W [internal]
278 static WINMM_MapType
MMDRV_MidiOut_Map16To32W (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
280 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
283 case MODM_GETNUMDEVS
:
293 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
296 case MODM_GETDEVCAPS
:
298 LPMIDIOUTCAPSW moc32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPS16
) + sizeof(MIDIOUTCAPSW
));
299 LPMIDIOUTCAPS16 moc16
= MapSL(*lpParam1
);
302 *(LPMIDIOUTCAPS16
*)moc32
= moc16
;
303 moc32
= (LPMIDIOUTCAPSW
)((LPSTR
)moc32
+ sizeof(LPMIDIOUTCAPS16
));
304 *lpParam1
= (DWORD
)moc32
;
305 *lpParam2
= sizeof(MIDIOUTCAPSW
);
307 ret
= WINMM_MAP_OKMEM
;
309 ret
= WINMM_MAP_NOMEM
;
315 LPMIDIHDR mh32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIHDR
) + sizeof(MIDIHDR
));
316 LPMIDIHDR mh16
= MapSL(*lpParam1
);
319 *(LPMIDIHDR
*)mh32
= (LPMIDIHDR
)*lpParam1
;
320 mh32
= (LPMIDIHDR
)((LPSTR
)mh32
+ sizeof(LPMIDIHDR
));
321 mh32
->lpData
= MapSL((SEGPTR
)mh16
->lpData
);
322 mh32
->dwBufferLength
= mh16
->dwBufferLength
;
323 mh32
->dwBytesRecorded
= mh16
->dwBytesRecorded
;
324 mh32
->dwUser
= mh16
->dwUser
;
325 mh32
->dwFlags
= mh16
->dwFlags
;
326 /* FIXME: nothing on mh32->lpNext */
327 /* could link the mh32->lpNext at this level for memory house keeping */
328 mh32
->dwOffset
= (*lpParam2
>= sizeof(MIDIHDR
)) ? ((LPMIDIHDR
)mh16
)->dwOffset
: 0;
329 mh16
->lpNext
= mh32
; /* for reuse in unprepare and write */
330 /* store size of passed MIDIHDR?? structure to know if dwOffset is available or not */
331 mh16
->reserved
= *lpParam2
;
332 *lpParam1
= (DWORD
)mh32
;
333 *lpParam2
= sizeof(MIDIHDR
);
335 ret
= WINMM_MAP_OKMEM
;
337 ret
= WINMM_MAP_NOMEM
;
344 LPMIDIHDR mh16
= MapSL(*lpParam1
);
345 LPMIDIHDR mh32
= (LPMIDIHDR
)mh16
->lpNext
;
347 *lpParam1
= (DWORD
)mh32
;
348 *lpParam2
= sizeof(MIDIHDR
);
349 /* dwBufferLength can be reduced between prepare & write */
350 if (wMsg
== MODM_LONGDATA
&& mh32
->dwBufferLength
< mh16
->dwBufferLength
) {
351 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
352 mh32
->dwBufferLength
, mh16
->dwBufferLength
);
354 mh32
->dwBufferLength
= mh16
->dwBufferLength
;
355 ret
= WINMM_MAP_OKMEM
;
359 case MODM_CACHEPATCHES
:
360 case MODM_CACHEDRUMPATCHES
:
362 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
368 /**************************************************************************
369 * MMDRV_MidiOut_UnMap16To32W [internal]
371 static WINMM_MapType
MMDRV_MidiOut_UnMap16To32W(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
373 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
376 case MODM_GETNUMDEVS
:
386 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
389 case MODM_GETDEVCAPS
:
391 LPMIDIOUTCAPSW moc32
= (LPMIDIOUTCAPSW
)(*lpParam1
);
392 LPMIDIOUTCAPS16 moc16
= *(LPMIDIOUTCAPS16
*)((LPSTR
)moc32
- sizeof(LPMIDIOUTCAPS16
));
394 moc16
->wMid
= moc32
->wMid
;
395 moc16
->wPid
= moc32
->wPid
;
396 moc16
->vDriverVersion
= moc32
->vDriverVersion
;
397 WideCharToMultiByte( CP_ACP
, 0, moc32
->szPname
, -1, moc16
->szPname
,
398 sizeof(moc16
->szPname
), NULL
, NULL
);
399 moc16
->wTechnology
= moc32
->wTechnology
;
400 moc16
->wVoices
= moc32
->wVoices
;
401 moc16
->wNotes
= moc32
->wNotes
;
402 moc16
->wChannelMask
= moc32
->wChannelMask
;
403 moc16
->dwSupport
= moc32
->dwSupport
;
404 HeapFree(GetProcessHeap(), 0, (LPSTR
)moc32
- sizeof(LPMIDIOUTCAPS16
));
412 LPMIDIHDR mh32
= (LPMIDIHDR
)(*lpParam1
);
413 LPMIDIHDR mh16
= MapSL(*(SEGPTR
*)((LPSTR
)mh32
- sizeof(LPMIDIHDR
)));
415 assert(mh16
->lpNext
== mh32
);
416 mh16
->dwBufferLength
= mh32
->dwBufferLength
;
417 mh16
->dwBytesRecorded
= mh32
->dwBytesRecorded
;
418 mh16
->dwUser
= mh32
->dwUser
;
419 mh16
->dwFlags
= mh32
->dwFlags
;
420 if (mh16
->reserved
>= sizeof(MIDIHDR
))
421 mh16
->dwOffset
= mh32
->dwOffset
;
423 if (wMsg
== MODM_UNPREPARE
&& fn_ret
== MMSYSERR_NOERROR
) {
424 HeapFree(GetProcessHeap(), 0, (LPSTR
)mh32
- sizeof(LPMIDIHDR
));
431 case MODM_CACHEPATCHES
:
432 case MODM_CACHEDRUMPATCHES
:
434 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
440 /**************************************************************************
441 * MMDRV_MidiOut_Map32WTo16 [internal]
443 static WINMM_MapType
MMDRV_MidiOut_Map32WTo16 (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
445 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
449 case MODM_GETNUMDEVS
:
455 case MODM_GETDEVCAPS
:
457 LPMIDIOUTCAPSW moc32
= (LPMIDIOUTCAPSW
)*lpParam1
;
458 LPSTR ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPSW
)+sizeof(MIDIOUTCAPS16
));
461 *(LPMIDIOUTCAPSW
*)ptr
= moc32
;
462 ret
= WINMM_MAP_OKMEM
;
464 ret
= WINMM_MAP_NOMEM
;
466 *lpParam1
= (DWORD
)MapLS(ptr
) + sizeof(LPMIDIOUTCAPSW
);
467 *lpParam2
= sizeof(MIDIOUTCAPS16
);
472 LPMIDIHDR mh32
= (LPMIDIHDR
)*lpParam1
;
474 LPVOID ptr
= HeapAlloc( GetProcessHeap(), 0,
475 sizeof(LPMIDIHDR
) + sizeof(MIDIHDR
) + mh32
->dwBufferLength
);
478 *(LPMIDIHDR
*)ptr
= mh32
;
479 mh16
= (LPMIDIHDR
)((LPSTR
)ptr
+ sizeof(LPMIDIHDR
));
480 *lpParam1
= MapLS(mh16
);
481 mh16
->lpData
= (LPSTR
)*lpParam1
+ sizeof(MIDIHDR
);
482 /* data will be copied on WODM_WRITE */
483 mh16
->dwBufferLength
= mh32
->dwBufferLength
;
484 mh16
->dwBytesRecorded
= mh32
->dwBytesRecorded
;
485 mh16
->dwUser
= mh32
->dwUser
;
486 mh16
->dwFlags
= mh32
->dwFlags
;
487 /* FIXME: nothing on mh32->lpNext */
488 /* could link the mh32->lpNext at this level for memory house keeping */
489 mh16
->dwOffset
= (*lpParam2
>= sizeof(MIDIHDR
)) ? mh32
->dwOffset
: 0;
491 mh32
->lpNext
= (LPMIDIHDR
)mh16
; /* for reuse in unprepare and write */
492 mh32
->reserved
= *lpParam2
;
494 TRACE("mh16=%08lx mh16->lpData=%p mh32->buflen=%u mh32->lpData=%p\n",
495 *lpParam1
, mh16
->lpData
, mh32
->dwBufferLength
, mh32
->lpData
);
496 *lpParam2
= sizeof(MIDIHDR
);
498 ret
= WINMM_MAP_OKMEM
;
500 ret
= WINMM_MAP_NOMEM
;
507 LPMIDIHDR mh32
= (LPMIDIHDR
)(*lpParam1
);
508 LPMIDIHDR mh16
= (LPMIDIHDR
)mh32
->lpNext
;
509 LPSTR ptr
= (LPSTR
)mh16
- sizeof(LPMIDIHDR
);
511 assert(*(LPMIDIHDR
*)ptr
== mh32
);
513 if (wMsg
== MODM_LONGDATA
)
514 memcpy((LPSTR
)mh16
+ sizeof(MIDIHDR
), mh32
->lpData
, mh32
->dwBufferLength
);
516 *lpParam1
= MapLS(mh16
);
517 *lpParam2
= sizeof(MIDIHDR
);
518 TRACE("mh16=%08lx mh16->lpData=%p mh32->buflen=%u mh32->lpData=%p\n",
519 *lpParam1
, mh16
->lpData
, mh32
->dwBufferLength
, mh32
->lpData
);
521 /* dwBufferLength can be reduced between prepare & write */
522 if (wMsg
== MODM_LONGDATA
&& mh16
->dwBufferLength
< mh32
->dwBufferLength
) {
523 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
524 mh16
->dwBufferLength
, mh32
->dwBufferLength
);
526 mh16
->dwBufferLength
= mh32
->dwBufferLength
;
527 ret
= WINMM_MAP_OKMEM
;
532 LPMIDIOPENDESC mod32
= (LPMIDIOPENDESC
)*lpParam1
;
534 LPMIDIOPENDESC16 mod16
;
536 /* allocated data are mapped as follows:
537 LPMIDIOPENDESC ptr to orig lParam1
538 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
539 DWORD dwUser passed to driver
540 MIDIOPENDESC16 mod16: openDesc passed to driver
543 ptr
= HeapAlloc( GetProcessHeap(), 0,
544 sizeof(LPMIDIOPENDESC
) + 2*sizeof(DWORD
) + sizeof(MIDIOPENDESC16
) +
545 mod32
->cIds
? (mod32
->cIds
- 1) * sizeof(MIDIOPENSTRMID
) : 0);
548 SEGPTR segptr
= MapLS(ptr
);
549 *(LPMIDIOPENDESC
*)ptr
= mod32
;
550 *(LPDWORD
)((char*)ptr
+ sizeof(LPMIDIOPENDESC
)) = *lpdwUser
;
551 mod16
= (LPMIDIOPENDESC16
)((LPSTR
)ptr
+ sizeof(LPMIDIOPENDESC
) + 2*sizeof(DWORD
));
553 mod16
->hMidi
= HMIDI_16(mod32
->hMidi
);
554 mod16
->dwCallback
= mod32
->dwCallback
;
555 mod16
->dwInstance
= mod32
->dwInstance
;
556 mod16
->dnDevNode
= mod32
->dnDevNode
;
557 mod16
->cIds
= mod32
->cIds
;
558 memcpy(&mod16
->rgIds
, &mod32
->rgIds
, mod32
->cIds
* sizeof(MIDIOPENSTRMID
));
560 *lpParam1
= (DWORD
)segptr
+ sizeof(LPMIDIOPENDESC
) + 2*sizeof(DWORD
);
561 *lpdwUser
= (DWORD
)segptr
+ sizeof(LPMIDIOPENDESC
) + sizeof(DWORD
);
563 ret
= WINMM_MAP_OKMEM
;
565 ret
= WINMM_MAP_NOMEM
;
570 case MODM_CACHEPATCHES
:
571 case MODM_CACHEDRUMPATCHES
:
573 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
579 /**************************************************************************
580 * MMDRV_MidiOut_UnMap32WTo16 [internal]
582 static WINMM_MapType
MMDRV_MidiOut_UnMap32WTo16(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
584 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
588 case MODM_GETNUMDEVS
:
594 case MODM_GETDEVCAPS
:
596 LPMIDIOUTCAPS16 moc16
= MapSL(*lpParam1
);
597 LPSTR ptr
= (LPSTR
)moc16
- sizeof(LPMIDIOUTCAPSW
);
598 LPMIDIOUTCAPSW moc32
= *(LPMIDIOUTCAPSW
*)ptr
;
600 moc32
->wMid
= moc16
->wMid
;
601 moc32
->wPid
= moc16
->wPid
;
602 moc32
->vDriverVersion
= moc16
->vDriverVersion
;
603 WideCharToMultiByte( CP_ACP
, 0, moc32
->szPname
, -1, moc16
->szPname
,
604 sizeof(moc16
->szPname
), NULL
, NULL
);
605 moc32
->wTechnology
= moc16
->wTechnology
;
606 moc32
->wVoices
= moc16
->wVoices
;
607 moc32
->wNotes
= moc16
->wNotes
;
608 moc32
->wChannelMask
= moc16
->wChannelMask
;
609 moc32
->dwSupport
= moc16
->dwSupport
;
610 UnMapLS( *lpParam1
);
611 HeapFree( GetProcessHeap(), 0, ptr
);
619 LPMIDIHDR mh16
= MapSL(*lpParam1
);
620 LPSTR ptr
= (LPSTR
)mh16
- sizeof(LPMIDIHDR
);
621 LPMIDIHDR mh32
= *(LPMIDIHDR
*)ptr
;
623 assert(mh32
->lpNext
== (LPMIDIHDR
)mh16
);
624 UnMapLS( *lpParam1
);
625 mh32
->dwBytesRecorded
= mh16
->dwBytesRecorded
;
626 mh32
->dwUser
= mh16
->dwUser
;
627 mh32
->dwFlags
= mh16
->dwFlags
;
629 if (wMsg
== MODM_UNPREPARE
&& fn_ret
== MMSYSERR_NOERROR
) {
630 HeapFree( GetProcessHeap(), 0, ptr
);
638 LPMIDIOPENDESC16 mod16
= MapSL(*lpParam1
);
639 LPSTR ptr
= (LPSTR
)mod16
- sizeof(LPMIDIOPENDESC
) - 2*sizeof(DWORD
);
640 UnMapLS( *lpParam1
);
641 **(DWORD
**)(ptr
+ sizeof(LPMIDIOPENDESC
)) = *(LPDWORD
)(ptr
+ sizeof(LPMIDIOPENDESC
) + sizeof(DWORD
));
643 HeapFree( GetProcessHeap(), 0, ptr
);
648 case MODM_CACHEPATCHES
:
649 case MODM_CACHEDRUMPATCHES
:
651 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
657 /**************************************************************************
658 * MMDRV_MidiOut_Callback [internal]
660 static void CALLBACK
MMDRV_MidiOut_Callback(HDRVR hDev
, UINT uMsg
, DWORD_PTR dwInstance
, DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
662 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
667 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
670 if (mld
->bFrom32
&& !MMDRV_Is32(mld
->mmdIndex
)) {
671 /* initial map is: 32 => 16 */
672 LPMIDIHDR mh16
= MapSL(dwParam1
);
673 LPMIDIHDR mh32
= *(LPMIDIHDR
*)((LPSTR
)mh16
- sizeof(LPMIDIHDR
));
675 dwParam1
= (DWORD
)mh32
;
676 mh32
->dwFlags
= mh16
->dwFlags
;
677 mh32
->dwOffset
= mh16
->dwOffset
;
678 if (mh32
->reserved
>= sizeof(MIDIHDR
))
679 mh32
->dwOffset
= mh16
->dwOffset
;
680 } else if (!mld
->bFrom32
&& MMDRV_Is32(mld
->mmdIndex
)) {
681 /* initial map is: 16 => 32 */
682 LPMIDIHDR mh32
= (LPMIDIHDR
)(dwParam1
);
683 SEGPTR segmh16
= *(SEGPTR
*)((LPSTR
)mh32
- sizeof(LPMIDIHDR
));
684 LPMIDIHDR mh16
= MapSL(segmh16
);
686 dwParam1
= (DWORD
)segmh16
;
687 mh16
->dwFlags
= mh32
->dwFlags
;
688 if (mh16
->reserved
>= sizeof(MIDIHDR
))
689 mh16
->dwOffset
= mh32
->dwOffset
;
691 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
693 /* case MOM_POSITIONCB: */
695 ERR("Unknown msg %u\n", uMsg
);
698 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
701 /* =================================
702 * W A V E I N M A P P E R S
703 * ================================= */
705 /**************************************************************************
706 * MMDRV_WaveIn_Map16To32W [internal]
708 static WINMM_MapType
MMDRV_WaveIn_Map16To32W (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
710 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
713 case WIDM_GETNUMDEVS
:
721 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
723 case WIDM_GETDEVCAPS
:
725 LPWAVEINCAPSW wic32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEINCAPS16
) + sizeof(WAVEINCAPSW
));
726 LPWAVEINCAPS16 wic16
= MapSL(*lpParam1
);
729 *(LPWAVEINCAPS16
*)wic32
= wic16
;
730 wic32
= (LPWAVEINCAPSW
)((LPSTR
)wic32
+ sizeof(LPWAVEINCAPS16
));
731 *lpParam1
= (DWORD
)wic32
;
732 *lpParam2
= sizeof(WAVEINCAPSW
);
734 ret
= WINMM_MAP_OKMEM
;
736 ret
= WINMM_MAP_NOMEM
;
742 LPMMTIME mmt32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16
) + sizeof(MMTIME
));
743 LPMMTIME16 mmt16
= MapSL(*lpParam1
);
746 *(LPMMTIME16
*)mmt32
= mmt16
;
747 mmt32
= (LPMMTIME
)((LPSTR
)mmt32
+ sizeof(LPMMTIME16
));
749 mmt32
->wType
= mmt16
->wType
;
750 *lpParam1
= (DWORD
)mmt32
;
751 *lpParam2
= sizeof(MMTIME
);
753 ret
= WINMM_MAP_OKMEM
;
755 ret
= WINMM_MAP_NOMEM
;
761 LPWAVEHDR wh32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
));
762 LPWAVEHDR wh16
= MapSL(*lpParam1
);
765 *(LPWAVEHDR
*)wh32
= (LPWAVEHDR
)*lpParam1
;
766 wh32
= (LPWAVEHDR
)((LPSTR
)wh32
+ sizeof(LPWAVEHDR
));
767 wh32
->lpData
= MapSL((SEGPTR
)wh16
->lpData
);
768 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
769 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
770 wh32
->dwUser
= wh16
->dwUser
;
771 wh32
->dwFlags
= wh16
->dwFlags
;
772 wh32
->dwLoops
= wh16
->dwLoops
;
773 /* FIXME: nothing on wh32->lpNext */
774 /* could link the wh32->lpNext at this level for memory house keeping */
775 wh16
->lpNext
= wh32
; /* for reuse in unprepare and write */
776 *lpParam1
= (DWORD
)wh32
;
777 *lpParam2
= sizeof(WAVEHDR
);
779 ret
= WINMM_MAP_OKMEM
;
781 ret
= WINMM_MAP_NOMEM
;
788 LPWAVEHDR wh16
= MapSL(*lpParam1
);
789 LPWAVEHDR wh32
= (LPWAVEHDR
)wh16
->lpNext
;
791 *lpParam1
= (DWORD
)wh32
;
792 *lpParam2
= sizeof(WAVEHDR
);
793 /* dwBufferLength can be reduced between prepare & write */
794 if (wMsg
== WIDM_ADDBUFFER
&& wh32
->dwBufferLength
< wh16
->dwBufferLength
) {
795 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
796 wh32
->dwBufferLength
, wh16
->dwBufferLength
);
798 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
799 ret
= WINMM_MAP_OKMEM
;
802 case WIDM_MAPPER_STATUS
:
803 /* just a single DWORD */
804 *lpParam2
= (DWORD
)MapSL(*lpParam2
);
808 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
814 /**************************************************************************
815 * MMDRV_WaveIn_UnMap16To32W [internal]
817 static WINMM_MapType
MMDRV_WaveIn_UnMap16To32W(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
819 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
822 case WIDM_GETNUMDEVS
:
826 case WIDM_MAPPER_STATUS
:
831 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
833 case WIDM_GETDEVCAPS
:
835 LPWAVEINCAPSW wic32
= (LPWAVEINCAPSW
)(*lpParam1
);
836 LPWAVEINCAPS16 wic16
= *(LPWAVEINCAPS16
*)((LPSTR
)wic32
- sizeof(LPWAVEINCAPS16
));
838 wic16
->wMid
= wic32
->wMid
;
839 wic16
->wPid
= wic32
->wPid
;
840 wic16
->vDriverVersion
= wic32
->vDriverVersion
;
841 WideCharToMultiByte( CP_ACP
, 0, wic32
->szPname
, -1, wic16
->szPname
,
842 sizeof(wic16
->szPname
), NULL
, NULL
);
843 wic16
->dwFormats
= wic32
->dwFormats
;
844 wic16
->wChannels
= wic32
->wChannels
;
845 HeapFree(GetProcessHeap(), 0, (LPSTR
)wic32
- sizeof(LPWAVEINCAPS16
));
851 LPMMTIME mmt32
= (LPMMTIME
)(*lpParam1
);
852 LPMMTIME16 mmt16
= *(LPMMTIME16
*)((LPSTR
)mmt32
- sizeof(LPMMTIME16
));
854 MMSYSTEM_MMTIME32to16(mmt16
, mmt32
);
855 HeapFree(GetProcessHeap(), 0, (LPSTR
)mmt32
- sizeof(LPMMTIME16
));
863 LPWAVEHDR wh32
= (LPWAVEHDR
)(*lpParam1
);
864 LPWAVEHDR wh16
= MapSL(*(SEGPTR
*)((LPSTR
)wh32
- sizeof(LPWAVEHDR
)));
866 assert(wh16
->lpNext
== wh32
);
867 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
868 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
869 wh16
->dwUser
= wh32
->dwUser
;
870 wh16
->dwFlags
= wh32
->dwFlags
;
871 wh16
->dwLoops
= wh32
->dwLoops
;
873 if (wMsg
== WIDM_UNPREPARE
&& fn_ret
== MMSYSERR_NOERROR
) {
874 HeapFree(GetProcessHeap(), 0, (LPSTR
)wh32
- sizeof(LPWAVEHDR
));
881 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
887 /**************************************************************************
888 * MMDRV_WaveIn_Map32WTo16 [internal]
890 static WINMM_MapType
MMDRV_WaveIn_Map32WTo16 (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
892 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
896 case WIDM_GETNUMDEVS
:
905 LPWAVEOPENDESC wod32
= (LPWAVEOPENDESC
)*lpParam1
;
906 int sz
= sizeof(WAVEFORMATEX
);
908 LPWAVEOPENDESC16 wod16
;
910 /* allocated data are mapped as follows:
911 LPWAVEOPENDESC ptr to orig lParam1
912 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
913 DWORD dwUser passed to driver
914 WAVEOPENDESC16 wod16: openDesc passed to driver
915 WAVEFORMATEX openDesc->lpFormat passed to driver
916 xxx extra bytes to WAVEFORMATEX
918 if (wod32
->lpFormat
->wFormatTag
!= WAVE_FORMAT_PCM
) {
919 TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX
)wod32
->lpFormat
)->cbSize
, wod32
->lpFormat
->wFormatTag
);
920 sz
+= ((LPWAVEFORMATEX
)wod32
->lpFormat
)->cbSize
;
923 ptr
= HeapAlloc( GetProcessHeap(), 0,
924 sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
) + sizeof(WAVEOPENDESC16
) + sz
);
927 SEGPTR seg_ptr
= MapLS( ptr
);
928 *(LPWAVEOPENDESC
*)ptr
= wod32
;
929 *(LPDWORD
)((char*)ptr
+ sizeof(LPWAVEOPENDESC
)) = *lpdwUser
;
930 wod16
= (LPWAVEOPENDESC16
)((LPSTR
)ptr
+ sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
));
932 wod16
->hWave
= HWAVE_16(wod32
->hWave
);
933 wod16
->lpFormat
= (LPWAVEFORMATEX
)(seg_ptr
+ sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
) + sizeof(WAVEOPENDESC16
));
934 memcpy(wod16
+ 1, wod32
->lpFormat
, sz
);
936 wod16
->dwCallback
= wod32
->dwCallback
;
937 wod16
->dwInstance
= wod32
->dwInstance
;
938 wod16
->uMappedDeviceID
= wod32
->uMappedDeviceID
;
939 wod16
->dnDevNode
= wod32
->dnDevNode
;
941 *lpParam1
= seg_ptr
+ sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
);
942 *lpdwUser
= seg_ptr
+ sizeof(LPWAVEOPENDESC
) + sizeof(DWORD
);
944 ret
= WINMM_MAP_OKMEM
;
946 ret
= WINMM_MAP_NOMEM
;
952 LPWAVEHDR wh32
= (LPWAVEHDR
)*lpParam1
;
954 LPVOID ptr
= HeapAlloc( GetProcessHeap(), 0,
955 sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
) + wh32
->dwBufferLength
);
958 SEGPTR seg_ptr
= MapLS( ptr
);
959 *(LPWAVEHDR
*)ptr
= wh32
;
960 wh16
= (LPWAVEHDR
)((LPSTR
)ptr
+ sizeof(LPWAVEHDR
));
961 wh16
->lpData
= (LPSTR
)seg_ptr
+ sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
);
962 /* data will be copied on WODM_WRITE */
963 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
964 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
965 wh16
->dwUser
= wh32
->dwUser
;
966 wh16
->dwFlags
= wh32
->dwFlags
;
967 wh16
->dwLoops
= wh32
->dwLoops
;
968 /* FIXME: nothing on wh32->lpNext */
969 /* could link the wh32->lpNext at this level for memory house keeping */
970 wh32
->lpNext
= wh16
; /* for reuse in unprepare and write */
971 TRACE("wh16=%08x wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n",
972 seg_ptr
+ sizeof(LPWAVEHDR
), wh16
->lpData
,
973 wh32
->dwBufferLength
, wh32
->lpData
);
974 *lpParam1
= seg_ptr
+ sizeof(LPWAVEHDR
);
975 *lpParam2
= sizeof(WAVEHDR
);
977 ret
= WINMM_MAP_OKMEM
;
979 ret
= WINMM_MAP_NOMEM
;
986 LPWAVEHDR wh32
= (LPWAVEHDR
)(*lpParam1
);
987 LPWAVEHDR wh16
= wh32
->lpNext
;
988 LPSTR ptr
= (LPSTR
)wh16
- sizeof(LPWAVEHDR
);
989 SEGPTR seg_ptr
= MapLS( ptr
);
991 assert(*(LPWAVEHDR
*)ptr
== wh32
);
993 TRACE("wh16=%08x wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n",
994 seg_ptr
+ sizeof(LPWAVEHDR
), wh16
->lpData
, wh32
->dwBufferLength
, wh32
->lpData
);
996 if (wMsg
== WIDM_ADDBUFFER
)
997 memcpy((LPSTR
)wh16
+ sizeof(WAVEHDR
), wh32
->lpData
, wh32
->dwBufferLength
);
999 *lpParam1
= seg_ptr
+ sizeof(LPWAVEHDR
);
1000 *lpParam2
= sizeof(WAVEHDR
);
1001 /* dwBufferLength can be reduced between prepare & write */
1002 if (wMsg
== WIDM_ADDBUFFER
&& wh16
->dwBufferLength
< wh32
->dwBufferLength
) {
1003 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
1004 wh16
->dwBufferLength
, wh32
->dwBufferLength
);
1006 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
1007 ret
= WINMM_MAP_OKMEM
;
1010 case WIDM_GETDEVCAPS
:
1012 LPWAVEINCAPSW wic32
= (LPWAVEINCAPSW
)*lpParam1
;
1013 LPSTR ptr
= HeapAlloc( GetProcessHeap(), 0 ,sizeof(LPWAVEINCAPSW
) + sizeof(WAVEINCAPS16
));
1016 *(LPWAVEINCAPSW
*)ptr
= wic32
;
1017 ret
= WINMM_MAP_OKMEM
;
1019 ret
= WINMM_MAP_NOMEM
;
1021 *lpParam1
= MapLS(ptr
) + sizeof(LPWAVEINCAPSW
);
1022 *lpParam2
= sizeof(WAVEINCAPS16
);
1027 LPMMTIME mmt32
= (LPMMTIME
)*lpParam1
;
1028 LPSTR ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME
) + sizeof(MMTIME16
));
1029 LPMMTIME16 mmt16
= (LPMMTIME16
)(ptr
+ sizeof(LPMMTIME
));
1032 *(LPMMTIME
*)ptr
= mmt32
;
1033 mmt16
->wType
= mmt32
->wType
;
1034 ret
= WINMM_MAP_OKMEM
;
1036 ret
= WINMM_MAP_NOMEM
;
1038 *lpParam1
= MapLS(ptr
) + sizeof(LPMMTIME
);
1039 *lpParam2
= sizeof(MMTIME16
);
1042 case DRVM_MAPPER_STATUS
:
1044 LPDWORD p32
= (LPDWORD
)*lpParam2
;
1045 *lpParam2
= MapLS(p32
);
1046 ret
= WINMM_MAP_OKMEM
;
1050 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1056 /**************************************************************************
1057 * MMDRV_WaveIn_UnMap32WTo16 [internal]
1059 static WINMM_MapType
MMDRV_WaveIn_UnMap32WTo16(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
1061 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
1065 case WIDM_GETNUMDEVS
:
1074 LPWAVEOPENDESC16 wod16
= MapSL(*lpParam1
);
1075 LPSTR ptr
= (LPSTR
)wod16
- sizeof(LPWAVEOPENDESC
) - 2*sizeof(DWORD
);
1076 LPWAVEOPENDESC wod32
= *(LPWAVEOPENDESC
*)ptr
;
1078 UnMapLS( *lpParam1
);
1079 wod32
->uMappedDeviceID
= wod16
->uMappedDeviceID
;
1080 **(DWORD
**)(ptr
+ sizeof(LPWAVEOPENDESC
)) = *(LPDWORD
)(ptr
+ sizeof(LPWAVEOPENDESC
) + sizeof(DWORD
));
1081 HeapFree( GetProcessHeap(), 0, ptr
);
1086 case WIDM_ADDBUFFER
:
1088 case WIDM_UNPREPARE
:
1090 LPWAVEHDR wh16
= MapSL(*lpParam1
);
1091 LPSTR ptr
= (LPSTR
)wh16
- sizeof(LPWAVEHDR
);
1092 LPWAVEHDR wh32
= *(LPWAVEHDR
*)ptr
;
1094 assert(wh32
->lpNext
== wh16
);
1095 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
1096 wh32
->dwUser
= wh16
->dwUser
;
1097 wh32
->dwFlags
= wh16
->dwFlags
;
1098 wh32
->dwLoops
= wh16
->dwLoops
;
1099 UnMapLS( *lpParam1
);
1101 if (wMsg
== WIDM_UNPREPARE
&& fn_ret
== MMSYSERR_NOERROR
) {
1102 HeapFree( GetProcessHeap(), 0, ptr
);
1108 case WIDM_GETDEVCAPS
:
1110 LPWAVEINCAPS16 wic16
= MapSL(*lpParam1
);
1111 LPSTR ptr
= (LPSTR
)wic16
- sizeof(LPWAVEINCAPSW
);
1112 LPWAVEINCAPSW wic32
= *(LPWAVEINCAPSW
*)ptr
;
1114 wic32
->wMid
= wic16
->wMid
;
1115 wic32
->wPid
= wic16
->wPid
;
1116 wic32
->vDriverVersion
= wic16
->vDriverVersion
;
1117 WideCharToMultiByte( CP_ACP
, 0, wic32
->szPname
, -1, wic16
->szPname
,
1118 sizeof(wic16
->szPname
), NULL
, NULL
);
1119 wic32
->dwFormats
= wic16
->dwFormats
;
1120 wic32
->wChannels
= wic16
->wChannels
;
1121 UnMapLS( *lpParam1
);
1122 HeapFree( GetProcessHeap(), 0, ptr
);
1128 LPMMTIME16 mmt16
= MapSL(*lpParam1
);
1129 LPSTR ptr
= (LPSTR
)mmt16
- sizeof(LPMMTIME
);
1130 LPMMTIME mmt32
= *(LPMMTIME
*)ptr
;
1132 MMSYSTEM_MMTIME16to32(mmt32
, mmt16
);
1133 UnMapLS( *lpParam1
);
1134 HeapFree( GetProcessHeap(), 0, ptr
);
1138 case DRVM_MAPPER_STATUS
:
1140 UnMapLS( *lpParam2
);
1145 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1151 /**************************************************************************
1152 * MMDRV_WaveIn_Callback [internal]
1154 static void CALLBACK
MMDRV_WaveIn_Callback(HDRVR hDev
, UINT uMsg
, DWORD_PTR dwInstance
, DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
1156 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
1161 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
1164 if (mld
->bFrom32
&& !MMDRV_Is32(mld
->mmdIndex
)) {
1165 /* initial map is: 32 => 16 */
1166 LPWAVEHDR wh16
= MapSL(dwParam1
);
1167 LPWAVEHDR wh32
= *(LPWAVEHDR
*)((LPSTR
)wh16
- sizeof(LPWAVEHDR
));
1169 dwParam1
= (DWORD
)wh32
;
1170 wh32
->dwFlags
= wh16
->dwFlags
;
1171 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
1172 } else if (!mld
->bFrom32
&& MMDRV_Is32(mld
->mmdIndex
)) {
1173 /* initial map is: 16 => 32 */
1174 LPWAVEHDR wh32
= (LPWAVEHDR
)(dwParam1
);
1175 SEGPTR segwh16
= *(SEGPTR
*)((LPSTR
)wh32
- sizeof(LPWAVEHDR
));
1176 LPWAVEHDR wh16
= MapSL(segwh16
);
1178 dwParam1
= (DWORD
)segwh16
;
1179 wh16
->dwFlags
= wh32
->dwFlags
;
1180 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
1182 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
1185 ERR("Unknown msg %u\n", uMsg
);
1188 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
1191 /* =================================
1192 * W A V E O U T M A P P E R S
1193 * ================================= */
1195 /**************************************************************************
1196 * MMDRV_WaveOut_Map16To32W [internal]
1198 static WINMM_MapType
MMDRV_WaveOut_Map16To32W (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
1200 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
1204 case WODM_BREAKLOOP
:
1206 case WODM_GETNUMDEVS
:
1211 case WODM_SETPLAYBACKRATE
:
1212 case WODM_SETVOLUME
:
1217 case WODM_GETPLAYBACKRATE
:
1218 case WODM_GETVOLUME
:
1220 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
1223 case WODM_GETDEVCAPS
:
1225 LPWAVEOUTCAPSW woc32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEOUTCAPS16
) + sizeof(WAVEOUTCAPSW
));
1226 LPWAVEOUTCAPS16 woc16
= MapSL(*lpParam1
);
1229 *(LPWAVEOUTCAPS16
*)woc32
= woc16
;
1230 woc32
= (LPWAVEOUTCAPSW
)((LPSTR
)woc32
+ sizeof(LPWAVEOUTCAPS16
));
1231 *lpParam1
= (DWORD
)woc32
;
1232 *lpParam2
= sizeof(WAVEOUTCAPSW
);
1234 ret
= WINMM_MAP_OKMEM
;
1236 ret
= WINMM_MAP_NOMEM
;
1242 LPMMTIME mmt32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16
) + sizeof(MMTIME
));
1243 LPMMTIME16 mmt16
= MapSL(*lpParam1
);
1246 *(LPMMTIME16
*)mmt32
= mmt16
;
1247 mmt32
= (LPMMTIME
)((LPSTR
)mmt32
+ sizeof(LPMMTIME16
));
1249 mmt32
->wType
= mmt16
->wType
;
1250 *lpParam1
= (DWORD
)mmt32
;
1251 *lpParam2
= sizeof(MMTIME
);
1253 ret
= WINMM_MAP_OKMEM
;
1255 ret
= WINMM_MAP_NOMEM
;
1261 LPWAVEHDR wh32
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
));
1262 LPWAVEHDR wh16
= MapSL(*lpParam1
);
1265 *(LPWAVEHDR
*)wh32
= (LPWAVEHDR
)*lpParam1
;
1266 wh32
= (LPWAVEHDR
)((LPSTR
)wh32
+ sizeof(LPWAVEHDR
));
1267 wh32
->lpData
= MapSL((SEGPTR
)wh16
->lpData
);
1268 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
1269 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
1270 wh32
->dwUser
= wh16
->dwUser
;
1271 wh32
->dwFlags
= wh16
->dwFlags
;
1272 wh32
->dwLoops
= wh16
->dwLoops
;
1273 /* FIXME: nothing on wh32->lpNext */
1274 /* could link the wh32->lpNext at this level for memory house keeping */
1275 wh16
->lpNext
= wh32
; /* for reuse in unprepare and write */
1276 *lpParam1
= (DWORD
)wh32
;
1277 *lpParam2
= sizeof(WAVEHDR
);
1279 ret
= WINMM_MAP_OKMEM
;
1281 ret
= WINMM_MAP_NOMEM
;
1285 case WODM_UNPREPARE
:
1288 LPWAVEHDR wh16
= MapSL(*lpParam1
);
1289 LPWAVEHDR wh32
= (LPWAVEHDR
)wh16
->lpNext
;
1291 *lpParam1
= (DWORD
)wh32
;
1292 *lpParam2
= sizeof(WAVEHDR
);
1293 /* dwBufferLength can be reduced between prepare & write */
1294 if (wMsg
== WODM_WRITE
&& wh32
->dwBufferLength
< wh16
->dwBufferLength
) {
1295 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
1296 wh32
->dwBufferLength
, wh16
->dwBufferLength
);
1298 wh32
->dwBufferLength
= wh16
->dwBufferLength
;
1299 ret
= WINMM_MAP_OKMEM
;
1302 case WODM_MAPPER_STATUS
:
1303 *lpParam2
= (DWORD
)MapSL(*lpParam2
);
1307 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1313 /**************************************************************************
1314 * MMDRV_WaveOut_UnMap16To32W [internal]
1316 static WINMM_MapType
MMDRV_WaveOut_UnMap16To32W(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
1318 WINMM_MapType ret
= WINMM_MAP_MSGERROR
;
1322 case WODM_BREAKLOOP
:
1324 case WODM_GETNUMDEVS
:
1329 case WODM_SETPLAYBACKRATE
:
1330 case WODM_SETVOLUME
:
1331 case WODM_MAPPER_STATUS
:
1336 case WODM_GETPLAYBACKRATE
:
1337 case WODM_GETVOLUME
:
1339 FIXME("Shouldn't be used: those 16 bit functions use the 32 bit interface\n");
1342 case WODM_GETDEVCAPS
:
1344 LPWAVEOUTCAPSW woc32
= (LPWAVEOUTCAPSW
)(*lpParam1
);
1345 LPWAVEOUTCAPS16 woc16
= *(LPWAVEOUTCAPS16
*)((LPSTR
)woc32
- sizeof(LPWAVEOUTCAPS16
));
1347 woc16
->wMid
= woc32
->wMid
;
1348 woc16
->wPid
= woc32
->wPid
;
1349 woc16
->vDriverVersion
= woc32
->vDriverVersion
;
1350 WideCharToMultiByte( CP_ACP
, 0, woc32
->szPname
, -1, woc16
->szPname
,
1351 sizeof(woc16
->szPname
), NULL
, NULL
);
1352 woc16
->dwFormats
= woc32
->dwFormats
;
1353 woc16
->wChannels
= woc32
->wChannels
;
1354 woc16
->dwSupport
= woc32
->dwSupport
;
1355 HeapFree(GetProcessHeap(), 0, (LPSTR
)woc32
- sizeof(LPWAVEOUTCAPS16
));
1361 LPMMTIME mmt32
= (LPMMTIME
)(*lpParam1
);
1362 LPMMTIME16 mmt16
= *(LPMMTIME16
*)((LPSTR
)mmt32
- sizeof(LPMMTIME16
));
1364 MMSYSTEM_MMTIME32to16(mmt16
, mmt32
);
1365 HeapFree(GetProcessHeap(), 0, (LPSTR
)mmt32
- sizeof(LPMMTIME16
));
1370 case WODM_UNPREPARE
:
1373 LPWAVEHDR wh32
= (LPWAVEHDR
)(*lpParam1
);
1374 LPWAVEHDR wh16
= MapSL(*(SEGPTR
*)((LPSTR
)wh32
- sizeof(LPWAVEHDR
)));
1376 assert(wh16
->lpNext
== wh32
);
1377 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
1378 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
1379 wh16
->dwUser
= wh32
->dwUser
;
1380 wh16
->dwFlags
= wh32
->dwFlags
;
1381 wh16
->dwLoops
= wh32
->dwLoops
;
1383 if (wMsg
== WODM_UNPREPARE
&& fn_ret
== MMSYSERR_NOERROR
) {
1384 HeapFree(GetProcessHeap(), 0, (LPSTR
)wh32
- sizeof(LPWAVEHDR
));
1391 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg
, *lpParam1
, *lpParam2
);
1397 /**************************************************************************
1398 * MMDRV_WaveOut_Map32WTo16 [internal]
1400 static WINMM_MapType
MMDRV_WaveOut_Map32WTo16 (UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
)
1406 case WODM_BREAKLOOP
:
1408 case WODM_GETNUMDEVS
:
1413 case WODM_SETPLAYBACKRATE
:
1414 case WODM_SETVOLUME
:
1418 case WODM_GETDEVCAPS
:
1420 LPWAVEOUTCAPSW woc32
= (LPWAVEOUTCAPSW
)*lpParam1
;
1421 LPSTR ptr
= HeapAlloc( GetProcessHeap(), 0,
1422 sizeof(LPWAVEOUTCAPSW
) + sizeof(WAVEOUTCAPS16
));
1425 *(LPWAVEOUTCAPSW
*)ptr
= woc32
;
1426 ret
= WINMM_MAP_OKMEM
;
1428 ret
= WINMM_MAP_NOMEM
;
1430 *lpParam1
= MapLS(ptr
) + sizeof(LPWAVEOUTCAPSW
);
1431 *lpParam2
= sizeof(WAVEOUTCAPS16
);
1435 FIXME("NIY: no conversion yet\n");
1436 ret
= WINMM_MAP_MSGERROR
;
1438 case WODM_GETPLAYBACKRATE
:
1439 FIXME("NIY: no conversion yet\n");
1440 ret
= WINMM_MAP_MSGERROR
;
1444 LPMMTIME mmt32
= (LPMMTIME
)*lpParam1
;
1445 LPSTR ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME
) + sizeof(MMTIME16
));
1446 LPMMTIME16 mmt16
= (LPMMTIME16
)(ptr
+ sizeof(LPMMTIME
));
1449 *(LPMMTIME
*)ptr
= mmt32
;
1450 mmt16
->wType
= mmt32
->wType
;
1451 ret
= WINMM_MAP_OKMEM
;
1453 ret
= WINMM_MAP_NOMEM
;
1455 *lpParam1
= MapLS(ptr
) + sizeof(LPMMTIME
);
1456 *lpParam2
= sizeof(MMTIME16
);
1459 case WODM_GETVOLUME
:
1460 FIXME("NIY: no conversion yet\n");
1461 ret
= WINMM_MAP_MSGERROR
;
1465 LPWAVEOPENDESC wod32
= (LPWAVEOPENDESC
)*lpParam1
;
1466 int sz
= sizeof(WAVEFORMATEX
);
1468 LPWAVEOPENDESC16 wod16
;
1470 /* allocated data are mapped as follows:
1471 LPWAVEOPENDESC ptr to orig lParam1
1472 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
1473 DWORD dwUser passed to driver
1474 WAVEOPENDESC16 wod16: openDesc passed to driver
1475 WAVEFORMATEX openDesc->lpFormat passed to driver
1476 xxx extra bytes to WAVEFORMATEX
1478 if (wod32
->lpFormat
->wFormatTag
!= WAVE_FORMAT_PCM
) {
1479 TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX
)wod32
->lpFormat
)->cbSize
, wod32
->lpFormat
->wFormatTag
);
1480 sz
+= ((LPWAVEFORMATEX
)wod32
->lpFormat
)->cbSize
;
1483 ptr
= HeapAlloc( GetProcessHeap(), 0,
1484 sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
) + sizeof(WAVEOPENDESC16
) + sz
);
1487 SEGPTR seg_ptr
= MapLS( ptr
);
1488 *(LPWAVEOPENDESC
*)ptr
= wod32
;
1489 *(LPDWORD
)((char*)ptr
+ sizeof(LPWAVEOPENDESC
)) = *lpdwUser
;
1490 wod16
= (LPWAVEOPENDESC16
)((LPSTR
)ptr
+ sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
));
1492 wod16
->hWave
= HWAVE_16(wod32
->hWave
);
1493 wod16
->lpFormat
= (LPWAVEFORMATEX
)(seg_ptr
+ sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
) + sizeof(WAVEOPENDESC16
));
1494 memcpy(wod16
+ 1, wod32
->lpFormat
, sz
);
1496 wod16
->dwCallback
= wod32
->dwCallback
;
1497 wod16
->dwInstance
= wod32
->dwInstance
;
1498 wod16
->uMappedDeviceID
= wod32
->uMappedDeviceID
;
1499 wod16
->dnDevNode
= wod32
->dnDevNode
;
1501 *lpParam1
= seg_ptr
+ sizeof(LPWAVEOPENDESC
) + 2*sizeof(DWORD
);
1502 *lpdwUser
= seg_ptr
+ sizeof(LPWAVEOPENDESC
) + sizeof(DWORD
);
1504 ret
= WINMM_MAP_OKMEM
;
1506 ret
= WINMM_MAP_NOMEM
;
1512 LPWAVEHDR wh32
= (LPWAVEHDR
)*lpParam1
;
1514 LPVOID ptr
= HeapAlloc( GetProcessHeap(), 0,
1515 sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
) + wh32
->dwBufferLength
);
1518 SEGPTR seg_ptr
= MapLS( ptr
);
1519 *(LPWAVEHDR
*)ptr
= wh32
;
1520 wh16
= (LPWAVEHDR
)((LPSTR
)ptr
+ sizeof(LPWAVEHDR
));
1521 wh16
->lpData
= (LPSTR
)seg_ptr
+ sizeof(LPWAVEHDR
) + sizeof(WAVEHDR
);
1522 /* data will be copied on WODM_WRITE */
1523 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
1524 wh16
->dwBytesRecorded
= wh32
->dwBytesRecorded
;
1525 wh16
->dwUser
= wh32
->dwUser
;
1526 wh16
->dwFlags
= wh32
->dwFlags
;
1527 wh16
->dwLoops
= wh32
->dwLoops
;
1528 /* FIXME: nothing on wh32->lpNext */
1529 /* could link the wh32->lpNext at this level for memory house keeping */
1530 wh32
->lpNext
= wh16
; /* for reuse in unprepare and write */
1531 TRACE("wh16=%08x wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n",
1532 seg_ptr
+ sizeof(LPWAVEHDR
), wh16
->lpData
,
1533 wh32
->dwBufferLength
, wh32
->lpData
);
1534 *lpParam1
= seg_ptr
+ sizeof(LPWAVEHDR
);
1535 *lpParam2
= sizeof(WAVEHDR
);
1537 ret
= WINMM_MAP_OKMEM
;
1539 ret
= WINMM_MAP_NOMEM
;
1543 case WODM_UNPREPARE
:
1546 LPWAVEHDR wh32
= (LPWAVEHDR
)(*lpParam1
);
1547 LPWAVEHDR wh16
= wh32
->lpNext
;
1548 LPSTR ptr
= (LPSTR
)wh16
- sizeof(LPWAVEHDR
);
1549 SEGPTR seg_ptr
= MapLS( ptr
);
1551 assert(*(LPWAVEHDR
*)ptr
== wh32
);
1553 TRACE("wh16=%08x wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n",
1554 seg_ptr
+ sizeof(LPWAVEHDR
), wh16
->lpData
,
1555 wh32
->dwBufferLength
, wh32
->lpData
);
1557 if (wMsg
== WODM_WRITE
)
1558 memcpy((LPSTR
)wh16
+ sizeof(WAVEHDR
), wh32
->lpData
, wh32
->dwBufferLength
);
1560 *lpParam1
= seg_ptr
+ sizeof(LPWAVEHDR
);
1561 *lpParam2
= sizeof(WAVEHDR
);
1562 /* dwBufferLength can be reduced between prepare & write */
1563 if (wMsg
== WODM_WRITE
&& wh16
->dwBufferLength
< wh32
->dwBufferLength
) {
1564 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
1565 wh16
->dwBufferLength
, wh32
->dwBufferLength
);
1567 wh16
->dwBufferLength
= wh32
->dwBufferLength
;
1568 ret
= WINMM_MAP_OKMEM
;
1571 case DRVM_MAPPER_STATUS
:
1573 LPDWORD p32
= (LPDWORD
)*lpParam2
;
1574 *lpParam2
= MapLS(p32
);
1575 ret
= WINMM_MAP_OKMEM
;
1579 FIXME("NIY: no conversion yet\n");
1580 ret
= WINMM_MAP_MSGERROR
;
1586 /**************************************************************************
1587 * MMDRV_WaveOut_UnMap32WTo16 [internal]
1589 static WINMM_MapType
MMDRV_WaveOut_UnMap32WTo16(UINT wMsg
, LPDWORD lpdwUser
, DWORD_PTR
* lpParam1
, DWORD_PTR
* lpParam2
, MMRESULT fn_ret
)
1595 case WODM_BREAKLOOP
:
1597 case WODM_GETNUMDEVS
:
1602 case WODM_SETPLAYBACKRATE
:
1603 case WODM_SETVOLUME
:
1607 case WODM_GETDEVCAPS
:
1609 LPWAVEOUTCAPS16 woc16
= MapSL(*lpParam1
);
1610 LPSTR ptr
= (LPSTR
)woc16
- sizeof(LPWAVEOUTCAPSW
);
1611 LPWAVEOUTCAPSW woc32
= *(LPWAVEOUTCAPSW
*)ptr
;
1613 woc32
->wMid
= woc16
->wMid
;
1614 woc32
->wPid
= woc16
->wPid
;
1615 woc32
->vDriverVersion
= woc16
->vDriverVersion
;
1616 WideCharToMultiByte( CP_ACP
, 0, woc32
->szPname
, -1, woc16
->szPname
,
1617 sizeof(woc16
->szPname
), NULL
, NULL
);
1618 woc32
->dwFormats
= woc16
->dwFormats
;
1619 woc32
->wChannels
= woc16
->wChannels
;
1620 woc32
->dwSupport
= woc16
->dwSupport
;
1621 UnMapLS( *lpParam1
);
1622 HeapFree( GetProcessHeap(), 0, ptr
);
1627 FIXME("NIY: no conversion yet\n");
1628 ret
= WINMM_MAP_MSGERROR
;
1630 case WODM_GETPLAYBACKRATE
:
1631 FIXME("NIY: no conversion yet\n");
1632 ret
= WINMM_MAP_MSGERROR
;
1636 LPMMTIME16 mmt16
= MapSL(*lpParam1
);
1637 LPSTR ptr
= (LPSTR
)mmt16
- sizeof(LPMMTIME
);
1638 LPMMTIME mmt32
= *(LPMMTIME
*)ptr
;
1640 MMSYSTEM_MMTIME16to32(mmt32
, mmt16
);
1641 UnMapLS( *lpParam1
);
1642 HeapFree( GetProcessHeap(), 0, ptr
);
1648 LPWAVEOPENDESC16 wod16
= MapSL(*lpParam1
);
1649 LPSTR ptr
= (LPSTR
)wod16
- sizeof(LPWAVEOPENDESC
) - 2*sizeof(DWORD
);
1650 LPWAVEOPENDESC wod32
= *(LPWAVEOPENDESC
*)ptr
;
1652 wod32
->uMappedDeviceID
= wod16
->uMappedDeviceID
;
1653 **(DWORD
**)(ptr
+ sizeof(LPWAVEOPENDESC
)) = *(LPDWORD
)(ptr
+ sizeof(LPWAVEOPENDESC
) + sizeof(DWORD
));
1654 UnMapLS( *lpParam1
);
1655 HeapFree( GetProcessHeap(), 0, ptr
);
1660 case WODM_UNPREPARE
:
1663 LPWAVEHDR wh16
= MapSL(*lpParam1
);
1664 LPSTR ptr
= (LPSTR
)wh16
- sizeof(LPWAVEHDR
);
1665 LPWAVEHDR wh32
= *(LPWAVEHDR
*)ptr
;
1667 assert(wh32
->lpNext
== wh16
);
1668 wh32
->dwBytesRecorded
= wh16
->dwBytesRecorded
;
1669 wh32
->dwUser
= wh16
->dwUser
;
1670 wh32
->dwFlags
= wh16
->dwFlags
;
1671 wh32
->dwLoops
= wh16
->dwLoops
;
1673 UnMapLS( *lpParam1
);
1674 if (wMsg
== WODM_UNPREPARE
&& fn_ret
== MMSYSERR_NOERROR
) {
1675 HeapFree( GetProcessHeap(), 0, ptr
);
1681 case WODM_GETVOLUME
:
1682 FIXME("NIY: no conversion yet\n");
1683 ret
= WINMM_MAP_MSGERROR
;
1685 case DRVM_MAPPER_STATUS
:
1687 UnMapLS( *lpParam2
);
1692 FIXME("NIY: no conversion yet\n");
1693 ret
= WINMM_MAP_MSGERROR
;
1699 /**************************************************************************
1700 * MMDRV_WaveOut_Callback [internal]
1702 static void CALLBACK
MMDRV_WaveOut_Callback(HDRVR hDev
, UINT uMsg
, DWORD_PTR dwInstance
, DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
1704 LPWINE_MLD mld
= (LPWINE_MLD
)dwInstance
;
1709 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
1712 if (mld
->bFrom32
&& !MMDRV_Is32(mld
->mmdIndex
)) {
1713 /* initial map is: 32 => 16 */
1714 LPWAVEHDR wh16
= MapSL(dwParam1
);
1715 LPWAVEHDR wh32
= *(LPWAVEHDR
*)((LPSTR
)wh16
- sizeof(LPWAVEHDR
));
1717 dwParam1
= (DWORD
)wh32
;
1718 wh32
->dwFlags
= wh16
->dwFlags
;
1719 } else if (!mld
->bFrom32
&& MMDRV_Is32(mld
->mmdIndex
)) {
1720 /* initial map is: 16 => 32 */
1721 LPWAVEHDR wh32
= (LPWAVEHDR
)(dwParam1
);
1722 SEGPTR segwh16
= *(SEGPTR
*)((LPSTR
)wh32
- sizeof(LPWAVEHDR
));
1723 LPWAVEHDR wh16
= MapSL(segwh16
);
1725 dwParam1
= (DWORD
)segwh16
;
1726 wh16
->dwFlags
= wh32
->dwFlags
;
1728 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
1731 ERR("Unknown msg %u\n", uMsg
);
1734 MMDRV_Callback(mld
, hDev
, uMsg
, dwParam1
, dwParam2
);
1737 /* =================================
1738 * M A P P E R S H A N D L I N G
1739 * ================================= */
1741 static LRESULT
MMDRV_CallMMDrvFunc16(DWORD fp16
, WORD dev
, WORD msg
, LONG instance
,
1749 args
[5] = HIWORD(instance
);
1750 args
[4] = LOWORD(instance
);
1751 args
[3] = HIWORD(lp1
);
1752 args
[2] = LOWORD(lp1
);
1753 args
[1] = HIWORD(lp2
);
1754 args
[0] = LOWORD(lp2
);
1755 WOWCallback16Ex( fp16
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
1759 /**************************************************************************
1760 * MMDRV_GetDescription16 [internal]
1762 static BOOL
MMDRV_GetDescription16(const char* fname
, char* buf
, int buflen
)
1770 if ((hFile
= OpenFile(fname
, &ofs
, OF_READ
| OF_SHARE_DENY_WRITE
)) == HFILE_ERROR
) {
1771 ERR("Can't open file %s (builtin driver ?)\n", fname
);
1775 #define E(_x) do {TRACE _x;goto theEnd;} while(0)
1777 if (_lread(hFile
, &w
, 2) != 2) E(("Can't read sig\n"));
1778 if (w
!= ('Z' * 256 + 'M')) E(("Bad sig %04x\n", w
));
1779 if (_llseek(hFile
, 0x3C, SEEK_SET
) < 0) E(("Can't seek to ext header offset\n"));
1780 if (_lread(hFile
, &dw
, 4) != 4) E(("Can't read ext header offset\n"));
1781 if (_llseek(hFile
, dw
+ 0x2C, SEEK_SET
) < 0) E(("Can't seek to ext header.nr table %u\n", dw
+0x2C));
1782 if (_lread(hFile
, &dw
, 4) != 4) E(("Can't read nr table offset\n"));
1783 if (_llseek(hFile
, dw
, SEEK_SET
) < 0) E(("Can't seek to nr table %u\n", dw
));
1784 if (_lread(hFile
, buf
, 1) != 1) E(("Can't read descr length\n"));
1785 buflen
= min((int)(unsigned)(BYTE
)buf
[0], buflen
- 1);
1786 if (_lread(hFile
, buf
, buflen
) != buflen
) E(("Can't read descr (%d)\n", buflen
));
1789 TRACE("Got '%s' [%d]\n", buf
, buflen
);
1795 /******************************************************************
1796 * MMDRV_LoadMMDrvFunc16
1799 unsigned MMDRV_LoadMMDrvFunc16(LPCSTR drvName
, LPWINE_DRIVER d
,
1800 LPWINE_MM_DRIVER lpDrv
)
1802 WINEMM_msgFunc16 func
;
1806 * DESCRIPTION 'wave,aux,mixer:Creative Labs Sound Blaster 16 Driver'
1807 * The beginning of the module description indicates the driver supports
1808 * waveform, auxiliary, and mixer devices. Use one of the following
1809 * device-type names, followed by a colon (:) to indicate the type of
1810 * device your driver supports. If the driver supports more than one
1811 * type of device, separate each device-type name with a comma (,).
1813 * wave for waveform audio devices
1814 * wavemapper for wave mappers
1815 * midi for MIDI audio devices
1816 * midimapper for midi mappers
1817 * aux for auxiliary audio devices
1818 * mixer for mixer devices
1821 if (d
->d
.d16
.hDriver16
) {
1822 HMODULE16 hMod16
= GetDriverModuleHandle16(d
->d
.d16
.hDriver16
);
1824 #define AA(_h,_w,_x,_y,_z) \
1825 func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
1827 { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \
1828 TRACE("Got %d bit func '%s'\n", _y, #_x); }
1830 #define A(_x,_y) AA(hMod16,_x,_y,16,GetProcAddress16)
1831 A(MMDRV_AUX
, auxMessage
);
1832 A(MMDRV_MIXER
, mxdMessage
);
1833 A(MMDRV_MIDIIN
, midMessage
);
1834 A(MMDRV_MIDIOUT
,modMessage
);
1835 A(MMDRV_WAVEIN
, widMessage
);
1836 A(MMDRV_WAVEOUT
,wodMessage
);
1840 if (TRACE_ON(winmm
)) {
1841 if (MMDRV_GetDescription16(drvName
, buffer
, sizeof(buffer
)))
1842 TRACE("%s => %s\n", drvName
, buffer
);
1844 TRACE("%s => No description\n", drvName
);
1850 /* =================================
1852 * ================================= */
1855 /* FIXME: this code is kept for not yet implemented optimisation for an application
1856 * using the 32A MCI interface and calling a 16 bit driver.
1857 * For now, we're doing two conversions:
1858 * - 32A => 32W (in 32 bit MCI code)
1859 * - 32W => 16 in this file
1864 * 0001 squeeze signed 4 bytes to 2 bytes *( LPINT16)D = ( INT16)*( LPINT16)S; D += 2; S += 4
1865 * 0010 squeeze unsigned 4 bytes to 2 bytes *(LPUINT16)D = (UINT16)*(LPUINT16)S; D += 2; S += 4
1868 * 0110 zero 4 bytes *(DWORD)D = 0 D += 4; S += 4
1869 * 0111 copy string *(LPSTR*)D = seg dup(*(LPSTR*)S) D += 4; S += 4
1870 * 1xxx copy xxx + 1 bytes memcpy(D, S, xxx + 1); D += xxx+1; S += xxx+1
1873 /**************************************************************************
1874 * MCI_MsgMapper32ATo16_Create [internal]
1876 * Helper for MCI_MapMsg32ATo16.
1877 * Maps the 32 bit pointer (*ptr), of size bytes, to an allocated 16 bit
1878 * segmented pointer.
1879 * map contains a list of action to be performed for the mapping (see list
1881 * if keep is TRUE, keeps track of in 32 bit ptr in allocated 16 bit area.
1883 static WINMM_MapType
MCI_MsgMapper32ATo16_Create(void** ptr
, int size16
, DWORD map
, BOOLEAN keep
)
1885 void* lp
= HeapAlloc( GetProcessHeap(), 0, (keep
? sizeof(void**) : 0) + size16
);
1889 return WINMM_MAP_NOMEM
;
1891 p32
= (LPBYTE
)(*ptr
);
1894 p16
= (LPBYTE
)lp
+ sizeof(void**);
1895 *ptr
= (char*)MapLS(lp
) + sizeof(void**);
1898 *ptr
= (void*)MapLS(lp
);
1902 memcpy(p16
, p32
, size16
);
1910 sz
= (nibble
& 7) + 1;
1911 memcpy(p16
, p32
, sz
);
1914 size16
-= sz
; /* DEBUG only */
1918 *(LPINT16
)p16
= *(LPINT
)p32
;
1919 p16
+= sizeof(INT16
);
1921 size16
-= sizeof(INT16
);
1924 *(LPUINT16
)p16
= *(LPUINT
)p32
;
1925 p16
+= sizeof(UINT16
);
1926 p32
+= sizeof(UINT
);
1927 size16
-= sizeof(UINT16
);
1931 p16
+= sizeof(DWORD
);
1932 p32
+= sizeof(DWORD
);
1933 size16
-= sizeof(DWORD
);
1936 *(SEGPTR
*)p16
= MapLS( *(LPSTR
*)p32
);
1937 p16
+= sizeof(SEGPTR
);
1938 p32
+= sizeof(LPSTR
);
1939 size16
-= sizeof(SEGPTR
);
1942 FIXME("Unknown nibble for mapping (%x)\n", nibble
);
1947 if (size16
!= 0) /* DEBUG only */
1948 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
1950 return WINMM_MAP_OKMEM
;
1953 /**************************************************************************
1954 * MCI_MsgMapper32ATo16_Destroy [internal]
1956 * Helper for MCI_UnMapMsg32ATo16.
1958 static WINMM_MapType
MCI_MsgMapper32ATo16_Destroy(void* ptr
, int size16
, DWORD map
, BOOLEAN kept
)
1961 void* msg16
= MapSL((SEGPTR
)ptr
);
1966 UnMapLS( (SEGPTR
)ptr
);
1968 alloc
= (char*)msg16
- sizeof(void**);
1969 p32
= *(void**)alloc
;
1973 memcpy(p32
, p16
, size16
);
1978 memcpy(p32
, p16
, (nibble
& 7) + 1);
1979 p16
+= (nibble
& 7) + 1;
1980 p32
+= (nibble
& 7) + 1;
1981 size16
-= (nibble
& 7) + 1;
1985 *(LPINT
)p32
= *(LPINT16
)p16
;
1986 p16
+= sizeof(INT16
);
1988 size16
-= sizeof(INT16
);
1991 *(LPUINT
)p32
= *(LPUINT16
)p16
;
1992 p16
+= sizeof(UINT16
);
1993 p32
+= sizeof(UINT
);
1994 size16
-= sizeof(UINT16
);
1997 p16
+= sizeof(UINT
);
1998 p32
+= sizeof(UINT
);
1999 size16
-= sizeof(UINT
);
2002 UnMapLS( *(SEGPTR
*)p16
);
2003 p16
+= sizeof(SEGPTR
);
2004 p32
+= sizeof(char*);
2005 size16
-= sizeof(SEGPTR
);
2008 FIXME("Unknown nibble for mapping (%x)\n", nibble
);
2013 if (size16
!= 0) /* DEBUG only */
2014 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
2020 HeapFree( GetProcessHeap(), 0, alloc
);
2022 return WINMM_MAP_OK
;
2025 /**************************************************************************
2026 * MCI_MapMsg32ATo16 [internal]
2028 * Map a 32-A bit MCI message to a 16 bit MCI message.
2030 static WINMM_MapType
MCI_MapMsg32ATo16(WORD uDevType
, WORD wMsg
, DWORD dwFlags
, DWORD
* lParam
)
2033 BOOLEAN keep
= FALSE
;
2037 return WINMM_MAP_OK
;
2039 /* FIXME: to add also (with seg/linear modifications to do):
2040 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
2041 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
2045 size
= sizeof(MCI_BREAK_PARMS
);
2047 /* case MCI_CAPTURE */
2049 case MCI_CLOSE_DRIVER
:
2051 size
= sizeof(MCI_GENERIC_PARMS
);
2053 /* case MCI_COPY: */
2056 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_CUE_PARMS
); break;
2057 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_CUE_PARMS); break;*/ FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2058 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2064 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_DELETE_PARMS16
); map
= 0x0F1111FB; break;
2065 case MCI_DEVTYPE_WAVEFORM_AUDIO
:size
= sizeof(MCI_WAVE_DELETE_PARMS
); break;
2066 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2069 /* case MCI_ESCAPE: */
2072 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_FREEZE_PARMS
); map
= 0x0001111B; break;
2073 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS
); map
= 0x0001111B; break;
2074 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2077 case MCI_GETDEVCAPS
:
2079 size
= sizeof(MCI_GETDEVCAPS_PARMS
);
2081 /* case MCI_INDEX: */
2084 LPMCI_INFO_PARMSA mip32a
= (LPMCI_INFO_PARMSA
)(*lParam
);
2085 LPMCI_INFO_PARMS16 mip16
;
2088 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_INFO_PARMS16
); break;
2089 default: size
= sizeof(MCI_INFO_PARMS16
); break;
2091 mip16
= HeapAlloc( GetProcessHeap(), 0, size
);
2094 mip16
->dwCallback
= mip32a
->dwCallback
;
2095 mip16
->lpstrReturn
= MapLS( mip32a
->lpstrReturn
);
2096 mip16
->dwRetSize
= mip32a
->dwRetSize
;
2097 if (uDevType
== MCI_DEVTYPE_DIGITAL_VIDEO
) {
2098 ((LPMCI_DGV_INFO_PARMS16
)mip16
)->dwItem
= ((LPMCI_DGV_INFO_PARMSA
)mip32a
)->dwItem
;
2101 return WINMM_MAP_NOMEM
;
2103 *lParam
= MapLS(mip16
);
2105 return WINMM_MAP_OKMEM
;
2106 /* case MCI_MARK: */
2107 /* case MCI_MONITOR: */
2109 case MCI_OPEN_DRIVER
:
2111 LPMCI_OPEN_PARMSA mop32a
= (LPMCI_OPEN_PARMSA
)(*lParam
);
2112 char* ptr
= HeapAlloc( GetProcessHeap(), 0,
2113 sizeof(LPMCI_OPEN_PARMSA
) + sizeof(MCI_OPEN_PARMS16
) + 2 * sizeof(DWORD
));
2114 LPMCI_OPEN_PARMS16 mop16
;
2118 *(LPMCI_OPEN_PARMSA
*)(ptr
) = mop32a
;
2119 mop16
= (LPMCI_OPEN_PARMS16
)(ptr
+ sizeof(LPMCI_OPEN_PARMSA
));
2120 mop16
->dwCallback
= mop32a
->dwCallback
;
2121 mop16
->wDeviceID
= mop32a
->wDeviceID
;
2122 if (dwFlags
& MCI_OPEN_TYPE
) {
2123 if (dwFlags
& MCI_OPEN_TYPE_ID
) {
2124 /* dword "transparent" value */
2125 mop16
->lpstrDeviceType
= (SEGPTR
)mop32a
->lpstrDeviceType
;
2128 mop16
->lpstrDeviceType
= MapLS( mop32a
->lpstrDeviceType
);
2132 mop16
->lpstrDeviceType
= 0;
2134 if (dwFlags
& MCI_OPEN_ELEMENT
) {
2135 if (dwFlags
& MCI_OPEN_ELEMENT_ID
) {
2136 mop16
->lpstrElementName
= (SEGPTR
)mop32a
->lpstrElementName
;
2138 mop16
->lpstrElementName
= MapLS( mop32a
->lpstrElementName
);
2141 mop16
->lpstrElementName
= 0;
2143 if (dwFlags
& MCI_OPEN_ALIAS
) {
2144 mop16
->lpstrAlias
= MapLS( mop32a
->lpstrAlias
);
2146 mop16
->lpstrAlias
= 0;
2148 /* copy extended information if any...
2149 * FIXME: this may seg fault if initial structure does not contain them and
2150 * the reads after msip16 fail under LDT limits...
2151 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
2152 * should not take care of extended parameters, and should be used by MCI_Open
2153 * to fetch uDevType. When, this is known, the mapping for sending the
2154 * MCI_OPEN_DRIVER shall be done depending on uDevType.
2156 memcpy(mop16
+ 1, mop32a
+ 1, 2 * sizeof(DWORD
));
2158 return WINMM_MAP_NOMEM
;
2160 *lParam
= (LPARAM
)MapLS(ptr
) + sizeof(LPMCI_OPEN_PARMSA
);
2162 return WINMM_MAP_OKMEM
;
2163 /* case MCI_PASTE:*/
2165 size
= sizeof(MCI_GENERIC_PARMS
);
2168 size
= sizeof(MCI_PLAY_PARMS
);
2172 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECT_PARMS16
); map
= 0x0001111B; break;
2173 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS
); map
= 0x0001111B; break;
2174 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2178 size
= sizeof(MCI_GENERIC_PARMS
);
2182 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECORD_PARMS16
); map
= 0x0F1111FB; break;
2183 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_RECORD_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2184 default: size
= sizeof(MCI_RECORD_PARMS
); break;
2188 size
= sizeof(MCI_GENERIC_PARMS
);
2192 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_SEEK_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2193 default: size
= sizeof(MCI_SEEK_PARMS
); break;
2198 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_SET_PARMS
); break;
2199 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_SET_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2200 case MCI_DEVTYPE_SEQUENCER
: size
= sizeof(MCI_SEQ_SET_PARMS
); break;
2201 /* FIXME: normally the 16 and 32 bit structures are byte by byte aligned,
2202 * so not doing anything should work...
2204 case MCI_DEVTYPE_WAVEFORM_AUDIO
:size
= sizeof(MCI_WAVE_SET_PARMS
); break;
2205 default: size
= sizeof(MCI_SET_PARMS
); break;
2210 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_SETAUDIO_PARMS16
);map
= 0x0000077FF; break;
2211 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2212 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2215 /* case MCI_SETTIMECODE:*/
2216 /* case MCI_SIGNAL:*/
2217 /* case MCI_SOUND:*/
2219 size
= sizeof(MCI_SET_PARMS
);
2225 * don't know if buffer for value is the one passed through lpstrDevice
2226 * or is provided by MCI driver.
2227 * Assuming solution 2: provided by MCI driver, so zeroing on entry
2229 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_STATUS_PARMS16
); map
= 0x0B6FF; break;
2230 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2231 default: size
= sizeof(MCI_STATUS_PARMS
); break;
2236 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_STEP_PARMS
); break;
2237 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_STEP_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2238 case MCI_DEVTYPE_VIDEODISC
: size
= sizeof(MCI_VD_STEP_PARMS
); break;
2239 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2243 size
= sizeof(MCI_SET_PARMS
);
2247 LPMCI_SYSINFO_PARMSA msip32a
= (LPMCI_SYSINFO_PARMSA
)(*lParam
);
2248 LPMCI_SYSINFO_PARMS16 msip16
;
2249 char* ptr
= HeapAlloc( GetProcessHeap(), 0,
2250 sizeof(LPMCI_SYSINFO_PARMSA
) + sizeof(MCI_SYSINFO_PARMS16
) );
2253 *(LPMCI_SYSINFO_PARMSA
*)(ptr
) = msip32a
;
2254 msip16
= (LPMCI_SYSINFO_PARMS16
)(ptr
+ sizeof(LPMCI_SYSINFO_PARMSA
));
2256 msip16
->dwCallback
= msip32a
->dwCallback
;
2257 msip16
->lpstrReturn
= MapLS( msip32a
->lpstrReturn
);
2258 msip16
->dwRetSize
= msip32a
->dwRetSize
;
2259 msip16
->dwNumber
= msip32a
->dwNumber
;
2260 msip16
->wDeviceType
= msip32a
->wDeviceType
;
2262 return WINMM_MAP_NOMEM
;
2264 *lParam
= (LPARAM
)MapLS(ptr
) + sizeof(LPMCI_SYSINFO_PARMSA
);
2266 return WINMM_MAP_OKMEM
;
2267 /* case MCI_UNDO: */
2270 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECT_PARMS16
); map
= 0x0001111B; break;
2271 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS16
); map
= 0x0001111B; break;
2272 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2277 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_UPDATE_PARMS16
); map
= 0x000B1111B; break;
2278 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2283 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECT_PARMS16
); map
= 0x0001111B; keep
= TRUE
; break;
2284 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS16
); map
= 0x0001111B; keep
= TRUE
; break;
2285 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2290 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_WINDOW_PARMS16
); if (dwFlags
& MCI_DGV_WINDOW_TEXT
) map
= 0x7FB; break;
2291 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_WINDOW_PARMS16
); if (dwFlags
& MCI_OVLY_WINDOW_TEXT
) map
= 0x7FB; break;
2292 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
2297 LPMCI_OPEN_DRIVER_PARMSA modp32a
= (LPMCI_OPEN_DRIVER_PARMSA
)(*lParam
);
2298 LPMCI_OPEN_DRIVER_PARMS16 modp16
;
2299 char *ptr
= HeapAlloc( GetProcessHeap(), 0,
2300 sizeof(LPMCI_OPEN_DRIVER_PARMSA
) + sizeof(MCI_OPEN_DRIVER_PARMS16
));
2303 *(LPMCI_OPEN_DRIVER_PARMSA
*)(ptr
) = modp32a
;
2304 modp16
= (LPMCI_OPEN_DRIVER_PARMS16
)(ptr
+ sizeof(LPMCI_OPEN_DRIVER_PARMSA
));
2305 modp16
->wDeviceID
= modp32a
->wDeviceID
;
2306 modp16
->lpstrParams
= MapLS( modp32a
->lpstrParams
);
2307 /* other fields are gonna be filled by the driver, don't copy them */
2309 return WINMM_MAP_NOMEM
;
2311 *lParam
= (LPARAM
)MapLS(ptr
) + sizeof(LPMCI_OPEN_DRIVER_PARMSA
);
2313 return WINMM_MAP_OKMEM
;
2320 case DRV_QUERYCONFIGURE
:
2323 case DRV_EXITSESSION
:
2324 case DRV_EXITAPPLICATION
:
2326 return WINMM_MAP_OK
;
2329 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg
));
2330 return WINMM_MAP_MSGERROR
;
2332 return MCI_MsgMapper32ATo16_Create((void**)lParam
, size
, map
, keep
);
2335 /**************************************************************************
2336 * MCI_UnMapMsg32ATo16 [internal]
2338 static WINMM_MapType
MCI_UnMapMsg32ATo16(WORD uDevType
, WORD wMsg
, DWORD dwFlags
, DWORD lParam
)
2341 BOOLEAN kept
= FALSE
; /* there is no need to compute size when kept is FALSE */
2347 /* case MCI_CAPTURE */
2349 case MCI_CLOSE_DRIVER
:
2352 /* case MCI_COPY: */
2358 /* case MCI_ESCAPE: */
2361 case MCI_GETDEVCAPS
:
2363 size
= sizeof(MCI_GETDEVCAPS_PARMS
);
2365 /* case MCI_INDEX: */
2368 LPMCI_INFO_PARMS16 mip16
= (LPMCI_INFO_PARMS16
)MapSL(lParam
);
2370 UnMapLS( mip16
->lpstrReturn
);
2371 HeapFree( GetProcessHeap(), 0, mip16
);
2373 return WINMM_MAP_OK
;
2374 /* case MCI_MARK: */
2375 /* case MCI_MONITOR: */
2377 case MCI_OPEN_DRIVER
:
2379 LPMCI_OPEN_PARMS16 mop16
= (LPMCI_OPEN_PARMS16
)MapSL(lParam
);
2380 LPMCI_OPEN_PARMSA mop32a
= *(LPMCI_OPEN_PARMSA
*)((char*)mop16
- sizeof(LPMCI_OPEN_PARMSA
));
2382 mop32a
->wDeviceID
= mop16
->wDeviceID
;
2383 if ((dwFlags
& MCI_OPEN_TYPE
) && !(dwFlags
& MCI_OPEN_TYPE_ID
))
2384 UnMapLS( mop16
->lpstrDeviceType
);
2385 if ((dwFlags
& MCI_OPEN_ELEMENT
) && !(dwFlags
& MCI_OPEN_ELEMENT_ID
))
2386 UnMapLS( mop16
->lpstrElementName
);
2387 if (dwFlags
& MCI_OPEN_ALIAS
)
2388 UnMapLS( mop16
->lpstrAlias
);
2389 HeapFree( GetProcessHeap(), 0, (char*)mop16
- sizeof(LPMCI_OPEN_PARMSA
) );
2391 return WINMM_MAP_OK
;
2392 /* case MCI_PASTE:*/
2411 case MCI_DEVTYPE_DIGITAL_VIDEO
: map
= 0x0000077FF; break;
2412 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2415 /* case MCI_SETTIMECODE:*/
2416 /* case MCI_SIGNAL:*/
2417 /* case MCI_SOUND:*/
2423 case MCI_DEVTYPE_DIGITAL_VIDEO
:
2425 LPMCI_DGV_STATUS_PARMS16 mdsp16
= (LPMCI_DGV_STATUS_PARMS16
)MapSL(lParam
);
2426 LPMCI_DGV_STATUS_PARMSA mdsp32a
= *(LPMCI_DGV_STATUS_PARMSA
*)((char*)mdsp16
- sizeof(LPMCI_DGV_STATUS_PARMSA
));
2430 mdsp32a
->dwReturn
= mdsp16
->dwReturn
;
2431 if (dwFlags
& MCI_DGV_STATUS_DISKSPACE
) {
2432 TRACE("MCI_STATUS (DGV) lpstrDrive=%08lx\n", mdsp16
->lpstrDrive
);
2433 TRACE("MCI_STATUS (DGV) lpstrDrive=%s\n", (LPSTR
)MapSL(mdsp16
->lpstrDrive
));
2434 UnMapLS( mdsp16
->lpstrDrive
);
2436 HeapFree( GetProcessHeap(), 0, (char*)mdsp16
- sizeof(LPMCI_DGV_STATUS_PARMSA
) );
2438 return WINMM_MAP_NOMEM
;
2441 return WINMM_MAP_OKMEM
;
2442 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
2443 default: size
= sizeof(MCI_STATUS_PARMS
); break;
2452 LPMCI_SYSINFO_PARMS16 msip16
= (LPMCI_SYSINFO_PARMS16
)MapSL(lParam
);
2453 LPMCI_SYSINFO_PARMSA msip32a
= *(LPMCI_SYSINFO_PARMSA
*)((char*)msip16
- sizeof(LPMCI_SYSINFO_PARMSA
));
2457 msip16
->dwCallback
= msip32a
->dwCallback
;
2458 UnMapLS( msip16
->lpstrReturn
);
2459 HeapFree( GetProcessHeap(), 0, (char*)msip16
- sizeof(LPMCI_SYSINFO_PARMSA
) );
2461 return WINMM_MAP_NOMEM
;
2464 return WINMM_MAP_OKMEM
;
2465 /* case MCI_UNDO: */
2472 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECT_PARMS16
); map
= 0x0001111B; kept
= TRUE
; break;
2473 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS16
); map
= 0x0001111B; kept
= TRUE
; break;
2479 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_WINDOW_PARMS16
); if (dwFlags
& MCI_DGV_WINDOW_TEXT
) map
= 0x7666; break;
2480 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_WINDOW_PARMS16
); if (dwFlags
& MCI_OVLY_WINDOW_TEXT
) map
= 0x7666; break;
2483 /* FIXME: see map function */
2488 LPMCI_OPEN_DRIVER_PARMS16 modp16
= (LPMCI_OPEN_DRIVER_PARMS16
)MapSL(lParam
);
2489 LPMCI_OPEN_DRIVER_PARMSA modp32a
= *(LPMCI_OPEN_DRIVER_PARMSA
*)((char*)modp16
- sizeof(LPMCI_OPEN_DRIVER_PARMSA
));
2492 modp32a
->wCustomCommandTable
= modp16
->wCustomCommandTable
;
2493 modp32a
->wType
= modp16
->wType
;
2494 UnMapLS( modp16
->lpstrParams
);
2495 HeapFree( GetProcessHeap(), 0, (char *)modp16
- sizeof(LPMCI_OPEN_DRIVER_PARMSA
) );
2497 return WINMM_MAP_OK
;
2504 case DRV_QUERYCONFIGURE
:
2507 case DRV_EXITSESSION
:
2508 case DRV_EXITAPPLICATION
:
2510 FIXME("This is a hack\n");
2511 return WINMM_MAP_OK
;
2513 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg
));
2514 return WINMM_MAP_MSGERROR
;
2516 return MCI_MsgMapper32ATo16_Destroy((void*)lParam
, size
, map
, kept
);
2520 /**************************************************************************
2521 * MCI_MapMsg16To32W [internal]
2523 static WINMM_MapType
MCI_MapMsg16To32W(WORD uDevType
, WORD wMsg
, DWORD dwFlags
, DWORD_PTR
* lParam
)
2526 return WINMM_MAP_OK
;
2527 /* FIXME: to add also (with seg/linear modifications to do):
2528 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
2529 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
2532 /* case MCI_CAPTURE */
2534 case MCI_CLOSE_DRIVER
:
2541 case MCI_GETDEVCAPS
:
2542 /* case MCI_INDEX: */
2543 /* case MCI_MARK: */
2544 /* case MCI_MONITOR: */
2554 /* case MCI_SETTIMECODE:*/
2555 /* case MCI_SIGNAL:*/
2557 case MCI_STATUS
: /* FIXME: is wrong for digital video */
2560 /* case MCI_UNDO: */
2564 *lParam
= (DWORD
)MapSL(*lParam
);
2565 return WINMM_MAP_OK
;
2567 /* in fact, I would also need the dwFlags... to see
2568 * which members of lParam are effectively used
2570 *lParam
= (DWORD
)MapSL(*lParam
);
2571 FIXME("Current mapping may be wrong\n");
2575 LPMCI_BREAK_PARMS mbp32
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_BREAK_PARMS
));
2576 LPMCI_BREAK_PARMS16 mbp16
= MapSL(*lParam
);
2579 mbp32
->dwCallback
= mbp16
->dwCallback
;
2580 mbp32
->nVirtKey
= mbp16
->nVirtKey
;
2581 mbp32
->hwndBreak
= HWND_32(mbp16
->hwndBreak
);
2583 return WINMM_MAP_NOMEM
;
2585 *lParam
= (DWORD
)mbp32
;
2587 return WINMM_MAP_OKMEM
;
2590 LPMCI_VD_ESCAPE_PARMSW mvep32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_VD_ESCAPE_PARMSW
));
2591 LPMCI_VD_ESCAPE_PARMS16 mvep16
= MapSL(*lParam
);
2594 mvep32w
->dwCallback
= mvep16
->dwCallback
;
2595 mvep32w
->lpstrCommand
= MCI_strdupAtoW(MapSL(mvep16
->lpstrCommand
));
2597 return WINMM_MAP_NOMEM
;
2599 *lParam
= (DWORD
)mvep32w
;
2601 return WINMM_MAP_OKMEM
;
2604 LPMCI_INFO_PARMSW mip32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16
) + sizeof(MCI_INFO_PARMSW
));
2605 LPMCI_INFO_PARMS16 mip16
= MapSL(*lParam
);
2607 /* FIXME this is wrong if device is of type
2608 * MCI_DEVTYPE_DIGITAL_VIDEO, some members are not mapped
2611 *(LPMCI_INFO_PARMS16
*)(mip32w
) = mip16
;
2612 mip32w
= (LPMCI_INFO_PARMSW
)((char*)mip32w
+ sizeof(LPMCI_INFO_PARMS16
));
2613 mip32w
->dwCallback
= mip16
->dwCallback
;
2614 mip32w
->lpstrReturn
= HeapAlloc(GetProcessHeap(), 0, mip16
->dwRetSize
* sizeof(WCHAR
));
2615 mip32w
->dwRetSize
= mip16
->dwRetSize
* sizeof(WCHAR
);
2617 return WINMM_MAP_NOMEM
;
2619 *lParam
= (DWORD
)mip32w
;
2621 return WINMM_MAP_OKMEM
;
2623 case MCI_OPEN_DRIVER
:
2625 LPMCI_OPEN_PARMSW mop32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16
) + sizeof(MCI_OPEN_PARMSW
) + 2 * sizeof(DWORD
));
2626 LPMCI_OPEN_PARMS16 mop16
= MapSL(*lParam
);
2629 *(LPMCI_OPEN_PARMS16
*)(mop32w
) = mop16
;
2630 mop32w
= (LPMCI_OPEN_PARMSW
)((char*)mop32w
+ sizeof(LPMCI_OPEN_PARMS16
));
2631 mop32w
->dwCallback
= mop16
->dwCallback
;
2632 mop32w
->wDeviceID
= mop16
->wDeviceID
;
2633 if( ( dwFlags
& ( MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
)) == MCI_OPEN_TYPE
)
2634 mop32w
->lpstrDeviceType
= MCI_strdupAtoW(MapSL(mop16
->lpstrDeviceType
));
2636 mop32w
->lpstrDeviceType
= (LPWSTR
) mop16
->lpstrDeviceType
;
2637 if( ( dwFlags
& ( MCI_OPEN_ELEMENT
| MCI_OPEN_ELEMENT_ID
)) == MCI_OPEN_ELEMENT
)
2638 mop32w
->lpstrElementName
= MCI_strdupAtoW(MapSL(mop16
->lpstrElementName
));
2640 mop32w
->lpstrElementName
= (LPWSTR
) mop16
->lpstrElementName
;
2641 if( ( dwFlags
& MCI_OPEN_ALIAS
))
2642 mop32w
->lpstrAlias
= MCI_strdupAtoW(MapSL(mop16
->lpstrAlias
));
2644 mop32w
->lpstrAlias
= (LPWSTR
) mop16
->lpstrAlias
;
2645 /* copy extended information if any...
2646 * FIXME: this may seg fault if initial structure does not contain them and
2647 * the reads after msip16 fail under LDT limits...
2648 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
2649 * should not take care of extended parameters, and should be used by MCI_Open
2650 * to fetch uDevType. When, this is known, the mapping for sending the
2651 * MCI_OPEN_DRIVER shall be done depending on uDevType.
2653 memcpy(mop32w
+ 1, mop16
+ 1, 2 * sizeof(DWORD
));
2655 return WINMM_MAP_NOMEM
;
2657 *lParam
= (DWORD
)mop32w
;
2659 return WINMM_MAP_OKMEM
;
2662 LPMCI_SYSINFO_PARMSW msip32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16
) + sizeof(MCI_SYSINFO_PARMSW
));
2663 LPMCI_SYSINFO_PARMS16 msip16
= MapSL(*lParam
);
2666 *(LPMCI_SYSINFO_PARMS16
*)(msip32w
) = msip16
;
2667 msip32w
= (LPMCI_SYSINFO_PARMSW
)((char*)msip32w
+ sizeof(LPMCI_OPEN_PARMS16
));
2668 msip32w
->dwCallback
= msip16
->dwCallback
;
2669 msip32w
->lpstrReturn
= HeapAlloc(GetProcessHeap(), 0, msip16
->dwRetSize
* sizeof(WCHAR
));
2670 msip32w
->dwRetSize
= msip16
->dwRetSize
;
2671 msip32w
->dwNumber
= msip16
->dwNumber
;
2672 msip32w
->wDeviceType
= msip16
->wDeviceType
;
2674 return WINMM_MAP_NOMEM
;
2676 *lParam
= (DWORD
)msip32w
;
2678 return WINMM_MAP_OKMEM
;
2681 LPMCI_SOUND_PARMSW mbp32
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_SOUND_PARMSW
));
2682 LPMCI_SOUND_PARMS16 mbp16
= MapSL(*lParam
);
2685 mbp32
->dwCallback
= mbp16
->dwCallback
;
2686 mbp32
->lpstrSoundName
= MCI_strdupAtoW(MapSL(mbp16
->lpstrSoundName
));
2688 return WINMM_MAP_NOMEM
;
2690 *lParam
= (DWORD
)mbp32
;
2692 return WINMM_MAP_OKMEM
;
2700 case DRV_QUERYCONFIGURE
:
2703 case DRV_EXITSESSION
:
2704 case DRV_EXITAPPLICATION
:
2706 FIXME("This is a hack\n");
2707 return WINMM_MAP_OK
;
2709 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg
));
2711 return WINMM_MAP_MSGERROR
;
2714 /**************************************************************************
2715 * MCI_UnMapMsg16To32W [internal]
2717 static WINMM_MapType
MCI_UnMapMsg16To32W(WORD uDevType
, WORD wMsg
, DWORD dwFlags
, DWORD_PTR lParam
)
2720 /* case MCI_CAPTURE */
2722 case MCI_CLOSE_DRIVER
:
2729 case MCI_GETDEVCAPS
:
2730 /* case MCI_INDEX: */
2731 /* case MCI_MARK: */
2732 /* case MCI_MONITOR: */
2742 /* case MCI_SETTIMECODE:*/
2743 /* case MCI_SIGNAL:*/
2748 /* case MCI_UNDO: */
2752 return WINMM_MAP_OK
;
2755 /* FIXME ?? see Map function */
2756 return WINMM_MAP_OK
;
2759 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
2760 return WINMM_MAP_OK
;
2763 LPMCI_VD_ESCAPE_PARMSW mvep32W
= (LPMCI_VD_ESCAPE_PARMSW
)lParam
;
2764 HeapFree(GetProcessHeap(), 0, (LPVOID
)mvep32W
->lpstrCommand
);
2765 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
2767 return WINMM_MAP_OK
;
2770 LPMCI_INFO_PARMSW mip32w
= (LPMCI_INFO_PARMSW
)lParam
;
2771 LPMCI_INFO_PARMS16 mip16
= *(LPMCI_INFO_PARMS16
*)((char*)mip32w
- sizeof(LPMCI_INFO_PARMS16
));
2773 WideCharToMultiByte(CP_ACP
, 0,
2774 mip32w
->lpstrReturn
, mip32w
->dwRetSize
/ sizeof(WCHAR
),
2775 MapSL(mip16
->lpstrReturn
), mip16
->dwRetSize
,
2777 HeapFree(GetProcessHeap(), 0, (LPVOID
)mip32w
->lpstrReturn
);
2778 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
2780 return WINMM_MAP_OK
;
2783 LPMCI_SYSINFO_PARMSW msip32w
= (LPMCI_SYSINFO_PARMSW
)lParam
;
2784 LPMCI_SYSINFO_PARMS16 msip16
= *(LPMCI_SYSINFO_PARMS16
*)((char*)msip32w
- sizeof(LPMCI_SYSINFO_PARMS16
));
2786 WideCharToMultiByte(CP_ACP
, 0,
2787 msip32w
->lpstrReturn
, msip32w
->dwRetSize
,
2788 MapSL(msip16
->lpstrReturn
), msip16
->dwRetSize
,
2790 HeapFree(GetProcessHeap(), 0, (LPVOID
)msip32w
->lpstrReturn
);
2791 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
2793 return WINMM_MAP_OK
;
2796 LPMCI_SOUND_PARMSW msp32W
= (LPMCI_SOUND_PARMSW
)lParam
;
2797 HeapFree(GetProcessHeap(), 0, (LPVOID
)msp32W
->lpstrSoundName
);
2798 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
2800 return WINMM_MAP_OK
;
2802 case MCI_OPEN_DRIVER
:
2804 LPMCI_OPEN_PARMSW mop32w
= (LPMCI_OPEN_PARMSW
)lParam
;
2805 LPMCI_OPEN_PARMS16 mop16
= *(LPMCI_OPEN_PARMS16
*)((char*)mop32w
- sizeof(LPMCI_OPEN_PARMS16
));
2807 mop16
->wDeviceID
= mop32w
->wDeviceID
;
2808 if( ( dwFlags
& ( MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
)) == MCI_OPEN_TYPE
)
2809 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrDeviceType
);
2810 if( ( dwFlags
& ( MCI_OPEN_ELEMENT
| MCI_OPEN_ELEMENT_ID
)) == MCI_OPEN_ELEMENT
)
2811 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrElementName
);
2812 if( ( dwFlags
& MCI_OPEN_ALIAS
))
2813 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrAlias
);
2814 if (!HeapFree(GetProcessHeap(), 0, (LPVOID
)(lParam
- sizeof(LPMCI_OPEN_PARMS16
))))
2815 FIXME("bad free line=%d\n", __LINE__
);
2817 return WINMM_MAP_OK
;
2825 case DRV_QUERYCONFIGURE
:
2828 case DRV_EXITSESSION
:
2829 case DRV_EXITAPPLICATION
:
2831 FIXME("This is a hack\n");
2832 return WINMM_MAP_OK
;
2834 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg
));
2836 return WINMM_MAP_MSGERROR
;
2841 * 0001 squeeze signed 4 bytes to 2 bytes *( LPINT16)D = ( INT16)*( LPINT16)S; D += 2; S += 4
2842 * 0010 squeeze unsigned 4 bytes to 2 bytes *(LPUINT16)D = (UINT16)*(LPUINT16)S; D += 2; S += 4
2845 * 0110 zero 4 bytes *(DWORD)D = 0 D += 4; S += 4
2846 * 0111 copy string *(LPSTR*)D = seg dup(*(LPSTR*)S) D += 4; S += 4
2847 * 1xxx copy xxx + 1 bytes memcpy(D, S, xxx + 1); D += xxx+1; S += xxx+1
2850 /**************************************************************************
2851 * MCI_MsgMapper32WTo16_Create [internal]
2853 * Helper for MCI_MapMsg32WTo16.
2854 * Maps the 32 bit pointer (*ptr), of size bytes, to an allocated 16 bit
2855 * segmented pointer.
2856 * map contains a list of action to be performed for the mapping (see list
2858 * if keep is TRUE, keeps track of in 32 bit ptr in allocated 16 bit area.
2860 static WINMM_MapType
MCI_MsgMapper32WTo16_Create(void** ptr
, int size16
, DWORD map
, BOOLEAN keep
)
2862 void* lp
= HeapAlloc( GetProcessHeap(), 0, (keep
? sizeof(void**) : 0) + size16
);
2866 return WINMM_MAP_NOMEM
;
2868 p32
= (LPBYTE
)(*ptr
);
2871 p16
= (LPBYTE
)lp
+ sizeof(void**);
2872 *ptr
= (char*)MapLS(lp
) + sizeof(void**);
2875 *ptr
= (void*)MapLS(lp
);
2879 memcpy(p16
, p32
, size16
);
2887 sz
= (nibble
& 7) + 1;
2888 memcpy(p16
, p32
, sz
);
2891 size16
-= sz
; /* DEBUG only */
2895 *(LPINT16
)p16
= *(LPINT
)p32
;
2896 p16
+= sizeof(INT16
);
2898 size16
-= sizeof(INT16
);
2901 *(LPUINT16
)p16
= *(LPUINT
)p32
;
2902 p16
+= sizeof(UINT16
);
2903 p32
+= sizeof(UINT
);
2904 size16
-= sizeof(UINT16
);
2908 p16
+= sizeof(DWORD
);
2909 p32
+= sizeof(DWORD
);
2910 size16
-= sizeof(DWORD
);
2913 *(SEGPTR
*)p16
= MapLS( MCI_strdupWtoA( *(LPCWSTR
*)p32
) );
2914 p16
+= sizeof(SEGPTR
);
2915 p32
+= sizeof(LPSTR
);
2916 size16
-= sizeof(SEGPTR
);
2919 FIXME("Unknown nibble for mapping (%x)\n", nibble
);
2924 if (size16
!= 0) /* DEBUG only */
2925 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
2927 return WINMM_MAP_OKMEM
;
2930 /**************************************************************************
2931 * MCI_MsgMapper32WTo16_Destroy [internal]
2933 * Helper for MCI_UnMapMsg32WTo16.
2935 static WINMM_MapType
MCI_MsgMapper32WTo16_Destroy(void* ptr
, int size16
, DWORD map
, BOOLEAN kept
)
2938 void* msg16
= MapSL((SEGPTR
)ptr
);
2943 UnMapLS( (SEGPTR
)ptr
);
2945 alloc
= (char*)msg16
- sizeof(void**);
2946 p32
= *(void**)alloc
;
2950 memcpy(p32
, p16
, size16
);
2955 memcpy(p32
, p16
, (nibble
& 7) + 1);
2956 p16
+= (nibble
& 7) + 1;
2957 p32
+= (nibble
& 7) + 1;
2958 size16
-= (nibble
& 7) + 1;
2962 *(LPINT
)p32
= *(LPINT16
)p16
;
2963 p16
+= sizeof(INT16
);
2965 size16
-= sizeof(INT16
);
2968 *(LPUINT
)p32
= *(LPUINT16
)p16
;
2969 p16
+= sizeof(UINT16
);
2970 p32
+= sizeof(UINT
);
2971 size16
-= sizeof(UINT16
);
2974 p16
+= sizeof(UINT
);
2975 p32
+= sizeof(UINT
);
2976 size16
-= sizeof(UINT
);
2979 HeapFree(GetProcessHeap(), 0, MapSL(*(SEGPTR
*)p16
));
2980 UnMapLS( *(SEGPTR
*)p16
);
2981 p16
+= sizeof(SEGPTR
);
2982 p32
+= sizeof(char*);
2983 size16
-= sizeof(SEGPTR
);
2986 FIXME("Unknown nibble for mapping (%x)\n", nibble
);
2991 if (size16
!= 0) /* DEBUG only */
2992 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
2998 HeapFree( GetProcessHeap(), 0, alloc
);
3000 return WINMM_MAP_OK
;
3003 /**************************************************************************
3004 * MCI_MapMsg32WTo16 [internal]
3006 * Map a 32W bit MCI message to a 16 bit MCI message.
3008 static WINMM_MapType
MCI_MapMsg32WTo16(WORD uDevType
, WORD wMsg
, DWORD dwFlags
, DWORD_PTR
* lParam
)
3011 BOOLEAN keep
= FALSE
;
3015 return WINMM_MAP_OK
;
3017 /* FIXME: to add also (with seg/linear modifications to do):
3018 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
3019 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
3023 size
= sizeof(MCI_BREAK_PARMS
);
3025 /* case MCI_CAPTURE */
3027 case MCI_CLOSE_DRIVER
:
3029 size
= sizeof(MCI_GENERIC_PARMS
);
3031 /* case MCI_COPY: */
3034 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_CUE_PARMS
); break;
3035 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_CUE_PARMS); break;*/ FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3036 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3042 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_DELETE_PARMS16
); map
= 0x0F1111FB; break;
3043 case MCI_DEVTYPE_WAVEFORM_AUDIO
:size
= sizeof(MCI_WAVE_DELETE_PARMS
); break;
3044 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3047 /* case MCI_ESCAPE: */
3050 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_FREEZE_PARMS
); map
= 0x0001111B; break;
3051 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS
); map
= 0x0001111B; break;
3052 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3055 case MCI_GETDEVCAPS
:
3057 size
= sizeof(MCI_GETDEVCAPS_PARMS
);
3059 /* case MCI_INDEX: */
3062 LPMCI_INFO_PARMSW mip32w
= (LPMCI_INFO_PARMSW
)(*lParam
);
3064 LPMCI_INFO_PARMS16 mip16
;
3067 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_INFO_PARMS16
); break;
3068 default: size
= sizeof(MCI_INFO_PARMS16
); break;
3070 ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPMCI_INFO_PARMSW
) + size
);
3073 *(LPMCI_INFO_PARMSW
*)ptr
= mip32w
;
3074 mip16
= (LPMCI_INFO_PARMS16
)(ptr
+ sizeof(LPMCI_INFO_PARMSW
));
3075 mip16
->dwCallback
= mip32w
->dwCallback
;
3076 mip16
->lpstrReturn
= MapLS( HeapAlloc(GetProcessHeap(), 0, mip32w
->dwRetSize
/ sizeof(WCHAR
)) );
3077 mip16
->dwRetSize
= mip32w
->dwRetSize
/ sizeof(WCHAR
);
3078 if (uDevType
== MCI_DEVTYPE_DIGITAL_VIDEO
) {
3079 ((LPMCI_DGV_INFO_PARMS16
)mip16
)->dwItem
= ((LPMCI_DGV_INFO_PARMSW
)mip32w
)->dwItem
;
3082 return WINMM_MAP_NOMEM
;
3084 *lParam
= (LPARAM
)MapLS(ptr
) + sizeof(LPMCI_INFO_PARMSW
);
3086 return WINMM_MAP_OKMEM
;
3087 /* case MCI_MARK: */
3088 /* case MCI_MONITOR: */
3090 case MCI_OPEN_DRIVER
:
3092 LPMCI_OPEN_PARMSW mop32w
= (LPMCI_OPEN_PARMSW
)(*lParam
);
3093 char* ptr
= HeapAlloc( GetProcessHeap(), 0,
3094 sizeof(LPMCI_OPEN_PARMSW
) + sizeof(MCI_OPEN_PARMS16
) + 2 * sizeof(DWORD
));
3095 LPMCI_OPEN_PARMS16 mop16
;
3099 *(LPMCI_OPEN_PARMSW
*)(ptr
) = mop32w
;
3100 mop16
= (LPMCI_OPEN_PARMS16
)(ptr
+ sizeof(LPMCI_OPEN_PARMSW
));
3101 mop16
->dwCallback
= mop32w
->dwCallback
;
3102 mop16
->wDeviceID
= mop32w
->wDeviceID
;
3103 if (dwFlags
& MCI_OPEN_TYPE
) {
3104 if (dwFlags
& MCI_OPEN_TYPE_ID
) {
3105 /* dword "transparent" value */
3106 mop16
->lpstrDeviceType
= (SEGPTR
)mop32w
->lpstrDeviceType
;
3109 mop16
->lpstrDeviceType
= MapLS( MCI_strdupWtoA(mop32w
->lpstrDeviceType
) );
3113 mop16
->lpstrDeviceType
= 0;
3115 if (dwFlags
& MCI_OPEN_ELEMENT
) {
3116 if (dwFlags
& MCI_OPEN_ELEMENT_ID
) {
3117 mop16
->lpstrElementName
= (SEGPTR
)mop32w
->lpstrElementName
;
3119 mop16
->lpstrElementName
= MapLS( MCI_strdupWtoA(mop32w
->lpstrElementName
) );
3122 mop16
->lpstrElementName
= 0;
3124 if (dwFlags
& MCI_OPEN_ALIAS
) {
3125 mop16
->lpstrAlias
= MapLS( MCI_strdupWtoA(mop32w
->lpstrAlias
) );
3127 mop16
->lpstrAlias
= 0;
3129 /* copy extended information if any...
3130 * FIXME: this may seg fault if initial structure does not contain them and
3131 * the reads after msip16 fail under LDT limits...
3132 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
3133 * should not take care of extended parameters, and should be used by MCI_Open
3134 * to fetch uDevType. When, this is known, the mapping for sending the
3135 * MCI_OPEN_DRIVER shall be done depending on uDevType.
3137 memcpy(mop16
+ 1, mop32w
+ 1, 2 * sizeof(DWORD
));
3139 return WINMM_MAP_NOMEM
;
3141 *lParam
= (LPARAM
)MapLS(ptr
) + sizeof(LPMCI_OPEN_PARMSW
);
3143 return WINMM_MAP_OKMEM
;
3144 /* case MCI_PASTE:*/
3146 size
= sizeof(MCI_GENERIC_PARMS
);
3149 size
= sizeof(MCI_PLAY_PARMS
);
3153 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECT_PARMS16
); map
= 0x0001111B; break;
3154 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS
); map
= 0x0001111B; break;
3155 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3159 size
= sizeof(MCI_GENERIC_PARMS
);
3163 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECORD_PARMS16
); map
= 0x0F1111FB; break;
3164 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_RECORD_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3165 default: size
= sizeof(MCI_RECORD_PARMS
); break;
3169 size
= sizeof(MCI_GENERIC_PARMS
);
3173 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_SEEK_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3174 default: size
= sizeof(MCI_SEEK_PARMS
); break;
3179 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_SET_PARMS
); break;
3180 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_SET_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3181 case MCI_DEVTYPE_SEQUENCER
: size
= sizeof(MCI_SEQ_SET_PARMS
); break;
3182 /* FIXME: normally the 16 and 32 bit structures are byte by byte aligned,
3183 * so not doing anything should work...
3185 case MCI_DEVTYPE_WAVEFORM_AUDIO
:size
= sizeof(MCI_WAVE_SET_PARMS
); break;
3186 default: size
= sizeof(MCI_SET_PARMS
); break;
3191 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_SETAUDIO_PARMS16
);map
= 0x0000077FF; break;
3192 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3193 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3196 /* case MCI_SETTIMECODE:*/
3197 /* case MCI_SIGNAL:*/
3198 /* case MCI_SOUND:*/
3200 size
= sizeof(MCI_SET_PARMS
);
3206 * don't know if buffer for value is the one passed through lpstrDevice
3207 * or is provided by MCI driver.
3208 * Assuming solution 2: provided by MCI driver, so zeroing on entry
3210 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_STATUS_PARMS16
); map
= 0x0B6FF; break;
3211 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3212 default: size
= sizeof(MCI_STATUS_PARMS
); break;
3217 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_STEP_PARMS
); break;
3218 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_STEP_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3219 case MCI_DEVTYPE_VIDEODISC
: size
= sizeof(MCI_VD_STEP_PARMS
); break;
3220 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3224 size
= sizeof(MCI_SET_PARMS
);
3228 LPMCI_SYSINFO_PARMSW msip32w
= (LPMCI_SYSINFO_PARMSW
)(*lParam
);
3229 LPMCI_SYSINFO_PARMS16 msip16
;
3230 char* ptr
= HeapAlloc( GetProcessHeap(), 0,
3231 sizeof(LPMCI_SYSINFO_PARMSW
) + sizeof(MCI_SYSINFO_PARMS16
) );
3234 *(LPMCI_SYSINFO_PARMSW
*)(ptr
) = msip32w
;
3235 msip16
= (LPMCI_SYSINFO_PARMS16
)(ptr
+ sizeof(LPMCI_SYSINFO_PARMSW
));
3237 msip16
->dwCallback
= msip32w
->dwCallback
;
3238 msip16
->lpstrReturn
= MapLS( HeapAlloc(GetProcessHeap(), 0, msip32w
->dwRetSize
) );
3239 msip16
->dwRetSize
= msip32w
->dwRetSize
;
3240 msip16
->dwNumber
= msip32w
->dwNumber
;
3241 msip16
->wDeviceType
= msip32w
->wDeviceType
;
3243 return WINMM_MAP_NOMEM
;
3245 *lParam
= (LPARAM
)MapLS(ptr
) + sizeof(LPMCI_SYSINFO_PARMSW
);
3247 return WINMM_MAP_OKMEM
;
3248 /* case MCI_UNDO: */
3251 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECT_PARMS16
); map
= 0x0001111B; break;
3252 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS16
); map
= 0x0001111B; break;
3253 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3258 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_UPDATE_PARMS16
); map
= 0x000B1111B; break;
3259 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3264 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECT_PARMS16
); map
= 0x0001111B; keep
= TRUE
; break;
3265 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS16
); map
= 0x0001111B; keep
= TRUE
; break;
3266 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3271 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_WINDOW_PARMS16
); if (dwFlags
& MCI_DGV_WINDOW_TEXT
) map
= 0x7FB; break;
3272 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_WINDOW_PARMS16
); if (dwFlags
& MCI_OVLY_WINDOW_TEXT
) map
= 0x7FB; break;
3273 default: size
= sizeof(MCI_GENERIC_PARMS
); break;
3278 LPMCI_OPEN_DRIVER_PARMSW modp32w
= (LPMCI_OPEN_DRIVER_PARMSW
)(*lParam
);
3279 LPMCI_OPEN_DRIVER_PARMS16 modp16
;
3280 char *ptr
= HeapAlloc( GetProcessHeap(), 0,
3281 sizeof(LPMCI_OPEN_DRIVER_PARMSW
) + sizeof(MCI_OPEN_DRIVER_PARMS16
));
3284 *(LPMCI_OPEN_DRIVER_PARMSW
*)(ptr
) = modp32w
;
3285 modp16
= (LPMCI_OPEN_DRIVER_PARMS16
)(ptr
+ sizeof(LPMCI_OPEN_DRIVER_PARMSW
));
3286 modp16
->wDeviceID
= modp32w
->wDeviceID
;
3287 modp16
->lpstrParams
= MapLS( MCI_strdupWtoA(modp32w
->lpstrParams
) );
3288 /* other fields are gonna be filled by the driver, don't copy them */
3290 return WINMM_MAP_NOMEM
;
3292 *lParam
= (LPARAM
)MapLS(ptr
) + sizeof(LPMCI_OPEN_DRIVER_PARMSW
);
3294 return WINMM_MAP_OKMEM
;
3301 case DRV_QUERYCONFIGURE
:
3304 case DRV_EXITSESSION
:
3305 case DRV_EXITAPPLICATION
:
3307 return WINMM_MAP_OK
;
3310 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg
));
3311 return WINMM_MAP_MSGERROR
;
3313 return MCI_MsgMapper32WTo16_Create((void**)lParam
, size
, map
, keep
);
3316 /**************************************************************************
3317 * MCI_UnMapMsg32WTo16 [internal]
3319 static WINMM_MapType
MCI_UnMapMsg32WTo16(WORD uDevType
, WORD wMsg
, DWORD dwFlags
, DWORD_PTR lParam
)
3322 BOOLEAN kept
= FALSE
; /* there is no need to compute size when kept is FALSE */
3328 /* case MCI_CAPTURE */
3330 case MCI_CLOSE_DRIVER
:
3333 /* case MCI_COPY: */
3339 /* case MCI_ESCAPE: */
3342 case MCI_GETDEVCAPS
:
3344 size
= sizeof(MCI_GETDEVCAPS_PARMS
);
3346 /* case MCI_INDEX: */
3349 LPMCI_INFO_PARMS16 mip16
= (LPMCI_INFO_PARMS16
)MapSL(lParam
);
3350 LPMCI_INFO_PARMSW mip32w
= *(LPMCI_INFO_PARMSW
*)((char*)mip16
- sizeof(LPMCI_INFO_PARMSW
));
3352 MultiByteToWideChar(CP_ACP
, 0, MapSL(mip16
->lpstrReturn
), mip16
->dwRetSize
,
3353 mip32w
->lpstrReturn
, mip32w
->dwRetSize
/ sizeof(WCHAR
));
3355 UnMapLS( mip16
->lpstrReturn
);
3356 HeapFree( GetProcessHeap(), 0, (void*)MapSL(mip16
->lpstrReturn
) );
3357 HeapFree( GetProcessHeap(), 0, (char*)mip16
- sizeof(LPMCI_OPEN_PARMSW
) );
3359 return WINMM_MAP_OK
;
3360 /* case MCI_MARK: */
3361 /* case MCI_MONITOR: */
3363 case MCI_OPEN_DRIVER
:
3365 LPMCI_OPEN_PARMS16 mop16
= (LPMCI_OPEN_PARMS16
)MapSL(lParam
);
3366 LPMCI_OPEN_PARMSW mop32w
= *(LPMCI_OPEN_PARMSW
*)((char*)mop16
- sizeof(LPMCI_OPEN_PARMSW
));
3368 mop32w
->wDeviceID
= mop16
->wDeviceID
;
3369 if ((dwFlags
& MCI_OPEN_TYPE
) && !(dwFlags
& MCI_OPEN_TYPE_ID
))
3371 HeapFree(GetProcessHeap(), 0, MapSL(mop16
->lpstrDeviceType
));
3372 UnMapLS( mop16
->lpstrDeviceType
);
3374 if ((dwFlags
& MCI_OPEN_ELEMENT
) && !(dwFlags
& MCI_OPEN_ELEMENT_ID
))
3376 HeapFree(GetProcessHeap(), 0, MapSL(mop16
->lpstrElementName
));
3377 UnMapLS( mop16
->lpstrElementName
);
3379 if (dwFlags
& MCI_OPEN_ALIAS
)
3381 HeapFree(GetProcessHeap(), 0, MapSL(mop16
->lpstrAlias
));
3382 UnMapLS( mop16
->lpstrAlias
);
3384 HeapFree( GetProcessHeap(), 0, (char*)mop16
- sizeof(LPMCI_OPEN_PARMSW
) );
3386 return WINMM_MAP_OK
;
3387 /* case MCI_PASTE:*/
3406 case MCI_DEVTYPE_DIGITAL_VIDEO
: map
= 0x0000077FF; break;
3407 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3410 /* case MCI_SETTIMECODE:*/
3411 /* case MCI_SIGNAL:*/
3412 /* case MCI_SOUND:*/
3418 case MCI_DEVTYPE_DIGITAL_VIDEO
:
3420 LPMCI_DGV_STATUS_PARMS16 mdsp16
= (LPMCI_DGV_STATUS_PARMS16
)MapSL(lParam
);
3421 LPMCI_DGV_STATUS_PARMSA mdsp32a
= *(LPMCI_DGV_STATUS_PARMSA
*)((char*)mdsp16
- sizeof(LPMCI_DGV_STATUS_PARMSA
));
3425 mdsp32a
->dwReturn
= mdsp16
->dwReturn
;
3426 if (dwFlags
& MCI_DGV_STATUS_DISKSPACE
) {
3427 TRACE("MCI_STATUS (DGV) lpstrDrive=%08x\n", mdsp16
->lpstrDrive
);
3428 TRACE("MCI_STATUS (DGV) lpstrDrive=%s\n", (LPSTR
)MapSL(mdsp16
->lpstrDrive
));
3429 UnMapLS( mdsp16
->lpstrDrive
);
3431 HeapFree( GetProcessHeap(), 0, (char*)mdsp16
- sizeof(LPMCI_DGV_STATUS_PARMSA
) );
3433 return WINMM_MAP_NOMEM
;
3436 return WINMM_MAP_OKMEM
;
3437 case MCI_DEVTYPE_VCR
: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM
;
3438 default: size
= sizeof(MCI_STATUS_PARMS
); break;
3447 LPMCI_SYSINFO_PARMS16 msip16
= (LPMCI_SYSINFO_PARMS16
)MapSL(lParam
);
3448 LPMCI_SYSINFO_PARMSW msip32w
= *(LPMCI_SYSINFO_PARMSW
*)((char*)msip16
- sizeof(LPMCI_SYSINFO_PARMSW
));
3452 MultiByteToWideChar(CP_ACP
, 0, MapSL(msip16
->lpstrReturn
), msip16
->dwRetSize
,
3453 msip32w
->lpstrReturn
, msip32w
->dwRetSize
/sizeof(WCHAR
));
3454 UnMapLS( msip16
->lpstrReturn
);
3455 HeapFree( GetProcessHeap(), 0, MapSL(msip16
->lpstrReturn
) );
3456 HeapFree( GetProcessHeap(), 0, (char*)msip16
- sizeof(LPMCI_SYSINFO_PARMSW
) );
3458 return WINMM_MAP_NOMEM
;
3461 return WINMM_MAP_OKMEM
;
3462 /* case MCI_UNDO: */
3469 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_RECT_PARMS16
); map
= 0x0001111B; kept
= TRUE
; break;
3470 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_RECT_PARMS16
); map
= 0x0001111B; kept
= TRUE
; break;
3476 case MCI_DEVTYPE_DIGITAL_VIDEO
: size
= sizeof(MCI_DGV_WINDOW_PARMS16
); if (dwFlags
& MCI_DGV_WINDOW_TEXT
) map
= 0x7666; break;
3477 case MCI_DEVTYPE_OVERLAY
: size
= sizeof(MCI_OVLY_WINDOW_PARMS16
); if (dwFlags
& MCI_OVLY_WINDOW_TEXT
) map
= 0x7666; break;
3480 /* FIXME: see map function */
3484 LPMCI_OPEN_DRIVER_PARMS16 modp16
= (LPMCI_OPEN_DRIVER_PARMS16
)MapSL(lParam
);
3485 LPMCI_OPEN_DRIVER_PARMSW modp32w
= *(LPMCI_OPEN_DRIVER_PARMSW
*)((char*)modp16
- sizeof(LPMCI_OPEN_DRIVER_PARMSW
));
3488 modp32w
->wCustomCommandTable
= modp16
->wCustomCommandTable
;
3489 modp32w
->wType
= modp16
->wType
;
3490 HeapFree(GetProcessHeap(), 0, MapSL(modp16
->lpstrParams
));
3491 UnMapLS( modp16
->lpstrParams
);
3492 HeapFree( GetProcessHeap(), 0, (char *)modp16
- sizeof(LPMCI_OPEN_DRIVER_PARMSW
) );
3494 return WINMM_MAP_OK
;
3501 case DRV_QUERYCONFIGURE
:
3504 case DRV_EXITSESSION
:
3505 case DRV_EXITAPPLICATION
:
3507 FIXME("This is a hack\n");
3508 return WINMM_MAP_OK
;
3511 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg
));
3512 return WINMM_MAP_MSGERROR
;
3514 return MCI_MsgMapper32WTo16_Destroy((void*)lParam
, size
, map
, kept
);
3517 void MMDRV_Init16(void)
3519 #define A(_x,_y) MMDRV_InstallMap(_x, \
3520 MMDRV_##_y##_Map16To32W, MMDRV_##_y##_UnMap16To32W, \
3521 MMDRV_##_y##_Map32WTo16, MMDRV_##_y##_UnMap32WTo16, \
3522 MMDRV_##_y##_Callback)
3524 A(MMDRV_MIXER
, Mixer
);
3525 A(MMDRV_MIDIIN
, MidiIn
);
3526 A(MMDRV_MIDIOUT
, MidiOut
);
3527 A(MMDRV_WAVEIN
, WaveIn
);
3528 A(MMDRV_WAVEOUT
, WaveOut
);
3531 pFnCallMMDrvFunc16
= MMDRV_CallMMDrvFunc16
;
3532 pFnLoadMMDrvFunc16
= MMDRV_LoadMMDrvFunc16
;
3534 pFnMciMapMsg16To32W
= MCI_MapMsg16To32W
;
3535 pFnMciUnMapMsg16To32W
= MCI_UnMapMsg16To32W
;
3536 pFnMciMapMsg32WTo16
= MCI_MapMsg32WTo16
;
3537 pFnMciUnMapMsg32WTo16
= MCI_UnMapMsg32WTo16
;