1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
4 * MMSYTEM MCI and low level mapping functions
6 * Copyright 1999 Eric Pouech
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "wine/winbase16.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(winmm);
39 /**************************************************************************
40 * MMDRV_Callback [internal]
42 static void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD dwParam1, DWORD dwParam2)
44 TRACE("CB (*%08lx)(%p %08x %08lx %08lx %08lx\n",
45 mld->dwCallback, hDev, uMsg, mld->dwClientInstance, dwParam1, dwParam2);
47 if (!mld->bFrom32 && (mld->dwFlags & DCB_TYPEMASK) == DCB_FUNCTION)
50 /* 16 bit func, call it */
51 TRACE("Function (16 bit) !\n");
53 args[7] = HDRVR_16(hDev);
55 args[5] = HIWORD(mld->dwClientInstance);
56 args[4] = LOWORD(mld->dwClientInstance);
57 args[3] = HIWORD(dwParam1);
58 args[2] = LOWORD(dwParam1);
59 args[1] = HIWORD(dwParam2);
60 args[0] = LOWORD(dwParam2);
61 WOWCallback16Ex( mld->dwCallback, WCB16_PASCAL, sizeof(args), args, NULL );
63 DriverCallback(mld->dwCallback, mld->dwFlags, hDev, uMsg,
64 mld->dwClientInstance, dwParam1, dwParam2);
68 /* =================================
70 * ================================= */
72 /**************************************************************************
73 * MMDRV_Aux_Map16To32A [internal]
75 static WINMM_MapType MMDRV_Aux_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
77 return WINMM_MAP_MSGERROR;
80 /**************************************************************************
81 * MMDRV_Aux_UnMap16To32A [internal]
83 static WINMM_MapType MMDRV_Aux_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
85 return WINMM_MAP_MSGERROR;
88 /**************************************************************************
89 * MMDRV_Aux_Map32ATo16 [internal]
91 static WINMM_MapType MMDRV_Aux_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
93 return WINMM_MAP_MSGERROR;
96 /**************************************************************************
97 * MMDRV_Aux_UnMap32ATo16 [internal]
99 static WINMM_MapType MMDRV_Aux_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
102 case AUXDM_GETDEVCAPS:
103 lpCaps->wMid = ac16.wMid;
104 lpCaps->wPid = ac16.wPid;
105 lpCaps->vDriverVersion = ac16.vDriverVersion;
106 strcpy(lpCaps->szPname, ac16.szPname);
107 lpCaps->wTechnology = ac16.wTechnology;
108 lpCaps->dwSupport = ac16.dwSupport;
110 return WINMM_MAP_MSGERROR;
113 /**************************************************************************
114 * MMDRV_Aux_Callback [internal]
116 static void CALLBACK MMDRV_Aux_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
118 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
121 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
124 /* =================================
125 * M I X E R M A P P E R S
126 * ================================= */
128 /**************************************************************************
129 * xMMDRV_Mixer_Map16To32A [internal]
131 static WINMM_MapType MMDRV_Mixer_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
133 return WINMM_MAP_MSGERROR;
136 /**************************************************************************
137 * MMDRV_Mixer_UnMap16To32A [internal]
139 static WINMM_MapType MMDRV_Mixer_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
143 UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
145 if (ret == MMSYSERR_NOERROR) {
146 mixcaps->wMid = micA.wMid;
147 mixcaps->wPid = micA.wPid;
148 mixcaps->vDriverVersion = micA.vDriverVersion;
149 strcpy(mixcaps->szPname, micA.szPname);
150 mixcaps->fdwSupport = micA.fdwSupport;
151 mixcaps->cDestinations = micA.cDestinations;
155 return WINMM_MAP_MSGERROR;
158 /**************************************************************************
159 * MMDRV_Mixer_Map32ATo16 [internal]
161 static WINMM_MapType MMDRV_Mixer_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
163 return WINMM_MAP_MSGERROR;
166 /**************************************************************************
167 * MMDRV_Mixer_UnMap32ATo16 [internal]
169 static WINMM_MapType MMDRV_Mixer_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
171 return WINMM_MAP_MSGERROR;
174 /**************************************************************************
175 * MMDRV_Mixer_Callback [internal]
177 static void CALLBACK MMDRV_Mixer_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
179 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
182 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
185 /* =================================
186 * M I D I I N M A P P E R S
187 * ================================= */
189 /**************************************************************************
190 * MMDRV_MidiIn_Map16To32A [internal]
192 static WINMM_MapType MMDRV_MidiIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
194 return WINMM_MAP_MSGERROR;
197 /**************************************************************************
198 * MMDRV_MidiIn_UnMap16To32A [internal]
200 static WINMM_MapType MMDRV_MidiIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
202 return WINMM_MAP_MSGERROR;
205 /**************************************************************************
206 * MMDRV_MidiIn_Map32ATo16 [internal]
208 static WINMM_MapType MMDRV_MidiIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
210 return WINMM_MAP_MSGERROR;
213 /**************************************************************************
214 * MMDRV_MidiIn_UnMap32ATo16 [internal]
216 static WINMM_MapType MMDRV_MidiIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
218 return WINMM_MAP_MSGERROR;
221 /**************************************************************************
222 * MMDRV_MidiIn_Callback [internal]
224 static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
226 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
231 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
236 /* dwParam1 & dwParam2 are are data, nothing to do */
240 /* dwParam1 points to a MidiHdr, work to be done !!! */
241 if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) {
242 /* initial map is: 32 => 16 */
243 LPMIDIHDR mh16 = MapSL(dwParam1);
244 LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR));
246 dwParam1 = (DWORD)mh32;
247 mh32->dwFlags = mh16->dwFlags;
248 mh32->dwBytesRecorded = mh16->dwBytesRecorded;
249 if (mh32->reserved >= sizeof(MIDIHDR))
250 mh32->dwOffset = mh16->dwOffset;
251 } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) {
252 /* initial map is: 16 => 32 */
253 LPMIDIHDR mh32 = (LPMIDIHDR)(dwParam1);
254 SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR));
255 LPMIDIHDR mh16 = MapSL(segmh16);
257 dwParam1 = (DWORD)segmh16;
258 mh16->dwFlags = mh32->dwFlags;
259 mh16->dwBytesRecorded = mh32->dwBytesRecorded;
260 if (mh16->reserved >= sizeof(MIDIHDR))
261 mh16->dwOffset = mh32->dwOffset;
263 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
265 /* case MOM_POSITIONCB: */
267 ERR("Unknown msg %u\n", uMsg);
270 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
273 /* =================================
274 * M I D I O U T M A P P E R S
275 * ================================= */
277 /**************************************************************************
278 * MMDRV_MidiOut_Map16To32A [internal]
280 static WINMM_MapType MMDRV_MidiOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
282 WINMM_MapType ret = WINMM_MAP_MSGERROR;
285 case MODM_GETNUMDEVS:
295 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
298 case MODM_GETDEVCAPS:
300 LPMIDIOUTCAPSA moc32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPS16) + sizeof(MIDIOUTCAPSA));
301 LPMIDIOUTCAPS16 moc16 = MapSL(*lpParam1);
304 *(LPMIDIOUTCAPS16*)moc32 = moc16;
305 moc32 = (LPMIDIOUTCAPSA)((LPSTR)moc32 + sizeof(LPMIDIOUTCAPS16));
306 *lpParam1 = (DWORD)moc32;
307 *lpParam2 = sizeof(MIDIOUTCAPSA);
309 ret = WINMM_MAP_OKMEM;
311 ret = WINMM_MAP_NOMEM;
317 LPMIDIHDR mh32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIHDR) + sizeof(MIDIHDR));
318 LPMIDIHDR mh16 = MapSL(*lpParam1);
321 *(LPMIDIHDR*)mh32 = (LPMIDIHDR)*lpParam1;
322 mh32 = (LPMIDIHDR)((LPSTR)mh32 + sizeof(LPMIDIHDR));
323 mh32->lpData = MapSL((SEGPTR)mh16->lpData);
324 mh32->dwBufferLength = mh16->dwBufferLength;
325 mh32->dwBytesRecorded = mh16->dwBytesRecorded;
326 mh32->dwUser = mh16->dwUser;
327 mh32->dwFlags = mh16->dwFlags;
328 /* FIXME: nothing on mh32->lpNext */
329 /* could link the mh32->lpNext at this level for memory house keeping */
330 mh32->dwOffset = (*lpParam2 >= sizeof(MIDIHDR)) ? ((LPMIDIHDR)mh16)->dwOffset : 0;
331 mh16->lpNext = mh32; /* for reuse in unprepare and write */
332 /* store size of passed MIDIHDR?? structure to know if dwOffset is available or not */
333 mh16->reserved = *lpParam2;
334 *lpParam1 = (DWORD)mh32;
335 *lpParam2 = sizeof(MIDIHDR);
337 ret = WINMM_MAP_OKMEM;
339 ret = WINMM_MAP_NOMEM;
346 LPMIDIHDR mh16 = MapSL(*lpParam1);
347 LPMIDIHDR mh32 = (LPMIDIHDR)mh16->lpNext;
349 *lpParam1 = (DWORD)mh32;
350 *lpParam2 = sizeof(MIDIHDR);
351 /* dwBufferLength can be reduced between prepare & write */
352 if (wMsg == MODM_LONGDATA && mh32->dwBufferLength < mh16->dwBufferLength) {
353 ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n",
354 mh32->dwBufferLength, mh16->dwBufferLength);
356 mh32->dwBufferLength = mh16->dwBufferLength;
357 ret = WINMM_MAP_OKMEM;
361 case MODM_CACHEPATCHES:
362 case MODM_CACHEDRUMPATCHES:
364 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
370 /**************************************************************************
371 * MMDRV_MidiOut_UnMap16To32A [internal]
373 static WINMM_MapType MMDRV_MidiOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
375 WINMM_MapType ret = WINMM_MAP_MSGERROR;
378 case MODM_GETNUMDEVS:
388 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
391 case MODM_GETDEVCAPS:
393 LPMIDIOUTCAPSA moc32 = (LPMIDIOUTCAPSA)(*lpParam1);
394 LPMIDIOUTCAPS16 moc16 = *(LPMIDIOUTCAPS16*)((LPSTR)moc32 - sizeof(LPMIDIOUTCAPS16));
396 moc16->wMid = moc32->wMid;
397 moc16->wPid = moc32->wPid;
398 moc16->vDriverVersion = moc32->vDriverVersion;
399 strcpy(moc16->szPname, moc32->szPname);
400 moc16->wTechnology = moc32->wTechnology;
401 moc16->wVoices = moc32->wVoices;
402 moc16->wNotes = moc32->wNotes;
403 moc16->wChannelMask = moc32->wChannelMask;
404 moc16->dwSupport = moc32->dwSupport;
405 HeapFree(GetProcessHeap(), 0, (LPSTR)moc32 - sizeof(LPMIDIOUTCAPS16));
413 LPMIDIHDR mh32 = (LPMIDIHDR)(*lpParam1);
414 LPMIDIHDR mh16 = MapSL(*(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR)));
416 assert(mh16->lpNext == mh32);
417 mh16->dwBufferLength = mh32->dwBufferLength;
418 mh16->dwBytesRecorded = mh32->dwBytesRecorded;
419 mh16->dwUser = mh32->dwUser;
420 mh16->dwFlags = mh32->dwFlags;
421 if (mh16->reserved >= sizeof(MIDIHDR))
422 mh16->dwOffset = mh32->dwOffset;
424 if (wMsg == MODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
425 HeapFree(GetProcessHeap(), 0, (LPSTR)mh32 - sizeof(LPMIDIHDR));
432 case MODM_CACHEPATCHES:
433 case MODM_CACHEDRUMPATCHES:
435 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
441 /**************************************************************************
442 * MMDRV_MidiOut_Map32ATo16 [internal]
444 static WINMM_MapType MMDRV_MidiOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
446 WINMM_MapType ret = WINMM_MAP_MSGERROR;
450 case MODM_GETNUMDEVS:
456 case MODM_GETDEVCAPS:
458 LPMIDIOUTCAPSA moc32 = (LPMIDIOUTCAPSA)*lpParam1;
459 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPSA)+sizeof(MIDIOUTCAPS16));
462 *(LPMIDIOUTCAPSA*)ptr = moc32;
463 ret = WINMM_MAP_OKMEM;
465 ret = WINMM_MAP_NOMEM;
467 *lpParam1 = (DWORD)MapLS(ptr) + sizeof(LPMIDIOUTCAPSA);
468 *lpParam2 = sizeof(MIDIOUTCAPS16);
473 LPMIDIHDR mh32 = (LPMIDIHDR)*lpParam1;
475 LPVOID ptr = HeapAlloc( GetProcessHeap(), 0,
476 sizeof(LPMIDIHDR) + sizeof(MIDIHDR) + mh32->dwBufferLength);
479 *(LPMIDIHDR*)ptr = mh32;
480 mh16 = (LPMIDIHDR)((LPSTR)ptr + sizeof(LPMIDIHDR));
481 *lpParam1 = MapLS(mh16);
482 mh16->lpData = (LPSTR)*lpParam1 + sizeof(MIDIHDR);
483 /* data will be copied on WODM_WRITE */
484 mh16->dwBufferLength = mh32->dwBufferLength;
485 mh16->dwBytesRecorded = mh32->dwBytesRecorded;
486 mh16->dwUser = mh32->dwUser;
487 mh16->dwFlags = mh32->dwFlags;
488 /* FIXME: nothing on mh32->lpNext */
489 /* could link the mh32->lpNext at this level for memory house keeping */
490 mh16->dwOffset = (*lpParam2 >= sizeof(MIDIHDR)) ? mh32->dwOffset : 0;
492 mh32->lpNext = (LPMIDIHDR)mh16; /* for reuse in unprepare and write */
493 mh32->reserved = *lpParam2;
495 TRACE("mh16=%08lx mh16->lpData=%08lx mh32->buflen=%lu mh32->lpData=%08lx\n",
496 *lpParam1, (DWORD)mh16->lpData,
497 mh32->dwBufferLength, (DWORD)mh32->lpData);
498 *lpParam2 = sizeof(MIDIHDR);
500 ret = WINMM_MAP_OKMEM;
502 ret = WINMM_MAP_NOMEM;
509 LPMIDIHDR mh32 = (LPMIDIHDR)(*lpParam1);
510 LPMIDIHDR mh16 = (LPMIDIHDR)mh32->lpNext;
511 LPSTR ptr = (LPSTR)mh16 - sizeof(LPMIDIHDR);
513 assert(*(LPMIDIHDR*)ptr == mh32);
515 if (wMsg == MODM_LONGDATA)
516 memcpy((LPSTR)mh16 + sizeof(MIDIHDR), mh32->lpData, mh32->dwBufferLength);
518 *lpParam1 = MapLS(mh16);
519 *lpParam2 = sizeof(MIDIHDR);
520 TRACE("mh16=%08lx mh16->lpData=%08lx mh32->buflen=%lu mh32->lpData=%08lx\n",
521 *lpParam1, (DWORD)mh16->lpData, mh32->dwBufferLength, (DWORD)mh32->lpData);
523 /* dwBufferLength can be reduced between prepare & write */
524 if (wMsg == MODM_LONGDATA && mh16->dwBufferLength < mh32->dwBufferLength) {
525 ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n",
526 mh16->dwBufferLength, mh32->dwBufferLength);
528 mh16->dwBufferLength = mh32->dwBufferLength;
529 ret = WINMM_MAP_OKMEM;
534 LPMIDIOPENDESC mod32 = (LPMIDIOPENDESC)*lpParam1;
536 LPMIDIOPENDESC16 mod16;
538 /* allocated data are mapped as follows:
539 LPMIDIOPENDESC ptr to orig lParam1
540 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
541 DWORD dwUser passed to driver
542 MIDIOPENDESC16 mod16: openDesc passed to driver
545 ptr = HeapAlloc( GetProcessHeap(), 0,
546 sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD) + sizeof(MIDIOPENDESC16) +
547 mod32->cIds ? (mod32->cIds - 1) * sizeof(MIDIOPENSTRMID) : 0);
550 SEGPTR segptr = MapLS(ptr);
551 *(LPMIDIOPENDESC*)ptr = mod32;
552 *(LPDWORD)((char*)ptr + sizeof(LPMIDIOPENDESC)) = *lpdwUser;
553 mod16 = (LPMIDIOPENDESC16)((LPSTR)ptr + sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD));
555 mod16->hMidi = HMIDI_16(mod32->hMidi);
556 mod16->dwCallback = mod32->dwCallback;
557 mod16->dwInstance = mod32->dwInstance;
558 mod16->dnDevNode = mod32->dnDevNode;
559 mod16->cIds = mod32->cIds;
560 memcpy(&mod16->rgIds, &mod32->rgIds, mod32->cIds * sizeof(MIDIOPENSTRMID));
562 *lpParam1 = (DWORD)segptr + sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD);
563 *lpdwUser = (DWORD)segptr + sizeof(LPMIDIOPENDESC) + sizeof(DWORD);
565 ret = WINMM_MAP_OKMEM;
567 ret = WINMM_MAP_NOMEM;
572 case MODM_CACHEPATCHES:
573 case MODM_CACHEDRUMPATCHES:
575 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
581 /**************************************************************************
582 * MMDRV_MidiOut_UnMap32ATo16 [internal]
584 static WINMM_MapType MMDRV_MidiOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
586 WINMM_MapType ret = WINMM_MAP_MSGERROR;
590 case MODM_GETNUMDEVS:
596 case MODM_GETDEVCAPS:
598 LPMIDIOUTCAPS16 moc16 = MapSL(*lpParam1);
599 LPSTR ptr = (LPSTR)moc16 - sizeof(LPMIDIOUTCAPSA);
600 LPMIDIOUTCAPSA moc32 = *(LPMIDIOUTCAPSA*)ptr;
602 moc32->wMid = moc16->wMid;
603 moc32->wPid = moc16->wPid;
604 moc32->vDriverVersion = moc16->vDriverVersion;
605 strcpy(moc32->szPname, moc16->szPname);
606 moc32->wTechnology = moc16->wTechnology;
607 moc32->wVoices = moc16->wVoices;
608 moc32->wNotes = moc16->wNotes;
609 moc32->wChannelMask = moc16->wChannelMask;
610 moc32->dwSupport = moc16->dwSupport;
611 UnMapLS( *lpParam1 );
612 HeapFree( GetProcessHeap(), 0, ptr );
620 LPMIDIHDR mh16 = MapSL(*lpParam1);
621 LPSTR ptr = (LPSTR)mh16 - sizeof(LPMIDIHDR);
622 LPMIDIHDR mh32 = *(LPMIDIHDR*)ptr;
624 assert(mh32->lpNext == (LPMIDIHDR)mh16);
625 UnMapLS( *lpParam1 );
626 mh32->dwBytesRecorded = mh16->dwBytesRecorded;
627 mh32->dwUser = mh16->dwUser;
628 mh32->dwFlags = mh16->dwFlags;
630 if (wMsg == MODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
631 HeapFree( GetProcessHeap(), 0, ptr );
639 LPMIDIOPENDESC16 mod16 = MapSL(*lpParam1);
640 LPSTR ptr = (LPSTR)mod16 - sizeof(LPMIDIOPENDESC) - 2*sizeof(DWORD);
641 UnMapLS( *lpParam1 );
642 **(DWORD**)(ptr + sizeof(LPMIDIOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPMIDIOPENDESC) + sizeof(DWORD));
644 HeapFree( GetProcessHeap(), 0, ptr );
649 case MODM_CACHEPATCHES:
650 case MODM_CACHEDRUMPATCHES:
652 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
658 /**************************************************************************
659 * MMDRV_MidiOut_Callback [internal]
661 static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
663 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
668 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
671 if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) {
672 /* initial map is: 32 => 16 */
673 LPMIDIHDR mh16 = MapSL(dwParam1);
674 LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR));
676 dwParam1 = (DWORD)mh32;
677 mh32->dwFlags = mh16->dwFlags;
678 mh32->dwOffset = mh16->dwOffset;
679 if (mh32->reserved >= sizeof(MIDIHDR))
680 mh32->dwOffset = mh16->dwOffset;
681 } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) {
682 /* initial map is: 16 => 32 */
683 LPMIDIHDR mh32 = (LPMIDIHDR)(dwParam1);
684 SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR));
685 LPMIDIHDR mh16 = MapSL(segmh16);
687 dwParam1 = (DWORD)segmh16;
688 mh16->dwFlags = mh32->dwFlags;
689 if (mh16->reserved >= sizeof(MIDIHDR))
690 mh16->dwOffset = mh32->dwOffset;
692 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
694 /* case MOM_POSITIONCB: */
696 ERR("Unknown msg %u\n", uMsg);
699 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
702 /* =================================
703 * W A V E I N M A P P E R S
704 * ================================= */
706 /**************************************************************************
707 * MMDRV_WaveIn_Map16To32A [internal]
709 static WINMM_MapType MMDRV_WaveIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
711 WINMM_MapType ret = WINMM_MAP_MSGERROR;
714 case WIDM_GETNUMDEVS:
722 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
724 case WIDM_GETDEVCAPS:
726 LPWAVEINCAPSA wic32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEINCAPS16) + sizeof(WAVEINCAPSA));
727 LPWAVEINCAPS16 wic16 = MapSL(*lpParam1);
730 *(LPWAVEINCAPS16*)wic32 = wic16;
731 wic32 = (LPWAVEINCAPSA)((LPSTR)wic32 + sizeof(LPWAVEINCAPS16));
732 *lpParam1 = (DWORD)wic32;
733 *lpParam2 = sizeof(WAVEINCAPSA);
735 ret = WINMM_MAP_OKMEM;
737 ret = WINMM_MAP_NOMEM;
743 LPMMTIME mmt32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16) + sizeof(MMTIME));
744 LPMMTIME16 mmt16 = MapSL(*lpParam1);
747 *(LPMMTIME16*)mmt32 = mmt16;
748 mmt32 = (LPMMTIME)((LPSTR)mmt32 + sizeof(LPMMTIME16));
750 mmt32->wType = mmt16->wType;
751 *lpParam1 = (DWORD)mmt32;
752 *lpParam2 = sizeof(MMTIME);
754 ret = WINMM_MAP_OKMEM;
756 ret = WINMM_MAP_NOMEM;
762 LPWAVEHDR wh32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR) + sizeof(WAVEHDR));
763 LPWAVEHDR wh16 = MapSL(*lpParam1);
766 *(LPWAVEHDR*)wh32 = (LPWAVEHDR)*lpParam1;
767 wh32 = (LPWAVEHDR)((LPSTR)wh32 + sizeof(LPWAVEHDR));
768 wh32->lpData = MapSL((SEGPTR)wh16->lpData);
769 wh32->dwBufferLength = wh16->dwBufferLength;
770 wh32->dwBytesRecorded = wh16->dwBytesRecorded;
771 wh32->dwUser = wh16->dwUser;
772 wh32->dwFlags = wh16->dwFlags;
773 wh32->dwLoops = wh16->dwLoops;
774 /* FIXME: nothing on wh32->lpNext */
775 /* could link the wh32->lpNext at this level for memory house keeping */
776 wh16->lpNext = wh32; /* for reuse in unprepare and write */
777 *lpParam1 = (DWORD)wh32;
778 *lpParam2 = sizeof(WAVEHDR);
780 ret = WINMM_MAP_OKMEM;
782 ret = WINMM_MAP_NOMEM;
789 LPWAVEHDR wh16 = MapSL(*lpParam1);
790 LPWAVEHDR wh32 = (LPWAVEHDR)wh16->lpNext;
792 *lpParam1 = (DWORD)wh32;
793 *lpParam2 = sizeof(WAVEHDR);
794 /* dwBufferLength can be reduced between prepare & write */
795 if (wMsg == WIDM_ADDBUFFER && wh32->dwBufferLength < wh16->dwBufferLength) {
796 ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n",
797 wh32->dwBufferLength, wh16->dwBufferLength);
799 wh32->dwBufferLength = wh16->dwBufferLength;
800 ret = WINMM_MAP_OKMEM;
803 case WIDM_MAPPER_STATUS:
804 /* just a single DWORD */
805 *lpParam2 = (DWORD)MapSL(*lpParam2);
809 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
815 /**************************************************************************
816 * MMDRV_WaveIn_UnMap16To32A [internal]
818 static WINMM_MapType MMDRV_WaveIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
820 WINMM_MapType ret = WINMM_MAP_MSGERROR;
823 case WIDM_GETNUMDEVS:
827 case WIDM_MAPPER_STATUS:
832 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
834 case WIDM_GETDEVCAPS:
836 LPWAVEINCAPSA wic32 = (LPWAVEINCAPSA)(*lpParam1);
837 LPWAVEINCAPS16 wic16 = *(LPWAVEINCAPS16*)((LPSTR)wic32 - sizeof(LPWAVEINCAPS16));
839 wic16->wMid = wic32->wMid;
840 wic16->wPid = wic32->wPid;
841 wic16->vDriverVersion = wic32->vDriverVersion;
842 strcpy(wic16->szPname, wic32->szPname);
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_Map32ATo16 [internal]
890 static WINMM_MapType MMDRV_WaveIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD 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=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n",
972 seg_ptr + sizeof(LPWAVEHDR), (DWORD)wh16->lpData,
973 wh32->dwBufferLength, (DWORD)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=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n",
994 seg_ptr + sizeof(LPWAVEHDR), (DWORD)wh16->lpData,
995 wh32->dwBufferLength, (DWORD)wh32->lpData);
997 if (wMsg == WIDM_ADDBUFFER)
998 memcpy((LPSTR)wh16 + sizeof(WAVEHDR), wh32->lpData, wh32->dwBufferLength);
1000 *lpParam1 = seg_ptr + sizeof(LPWAVEHDR);
1001 *lpParam2 = sizeof(WAVEHDR);
1002 /* dwBufferLength can be reduced between prepare & write */
1003 if (wMsg == WIDM_ADDBUFFER && wh16->dwBufferLength < wh32->dwBufferLength) {
1004 ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n",
1005 wh16->dwBufferLength, wh32->dwBufferLength);
1007 wh16->dwBufferLength = wh32->dwBufferLength;
1008 ret = WINMM_MAP_OKMEM;
1011 case WIDM_GETDEVCAPS:
1013 LPWAVEINCAPSA wic32 = (LPWAVEINCAPSA)*lpParam1;
1014 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0 ,sizeof(LPWAVEINCAPSA) + sizeof(WAVEINCAPS16));
1017 *(LPWAVEINCAPSA*)ptr = wic32;
1018 ret = WINMM_MAP_OKMEM;
1020 ret = WINMM_MAP_NOMEM;
1022 *lpParam1 = MapLS(ptr) + sizeof(LPWAVEINCAPSA);
1023 *lpParam2 = sizeof(WAVEINCAPS16);
1028 LPMMTIME mmt32 = (LPMMTIME)*lpParam1;
1029 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME) + sizeof(MMTIME16));
1030 LPMMTIME16 mmt16 = (LPMMTIME16)(ptr + sizeof(LPMMTIME));
1033 *(LPMMTIME*)ptr = mmt32;
1034 mmt16->wType = mmt32->wType;
1035 ret = WINMM_MAP_OKMEM;
1037 ret = WINMM_MAP_NOMEM;
1039 *lpParam1 = MapLS(ptr) + sizeof(LPMMTIME);
1040 *lpParam2 = sizeof(MMTIME16);
1043 case DRVM_MAPPER_STATUS:
1045 LPDWORD p32 = (LPDWORD)*lpParam2;
1046 *lpParam2 = MapLS(p32);
1047 ret = WINMM_MAP_OKMEM;
1051 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
1057 /**************************************************************************
1058 * MMDRV_WaveIn_UnMap32ATo16 [internal]
1060 static WINMM_MapType MMDRV_WaveIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
1062 WINMM_MapType ret = WINMM_MAP_MSGERROR;
1066 case WIDM_GETNUMDEVS:
1075 LPWAVEOPENDESC16 wod16 = MapSL(*lpParam1);
1076 LPSTR ptr = (LPSTR)wod16 - sizeof(LPWAVEOPENDESC) - 2*sizeof(DWORD);
1077 LPWAVEOPENDESC wod32 = *(LPWAVEOPENDESC*)ptr;
1079 UnMapLS( *lpParam1 );
1080 wod32->uMappedDeviceID = wod16->uMappedDeviceID;
1081 **(DWORD**)(ptr + sizeof(LPWAVEOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD));
1082 HeapFree( GetProcessHeap(), 0, ptr );
1087 case WIDM_ADDBUFFER:
1089 case WIDM_UNPREPARE:
1091 LPWAVEHDR wh16 = MapSL(*lpParam1);
1092 LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR);
1093 LPWAVEHDR wh32 = *(LPWAVEHDR*)ptr;
1095 assert(wh32->lpNext == wh16);
1096 wh32->dwBytesRecorded = wh16->dwBytesRecorded;
1097 wh32->dwUser = wh16->dwUser;
1098 wh32->dwFlags = wh16->dwFlags;
1099 wh32->dwLoops = wh16->dwLoops;
1100 UnMapLS( *lpParam1 );
1102 if (wMsg == WIDM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
1103 HeapFree( GetProcessHeap(), 0, ptr );
1109 case WIDM_GETDEVCAPS:
1111 LPWAVEINCAPS16 wic16 = MapSL(*lpParam1);
1112 LPSTR ptr = (LPSTR)wic16 - sizeof(LPWAVEINCAPSA);
1113 LPWAVEINCAPSA wic32 = *(LPWAVEINCAPSA*)ptr;
1115 wic32->wMid = wic16->wMid;
1116 wic32->wPid = wic16->wPid;
1117 wic32->vDriverVersion = wic16->vDriverVersion;
1118 strcpy(wic32->szPname, wic16->szPname);
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 dwInstance, DWORD dwParam1, DWORD 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_Map16To32A [internal]
1198 static WINMM_MapType MMDRV_WaveOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD 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 LPWAVEOUTCAPSA woc32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEOUTCAPS16) + sizeof(WAVEOUTCAPSA));
1226 LPWAVEOUTCAPS16 woc16 = MapSL(*lpParam1);
1229 *(LPWAVEOUTCAPS16*)woc32 = woc16;
1230 woc32 = (LPWAVEOUTCAPSA)((LPSTR)woc32 + sizeof(LPWAVEOUTCAPS16));
1231 *lpParam1 = (DWORD)woc32;
1232 *lpParam2 = sizeof(WAVEOUTCAPSA);
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 %ld to %ld, 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_UnMap16To32A [internal]
1316 static WINMM_MapType MMDRV_WaveOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD 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 LPWAVEOUTCAPSA woc32 = (LPWAVEOUTCAPSA)(*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 strcpy(woc16->szPname, woc32->szPname);
1351 woc16->dwFormats = woc32->dwFormats;
1352 woc16->wChannels = woc32->wChannels;
1353 woc16->dwSupport = woc32->dwSupport;
1354 HeapFree(GetProcessHeap(), 0, (LPSTR)woc32 - sizeof(LPWAVEOUTCAPS16));
1360 LPMMTIME mmt32 = (LPMMTIME)(*lpParam1);
1361 LPMMTIME16 mmt16 = *(LPMMTIME16*)((LPSTR)mmt32 - sizeof(LPMMTIME16));
1363 MMSYSTEM_MMTIME32to16(mmt16, mmt32);
1364 HeapFree(GetProcessHeap(), 0, (LPSTR)mmt32 - sizeof(LPMMTIME16));
1369 case WODM_UNPREPARE:
1372 LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1);
1373 LPWAVEHDR wh16 = MapSL(*(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR)));
1375 assert(wh16->lpNext == wh32);
1376 wh16->dwBufferLength = wh32->dwBufferLength;
1377 wh16->dwBytesRecorded = wh32->dwBytesRecorded;
1378 wh16->dwUser = wh32->dwUser;
1379 wh16->dwFlags = wh32->dwFlags;
1380 wh16->dwLoops = wh32->dwLoops;
1382 if (wMsg == WODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
1383 HeapFree(GetProcessHeap(), 0, (LPSTR)wh32 - sizeof(LPWAVEHDR));
1390 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
1396 /**************************************************************************
1397 * MMDRV_WaveOut_Map32ATo16 [internal]
1399 static WINMM_MapType MMDRV_WaveOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2)
1405 case WODM_BREAKLOOP:
1407 case WODM_GETNUMDEVS:
1412 case WODM_SETPLAYBACKRATE:
1413 case WODM_SETVOLUME:
1417 case WODM_GETDEVCAPS:
1419 LPWAVEOUTCAPSA woc32 = (LPWAVEOUTCAPSA)*lpParam1;
1420 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0,
1421 sizeof(LPWAVEOUTCAPSA) + sizeof(WAVEOUTCAPS16));
1424 *(LPWAVEOUTCAPSA*)ptr = woc32;
1425 ret = WINMM_MAP_OKMEM;
1427 ret = WINMM_MAP_NOMEM;
1429 *lpParam1 = MapLS(ptr) + sizeof(LPWAVEOUTCAPSA);
1430 *lpParam2 = sizeof(WAVEOUTCAPS16);
1434 FIXME("NIY: no conversion yet\n");
1435 ret = WINMM_MAP_MSGERROR;
1437 case WODM_GETPLAYBACKRATE:
1438 FIXME("NIY: no conversion yet\n");
1439 ret = WINMM_MAP_MSGERROR;
1443 LPMMTIME mmt32 = (LPMMTIME)*lpParam1;
1444 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME) + sizeof(MMTIME16));
1445 LPMMTIME16 mmt16 = (LPMMTIME16)(ptr + sizeof(LPMMTIME));
1448 *(LPMMTIME*)ptr = mmt32;
1449 mmt16->wType = mmt32->wType;
1450 ret = WINMM_MAP_OKMEM;
1452 ret = WINMM_MAP_NOMEM;
1454 *lpParam1 = MapLS(ptr) + sizeof(LPMMTIME);
1455 *lpParam2 = sizeof(MMTIME16);
1458 case WODM_GETVOLUME:
1459 FIXME("NIY: no conversion yet\n");
1460 ret = WINMM_MAP_MSGERROR;
1464 LPWAVEOPENDESC wod32 = (LPWAVEOPENDESC)*lpParam1;
1465 int sz = sizeof(WAVEFORMATEX);
1467 LPWAVEOPENDESC16 wod16;
1469 /* allocated data are mapped as follows:
1470 LPWAVEOPENDESC ptr to orig lParam1
1471 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
1472 DWORD dwUser passed to driver
1473 WAVEOPENDESC16 wod16: openDesc passed to driver
1474 WAVEFORMATEX openDesc->lpFormat passed to driver
1475 xxx extra bytes to WAVEFORMATEX
1477 if (wod32->lpFormat->wFormatTag != WAVE_FORMAT_PCM) {
1478 TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize, wod32->lpFormat->wFormatTag);
1479 sz += ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize;
1482 ptr = HeapAlloc( GetProcessHeap(), 0,
1483 sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16) + sz);
1486 SEGPTR seg_ptr = MapLS( ptr );
1487 *(LPWAVEOPENDESC*)ptr = wod32;
1488 *(LPDWORD)((char*)ptr + sizeof(LPWAVEOPENDESC)) = *lpdwUser;
1489 wod16 = (LPWAVEOPENDESC16)((LPSTR)ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD));
1491 wod16->hWave = HWAVE_16(wod32->hWave);
1492 wod16->lpFormat = (LPWAVEFORMATEX)(seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16));
1493 memcpy(wod16 + 1, wod32->lpFormat, sz);
1495 wod16->dwCallback = wod32->dwCallback;
1496 wod16->dwInstance = wod32->dwInstance;
1497 wod16->uMappedDeviceID = wod32->uMappedDeviceID;
1498 wod16->dnDevNode = wod32->dnDevNode;
1500 *lpParam1 = seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD);
1501 *lpdwUser = seg_ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD);
1503 ret = WINMM_MAP_OKMEM;
1505 ret = WINMM_MAP_NOMEM;
1511 LPWAVEHDR wh32 = (LPWAVEHDR)*lpParam1;
1513 LPVOID ptr = HeapAlloc( GetProcessHeap(), 0,
1514 sizeof(LPWAVEHDR) + sizeof(WAVEHDR) + wh32->dwBufferLength);
1517 SEGPTR seg_ptr = MapLS( ptr );
1518 *(LPWAVEHDR*)ptr = wh32;
1519 wh16 = (LPWAVEHDR)((LPSTR)ptr + sizeof(LPWAVEHDR));
1520 wh16->lpData = (LPSTR)seg_ptr + sizeof(LPWAVEHDR) + sizeof(WAVEHDR);
1521 /* data will be copied on WODM_WRITE */
1522 wh16->dwBufferLength = wh32->dwBufferLength;
1523 wh16->dwBytesRecorded = wh32->dwBytesRecorded;
1524 wh16->dwUser = wh32->dwUser;
1525 wh16->dwFlags = wh32->dwFlags;
1526 wh16->dwLoops = wh32->dwLoops;
1527 /* FIXME: nothing on wh32->lpNext */
1528 /* could link the wh32->lpNext at this level for memory house keeping */
1529 wh32->lpNext = wh16; /* for reuse in unprepare and write */
1530 TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n",
1531 seg_ptr + sizeof(LPWAVEHDR), (DWORD)wh16->lpData,
1532 wh32->dwBufferLength, (DWORD)wh32->lpData);
1533 *lpParam1 = seg_ptr + sizeof(LPWAVEHDR);
1534 *lpParam2 = sizeof(WAVEHDR);
1536 ret = WINMM_MAP_OKMEM;
1538 ret = WINMM_MAP_NOMEM;
1542 case WODM_UNPREPARE:
1545 LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1);
1546 LPWAVEHDR wh16 = wh32->lpNext;
1547 LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR);
1548 SEGPTR seg_ptr = MapLS( ptr );
1550 assert(*(LPWAVEHDR*)ptr == wh32);
1552 TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n",
1553 seg_ptr + sizeof(LPWAVEHDR), (DWORD)wh16->lpData,
1554 wh32->dwBufferLength, (DWORD)wh32->lpData);
1556 if (wMsg == WODM_WRITE)
1557 memcpy((LPSTR)wh16 + sizeof(WAVEHDR), wh32->lpData, wh32->dwBufferLength);
1559 *lpParam1 = seg_ptr + sizeof(LPWAVEHDR);
1560 *lpParam2 = sizeof(WAVEHDR);
1561 /* dwBufferLength can be reduced between prepare & write */
1562 if (wMsg == WODM_WRITE && wh16->dwBufferLength < wh32->dwBufferLength) {
1563 ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n",
1564 wh16->dwBufferLength, wh32->dwBufferLength);
1566 wh16->dwBufferLength = wh32->dwBufferLength;
1567 ret = WINMM_MAP_OKMEM;
1570 case DRVM_MAPPER_STATUS:
1572 LPDWORD p32 = (LPDWORD)*lpParam2;
1573 *lpParam2 = MapLS(p32);
1574 ret = WINMM_MAP_OKMEM;
1578 FIXME("NIY: no conversion yet\n");
1579 ret = WINMM_MAP_MSGERROR;
1585 /**************************************************************************
1586 * MMDRV_WaveOut_UnMap32ATo16 [internal]
1588 static WINMM_MapType MMDRV_WaveOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT fn_ret)
1594 case WODM_BREAKLOOP:
1596 case WODM_GETNUMDEVS:
1601 case WODM_SETPLAYBACKRATE:
1602 case WODM_SETVOLUME:
1606 case WODM_GETDEVCAPS:
1608 LPWAVEOUTCAPS16 woc16 = MapSL(*lpParam1);
1609 LPSTR ptr = (LPSTR)woc16 - sizeof(LPWAVEOUTCAPSA);
1610 LPWAVEOUTCAPSA woc32 = *(LPWAVEOUTCAPSA*)ptr;
1612 woc32->wMid = woc16->wMid;
1613 woc32->wPid = woc16->wPid;
1614 woc32->vDriverVersion = woc16->vDriverVersion;
1615 strcpy(woc32->szPname, woc16->szPname);
1616 woc32->dwFormats = woc16->dwFormats;
1617 woc32->wChannels = woc16->wChannels;
1618 woc32->dwSupport = woc16->dwSupport;
1619 UnMapLS( *lpParam1 );
1620 HeapFree( GetProcessHeap(), 0, ptr );
1625 FIXME("NIY: no conversion yet\n");
1626 ret = WINMM_MAP_MSGERROR;
1628 case WODM_GETPLAYBACKRATE:
1629 FIXME("NIY: no conversion yet\n");
1630 ret = WINMM_MAP_MSGERROR;
1634 LPMMTIME16 mmt16 = MapSL(*lpParam1);
1635 LPSTR ptr = (LPSTR)mmt16 - sizeof(LPMMTIME);
1636 LPMMTIME mmt32 = *(LPMMTIME*)ptr;
1638 MMSYSTEM_MMTIME16to32(mmt32, mmt16);
1639 UnMapLS( *lpParam1 );
1640 HeapFree( GetProcessHeap(), 0, ptr );
1646 LPWAVEOPENDESC16 wod16 = MapSL(*lpParam1);
1647 LPSTR ptr = (LPSTR)wod16 - sizeof(LPWAVEOPENDESC) - 2*sizeof(DWORD);
1648 LPWAVEOPENDESC wod32 = *(LPWAVEOPENDESC*)ptr;
1650 wod32->uMappedDeviceID = wod16->uMappedDeviceID;
1651 **(DWORD**)(ptr + sizeof(LPWAVEOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD));
1652 UnMapLS( *lpParam1 );
1653 HeapFree( GetProcessHeap(), 0, ptr );
1658 case WODM_UNPREPARE:
1661 LPWAVEHDR wh16 = MapSL(*lpParam1);
1662 LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR);
1663 LPWAVEHDR wh32 = *(LPWAVEHDR*)ptr;
1665 assert(wh32->lpNext == wh16);
1666 wh32->dwBytesRecorded = wh16->dwBytesRecorded;
1667 wh32->dwUser = wh16->dwUser;
1668 wh32->dwFlags = wh16->dwFlags;
1669 wh32->dwLoops = wh16->dwLoops;
1671 UnMapLS( *lpParam1 );
1672 if (wMsg == WODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
1673 HeapFree( GetProcessHeap(), 0, ptr );
1679 case WODM_GETVOLUME:
1680 FIXME("NIY: no conversion yet\n");
1681 ret = WINMM_MAP_MSGERROR;
1683 case DRVM_MAPPER_STATUS:
1685 UnMapLS( *lpParam2 );
1690 FIXME("NIY: no conversion yet\n");
1691 ret = WINMM_MAP_MSGERROR;
1697 /**************************************************************************
1698 * MMDRV_WaveOut_Callback [internal]
1700 static void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
1702 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
1707 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
1710 if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) {
1711 /* initial map is: 32 => 16 */
1712 LPWAVEHDR wh16 = MapSL(dwParam1);
1713 LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR));
1715 dwParam1 = (DWORD)wh32;
1716 wh32->dwFlags = wh16->dwFlags;
1717 } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) {
1718 /* initial map is: 16 => 32 */
1719 LPWAVEHDR wh32 = (LPWAVEHDR)(dwParam1);
1720 SEGPTR segwh16 = *(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR));
1721 LPWAVEHDR wh16 = MapSL(segwh16);
1723 dwParam1 = (DWORD)segwh16;
1724 wh16->dwFlags = wh32->dwFlags;
1726 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
1729 ERR("Unknown msg %u\n", uMsg);
1732 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
1735 /* =================================
1736 * M A P P E R S H A N D L I N G
1737 * ================================= */
1739 static LRESULT MMDRV_CallMMDrvFunc16(DWORD fp16, WORD dev, WORD msg, LONG instance,
1747 args[5] = HIWORD(instance);
1748 args[4] = LOWORD(instance);
1749 args[3] = HIWORD(lp1);
1750 args[2] = LOWORD(lp1);
1751 args[1] = HIWORD(lp2);
1752 args[0] = LOWORD(lp2);
1753 WOWCallback16Ex( fp16, WCB16_PASCAL, sizeof(args), args, &ret );
1757 /**************************************************************************
1758 * MMDRV_GetDescription16 [internal]
1760 static BOOL MMDRV_GetDescription16(const char* fname, char* buf, int buflen)
1768 if ((hFile = OpenFile(fname, &ofs, OF_READ | OF_SHARE_DENY_WRITE)) == HFILE_ERROR) {
1769 ERR("Can't open file %s (builtin driver ?)\n", fname);
1773 #define E(_x) do {TRACE _x;goto theEnd;} while(0)
1775 if (_lread(hFile, &w, 2) != 2) E(("Can't read sig\n"));
1776 if (w != ('Z' * 256 + 'M')) E(("Bad sig %04x\n", w));
1777 if (_llseek(hFile, 0x3C, SEEK_SET) < 0) E(("Can't seek to ext header offset\n"));
1778 if (_lread(hFile, &dw, 4) != 4) E(("Can't read ext header offset\n"));
1779 if (_llseek(hFile, dw + 0x2C, SEEK_SET) < 0) E(("Can't seek to ext header.nr table %lu\n", dw+0x2C));
1780 if (_lread(hFile, &dw, 4) != 4) E(("Can't read nr table offset\n"));
1781 if (_llseek(hFile, dw, SEEK_SET) < 0) E(("Can't seek to nr table %lu\n", dw));
1782 if (_lread(hFile, buf, 1) != 1) E(("Can't read descr length\n"));
1783 buflen = min((int)(unsigned)(BYTE)buf[0], buflen - 1);
1784 if (_lread(hFile, buf, buflen) != buflen) E(("Can't read descr (%d)\n", buflen));
1787 TRACE("Got '%s' [%d]\n", buf, buflen);
1793 /******************************************************************
1794 * MMDRV_LoadMMDrvFunc16
1797 unsigned MMDRV_LoadMMDrvFunc16(LPCSTR drvName, LPWINE_DRIVER d,
1798 LPWINE_MM_DRIVER lpDrv)
1800 WINEMM_msgFunc16 func;
1804 * DESCRIPTION 'wave,aux,mixer:Creative Labs Sound Blaster 16 Driver'
1805 * The beginning of the module description indicates the driver supports
1806 * waveform, auxiliary, and mixer devices. Use one of the following
1807 * device-type names, followed by a colon (:) to indicate the type of
1808 * device your driver supports. If the driver supports more than one
1809 * type of device, separate each device-type name with a comma (,).
1811 * wave for waveform audio devices
1812 * wavemapper for wave mappers
1813 * midi for MIDI audio devices
1814 * midimapper for midi mappers
1815 * aux for auxiliary audio devices
1816 * mixer for mixer devices
1819 if (d->d.d16.hDriver16) {
1820 HMODULE16 hMod16 = GetDriverModuleHandle16(d->d.d16.hDriver16);
1822 #define AA(_h,_w,_x,_y,_z) \
1823 func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
1825 { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \
1826 TRACE("Got %d bit func '%s'\n", _y, #_x); }
1828 #define A(_x,_y) AA(hMod16,_x,_y,16,GetProcAddress16)
1829 A(MMDRV_AUX, auxMessage);
1830 A(MMDRV_MIXER, mxdMessage);
1831 A(MMDRV_MIDIIN, midMessage);
1832 A(MMDRV_MIDIOUT,modMessage);
1833 A(MMDRV_WAVEIN, widMessage);
1834 A(MMDRV_WAVEOUT,wodMessage);
1838 if (TRACE_ON(winmm)) {
1839 if (MMDRV_GetDescription16(drvName, buffer, sizeof(buffer)))
1840 TRACE("%s => %s\n", drvName, buffer);
1842 TRACE("%s => No description\n", drvName);
1848 /* =================================
1850 * ================================= */
1852 /**************************************************************************
1853 * MCI_MapMsg16To32A [internal]
1855 static WINMM_MapType MCI_MapMsg16To32A(WORD uDevType, WORD wMsg, DWORD* lParam)
1858 return WINMM_MAP_OK;
1859 /* FIXME: to add also (with seg/linear modifications to do):
1860 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
1861 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
1864 /* case MCI_CAPTURE */
1866 case MCI_CLOSE_DRIVER:
1873 case MCI_GETDEVCAPS:
1874 /* case MCI_INDEX: */
1875 /* case MCI_MARK: */
1876 /* case MCI_MONITOR: */
1886 /* case MCI_SETTIMECODE:*/
1887 /* case MCI_SIGNAL:*/
1889 case MCI_STATUS: /* FIXME: is wrong for digital video */
1892 /* case MCI_UNDO: */
1896 *lParam = (DWORD)MapSL(*lParam);
1897 return WINMM_MAP_OK;
1899 /* in fact, I would also need the dwFlags... to see
1900 * which members of lParam are effectively used
1902 *lParam = (DWORD)MapSL(*lParam);
1903 FIXME("Current mapping may be wrong\n");
1907 LPMCI_BREAK_PARMS mbp32 = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_BREAK_PARMS));
1908 LPMCI_BREAK_PARMS16 mbp16 = MapSL(*lParam);
1911 mbp32->dwCallback = mbp16->dwCallback;
1912 mbp32->nVirtKey = mbp16->nVirtKey;
1913 mbp32->hwndBreak = HWND_32(mbp16->hwndBreak);
1915 return WINMM_MAP_NOMEM;
1917 *lParam = (DWORD)mbp32;
1919 return WINMM_MAP_OKMEM;
1922 LPMCI_VD_ESCAPE_PARMSA mvep32a = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_VD_ESCAPE_PARMSA));
1923 LPMCI_VD_ESCAPE_PARMS16 mvep16 = MapSL(*lParam);
1926 mvep32a->dwCallback = mvep16->dwCallback;
1927 mvep32a->lpstrCommand = MapSL(mvep16->lpstrCommand);
1929 return WINMM_MAP_NOMEM;
1931 *lParam = (DWORD)mvep32a;
1933 return WINMM_MAP_OKMEM;
1936 LPMCI_INFO_PARMSA mip32a = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_INFO_PARMSA));
1937 LPMCI_INFO_PARMS16 mip16 = MapSL(*lParam);
1939 /* FIXME this is wrong if device is of type
1940 * MCI_DEVTYPE_DIGITAL_VIDEO, some members are not mapped
1943 mip32a->dwCallback = mip16->dwCallback;
1944 mip32a->lpstrReturn = MapSL(mip16->lpstrReturn);
1945 mip32a->dwRetSize = mip16->dwRetSize;
1947 return WINMM_MAP_NOMEM;
1949 *lParam = (DWORD)mip32a;
1951 return WINMM_MAP_OKMEM;
1953 case MCI_OPEN_DRIVER:
1955 LPMCI_OPEN_PARMSA mop32a = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_OPEN_PARMSA) + 2 * sizeof(DWORD));
1956 LPMCI_OPEN_PARMS16 mop16 = MapSL(*lParam);
1959 *(LPMCI_OPEN_PARMS16*)(mop32a) = mop16;
1960 mop32a = (LPMCI_OPEN_PARMSA)((char*)mop32a + sizeof(LPMCI_OPEN_PARMS16));
1961 mop32a->dwCallback = mop16->dwCallback;
1962 mop32a->wDeviceID = mop16->wDeviceID;
1963 mop32a->lpstrDeviceType = MapSL(mop16->lpstrDeviceType);
1964 mop32a->lpstrElementName = MapSL(mop16->lpstrElementName);
1965 mop32a->lpstrAlias = MapSL(mop16->lpstrAlias);
1966 /* copy extended information if any...
1967 * FIXME: this may seg fault if initial structure does not contain them and
1968 * the reads after msip16 fail under LDT limits...
1969 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
1970 * should not take care of extended parameters, and should be used by MCI_Open
1971 * to fetch uDevType. When, this is known, the mapping for sending the
1972 * MCI_OPEN_DRIVER shall be done depending on uDevType.
1974 memcpy(mop32a + 1, mop16 + 1, 2 * sizeof(DWORD));
1976 return WINMM_MAP_NOMEM;
1978 *lParam = (DWORD)mop32a;
1980 return WINMM_MAP_OKMEM;
1983 LPMCI_SYSINFO_PARMSA msip32a = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_SYSINFO_PARMSA));
1984 LPMCI_SYSINFO_PARMS16 msip16 = MapSL(*lParam);
1987 msip32a->dwCallback = msip16->dwCallback;
1988 msip32a->lpstrReturn = MapSL(msip16->lpstrReturn);
1989 msip32a->dwRetSize = msip16->dwRetSize;
1990 msip32a->dwNumber = msip16->dwNumber;
1991 msip32a->wDeviceType = msip16->wDeviceType;
1993 return WINMM_MAP_NOMEM;
1995 *lParam = (DWORD)msip32a;
1997 return WINMM_MAP_OKMEM;
2005 case DRV_QUERYCONFIGURE:
2008 case DRV_EXITSESSION:
2009 case DRV_EXITAPPLICATION:
2011 FIXME("This is a hack\n");
2012 return WINMM_MAP_OK;
2015 WARN("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg));
2017 return WINMM_MAP_MSGERROR;
2020 /**************************************************************************
2021 * MCI_UnMapMsg16To32A [internal]
2023 static WINMM_MapType MCI_UnMapMsg16To32A(WORD uDevType, WORD wMsg, DWORD lParam)
2026 /* case MCI_CAPTURE */
2028 case MCI_CLOSE_DRIVER:
2035 case MCI_GETDEVCAPS:
2036 /* case MCI_INDEX: */
2037 /* case MCI_MARK: */
2038 /* case MCI_MONITOR: */
2048 /* case MCI_SETTIMECODE:*/
2049 /* case MCI_SIGNAL:*/
2054 /* case MCI_UNDO: */
2058 return WINMM_MAP_OK;
2061 /* FIXME ?? see Map function */
2062 return WINMM_MAP_OK;
2068 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
2069 return WINMM_MAP_OK;
2071 case MCI_OPEN_DRIVER:
2073 LPMCI_OPEN_PARMSA mop32a = (LPMCI_OPEN_PARMSA)lParam;
2074 LPMCI_OPEN_PARMS16 mop16 = *(LPMCI_OPEN_PARMS16*)((char*)mop32a - sizeof(LPMCI_OPEN_PARMS16));
2076 mop16->wDeviceID = mop32a->wDeviceID;
2077 if (!HeapFree(GetProcessHeap(), 0, (LPVOID)(lParam - sizeof(LPMCI_OPEN_PARMS16))))
2078 FIXME("bad free line=%d\n", __LINE__);
2080 return WINMM_MAP_OK;
2088 case DRV_QUERYCONFIGURE:
2091 case DRV_EXITSESSION:
2092 case DRV_EXITAPPLICATION:
2094 FIXME("This is a hack\n");
2095 return WINMM_MAP_OK;
2097 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg));
2099 return WINMM_MAP_MSGERROR;
2104 * 0001 squeeze signed 4 bytes to 2 bytes *( LPINT16)D = ( INT16)*( LPINT16)S; D += 2; S += 4
2105 * 0010 squeeze unsigned 4 bytes to 2 bytes *(LPUINT16)D = (UINT16)*(LPUINT16)S; D += 2; S += 4
2108 * 0110 zero 4 bytes *(DWORD)D = 0 D += 4; S += 4
2109 * 0111 copy string *(LPSTR*)D = seg dup(*(LPSTR*)S) D += 4; S += 4
2110 * 1xxx copy xxx + 1 bytes memcpy(D, S, xxx + 1); D += xxx+1; S += xxx+1
2113 /**************************************************************************
2114 * MCI_MsgMapper32To16_Create [internal]
2116 * Helper for MCI_MapMsg32ATo16.
2117 * Maps the 32 bit pointer (*ptr), of size bytes, to an allocated 16 bit
2118 * segmented pointer.
2119 * map contains a list of action to be performed for the mapping (see list
2121 * if keep is TRUE, keeps track of in 32 bit ptr in allocated 16 bit area.
2123 static WINMM_MapType MCI_MsgMapper32To16_Create(void** ptr, int size16, DWORD map, BOOLEAN keep)
2125 void* lp = HeapAlloc( GetProcessHeap(), 0, (keep ? sizeof(void**) : 0) + size16 );
2129 return WINMM_MAP_NOMEM;
2131 p32 = (LPBYTE)(*ptr);
2134 p16 = (LPBYTE)lp + sizeof(void**);
2135 *ptr = (char*)MapLS(lp) + sizeof(void**);
2138 *ptr = (void*)MapLS(lp);
2142 memcpy(p16, p32, size16);
2150 sz = (nibble & 7) + 1;
2151 memcpy(p16, p32, sz);
2154 size16 -= sz; /* DEBUG only */
2158 *(LPINT16)p16 = *(LPINT)p32;
2159 p16 += sizeof(INT16);
2161 size16 -= sizeof(INT16);
2164 *(LPUINT16)p16 = *(LPUINT)p32;
2165 p16 += sizeof(UINT16);
2166 p32 += sizeof(UINT);
2167 size16 -= sizeof(UINT16);
2171 p16 += sizeof(DWORD);
2172 p32 += sizeof(DWORD);
2173 size16 -= sizeof(DWORD);
2176 *(SEGPTR *)p16 = MapLS( *(LPSTR *)p32 );
2177 p16 += sizeof(SEGPTR);
2178 p32 += sizeof(LPSTR);
2179 size16 -= sizeof(SEGPTR);
2182 FIXME("Unknown nibble for mapping (%x)\n", nibble);
2187 if (size16 != 0) /* DEBUG only */
2188 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
2190 return WINMM_MAP_OKMEM;
2193 /**************************************************************************
2194 * MCI_MsgMapper32To16_Destroy [internal]
2196 * Helper for MCI_UnMapMsg32ATo16.
2198 static WINMM_MapType MCI_MsgMapper32To16_Destroy(void* ptr, int size16, DWORD map, BOOLEAN kept)
2201 void* msg16 = MapSL((SEGPTR)ptr);
2206 UnMapLS( (SEGPTR)ptr );
2208 alloc = (char*)msg16 - sizeof(void**);
2209 p32 = *(void**)alloc;
2213 memcpy(p32, p16, size16);
2218 memcpy(p32, p16, (nibble & 7) + 1);
2219 p16 += (nibble & 7) + 1;
2220 p32 += (nibble & 7) + 1;
2221 size16 -= (nibble & 7) + 1;
2225 *(LPINT)p32 = *(LPINT16)p16;
2226 p16 += sizeof(INT16);
2228 size16 -= sizeof(INT16);
2231 *(LPUINT)p32 = *(LPUINT16)p16;
2232 p16 += sizeof(UINT16);
2233 p32 += sizeof(UINT);
2234 size16 -= sizeof(UINT16);
2237 p16 += sizeof(UINT);
2238 p32 += sizeof(UINT);
2239 size16 -= sizeof(UINT);
2242 UnMapLS( *(SEGPTR *)p16 );
2243 p16 += sizeof(SEGPTR);
2244 p32 += sizeof(char*);
2245 size16 -= sizeof(SEGPTR);
2248 FIXME("Unknown nibble for mapping (%x)\n", nibble);
2253 if (size16 != 0) /* DEBUG only */
2254 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
2260 HeapFree( GetProcessHeap(), 0, alloc );
2262 return WINMM_MAP_OK;
2265 /**************************************************************************
2266 * MCI_MapMsg32ATo16 [internal]
2268 * Map a 32-A bit MCI message to a 16 bit MCI message.
2270 static WINMM_MapType MCI_MapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam)
2273 BOOLEAN keep = FALSE;
2277 return WINMM_MAP_OK;
2279 /* FIXME: to add also (with seg/linear modifications to do):
2280 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
2281 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
2285 size = sizeof(MCI_BREAK_PARMS);
2287 /* case MCI_CAPTURE */
2289 case MCI_CLOSE_DRIVER:
2291 size = sizeof(MCI_GENERIC_PARMS);
2293 /* case MCI_COPY: */
2296 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_CUE_PARMS); break;
2297 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_CUE_PARMS); break;*/ FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2298 default: size = sizeof(MCI_GENERIC_PARMS); break;
2304 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_DELETE_PARMS16); map = 0x0F1111FB; break;
2305 case MCI_DEVTYPE_WAVEFORM_AUDIO:size = sizeof(MCI_WAVE_DELETE_PARMS); break;
2306 default: size = sizeof(MCI_GENERIC_PARMS); break;
2309 /* case MCI_ESCAPE: */
2312 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_FREEZE_PARMS); map = 0x0001111B; break;
2313 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS); map = 0x0001111B; break;
2314 default: size = sizeof(MCI_GENERIC_PARMS); break;
2317 case MCI_GETDEVCAPS:
2319 size = sizeof(MCI_GETDEVCAPS_PARMS);
2321 /* case MCI_INDEX: */
2324 LPMCI_INFO_PARMSA mip32a = (LPMCI_INFO_PARMSA)(*lParam);
2325 LPMCI_INFO_PARMS16 mip16;
2328 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_INFO_PARMS16); break;
2329 default: size = sizeof(MCI_INFO_PARMS16); break;
2331 mip16 = HeapAlloc( GetProcessHeap(), 0, size);
2334 mip16->dwCallback = mip32a->dwCallback;
2335 mip16->lpstrReturn = MapLS( mip32a->lpstrReturn );
2336 mip16->dwRetSize = mip32a->dwRetSize;
2337 if (uDevType == MCI_DEVTYPE_DIGITAL_VIDEO) {
2338 ((LPMCI_DGV_INFO_PARMS16)mip16)->dwItem = ((LPMCI_DGV_INFO_PARMSA)mip32a)->dwItem;
2341 return WINMM_MAP_NOMEM;
2343 *lParam = MapLS(mip16);
2345 return WINMM_MAP_OKMEM;
2346 /* case MCI_MARK: */
2347 /* case MCI_MONITOR: */
2349 case MCI_OPEN_DRIVER:
2351 LPMCI_OPEN_PARMSA mop32a = (LPMCI_OPEN_PARMSA)(*lParam);
2352 char* ptr = HeapAlloc( GetProcessHeap(), 0,
2353 sizeof(LPMCI_OPEN_PARMSA) + sizeof(MCI_OPEN_PARMS16) + 2 * sizeof(DWORD));
2354 LPMCI_OPEN_PARMS16 mop16;
2358 *(LPMCI_OPEN_PARMSA*)(ptr) = mop32a;
2359 mop16 = (LPMCI_OPEN_PARMS16)(ptr + sizeof(LPMCI_OPEN_PARMSA));
2360 mop16->dwCallback = mop32a->dwCallback;
2361 mop16->wDeviceID = mop32a->wDeviceID;
2362 if (dwFlags & MCI_OPEN_TYPE) {
2363 if (dwFlags & MCI_OPEN_TYPE_ID) {
2364 /* dword "transparent" value */
2365 mop16->lpstrDeviceType = (SEGPTR)mop32a->lpstrDeviceType;
2368 mop16->lpstrDeviceType = MapLS( mop32a->lpstrDeviceType );
2372 mop16->lpstrDeviceType = 0;
2374 if (dwFlags & MCI_OPEN_ELEMENT) {
2375 if (dwFlags & MCI_OPEN_ELEMENT_ID) {
2376 mop16->lpstrElementName = (SEGPTR)mop32a->lpstrElementName;
2378 mop16->lpstrElementName = MapLS( mop32a->lpstrElementName );
2381 mop16->lpstrElementName = 0;
2383 if (dwFlags & MCI_OPEN_ALIAS) {
2384 mop16->lpstrAlias = MapLS( mop32a->lpstrAlias );
2386 mop16->lpstrAlias = 0;
2388 /* copy extended information if any...
2389 * FIXME: this may seg fault if initial structure does not contain them and
2390 * the reads after msip16 fail under LDT limits...
2391 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
2392 * should not take care of extended parameters, and should be used by MCI_Open
2393 * to fetch uDevType. When, this is known, the mapping for sending the
2394 * MCI_OPEN_DRIVER shall be done depending on uDevType.
2396 memcpy(mop16 + 1, mop32a + 1, 2 * sizeof(DWORD));
2398 return WINMM_MAP_NOMEM;
2400 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_OPEN_PARMSA);
2402 return WINMM_MAP_OKMEM;
2403 /* case MCI_PASTE:*/
2405 size = sizeof(MCI_GENERIC_PARMS);
2408 size = sizeof(MCI_PLAY_PARMS);
2412 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; break;
2413 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS); map = 0x0001111B; break;
2414 default: size = sizeof(MCI_GENERIC_PARMS); break;
2418 size = sizeof(MCI_GENERIC_PARMS);
2422 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECORD_PARMS16); map = 0x0F1111FB; break;
2423 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_RECORD_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2424 default: size = sizeof(MCI_RECORD_PARMS); break;
2428 size = sizeof(MCI_GENERIC_PARMS);
2432 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SEEK_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2433 default: size = sizeof(MCI_SEEK_PARMS); break;
2438 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_SET_PARMS); break;
2439 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SET_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2440 case MCI_DEVTYPE_SEQUENCER: size = sizeof(MCI_SEQ_SET_PARMS); break;
2441 /* FIXME: normally the 16 and 32 bit structures are byte by byte aligned,
2442 * so not doing anything should work...
2444 case MCI_DEVTYPE_WAVEFORM_AUDIO:size = sizeof(MCI_WAVE_SET_PARMS); break;
2445 default: size = sizeof(MCI_SET_PARMS); break;
2450 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_SETAUDIO_PARMS16);map = 0x0000077FF; break;
2451 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2452 default: size = sizeof(MCI_GENERIC_PARMS); break;
2455 /* case MCI_SETTIMECODE:*/
2456 /* case MCI_SIGNAL:*/
2458 size = sizeof(MCI_SET_PARMS);
2464 * don't know if buffer for value is the one passed through lpstrDevice
2465 * or is provided by MCI driver.
2466 * Assuming solution 2: provided by MCI driver, so zeroing on entry
2468 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_STATUS_PARMS16); map = 0x0B6FF; break;
2469 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2470 default: size = sizeof(MCI_STATUS_PARMS); break;
2475 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_STEP_PARMS); break;
2476 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STEP_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2477 case MCI_DEVTYPE_VIDEODISC: size = sizeof(MCI_VD_STEP_PARMS); break;
2478 default: size = sizeof(MCI_GENERIC_PARMS); break;
2482 size = sizeof(MCI_SET_PARMS);
2486 LPMCI_SYSINFO_PARMSA msip32a = (LPMCI_SYSINFO_PARMSA)(*lParam);
2487 LPMCI_SYSINFO_PARMS16 msip16;
2488 char* ptr = HeapAlloc( GetProcessHeap(), 0,
2489 sizeof(LPMCI_SYSINFO_PARMSA) + sizeof(MCI_SYSINFO_PARMS16) );
2492 *(LPMCI_SYSINFO_PARMSA*)(ptr) = msip32a;
2493 msip16 = (LPMCI_SYSINFO_PARMS16)(ptr + sizeof(LPMCI_SYSINFO_PARMSA));
2495 msip16->dwCallback = msip32a->dwCallback;
2496 msip16->lpstrReturn = MapLS( msip32a->lpstrReturn );
2497 msip16->dwRetSize = msip32a->dwRetSize;
2498 msip16->dwNumber = msip32a->dwNumber;
2499 msip16->wDeviceType = msip32a->wDeviceType;
2501 return WINMM_MAP_NOMEM;
2503 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_SYSINFO_PARMSA);
2505 return WINMM_MAP_OKMEM;
2506 /* case MCI_UNDO: */
2509 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; break;
2510 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; break;
2511 default: size = sizeof(MCI_GENERIC_PARMS); break;
2516 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_UPDATE_PARMS16); map = 0x000B1111B; break;
2517 default: size = sizeof(MCI_GENERIC_PARMS); break;
2522 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; keep = TRUE; break;
2523 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; keep = TRUE; break;
2524 default: size = sizeof(MCI_GENERIC_PARMS); break;
2529 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_WINDOW_PARMS16); if (dwFlags & MCI_DGV_WINDOW_TEXT) map = 0x7FB; break;
2530 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_WINDOW_PARMS16); if (dwFlags & MCI_OVLY_WINDOW_TEXT) map = 0x7FB; break;
2531 default: size = sizeof(MCI_GENERIC_PARMS); break;
2536 LPMCI_OPEN_DRIVER_PARMSA modp32a = (LPMCI_OPEN_DRIVER_PARMSA)(*lParam);
2537 LPMCI_OPEN_DRIVER_PARMS16 modp16;
2538 char *ptr = HeapAlloc( GetProcessHeap(), 0,
2539 sizeof(LPMCI_OPEN_DRIVER_PARMSA) + sizeof(MCI_OPEN_DRIVER_PARMS16));
2542 *(LPMCI_OPEN_DRIVER_PARMSA*)(ptr) = modp32a;
2543 modp16 = (LPMCI_OPEN_DRIVER_PARMS16)(ptr + sizeof(LPMCI_OPEN_DRIVER_PARMSA));
2544 modp16->wDeviceID = modp32a->wDeviceID;
2545 modp16->lpstrParams = MapLS( modp32a->lpstrParams );
2546 /* other fields are gonna be filled by the driver, don't copy them */
2548 return WINMM_MAP_NOMEM;
2550 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_OPEN_DRIVER_PARMSA);
2552 return WINMM_MAP_OKMEM;
2559 case DRV_QUERYCONFIGURE:
2562 case DRV_EXITSESSION:
2563 case DRV_EXITAPPLICATION:
2565 return WINMM_MAP_OK;
2568 WARN("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg));
2569 return WINMM_MAP_MSGERROR;
2571 return MCI_MsgMapper32To16_Create((void**)lParam, size, map, keep);
2574 /**************************************************************************
2575 * MCI_UnMapMsg32ATo16 [internal]
2577 static WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD lParam)
2580 BOOLEAN kept = FALSE; /* there is no need to compute size when kept is FALSE */
2586 /* case MCI_CAPTURE */
2588 case MCI_CLOSE_DRIVER:
2591 /* case MCI_COPY: */
2597 /* case MCI_ESCAPE: */
2600 case MCI_GETDEVCAPS:
2602 size = sizeof(MCI_GETDEVCAPS_PARMS);
2604 /* case MCI_INDEX: */
2607 LPMCI_INFO_PARMS16 mip16 = (LPMCI_INFO_PARMS16)MapSL(lParam);
2609 UnMapLS( mip16->lpstrReturn );
2610 HeapFree( GetProcessHeap(), 0, mip16 );
2612 return WINMM_MAP_OK;
2613 /* case MCI_MARK: */
2614 /* case MCI_MONITOR: */
2616 case MCI_OPEN_DRIVER:
2618 LPMCI_OPEN_PARMS16 mop16 = (LPMCI_OPEN_PARMS16)MapSL(lParam);
2619 LPMCI_OPEN_PARMSA mop32a = *(LPMCI_OPEN_PARMSA*)((char*)mop16 - sizeof(LPMCI_OPEN_PARMSA));
2621 mop32a->wDeviceID = mop16->wDeviceID;
2622 if ((dwFlags & MCI_OPEN_TYPE) && !(dwFlags & MCI_OPEN_TYPE_ID))
2623 UnMapLS( mop16->lpstrDeviceType );
2624 if ((dwFlags & MCI_OPEN_ELEMENT) && !(dwFlags & MCI_OPEN_ELEMENT_ID))
2625 UnMapLS( mop16->lpstrElementName );
2626 if (dwFlags & MCI_OPEN_ALIAS)
2627 UnMapLS( mop16->lpstrAlias );
2628 HeapFree( GetProcessHeap(), 0, (char*)mop16 - sizeof(LPMCI_OPEN_PARMSA) );
2630 return WINMM_MAP_OK;
2631 /* case MCI_PASTE:*/
2650 case MCI_DEVTYPE_DIGITAL_VIDEO: map = 0x0000077FF; break;
2651 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2654 /* case MCI_SETTIMECODE:*/
2655 /* case MCI_SIGNAL:*/
2661 case MCI_DEVTYPE_DIGITAL_VIDEO:
2663 LPMCI_DGV_STATUS_PARMS16 mdsp16 = (LPMCI_DGV_STATUS_PARMS16)MapSL(lParam);
2664 LPMCI_DGV_STATUS_PARMSA mdsp32a = *(LPMCI_DGV_STATUS_PARMSA*)((char*)mdsp16 - sizeof(LPMCI_DGV_STATUS_PARMSA));
2668 mdsp32a->dwReturn = mdsp16->dwReturn;
2669 if (dwFlags & MCI_DGV_STATUS_DISKSPACE) {
2670 TRACE("MCI_STATUS (DGV) lpstrDrive=%08lx\n", mdsp16->lpstrDrive);
2671 TRACE("MCI_STATUS (DGV) lpstrDrive=%s\n", (LPSTR)MapSL(mdsp16->lpstrDrive));
2672 UnMapLS( mdsp16->lpstrDrive );
2674 HeapFree( GetProcessHeap(), 0, (char*)mdsp16 - sizeof(LPMCI_DGV_STATUS_PARMSA) );
2676 return WINMM_MAP_NOMEM;
2679 return WINMM_MAP_OKMEM;
2680 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2681 default: size = sizeof(MCI_STATUS_PARMS); break;
2690 LPMCI_SYSINFO_PARMS16 msip16 = (LPMCI_SYSINFO_PARMS16)MapSL(lParam);
2691 LPMCI_SYSINFO_PARMSA msip32a = *(LPMCI_SYSINFO_PARMSA*)((char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSA));
2695 msip16->dwCallback = msip32a->dwCallback;
2696 UnMapLS( msip16->lpstrReturn );
2697 HeapFree( GetProcessHeap(), 0, (char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSA) );
2699 return WINMM_MAP_NOMEM;
2702 return WINMM_MAP_OKMEM;
2703 /* case MCI_UNDO: */
2710 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; kept = TRUE; break;
2711 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; kept = TRUE; break;
2717 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_WINDOW_PARMS16); if (dwFlags & MCI_DGV_WINDOW_TEXT) map = 0x7666; break;
2718 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_WINDOW_PARMS16); if (dwFlags & MCI_OVLY_WINDOW_TEXT) map = 0x7666; break;
2721 /* FIXME: see map function */
2726 LPMCI_OPEN_DRIVER_PARMS16 modp16 = (LPMCI_OPEN_DRIVER_PARMS16)MapSL(lParam);
2727 LPMCI_OPEN_DRIVER_PARMSA modp32a = *(LPMCI_OPEN_DRIVER_PARMSA*)((char*)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSA));
2730 modp32a->wCustomCommandTable = modp16->wCustomCommandTable;
2731 modp32a->wType = modp16->wType;
2732 UnMapLS( modp16->lpstrParams );
2733 HeapFree( GetProcessHeap(), 0, (char *)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSA) );
2735 return WINMM_MAP_OK;
2742 case DRV_QUERYCONFIGURE:
2745 case DRV_EXITSESSION:
2746 case DRV_EXITAPPLICATION:
2748 FIXME("This is a hack\n");
2749 return WINMM_MAP_OK;
2751 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg));
2752 return WINMM_MAP_MSGERROR;
2754 return MCI_MsgMapper32To16_Destroy((void*)lParam, size, map, kept);
2757 void MMDRV_Init16(void)
2759 #define A(_x,_y) MMDRV_InstallMap(_x, \
2760 MMDRV_##_y##_Map16To32A, MMDRV_##_y##_UnMap16To32A, \
2761 MMDRV_##_y##_Map32ATo16, MMDRV_##_y##_UnMap32ATo16, \
2762 MMDRV_##_y##_Callback)
2764 A(MMDRV_MIXER, Mixer);
2765 A(MMDRV_MIDIIN, MidiIn);
2766 A(MMDRV_MIDIOUT, MidiOut);
2767 A(MMDRV_WAVEIN, WaveIn);
2768 A(MMDRV_WAVEOUT, WaveOut);
2771 pFnCallMMDrvFunc16 = MMDRV_CallMMDrvFunc16;
2772 pFnLoadMMDrvFunc16 = MMDRV_LoadMMDrvFunc16;
2774 pFnMciMapMsg16To32A = MCI_MapMsg16To32A;
2775 pFnMciUnMapMsg16To32A = MCI_UnMapMsg16To32A;
2776 pFnMciMapMsg32ATo16 = MCI_MapMsg32ATo16;
2777 pFnMciUnMapMsg32ATo16 = MCI_UnMapMsg32ATo16;