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"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(winmm);
35 /**************************************************************************
36 * MMDRV_Callback [internal]
38 static void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
40 TRACE("CB (*%08lx)(%p %08x %08lx %08lx %08lx\n",
41 mld->dwCallback, hDev, uMsg, mld->dwClientInstance, dwParam1, dwParam2);
43 if (!mld->bFrom32 && (mld->dwFlags & DCB_TYPEMASK) == DCB_FUNCTION)
46 /* 16 bit func, call it */
47 TRACE("Function (16 bit) !\n");
49 args[7] = HDRVR_16(hDev);
51 args[5] = HIWORD(mld->dwClientInstance);
52 args[4] = LOWORD(mld->dwClientInstance);
53 args[3] = HIWORD(dwParam1);
54 args[2] = LOWORD(dwParam1);
55 args[1] = HIWORD(dwParam2);
56 args[0] = LOWORD(dwParam2);
57 WOWCallback16Ex( mld->dwCallback, WCB16_PASCAL, sizeof(args), args, NULL );
59 DriverCallback(mld->dwCallback, mld->dwFlags, hDev, uMsg,
60 mld->dwClientInstance, dwParam1, dwParam2);
64 /* =================================
66 * ================================= */
68 /**************************************************************************
69 * MMDRV_Aux_Map16To32W [internal]
71 static WINMM_MapType MMDRV_Aux_Map16To32W (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
73 return WINMM_MAP_MSGERROR;
76 /**************************************************************************
77 * MMDRV_Aux_UnMap16To32W [internal]
79 static WINMM_MapType MMDRV_Aux_UnMap16To32W(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
81 return WINMM_MAP_MSGERROR;
84 /**************************************************************************
85 * MMDRV_Aux_Map32WTo16 [internal]
87 static WINMM_MapType MMDRV_Aux_Map32WTo16 (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
89 return WINMM_MAP_MSGERROR;
92 /**************************************************************************
93 * MMDRV_Aux_UnMap32WTo16 [internal]
95 static WINMM_MapType MMDRV_Aux_UnMap32WTo16(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
98 case AUXDM_GETDEVCAPS:
99 lpCaps->wMid = ac16.wMid;
100 lpCaps->wPid = ac16.wPid;
101 lpCaps->vDriverVersion = ac16.vDriverVersion;
102 strcpy(lpCaps->szPname, ac16.szPname);
103 lpCaps->wTechnology = ac16.wTechnology;
104 lpCaps->dwSupport = ac16.dwSupport;
106 return WINMM_MAP_MSGERROR;
109 /**************************************************************************
110 * MMDRV_Aux_Callback [internal]
112 static void CALLBACK MMDRV_Aux_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
114 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
117 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
120 /* =================================
121 * M I X E R M A P P E R S
122 * ================================= */
124 /**************************************************************************
125 * xMMDRV_Mixer_Map16To32W [internal]
127 static WINMM_MapType MMDRV_Mixer_Map16To32W (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
129 return WINMM_MAP_MSGERROR;
132 /**************************************************************************
133 * MMDRV_Mixer_UnMap16To32W [internal]
135 static WINMM_MapType MMDRV_Mixer_UnMap16To32W(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
139 UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
141 if (ret == MMSYSERR_NOERROR) {
142 mixcaps->wMid = micA.wMid;
143 mixcaps->wPid = micA.wPid;
144 mixcaps->vDriverVersion = micA.vDriverVersion;
145 strcpy(mixcaps->szPname, micA.szPname);
146 mixcaps->fdwSupport = micA.fdwSupport;
147 mixcaps->cDestinations = micA.cDestinations;
151 return WINMM_MAP_MSGERROR;
154 /**************************************************************************
155 * MMDRV_Mixer_Map32WTo16 [internal]
157 static WINMM_MapType MMDRV_Mixer_Map32WTo16 (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
159 return WINMM_MAP_MSGERROR;
162 /**************************************************************************
163 * MMDRV_Mixer_UnMap32WTo16 [internal]
165 static WINMM_MapType MMDRV_Mixer_UnMap32WTo16(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
167 return WINMM_MAP_MSGERROR;
170 /**************************************************************************
171 * MMDRV_Mixer_Callback [internal]
173 static void CALLBACK MMDRV_Mixer_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
175 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
178 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
181 /* =================================
182 * M I D I I N M A P P E R S
183 * ================================= */
185 /**************************************************************************
186 * MMDRV_MidiIn_Map16To32W [internal]
188 static WINMM_MapType MMDRV_MidiIn_Map16To32W (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
190 return WINMM_MAP_MSGERROR;
193 /**************************************************************************
194 * MMDRV_MidiIn_UnMap16To32W [internal]
196 static WINMM_MapType MMDRV_MidiIn_UnMap16To32W(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
198 return WINMM_MAP_MSGERROR;
201 /**************************************************************************
202 * MMDRV_MidiIn_Map32WTo16 [internal]
204 static WINMM_MapType MMDRV_MidiIn_Map32WTo16 (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
206 return WINMM_MAP_MSGERROR;
209 /**************************************************************************
210 * MMDRV_MidiIn_UnMap32WTo16 [internal]
212 static WINMM_MapType MMDRV_MidiIn_UnMap32WTo16(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
214 return WINMM_MAP_MSGERROR;
217 /**************************************************************************
218 * MMDRV_MidiIn_Callback [internal]
220 static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
222 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
227 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
232 /* dwParam1 & dwParam2 are data, nothing to do */
236 /* dwParam1 points to a MidiHdr, work to be done !!! */
237 if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) {
238 /* initial map is: 32 => 16 */
239 LPMIDIHDR mh16 = MapSL(dwParam1);
240 LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR));
242 dwParam1 = (DWORD)mh32;
243 mh32->dwFlags = mh16->dwFlags;
244 mh32->dwBytesRecorded = mh16->dwBytesRecorded;
245 if (mh32->reserved >= sizeof(MIDIHDR))
246 mh32->dwOffset = mh16->dwOffset;
247 } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) {
248 /* initial map is: 16 => 32 */
249 LPMIDIHDR mh32 = (LPMIDIHDR)(dwParam1);
250 SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR));
251 LPMIDIHDR mh16 = MapSL(segmh16);
253 dwParam1 = (DWORD)segmh16;
254 mh16->dwFlags = mh32->dwFlags;
255 mh16->dwBytesRecorded = mh32->dwBytesRecorded;
256 if (mh16->reserved >= sizeof(MIDIHDR))
257 mh16->dwOffset = mh32->dwOffset;
259 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
261 /* case MOM_POSITIONCB: */
263 ERR("Unknown msg %u\n", uMsg);
266 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
269 /* =================================
270 * M I D I O U T M A P P E R S
271 * ================================= */
273 /**************************************************************************
274 * MMDRV_MidiOut_Map16To32W [internal]
276 static WINMM_MapType MMDRV_MidiOut_Map16To32W (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
278 WINMM_MapType ret = WINMM_MAP_MSGERROR;
281 case MODM_GETNUMDEVS:
291 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
294 case MODM_GETDEVCAPS:
296 LPMIDIOUTCAPSW moc32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPS16) + sizeof(MIDIOUTCAPSW));
297 LPMIDIOUTCAPS16 moc16 = MapSL(*lpParam1);
300 *(LPMIDIOUTCAPS16*)moc32 = moc16;
301 moc32 = (LPMIDIOUTCAPSW)((LPSTR)moc32 + sizeof(LPMIDIOUTCAPS16));
302 *lpParam1 = (DWORD)moc32;
303 *lpParam2 = sizeof(MIDIOUTCAPSW);
305 ret = WINMM_MAP_OKMEM;
307 ret = WINMM_MAP_NOMEM;
313 LPMIDIHDR mh32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIHDR) + sizeof(MIDIHDR));
314 LPMIDIHDR mh16 = MapSL(*lpParam1);
317 *(LPMIDIHDR*)mh32 = (LPMIDIHDR)*lpParam1;
318 mh32 = (LPMIDIHDR)((LPSTR)mh32 + sizeof(LPMIDIHDR));
319 mh32->lpData = MapSL((SEGPTR)mh16->lpData);
320 mh32->dwBufferLength = mh16->dwBufferLength;
321 mh32->dwBytesRecorded = mh16->dwBytesRecorded;
322 mh32->dwUser = mh16->dwUser;
323 mh32->dwFlags = mh16->dwFlags;
324 /* FIXME: nothing on mh32->lpNext */
325 /* could link the mh32->lpNext at this level for memory house keeping */
326 mh32->dwOffset = (*lpParam2 >= sizeof(MIDIHDR)) ? ((LPMIDIHDR)mh16)->dwOffset : 0;
327 mh16->lpNext = mh32; /* for reuse in unprepare and write */
328 /* store size of passed MIDIHDR?? structure to know if dwOffset is available or not */
329 mh16->reserved = *lpParam2;
330 *lpParam1 = (DWORD)mh32;
331 *lpParam2 = sizeof(MIDIHDR);
333 ret = WINMM_MAP_OKMEM;
335 ret = WINMM_MAP_NOMEM;
342 LPMIDIHDR mh16 = MapSL(*lpParam1);
343 LPMIDIHDR mh32 = (LPMIDIHDR)mh16->lpNext;
345 *lpParam1 = (DWORD)mh32;
346 *lpParam2 = sizeof(MIDIHDR);
347 /* dwBufferLength can be reduced between prepare & write */
348 if (wMsg == MODM_LONGDATA && mh32->dwBufferLength < mh16->dwBufferLength) {
349 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
350 mh32->dwBufferLength, mh16->dwBufferLength);
352 mh32->dwBufferLength = mh16->dwBufferLength;
353 ret = WINMM_MAP_OKMEM;
357 case MODM_CACHEPATCHES:
358 case MODM_CACHEDRUMPATCHES:
360 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
366 /**************************************************************************
367 * MMDRV_MidiOut_UnMap16To32W [internal]
369 static WINMM_MapType MMDRV_MidiOut_UnMap16To32W(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
371 WINMM_MapType ret = WINMM_MAP_MSGERROR;
374 case MODM_GETNUMDEVS:
384 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
387 case MODM_GETDEVCAPS:
389 LPMIDIOUTCAPSW moc32 = (LPMIDIOUTCAPSW)(*lpParam1);
390 LPMIDIOUTCAPS16 moc16 = *(LPMIDIOUTCAPS16*)((LPSTR)moc32 - sizeof(LPMIDIOUTCAPS16));
392 moc16->wMid = moc32->wMid;
393 moc16->wPid = moc32->wPid;
394 moc16->vDriverVersion = moc32->vDriverVersion;
395 WideCharToMultiByte( CP_ACP, 0, moc32->szPname, -1, moc16->szPname,
396 sizeof(moc16->szPname), NULL, NULL );
397 moc16->wTechnology = moc32->wTechnology;
398 moc16->wVoices = moc32->wVoices;
399 moc16->wNotes = moc32->wNotes;
400 moc16->wChannelMask = moc32->wChannelMask;
401 moc16->dwSupport = moc32->dwSupport;
402 HeapFree(GetProcessHeap(), 0, (LPSTR)moc32 - sizeof(LPMIDIOUTCAPS16));
410 LPMIDIHDR mh32 = (LPMIDIHDR)(*lpParam1);
411 LPMIDIHDR mh16 = MapSL(*(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR)));
413 assert(mh16->lpNext == mh32);
414 mh16->dwBufferLength = mh32->dwBufferLength;
415 mh16->dwBytesRecorded = mh32->dwBytesRecorded;
416 mh16->dwUser = mh32->dwUser;
417 mh16->dwFlags = mh32->dwFlags;
418 if (mh16->reserved >= sizeof(MIDIHDR))
419 mh16->dwOffset = mh32->dwOffset;
421 if (wMsg == MODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
422 HeapFree(GetProcessHeap(), 0, (LPSTR)mh32 - sizeof(LPMIDIHDR));
429 case MODM_CACHEPATCHES:
430 case MODM_CACHEDRUMPATCHES:
432 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
438 /**************************************************************************
439 * MMDRV_MidiOut_Map32WTo16 [internal]
441 static WINMM_MapType MMDRV_MidiOut_Map32WTo16 (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
443 WINMM_MapType ret = WINMM_MAP_MSGERROR;
447 case MODM_GETNUMDEVS:
453 case MODM_GETDEVCAPS:
455 LPMIDIOUTCAPSW moc32 = (LPMIDIOUTCAPSW)*lpParam1;
456 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPSW)+sizeof(MIDIOUTCAPS16));
459 *(LPMIDIOUTCAPSW*)ptr = moc32;
460 ret = WINMM_MAP_OKMEM;
462 ret = WINMM_MAP_NOMEM;
464 *lpParam1 = (DWORD)MapLS(ptr) + sizeof(LPMIDIOUTCAPSW);
465 *lpParam2 = sizeof(MIDIOUTCAPS16);
470 LPMIDIHDR mh32 = (LPMIDIHDR)*lpParam1;
472 LPVOID ptr = HeapAlloc( GetProcessHeap(), 0,
473 sizeof(LPMIDIHDR) + sizeof(MIDIHDR) + mh32->dwBufferLength);
476 *(LPMIDIHDR*)ptr = mh32;
477 mh16 = (LPMIDIHDR)((LPSTR)ptr + sizeof(LPMIDIHDR));
478 *lpParam1 = MapLS(mh16);
479 mh16->lpData = (LPSTR)*lpParam1 + sizeof(MIDIHDR);
480 /* data will be copied on WODM_WRITE */
481 mh16->dwBufferLength = mh32->dwBufferLength;
482 mh16->dwBytesRecorded = mh32->dwBytesRecorded;
483 mh16->dwUser = mh32->dwUser;
484 mh16->dwFlags = mh32->dwFlags;
485 /* FIXME: nothing on mh32->lpNext */
486 /* could link the mh32->lpNext at this level for memory house keeping */
487 mh16->dwOffset = (*lpParam2 >= sizeof(MIDIHDR)) ? mh32->dwOffset : 0;
489 mh32->lpNext = (LPMIDIHDR)mh16; /* for reuse in unprepare and write */
490 mh32->reserved = *lpParam2;
492 TRACE("mh16=%08lx mh16->lpData=%p mh32->buflen=%u mh32->lpData=%p\n",
493 *lpParam1, mh16->lpData, mh32->dwBufferLength, mh32->lpData);
494 *lpParam2 = sizeof(MIDIHDR);
496 ret = WINMM_MAP_OKMEM;
498 ret = WINMM_MAP_NOMEM;
505 LPMIDIHDR mh32 = (LPMIDIHDR)(*lpParam1);
506 LPMIDIHDR mh16 = (LPMIDIHDR)mh32->lpNext;
507 LPSTR ptr = (LPSTR)mh16 - sizeof(LPMIDIHDR);
509 assert(*(LPMIDIHDR*)ptr == mh32);
511 if (wMsg == MODM_LONGDATA)
512 memcpy((LPSTR)mh16 + sizeof(MIDIHDR), mh32->lpData, mh32->dwBufferLength);
514 *lpParam1 = MapLS(mh16);
515 *lpParam2 = sizeof(MIDIHDR);
516 TRACE("mh16=%08lx mh16->lpData=%p mh32->buflen=%u mh32->lpData=%p\n",
517 *lpParam1, mh16->lpData, mh32->dwBufferLength, mh32->lpData);
519 /* dwBufferLength can be reduced between prepare & write */
520 if (wMsg == MODM_LONGDATA && mh16->dwBufferLength < mh32->dwBufferLength) {
521 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
522 mh16->dwBufferLength, mh32->dwBufferLength);
524 mh16->dwBufferLength = mh32->dwBufferLength;
525 ret = WINMM_MAP_OKMEM;
530 LPMIDIOPENDESC mod32 = (LPMIDIOPENDESC)*lpParam1;
532 LPMIDIOPENDESC16 mod16;
534 /* allocated data are mapped as follows:
535 LPMIDIOPENDESC ptr to orig lParam1
536 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
537 DWORD dwUser passed to driver
538 MIDIOPENDESC16 mod16: openDesc passed to driver
541 ptr = HeapAlloc( GetProcessHeap(), 0,
542 sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD) + sizeof(MIDIOPENDESC16) +
543 mod32->cIds ? (mod32->cIds - 1) * sizeof(MIDIOPENSTRMID) : 0);
546 SEGPTR segptr = MapLS(ptr);
547 *(LPMIDIOPENDESC*)ptr = mod32;
548 *(LPDWORD)((char*)ptr + sizeof(LPMIDIOPENDESC)) = *lpdwUser;
549 mod16 = (LPMIDIOPENDESC16)((LPSTR)ptr + sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD));
551 mod16->hMidi = HMIDI_16(mod32->hMidi);
552 mod16->dwCallback = mod32->dwCallback;
553 mod16->dwInstance = mod32->dwInstance;
554 mod16->dnDevNode = mod32->dnDevNode;
555 mod16->cIds = mod32->cIds;
556 memcpy(&mod16->rgIds, &mod32->rgIds, mod32->cIds * sizeof(MIDIOPENSTRMID));
558 *lpParam1 = (DWORD)segptr + sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD);
559 *lpdwUser = (DWORD)segptr + sizeof(LPMIDIOPENDESC) + sizeof(DWORD);
561 ret = WINMM_MAP_OKMEM;
563 ret = WINMM_MAP_NOMEM;
568 case MODM_CACHEPATCHES:
569 case MODM_CACHEDRUMPATCHES:
571 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
577 /**************************************************************************
578 * MMDRV_MidiOut_UnMap32WTo16 [internal]
580 static WINMM_MapType MMDRV_MidiOut_UnMap32WTo16(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
582 WINMM_MapType ret = WINMM_MAP_MSGERROR;
586 case MODM_GETNUMDEVS:
592 case MODM_GETDEVCAPS:
594 LPMIDIOUTCAPS16 moc16 = MapSL(*lpParam1);
595 LPSTR ptr = (LPSTR)moc16 - sizeof(LPMIDIOUTCAPSW);
596 LPMIDIOUTCAPSW moc32 = *(LPMIDIOUTCAPSW*)ptr;
598 moc32->wMid = moc16->wMid;
599 moc32->wPid = moc16->wPid;
600 moc32->vDriverVersion = moc16->vDriverVersion;
601 WideCharToMultiByte( CP_ACP, 0, moc32->szPname, -1, moc16->szPname,
602 sizeof(moc16->szPname), NULL, NULL );
603 moc32->wTechnology = moc16->wTechnology;
604 moc32->wVoices = moc16->wVoices;
605 moc32->wNotes = moc16->wNotes;
606 moc32->wChannelMask = moc16->wChannelMask;
607 moc32->dwSupport = moc16->dwSupport;
608 UnMapLS( *lpParam1 );
609 HeapFree( GetProcessHeap(), 0, ptr );
617 LPMIDIHDR mh16 = MapSL(*lpParam1);
618 LPSTR ptr = (LPSTR)mh16 - sizeof(LPMIDIHDR);
619 LPMIDIHDR mh32 = *(LPMIDIHDR*)ptr;
621 assert(mh32->lpNext == (LPMIDIHDR)mh16);
622 UnMapLS( *lpParam1 );
623 mh32->dwBytesRecorded = mh16->dwBytesRecorded;
624 mh32->dwUser = mh16->dwUser;
625 mh32->dwFlags = mh16->dwFlags;
627 if (wMsg == MODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
628 HeapFree( GetProcessHeap(), 0, ptr );
636 LPMIDIOPENDESC16 mod16 = MapSL(*lpParam1);
637 LPSTR ptr = (LPSTR)mod16 - sizeof(LPMIDIOPENDESC) - 2*sizeof(DWORD);
638 UnMapLS( *lpParam1 );
639 **(DWORD**)(ptr + sizeof(LPMIDIOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPMIDIOPENDESC) + sizeof(DWORD));
641 HeapFree( GetProcessHeap(), 0, ptr );
646 case MODM_CACHEPATCHES:
647 case MODM_CACHEDRUMPATCHES:
649 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
655 /**************************************************************************
656 * MMDRV_MidiOut_Callback [internal]
658 static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
660 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
665 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
668 if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) {
669 /* initial map is: 32 => 16 */
670 LPMIDIHDR mh16 = MapSL(dwParam1);
671 LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR));
673 dwParam1 = (DWORD)mh32;
674 mh32->dwFlags = mh16->dwFlags;
675 mh32->dwOffset = mh16->dwOffset;
676 if (mh32->reserved >= sizeof(MIDIHDR))
677 mh32->dwOffset = mh16->dwOffset;
678 } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) {
679 /* initial map is: 16 => 32 */
680 LPMIDIHDR mh32 = (LPMIDIHDR)(dwParam1);
681 SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR));
682 LPMIDIHDR mh16 = MapSL(segmh16);
684 dwParam1 = (DWORD)segmh16;
685 mh16->dwFlags = mh32->dwFlags;
686 if (mh16->reserved >= sizeof(MIDIHDR))
687 mh16->dwOffset = mh32->dwOffset;
689 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
691 /* case MOM_POSITIONCB: */
693 ERR("Unknown msg %u\n", uMsg);
696 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
699 /* =================================
700 * W A V E I N M A P P E R S
701 * ================================= */
703 /**************************************************************************
704 * MMDRV_WaveIn_Map16To32W [internal]
706 static WINMM_MapType MMDRV_WaveIn_Map16To32W (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
708 WINMM_MapType ret = WINMM_MAP_MSGERROR;
711 case WIDM_GETNUMDEVS:
719 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
721 case WIDM_GETDEVCAPS:
723 LPWAVEINCAPSW wic32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEINCAPS16) + sizeof(WAVEINCAPSW));
724 LPWAVEINCAPS16 wic16 = MapSL(*lpParam1);
727 *(LPWAVEINCAPS16*)wic32 = wic16;
728 wic32 = (LPWAVEINCAPSW)((LPSTR)wic32 + sizeof(LPWAVEINCAPS16));
729 *lpParam1 = (DWORD)wic32;
730 *lpParam2 = sizeof(WAVEINCAPSW);
732 ret = WINMM_MAP_OKMEM;
734 ret = WINMM_MAP_NOMEM;
740 LPMMTIME mmt32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16) + sizeof(MMTIME));
741 LPMMTIME16 mmt16 = MapSL(*lpParam1);
744 *(LPMMTIME16*)mmt32 = mmt16;
745 mmt32 = (LPMMTIME)((LPSTR)mmt32 + sizeof(LPMMTIME16));
747 mmt32->wType = mmt16->wType;
748 *lpParam1 = (DWORD)mmt32;
749 *lpParam2 = sizeof(MMTIME);
751 ret = WINMM_MAP_OKMEM;
753 ret = WINMM_MAP_NOMEM;
759 LPWAVEHDR wh32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR) + sizeof(WAVEHDR));
760 LPWAVEHDR wh16 = MapSL(*lpParam1);
763 *(LPWAVEHDR*)wh32 = (LPWAVEHDR)*lpParam1;
764 wh32 = (LPWAVEHDR)((LPSTR)wh32 + sizeof(LPWAVEHDR));
765 wh32->lpData = MapSL((SEGPTR)wh16->lpData);
766 wh32->dwBufferLength = wh16->dwBufferLength;
767 wh32->dwBytesRecorded = wh16->dwBytesRecorded;
768 wh32->dwUser = wh16->dwUser;
769 wh32->dwFlags = wh16->dwFlags;
770 wh32->dwLoops = wh16->dwLoops;
771 /* FIXME: nothing on wh32->lpNext */
772 /* could link the wh32->lpNext at this level for memory house keeping */
773 wh16->lpNext = wh32; /* for reuse in unprepare and write */
774 *lpParam1 = (DWORD)wh32;
775 *lpParam2 = sizeof(WAVEHDR);
777 ret = WINMM_MAP_OKMEM;
779 ret = WINMM_MAP_NOMEM;
786 LPWAVEHDR wh16 = MapSL(*lpParam1);
787 LPWAVEHDR wh32 = (LPWAVEHDR)wh16->lpNext;
789 *lpParam1 = (DWORD)wh32;
790 *lpParam2 = sizeof(WAVEHDR);
791 /* dwBufferLength can be reduced between prepare & write */
792 if (wMsg == WIDM_ADDBUFFER && wh32->dwBufferLength < wh16->dwBufferLength) {
793 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
794 wh32->dwBufferLength, wh16->dwBufferLength);
796 wh32->dwBufferLength = wh16->dwBufferLength;
797 ret = WINMM_MAP_OKMEM;
800 case WIDM_MAPPER_STATUS:
801 /* just a single DWORD */
802 *lpParam2 = (DWORD)MapSL(*lpParam2);
806 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
812 /**************************************************************************
813 * MMDRV_WaveIn_UnMap16To32W [internal]
815 static WINMM_MapType MMDRV_WaveIn_UnMap16To32W(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
817 WINMM_MapType ret = WINMM_MAP_MSGERROR;
820 case WIDM_GETNUMDEVS:
824 case WIDM_MAPPER_STATUS:
829 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
831 case WIDM_GETDEVCAPS:
833 LPWAVEINCAPSW wic32 = (LPWAVEINCAPSW)(*lpParam1);
834 LPWAVEINCAPS16 wic16 = *(LPWAVEINCAPS16*)((LPSTR)wic32 - sizeof(LPWAVEINCAPS16));
836 wic16->wMid = wic32->wMid;
837 wic16->wPid = wic32->wPid;
838 wic16->vDriverVersion = wic32->vDriverVersion;
839 WideCharToMultiByte( CP_ACP, 0, wic32->szPname, -1, wic16->szPname,
840 sizeof(wic16->szPname), NULL, NULL );
841 wic16->dwFormats = wic32->dwFormats;
842 wic16->wChannels = wic32->wChannels;
843 HeapFree(GetProcessHeap(), 0, (LPSTR)wic32 - sizeof(LPWAVEINCAPS16));
849 LPMMTIME mmt32 = (LPMMTIME)(*lpParam1);
850 LPMMTIME16 mmt16 = *(LPMMTIME16*)((LPSTR)mmt32 - sizeof(LPMMTIME16));
852 MMSYSTEM_MMTIME32to16(mmt16, mmt32);
853 HeapFree(GetProcessHeap(), 0, (LPSTR)mmt32 - sizeof(LPMMTIME16));
861 LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1);
862 LPWAVEHDR wh16 = MapSL(*(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR)));
864 assert(wh16->lpNext == wh32);
865 wh16->dwBufferLength = wh32->dwBufferLength;
866 wh16->dwBytesRecorded = wh32->dwBytesRecorded;
867 wh16->dwUser = wh32->dwUser;
868 wh16->dwFlags = wh32->dwFlags;
869 wh16->dwLoops = wh32->dwLoops;
871 if (wMsg == WIDM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
872 HeapFree(GetProcessHeap(), 0, (LPSTR)wh32 - sizeof(LPWAVEHDR));
879 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
885 /**************************************************************************
886 * MMDRV_WaveIn_Map32WTo16 [internal]
888 static WINMM_MapType MMDRV_WaveIn_Map32WTo16 (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
890 WINMM_MapType ret = WINMM_MAP_MSGERROR;
894 case WIDM_GETNUMDEVS:
903 LPWAVEOPENDESC wod32 = (LPWAVEOPENDESC)*lpParam1;
904 int sz = sizeof(WAVEFORMATEX);
906 LPWAVEOPENDESC16 wod16;
908 /* allocated data are mapped as follows:
909 LPWAVEOPENDESC ptr to orig lParam1
910 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
911 DWORD dwUser passed to driver
912 WAVEOPENDESC16 wod16: openDesc passed to driver
913 WAVEFORMATEX openDesc->lpFormat passed to driver
914 xxx extra bytes to WAVEFORMATEX
916 if (wod32->lpFormat->wFormatTag != WAVE_FORMAT_PCM) {
917 TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize, wod32->lpFormat->wFormatTag);
918 sz += ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize;
921 ptr = HeapAlloc( GetProcessHeap(), 0,
922 sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16) + sz);
925 SEGPTR seg_ptr = MapLS( ptr );
926 *(LPWAVEOPENDESC*)ptr = wod32;
927 *(LPDWORD)((char*)ptr + sizeof(LPWAVEOPENDESC)) = *lpdwUser;
928 wod16 = (LPWAVEOPENDESC16)((LPSTR)ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD));
930 wod16->hWave = HWAVE_16(wod32->hWave);
931 wod16->lpFormat = (LPWAVEFORMATEX)(seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16));
932 memcpy(wod16 + 1, wod32->lpFormat, sz);
934 wod16->dwCallback = wod32->dwCallback;
935 wod16->dwInstance = wod32->dwInstance;
936 wod16->uMappedDeviceID = wod32->uMappedDeviceID;
937 wod16->dnDevNode = wod32->dnDevNode;
939 *lpParam1 = seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD);
940 *lpdwUser = seg_ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD);
942 ret = WINMM_MAP_OKMEM;
944 ret = WINMM_MAP_NOMEM;
950 LPWAVEHDR wh32 = (LPWAVEHDR)*lpParam1;
952 LPVOID ptr = HeapAlloc( GetProcessHeap(), 0,
953 sizeof(LPWAVEHDR) + sizeof(WAVEHDR) + wh32->dwBufferLength);
956 SEGPTR seg_ptr = MapLS( ptr );
957 *(LPWAVEHDR*)ptr = wh32;
958 wh16 = (LPWAVEHDR)((LPSTR)ptr + sizeof(LPWAVEHDR));
959 wh16->lpData = (LPSTR)seg_ptr + sizeof(LPWAVEHDR) + sizeof(WAVEHDR);
960 /* data will be copied on WODM_WRITE */
961 wh16->dwBufferLength = wh32->dwBufferLength;
962 wh16->dwBytesRecorded = wh32->dwBytesRecorded;
963 wh16->dwUser = wh32->dwUser;
964 wh16->dwFlags = wh32->dwFlags;
965 wh16->dwLoops = wh32->dwLoops;
966 /* FIXME: nothing on wh32->lpNext */
967 /* could link the wh32->lpNext at this level for memory house keeping */
968 wh32->lpNext = wh16; /* for reuse in unprepare and write */
969 *lpParam1 = seg_ptr + sizeof(LPWAVEHDR);
970 *lpParam2 = sizeof(WAVEHDR);
971 TRACE("wh16=%08lx wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n",
972 *lpParam1, wh16->lpData, wh32->dwBufferLength, wh32->lpData);
974 ret = WINMM_MAP_OKMEM;
976 ret = WINMM_MAP_NOMEM;
983 LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1);
984 LPWAVEHDR wh16 = wh32->lpNext;
985 LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR);
986 SEGPTR seg_ptr = MapLS( ptr );
988 assert(*(LPWAVEHDR*)ptr == wh32);
990 if (wMsg == WIDM_ADDBUFFER)
991 memcpy((LPSTR)wh16 + sizeof(WAVEHDR), wh32->lpData, wh32->dwBufferLength);
993 *lpParam1 = seg_ptr + sizeof(LPWAVEHDR);
994 *lpParam2 = sizeof(WAVEHDR);
995 TRACE("wh16=%08lx wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n",
996 *lpParam1, wh16->lpData, wh32->dwBufferLength, wh32->lpData);
998 /* dwBufferLength can be reduced between prepare & write */
999 if (wMsg == WIDM_ADDBUFFER && wh16->dwBufferLength < wh32->dwBufferLength) {
1000 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
1001 wh16->dwBufferLength, wh32->dwBufferLength);
1003 wh16->dwBufferLength = wh32->dwBufferLength;
1004 ret = WINMM_MAP_OKMEM;
1007 case WIDM_GETDEVCAPS:
1009 LPWAVEINCAPSW wic32 = (LPWAVEINCAPSW)*lpParam1;
1010 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0 ,sizeof(LPWAVEINCAPSW) + sizeof(WAVEINCAPS16));
1013 *(LPWAVEINCAPSW*)ptr = wic32;
1014 ret = WINMM_MAP_OKMEM;
1016 ret = WINMM_MAP_NOMEM;
1018 *lpParam1 = MapLS(ptr) + sizeof(LPWAVEINCAPSW);
1019 *lpParam2 = sizeof(WAVEINCAPS16);
1024 LPMMTIME mmt32 = (LPMMTIME)*lpParam1;
1025 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME) + sizeof(MMTIME16));
1026 LPMMTIME16 mmt16 = (LPMMTIME16)(ptr + sizeof(LPMMTIME));
1029 *(LPMMTIME*)ptr = mmt32;
1030 mmt16->wType = mmt32->wType;
1031 ret = WINMM_MAP_OKMEM;
1033 ret = WINMM_MAP_NOMEM;
1035 *lpParam1 = MapLS(ptr) + sizeof(LPMMTIME);
1036 *lpParam2 = sizeof(MMTIME16);
1039 case DRVM_MAPPER_STATUS:
1041 LPDWORD p32 = (LPDWORD)*lpParam2;
1042 *lpParam2 = MapLS(p32);
1043 ret = WINMM_MAP_OKMEM;
1047 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
1053 /**************************************************************************
1054 * MMDRV_WaveIn_UnMap32WTo16 [internal]
1056 static WINMM_MapType MMDRV_WaveIn_UnMap32WTo16(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
1058 WINMM_MapType ret = WINMM_MAP_MSGERROR;
1062 case WIDM_GETNUMDEVS:
1071 LPWAVEOPENDESC16 wod16 = MapSL(*lpParam1);
1072 LPSTR ptr = (LPSTR)wod16 - sizeof(LPWAVEOPENDESC) - 2*sizeof(DWORD);
1073 LPWAVEOPENDESC wod32 = *(LPWAVEOPENDESC*)ptr;
1075 UnMapLS( *lpParam1 );
1076 wod32->uMappedDeviceID = wod16->uMappedDeviceID;
1077 **(DWORD**)(ptr + sizeof(LPWAVEOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD));
1078 HeapFree( GetProcessHeap(), 0, ptr );
1083 case WIDM_ADDBUFFER:
1085 case WIDM_UNPREPARE:
1087 LPWAVEHDR wh16 = MapSL(*lpParam1);
1088 LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR);
1089 LPWAVEHDR wh32 = *(LPWAVEHDR*)ptr;
1091 assert(wh32->lpNext == wh16);
1092 wh32->dwBytesRecorded = wh16->dwBytesRecorded;
1093 wh32->dwUser = wh16->dwUser;
1094 wh32->dwFlags = wh16->dwFlags;
1095 wh32->dwLoops = wh16->dwLoops;
1096 UnMapLS( *lpParam1 );
1098 if (wMsg == WIDM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
1099 HeapFree( GetProcessHeap(), 0, ptr );
1105 case WIDM_GETDEVCAPS:
1107 LPWAVEINCAPS16 wic16 = MapSL(*lpParam1);
1108 LPSTR ptr = (LPSTR)wic16 - sizeof(LPWAVEINCAPSW);
1109 LPWAVEINCAPSW wic32 = *(LPWAVEINCAPSW*)ptr;
1111 wic32->wMid = wic16->wMid;
1112 wic32->wPid = wic16->wPid;
1113 wic32->vDriverVersion = wic16->vDriverVersion;
1114 WideCharToMultiByte( CP_ACP, 0, wic32->szPname, -1, wic16->szPname,
1115 sizeof(wic16->szPname), NULL, NULL );
1116 wic32->dwFormats = wic16->dwFormats;
1117 wic32->wChannels = wic16->wChannels;
1118 UnMapLS( *lpParam1 );
1119 HeapFree( GetProcessHeap(), 0, ptr );
1125 LPMMTIME16 mmt16 = MapSL(*lpParam1);
1126 LPSTR ptr = (LPSTR)mmt16 - sizeof(LPMMTIME);
1127 LPMMTIME mmt32 = *(LPMMTIME*)ptr;
1129 MMSYSTEM_MMTIME16to32(mmt32, mmt16);
1130 UnMapLS( *lpParam1 );
1131 HeapFree( GetProcessHeap(), 0, ptr );
1135 case DRVM_MAPPER_STATUS:
1137 UnMapLS( *lpParam2 );
1142 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
1148 /**************************************************************************
1149 * MMDRV_WaveIn_Callback [internal]
1151 static void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
1153 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
1158 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
1161 if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) {
1162 /* initial map is: 32 => 16 */
1163 LPWAVEHDR wh16 = MapSL(dwParam1);
1164 LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR));
1166 dwParam1 = (DWORD)wh32;
1167 wh32->dwFlags = wh16->dwFlags;
1168 wh32->dwBytesRecorded = wh16->dwBytesRecorded;
1169 } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) {
1170 /* initial map is: 16 => 32 */
1171 LPWAVEHDR wh32 = (LPWAVEHDR)(dwParam1);
1172 SEGPTR segwh16 = *(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR));
1173 LPWAVEHDR wh16 = MapSL(segwh16);
1175 dwParam1 = (DWORD)segwh16;
1176 wh16->dwFlags = wh32->dwFlags;
1177 wh16->dwBytesRecorded = wh32->dwBytesRecorded;
1179 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
1182 ERR("Unknown msg %u\n", uMsg);
1185 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
1188 /* =================================
1189 * W A V E O U T M A P P E R S
1190 * ================================= */
1192 /**************************************************************************
1193 * MMDRV_WaveOut_Map16To32W [internal]
1195 static WINMM_MapType MMDRV_WaveOut_Map16To32W (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
1197 WINMM_MapType ret = WINMM_MAP_MSGERROR;
1201 case WODM_BREAKLOOP:
1203 case WODM_GETNUMDEVS:
1208 case WODM_SETPLAYBACKRATE:
1209 case WODM_SETVOLUME:
1214 case WODM_GETPLAYBACKRATE:
1215 case WODM_GETVOLUME:
1217 FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n");
1220 case WODM_GETDEVCAPS:
1222 LPWAVEOUTCAPSW woc32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEOUTCAPS16) + sizeof(WAVEOUTCAPSW));
1223 LPWAVEOUTCAPS16 woc16 = MapSL(*lpParam1);
1226 *(LPWAVEOUTCAPS16*)woc32 = woc16;
1227 woc32 = (LPWAVEOUTCAPSW)((LPSTR)woc32 + sizeof(LPWAVEOUTCAPS16));
1228 *lpParam1 = (DWORD)woc32;
1229 *lpParam2 = sizeof(WAVEOUTCAPSW);
1231 ret = WINMM_MAP_OKMEM;
1233 ret = WINMM_MAP_NOMEM;
1239 LPMMTIME mmt32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16) + sizeof(MMTIME));
1240 LPMMTIME16 mmt16 = MapSL(*lpParam1);
1243 *(LPMMTIME16*)mmt32 = mmt16;
1244 mmt32 = (LPMMTIME)((LPSTR)mmt32 + sizeof(LPMMTIME16));
1246 mmt32->wType = mmt16->wType;
1247 *lpParam1 = (DWORD)mmt32;
1248 *lpParam2 = sizeof(MMTIME);
1250 ret = WINMM_MAP_OKMEM;
1252 ret = WINMM_MAP_NOMEM;
1258 LPWAVEHDR wh32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR) + sizeof(WAVEHDR));
1259 LPWAVEHDR wh16 = MapSL(*lpParam1);
1262 *(LPWAVEHDR*)wh32 = (LPWAVEHDR)*lpParam1;
1263 wh32 = (LPWAVEHDR)((LPSTR)wh32 + sizeof(LPWAVEHDR));
1264 wh32->lpData = MapSL((SEGPTR)wh16->lpData);
1265 wh32->dwBufferLength = wh16->dwBufferLength;
1266 wh32->dwBytesRecorded = wh16->dwBytesRecorded;
1267 wh32->dwUser = wh16->dwUser;
1268 wh32->dwFlags = wh16->dwFlags;
1269 wh32->dwLoops = wh16->dwLoops;
1270 /* FIXME: nothing on wh32->lpNext */
1271 /* could link the wh32->lpNext at this level for memory house keeping */
1272 wh16->lpNext = wh32; /* for reuse in unprepare and write */
1273 *lpParam1 = (DWORD)wh32;
1274 *lpParam2 = sizeof(WAVEHDR);
1276 ret = WINMM_MAP_OKMEM;
1278 ret = WINMM_MAP_NOMEM;
1282 case WODM_UNPREPARE:
1285 LPWAVEHDR wh16 = MapSL(*lpParam1);
1286 LPWAVEHDR wh32 = (LPWAVEHDR)wh16->lpNext;
1288 *lpParam1 = (DWORD)wh32;
1289 *lpParam2 = sizeof(WAVEHDR);
1290 /* dwBufferLength can be reduced between prepare & write */
1291 if (wMsg == WODM_WRITE && wh32->dwBufferLength < wh16->dwBufferLength) {
1292 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
1293 wh32->dwBufferLength, wh16->dwBufferLength);
1295 wh32->dwBufferLength = wh16->dwBufferLength;
1296 ret = WINMM_MAP_OKMEM;
1299 case WODM_MAPPER_STATUS:
1300 *lpParam2 = (DWORD)MapSL(*lpParam2);
1304 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
1310 /**************************************************************************
1311 * MMDRV_WaveOut_UnMap16To32W [internal]
1313 static WINMM_MapType MMDRV_WaveOut_UnMap16To32W(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
1315 WINMM_MapType ret = WINMM_MAP_MSGERROR;
1319 case WODM_BREAKLOOP:
1321 case WODM_GETNUMDEVS:
1326 case WODM_SETPLAYBACKRATE:
1327 case WODM_SETVOLUME:
1328 case WODM_MAPPER_STATUS:
1333 case WODM_GETPLAYBACKRATE:
1334 case WODM_GETVOLUME:
1336 FIXME("Shouldn't be used: those 16 bit functions use the 32 bit interface\n");
1339 case WODM_GETDEVCAPS:
1341 LPWAVEOUTCAPSW woc32 = (LPWAVEOUTCAPSW)(*lpParam1);
1342 LPWAVEOUTCAPS16 woc16 = *(LPWAVEOUTCAPS16*)((LPSTR)woc32 - sizeof(LPWAVEOUTCAPS16));
1344 woc16->wMid = woc32->wMid;
1345 woc16->wPid = woc32->wPid;
1346 woc16->vDriverVersion = woc32->vDriverVersion;
1347 WideCharToMultiByte( CP_ACP, 0, woc32->szPname, -1, woc16->szPname,
1348 sizeof(woc16->szPname), NULL, NULL );
1349 woc16->dwFormats = woc32->dwFormats;
1350 woc16->wChannels = woc32->wChannels;
1351 woc16->dwSupport = woc32->dwSupport;
1352 HeapFree(GetProcessHeap(), 0, (LPSTR)woc32 - sizeof(LPWAVEOUTCAPS16));
1358 LPMMTIME mmt32 = (LPMMTIME)(*lpParam1);
1359 LPMMTIME16 mmt16 = *(LPMMTIME16*)((LPSTR)mmt32 - sizeof(LPMMTIME16));
1361 MMSYSTEM_MMTIME32to16(mmt16, mmt32);
1362 HeapFree(GetProcessHeap(), 0, (LPSTR)mmt32 - sizeof(LPMMTIME16));
1367 case WODM_UNPREPARE:
1370 LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1);
1371 LPWAVEHDR wh16 = MapSL(*(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR)));
1373 assert(wh16->lpNext == wh32);
1374 wh16->dwBufferLength = wh32->dwBufferLength;
1375 wh16->dwBytesRecorded = wh32->dwBytesRecorded;
1376 wh16->dwUser = wh32->dwUser;
1377 wh16->dwFlags = wh32->dwFlags;
1378 wh16->dwLoops = wh32->dwLoops;
1380 if (wMsg == WODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
1381 HeapFree(GetProcessHeap(), 0, (LPSTR)wh32 - sizeof(LPWAVEHDR));
1388 FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
1394 /**************************************************************************
1395 * MMDRV_WaveOut_Map32WTo16 [internal]
1397 static WINMM_MapType MMDRV_WaveOut_Map32WTo16 (UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
1403 case WODM_BREAKLOOP:
1405 case WODM_GETNUMDEVS:
1410 case WODM_SETPLAYBACKRATE:
1411 case WODM_SETVOLUME:
1415 case WODM_GETDEVCAPS:
1417 LPWAVEOUTCAPSW woc32 = (LPWAVEOUTCAPSW)*lpParam1;
1418 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0,
1419 sizeof(LPWAVEOUTCAPSW) + sizeof(WAVEOUTCAPS16));
1422 *(LPWAVEOUTCAPSW*)ptr = woc32;
1423 ret = WINMM_MAP_OKMEM;
1425 ret = WINMM_MAP_NOMEM;
1427 *lpParam1 = MapLS(ptr) + sizeof(LPWAVEOUTCAPSW);
1428 *lpParam2 = sizeof(WAVEOUTCAPS16);
1432 FIXME("NIY: no conversion yet\n");
1433 ret = WINMM_MAP_MSGERROR;
1435 case WODM_GETPLAYBACKRATE:
1436 FIXME("NIY: no conversion yet\n");
1437 ret = WINMM_MAP_MSGERROR;
1441 LPMMTIME mmt32 = (LPMMTIME)*lpParam1;
1442 LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME) + sizeof(MMTIME16));
1443 LPMMTIME16 mmt16 = (LPMMTIME16)(ptr + sizeof(LPMMTIME));
1446 *(LPMMTIME*)ptr = mmt32;
1447 mmt16->wType = mmt32->wType;
1448 ret = WINMM_MAP_OKMEM;
1450 ret = WINMM_MAP_NOMEM;
1452 *lpParam1 = MapLS(ptr) + sizeof(LPMMTIME);
1453 *lpParam2 = sizeof(MMTIME16);
1456 case WODM_GETVOLUME:
1457 FIXME("NIY: no conversion yet\n");
1458 ret = WINMM_MAP_MSGERROR;
1462 LPWAVEOPENDESC wod32 = (LPWAVEOPENDESC)*lpParam1;
1463 int sz = sizeof(WAVEFORMATEX);
1465 LPWAVEOPENDESC16 wod16;
1467 /* allocated data are mapped as follows:
1468 LPWAVEOPENDESC ptr to orig lParam1
1469 DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance
1470 DWORD dwUser passed to driver
1471 WAVEOPENDESC16 wod16: openDesc passed to driver
1472 WAVEFORMATEX openDesc->lpFormat passed to driver
1473 xxx extra bytes to WAVEFORMATEX
1475 if (wod32->lpFormat->wFormatTag != WAVE_FORMAT_PCM) {
1476 TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize, wod32->lpFormat->wFormatTag);
1477 sz += ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize;
1480 ptr = HeapAlloc( GetProcessHeap(), 0,
1481 sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16) + sz);
1484 SEGPTR seg_ptr = MapLS( ptr );
1485 *(LPWAVEOPENDESC*)ptr = wod32;
1486 *(LPDWORD)((char*)ptr + sizeof(LPWAVEOPENDESC)) = *lpdwUser;
1487 wod16 = (LPWAVEOPENDESC16)((LPSTR)ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD));
1489 wod16->hWave = HWAVE_16(wod32->hWave);
1490 wod16->lpFormat = (LPWAVEFORMATEX)(seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16));
1491 memcpy(wod16 + 1, wod32->lpFormat, sz);
1493 wod16->dwCallback = wod32->dwCallback;
1494 wod16->dwInstance = wod32->dwInstance;
1495 wod16->uMappedDeviceID = wod32->uMappedDeviceID;
1496 wod16->dnDevNode = wod32->dnDevNode;
1498 *lpParam1 = seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD);
1499 *lpdwUser = seg_ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD);
1501 ret = WINMM_MAP_OKMEM;
1503 ret = WINMM_MAP_NOMEM;
1509 LPWAVEHDR wh32 = (LPWAVEHDR)*lpParam1;
1511 LPVOID ptr = HeapAlloc( GetProcessHeap(), 0,
1512 sizeof(LPWAVEHDR) + sizeof(WAVEHDR) + wh32->dwBufferLength);
1515 SEGPTR seg_ptr = MapLS( ptr );
1516 *(LPWAVEHDR*)ptr = wh32;
1517 wh16 = (LPWAVEHDR)((LPSTR)ptr + sizeof(LPWAVEHDR));
1518 wh16->lpData = (LPSTR)seg_ptr + sizeof(LPWAVEHDR) + sizeof(WAVEHDR);
1519 /* data will be copied on WODM_WRITE */
1520 wh16->dwBufferLength = wh32->dwBufferLength;
1521 wh16->dwBytesRecorded = wh32->dwBytesRecorded;
1522 wh16->dwUser = wh32->dwUser;
1523 wh16->dwFlags = wh32->dwFlags;
1524 wh16->dwLoops = wh32->dwLoops;
1525 /* FIXME: nothing on wh32->lpNext */
1526 /* could link the wh32->lpNext at this level for memory house keeping */
1527 wh32->lpNext = wh16; /* for reuse in unprepare and write */
1528 *lpParam1 = seg_ptr + sizeof(LPWAVEHDR);
1529 *lpParam2 = sizeof(WAVEHDR);
1530 TRACE("wh16=%08lx wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n",
1531 *lpParam1, wh16->lpData, wh32->dwBufferLength, wh32->lpData);
1533 ret = WINMM_MAP_OKMEM;
1535 ret = WINMM_MAP_NOMEM;
1539 case WODM_UNPREPARE:
1542 LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1);
1543 LPWAVEHDR wh16 = wh32->lpNext;
1544 LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR);
1545 SEGPTR seg_ptr = MapLS( ptr );
1547 assert(*(LPWAVEHDR*)ptr == wh32);
1549 if (wMsg == WODM_WRITE)
1550 memcpy((LPSTR)wh16 + sizeof(WAVEHDR), wh32->lpData, wh32->dwBufferLength);
1552 *lpParam1 = seg_ptr + sizeof(LPWAVEHDR);
1553 *lpParam2 = sizeof(WAVEHDR);
1554 TRACE("wh16=%08lx wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n",
1555 *lpParam1, wh16->lpData, wh32->dwBufferLength, wh32->lpData);
1557 /* dwBufferLength can be reduced between prepare & write */
1558 if (wMsg == WODM_WRITE && wh16->dwBufferLength < wh32->dwBufferLength) {
1559 ERR("Size of buffer has been increased from %d to %d, keeping initial value\n",
1560 wh16->dwBufferLength, wh32->dwBufferLength);
1562 wh16->dwBufferLength = wh32->dwBufferLength;
1563 ret = WINMM_MAP_OKMEM;
1566 case DRVM_MAPPER_STATUS:
1568 LPDWORD p32 = (LPDWORD)*lpParam2;
1569 *lpParam2 = MapLS(p32);
1570 ret = WINMM_MAP_OKMEM;
1574 FIXME("NIY: no conversion yet\n");
1575 ret = WINMM_MAP_MSGERROR;
1581 /**************************************************************************
1582 * MMDRV_WaveOut_UnMap32WTo16 [internal]
1584 static WINMM_MapType MMDRV_WaveOut_UnMap32WTo16(UINT wMsg, LPDWORD lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
1590 case WODM_BREAKLOOP:
1592 case WODM_GETNUMDEVS:
1597 case WODM_SETPLAYBACKRATE:
1598 case WODM_SETVOLUME:
1602 case WODM_GETDEVCAPS:
1604 LPWAVEOUTCAPS16 woc16 = MapSL(*lpParam1);
1605 LPSTR ptr = (LPSTR)woc16 - sizeof(LPWAVEOUTCAPSW);
1606 LPWAVEOUTCAPSW woc32 = *(LPWAVEOUTCAPSW*)ptr;
1608 woc32->wMid = woc16->wMid;
1609 woc32->wPid = woc16->wPid;
1610 woc32->vDriverVersion = woc16->vDriverVersion;
1611 WideCharToMultiByte( CP_ACP, 0, woc32->szPname, -1, woc16->szPname,
1612 sizeof(woc16->szPname), NULL, NULL );
1613 woc32->dwFormats = woc16->dwFormats;
1614 woc32->wChannels = woc16->wChannels;
1615 woc32->dwSupport = woc16->dwSupport;
1616 UnMapLS( *lpParam1 );
1617 HeapFree( GetProcessHeap(), 0, ptr );
1622 FIXME("NIY: no conversion yet\n");
1623 ret = WINMM_MAP_MSGERROR;
1625 case WODM_GETPLAYBACKRATE:
1626 FIXME("NIY: no conversion yet\n");
1627 ret = WINMM_MAP_MSGERROR;
1631 LPMMTIME16 mmt16 = MapSL(*lpParam1);
1632 LPSTR ptr = (LPSTR)mmt16 - sizeof(LPMMTIME);
1633 LPMMTIME mmt32 = *(LPMMTIME*)ptr;
1635 MMSYSTEM_MMTIME16to32(mmt32, mmt16);
1636 UnMapLS( *lpParam1 );
1637 HeapFree( GetProcessHeap(), 0, ptr );
1643 LPWAVEOPENDESC16 wod16 = MapSL(*lpParam1);
1644 LPSTR ptr = (LPSTR)wod16 - sizeof(LPWAVEOPENDESC) - 2*sizeof(DWORD);
1645 LPWAVEOPENDESC wod32 = *(LPWAVEOPENDESC*)ptr;
1647 wod32->uMappedDeviceID = wod16->uMappedDeviceID;
1648 **(DWORD**)(ptr + sizeof(LPWAVEOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD));
1649 UnMapLS( *lpParam1 );
1650 HeapFree( GetProcessHeap(), 0, ptr );
1655 case WODM_UNPREPARE:
1658 LPWAVEHDR wh16 = MapSL(*lpParam1);
1659 LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR);
1660 LPWAVEHDR wh32 = *(LPWAVEHDR*)ptr;
1662 assert(wh32->lpNext == wh16);
1663 wh32->dwBytesRecorded = wh16->dwBytesRecorded;
1664 wh32->dwUser = wh16->dwUser;
1665 wh32->dwFlags = wh16->dwFlags;
1666 wh32->dwLoops = wh16->dwLoops;
1668 UnMapLS( *lpParam1 );
1669 if (wMsg == WODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) {
1670 HeapFree( GetProcessHeap(), 0, ptr );
1676 case WODM_GETVOLUME:
1677 FIXME("NIY: no conversion yet\n");
1678 ret = WINMM_MAP_MSGERROR;
1680 case DRVM_MAPPER_STATUS:
1682 UnMapLS( *lpParam2 );
1687 FIXME("NIY: no conversion yet\n");
1688 ret = WINMM_MAP_MSGERROR;
1694 /**************************************************************************
1695 * MMDRV_WaveOut_Callback [internal]
1697 static void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
1699 LPWINE_MLD mld = (LPWINE_MLD)dwInstance;
1704 /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
1707 if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) {
1708 /* initial map is: 32 => 16 */
1709 LPWAVEHDR wh16 = MapSL(dwParam1);
1710 LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR));
1712 dwParam1 = (DWORD)wh32;
1713 wh32->dwFlags = wh16->dwFlags;
1714 } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) {
1715 /* initial map is: 16 => 32 */
1716 LPWAVEHDR wh32 = (LPWAVEHDR)(dwParam1);
1717 SEGPTR segwh16 = *(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR));
1718 LPWAVEHDR wh16 = MapSL(segwh16);
1720 dwParam1 = (DWORD)segwh16;
1721 wh16->dwFlags = wh32->dwFlags;
1723 /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/
1726 ERR("Unknown msg %u\n", uMsg);
1729 MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
1732 /* =================================
1733 * M A P P E R S H A N D L I N G
1734 * ================================= */
1736 static LRESULT MMDRV_CallMMDrvFunc16(DWORD fp16, WORD dev, WORD msg, LONG instance,
1744 args[5] = HIWORD(instance);
1745 args[4] = LOWORD(instance);
1746 args[3] = HIWORD(lp1);
1747 args[2] = LOWORD(lp1);
1748 args[1] = HIWORD(lp2);
1749 args[0] = LOWORD(lp2);
1750 WOWCallback16Ex( fp16, WCB16_PASCAL, sizeof(args), args, &ret );
1754 /**************************************************************************
1755 * MMDRV_GetDescription16 [internal]
1757 static BOOL MMDRV_GetDescription16(const char* fname, char* buf, int buflen)
1765 if ((hFile = OpenFile(fname, &ofs, OF_READ | OF_SHARE_DENY_WRITE)) == HFILE_ERROR) {
1766 ERR("Can't open file %s (builtin driver ?)\n", fname);
1770 #define E(_x) do {TRACE _x;goto theEnd;} while(0)
1772 if (_lread(hFile, &w, 2) != 2) E(("Can't read sig\n"));
1773 if (w != ('Z' * 256 + 'M')) E(("Bad sig %04x\n", w));
1774 if (_llseek(hFile, 0x3C, SEEK_SET) < 0) E(("Can't seek to ext header offset\n"));
1775 if (_lread(hFile, &dw, 4) != 4) E(("Can't read ext header offset\n"));
1776 if (_llseek(hFile, dw + 0x2C, SEEK_SET) < 0) E(("Can't seek to ext header.nr table %u\n", dw+0x2C));
1777 if (_lread(hFile, &dw, 4) != 4) E(("Can't read nr table offset\n"));
1778 if (_llseek(hFile, dw, SEEK_SET) < 0) E(("Can't seek to nr table %u\n", dw));
1779 if (_lread(hFile, buf, 1) != 1) E(("Can't read descr length\n"));
1780 buflen = min((int)(unsigned)(BYTE)buf[0], buflen - 1);
1781 if (_lread(hFile, buf, buflen) != buflen) E(("Can't read descr (%d)\n", buflen));
1784 TRACE("Got '%s' [%d]\n", buf, buflen);
1790 /******************************************************************
1791 * MMDRV_LoadMMDrvFunc16
1794 static unsigned MMDRV_LoadMMDrvFunc16(LPCSTR drvName, LPWINE_DRIVER d,
1795 LPWINE_MM_DRIVER lpDrv)
1797 WINEMM_msgFunc16 func;
1801 * DESCRIPTION 'wave,aux,mixer:Creative Labs Sound Blaster 16 Driver'
1802 * The beginning of the module description indicates the driver supports
1803 * waveform, auxiliary, and mixer devices. Use one of the following
1804 * device-type names, followed by a colon (:) to indicate the type of
1805 * device your driver supports. If the driver supports more than one
1806 * type of device, separate each device-type name with a comma (,).
1808 * wave for waveform audio devices
1809 * wavemapper for wave mappers
1810 * midi for MIDI audio devices
1811 * midimapper for midi mappers
1812 * aux for auxiliary audio devices
1813 * mixer for mixer devices
1816 if (d->d.d16.hDriver16) {
1817 HMODULE16 hMod16 = GetDriverModuleHandle16(d->d.d16.hDriver16);
1819 #define AA(_h,_w,_x,_y,_z) \
1820 func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
1822 { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \
1823 TRACE("Got %d bit func '%s'\n", _y, #_x); }
1825 #define A(_x,_y) AA(hMod16,_x,_y,16,GetProcAddress16)
1826 A(MMDRV_AUX, auxMessage);
1827 A(MMDRV_MIXER, mxdMessage);
1828 A(MMDRV_MIDIIN, midMessage);
1829 A(MMDRV_MIDIOUT,modMessage);
1830 A(MMDRV_WAVEIN, widMessage);
1831 A(MMDRV_WAVEOUT,wodMessage);
1835 if (TRACE_ON(winmm)) {
1836 if (MMDRV_GetDescription16(drvName, buffer, sizeof(buffer)))
1837 TRACE("%s => %s\n", drvName, buffer);
1839 TRACE("%s => No description\n", drvName);
1845 /* =================================
1847 * ================================= */
1850 /* FIXME: this code is kept for not yet implemented optimisation for an application
1851 * using the 32A MCI interface and calling a 16 bit driver.
1852 * For now, we're doing two conversions:
1853 * - 32A => 32W (in 32 bit MCI code)
1854 * - 32W => 16 in this file
1859 * 0001 squeeze signed 4 bytes to 2 bytes *( LPINT16)D = ( INT16)*( LPINT16)S; D += 2; S += 4
1860 * 0010 squeeze unsigned 4 bytes to 2 bytes *(LPUINT16)D = (UINT16)*(LPUINT16)S; D += 2; S += 4
1863 * 0110 zero 4 bytes *(DWORD)D = 0 D += 4; S += 4
1864 * 0111 copy string *(LPSTR*)D = seg dup(*(LPSTR*)S) D += 4; S += 4
1865 * 1xxx copy xxx + 1 bytes memcpy(D, S, xxx + 1); D += xxx+1; S += xxx+1
1868 /**************************************************************************
1869 * MCI_MsgMapper32ATo16_Create [internal]
1871 * Helper for MCI_MapMsg32ATo16.
1872 * Maps the 32 bit pointer (*ptr), of size bytes, to an allocated 16 bit
1873 * segmented pointer.
1874 * map contains a list of action to be performed for the mapping (see list
1876 * if keep is TRUE, keeps track of in 32 bit ptr in allocated 16 bit area.
1878 static WINMM_MapType MCI_MsgMapper32ATo16_Create(void** ptr, int size16, DWORD map, BOOLEAN keep)
1880 void* lp = HeapAlloc( GetProcessHeap(), 0, (keep ? sizeof(void**) : 0) + size16 );
1884 return WINMM_MAP_NOMEM;
1886 p32 = (LPBYTE)(*ptr);
1889 p16 = (LPBYTE)lp + sizeof(void**);
1890 *ptr = (char*)MapLS(lp) + sizeof(void**);
1893 *ptr = (void*)MapLS(lp);
1897 memcpy(p16, p32, size16);
1905 sz = (nibble & 7) + 1;
1906 memcpy(p16, p32, sz);
1909 size16 -= sz; /* DEBUG only */
1913 *(LPINT16)p16 = *(LPINT)p32;
1914 p16 += sizeof(INT16);
1916 size16 -= sizeof(INT16);
1919 *(LPUINT16)p16 = *(LPUINT)p32;
1920 p16 += sizeof(UINT16);
1921 p32 += sizeof(UINT);
1922 size16 -= sizeof(UINT16);
1926 p16 += sizeof(DWORD);
1927 p32 += sizeof(DWORD);
1928 size16 -= sizeof(DWORD);
1931 *(SEGPTR *)p16 = MapLS( *(LPSTR *)p32 );
1932 p16 += sizeof(SEGPTR);
1933 p32 += sizeof(LPSTR);
1934 size16 -= sizeof(SEGPTR);
1937 FIXME("Unknown nibble for mapping (%x)\n", nibble);
1942 if (size16 != 0) /* DEBUG only */
1943 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
1945 return WINMM_MAP_OKMEM;
1948 /**************************************************************************
1949 * MCI_MsgMapper32ATo16_Destroy [internal]
1951 * Helper for MCI_UnMapMsg32ATo16.
1953 static WINMM_MapType MCI_MsgMapper32ATo16_Destroy(void* ptr, int size16, DWORD map, BOOLEAN kept)
1956 void* msg16 = MapSL((SEGPTR)ptr);
1961 UnMapLS( (SEGPTR)ptr );
1963 alloc = (char*)msg16 - sizeof(void**);
1964 p32 = *(void**)alloc;
1968 memcpy(p32, p16, size16);
1973 memcpy(p32, p16, (nibble & 7) + 1);
1974 p16 += (nibble & 7) + 1;
1975 p32 += (nibble & 7) + 1;
1976 size16 -= (nibble & 7) + 1;
1980 *(LPINT)p32 = *(LPINT16)p16;
1981 p16 += sizeof(INT16);
1983 size16 -= sizeof(INT16);
1986 *(LPUINT)p32 = *(LPUINT16)p16;
1987 p16 += sizeof(UINT16);
1988 p32 += sizeof(UINT);
1989 size16 -= sizeof(UINT16);
1992 p16 += sizeof(UINT);
1993 p32 += sizeof(UINT);
1994 size16 -= sizeof(UINT);
1997 UnMapLS( *(SEGPTR *)p16 );
1998 p16 += sizeof(SEGPTR);
1999 p32 += sizeof(char*);
2000 size16 -= sizeof(SEGPTR);
2003 FIXME("Unknown nibble for mapping (%x)\n", nibble);
2008 if (size16 != 0) /* DEBUG only */
2009 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
2015 HeapFree( GetProcessHeap(), 0, alloc );
2017 return WINMM_MAP_OK;
2020 /**************************************************************************
2021 * MCI_MapMsg32ATo16 [internal]
2023 * Map a 32-A bit MCI message to a 16 bit MCI message.
2025 static WINMM_MapType MCI_MapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam)
2028 BOOLEAN keep = FALSE;
2032 return WINMM_MAP_OK;
2034 /* FIXME: to add also (with seg/linear modifications to do):
2035 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
2036 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
2040 size = sizeof(MCI_BREAK_PARMS);
2042 /* case MCI_CAPTURE */
2044 case MCI_CLOSE_DRIVER:
2046 size = sizeof(MCI_GENERIC_PARMS);
2048 /* case MCI_COPY: */
2051 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_CUE_PARMS); break;
2052 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_CUE_PARMS); break;*/ FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2053 default: size = sizeof(MCI_GENERIC_PARMS); break;
2059 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_DELETE_PARMS16); map = 0x0F1111FB; break;
2060 case MCI_DEVTYPE_WAVEFORM_AUDIO:size = sizeof(MCI_WAVE_DELETE_PARMS); break;
2061 default: size = sizeof(MCI_GENERIC_PARMS); break;
2064 /* case MCI_ESCAPE: */
2067 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_FREEZE_PARMS); map = 0x0001111B; break;
2068 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS); map = 0x0001111B; break;
2069 default: size = sizeof(MCI_GENERIC_PARMS); break;
2072 case MCI_GETDEVCAPS:
2074 size = sizeof(MCI_GETDEVCAPS_PARMS);
2076 /* case MCI_INDEX: */
2079 LPMCI_INFO_PARMSA mip32a = (LPMCI_INFO_PARMSA)(*lParam);
2080 LPMCI_INFO_PARMS16 mip16;
2083 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_INFO_PARMS16); break;
2084 default: size = sizeof(MCI_INFO_PARMS16); break;
2086 mip16 = HeapAlloc( GetProcessHeap(), 0, size);
2089 mip16->dwCallback = mip32a->dwCallback;
2090 mip16->lpstrReturn = MapLS( mip32a->lpstrReturn );
2091 mip16->dwRetSize = mip32a->dwRetSize;
2092 if (uDevType == MCI_DEVTYPE_DIGITAL_VIDEO) {
2093 ((LPMCI_DGV_INFO_PARMS16)mip16)->dwItem = ((LPMCI_DGV_INFO_PARMSA)mip32a)->dwItem;
2096 return WINMM_MAP_NOMEM;
2098 *lParam = MapLS(mip16);
2100 return WINMM_MAP_OKMEM;
2101 /* case MCI_MARK: */
2102 /* case MCI_MONITOR: */
2104 case MCI_OPEN_DRIVER:
2106 LPMCI_OPEN_PARMSA mop32a = (LPMCI_OPEN_PARMSA)(*lParam);
2107 char* ptr = HeapAlloc( GetProcessHeap(), 0,
2108 sizeof(LPMCI_OPEN_PARMSA) + sizeof(MCI_OPEN_PARMS16) + 2 * sizeof(DWORD));
2109 LPMCI_OPEN_PARMS16 mop16;
2113 *(LPMCI_OPEN_PARMSA*)(ptr) = mop32a;
2114 mop16 = (LPMCI_OPEN_PARMS16)(ptr + sizeof(LPMCI_OPEN_PARMSA));
2115 mop16->dwCallback = mop32a->dwCallback;
2116 mop16->wDeviceID = mop32a->wDeviceID;
2117 if (dwFlags & MCI_OPEN_TYPE) {
2118 if (dwFlags & MCI_OPEN_TYPE_ID) {
2119 /* dword "transparent" value */
2120 mop16->lpstrDeviceType = (SEGPTR)mop32a->lpstrDeviceType;
2123 mop16->lpstrDeviceType = MapLS( mop32a->lpstrDeviceType );
2127 mop16->lpstrDeviceType = 0;
2129 if (dwFlags & MCI_OPEN_ELEMENT) {
2130 if (dwFlags & MCI_OPEN_ELEMENT_ID) {
2131 mop16->lpstrElementName = (SEGPTR)mop32a->lpstrElementName;
2133 mop16->lpstrElementName = MapLS( mop32a->lpstrElementName );
2136 mop16->lpstrElementName = 0;
2138 if (dwFlags & MCI_OPEN_ALIAS) {
2139 mop16->lpstrAlias = MapLS( mop32a->lpstrAlias );
2141 mop16->lpstrAlias = 0;
2143 /* copy extended information if any...
2144 * FIXME: this may seg fault if initial structure does not contain them and
2145 * the reads after msip16 fail under LDT limits...
2146 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
2147 * should not take care of extended parameters, and should be used by MCI_Open
2148 * to fetch uDevType. When, this is known, the mapping for sending the
2149 * MCI_OPEN_DRIVER shall be done depending on uDevType.
2151 memcpy(mop16 + 1, mop32a + 1, 2 * sizeof(DWORD));
2153 return WINMM_MAP_NOMEM;
2155 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_OPEN_PARMSA);
2157 return WINMM_MAP_OKMEM;
2158 /* case MCI_PASTE:*/
2160 size = sizeof(MCI_GENERIC_PARMS);
2163 size = sizeof(MCI_PLAY_PARMS);
2167 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; break;
2168 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS); map = 0x0001111B; break;
2169 default: size = sizeof(MCI_GENERIC_PARMS); break;
2173 size = sizeof(MCI_GENERIC_PARMS);
2177 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECORD_PARMS16); map = 0x0F1111FB; break;
2178 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_RECORD_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2179 default: size = sizeof(MCI_RECORD_PARMS); break;
2183 size = sizeof(MCI_GENERIC_PARMS);
2187 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SEEK_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2188 default: size = sizeof(MCI_SEEK_PARMS); break;
2193 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_SET_PARMS); break;
2194 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SET_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2195 case MCI_DEVTYPE_SEQUENCER: size = sizeof(MCI_SEQ_SET_PARMS); break;
2196 /* FIXME: normally the 16 and 32 bit structures are byte by byte aligned,
2197 * so not doing anything should work...
2199 case MCI_DEVTYPE_WAVEFORM_AUDIO:size = sizeof(MCI_WAVE_SET_PARMS); break;
2200 default: size = sizeof(MCI_SET_PARMS); break;
2205 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_SETAUDIO_PARMS16);map = 0x0000077FF; break;
2206 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2207 default: size = sizeof(MCI_GENERIC_PARMS); break;
2210 /* case MCI_SETTIMECODE:*/
2211 /* case MCI_SIGNAL:*/
2212 /* case MCI_SOUND:*/
2214 size = sizeof(MCI_SET_PARMS);
2220 * don't know if buffer for value is the one passed through lpstrDevice
2221 * or is provided by MCI driver.
2222 * Assuming solution 2: provided by MCI driver, so zeroing on entry
2224 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_STATUS_PARMS16); map = 0x0B6FF; break;
2225 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2226 default: size = sizeof(MCI_STATUS_PARMS); break;
2231 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_STEP_PARMS); break;
2232 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STEP_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2233 case MCI_DEVTYPE_VIDEODISC: size = sizeof(MCI_VD_STEP_PARMS); break;
2234 default: size = sizeof(MCI_GENERIC_PARMS); break;
2238 size = sizeof(MCI_SET_PARMS);
2242 LPMCI_SYSINFO_PARMSA msip32a = (LPMCI_SYSINFO_PARMSA)(*lParam);
2243 LPMCI_SYSINFO_PARMS16 msip16;
2244 char* ptr = HeapAlloc( GetProcessHeap(), 0,
2245 sizeof(LPMCI_SYSINFO_PARMSA) + sizeof(MCI_SYSINFO_PARMS16) );
2248 *(LPMCI_SYSINFO_PARMSA*)(ptr) = msip32a;
2249 msip16 = (LPMCI_SYSINFO_PARMS16)(ptr + sizeof(LPMCI_SYSINFO_PARMSA));
2251 msip16->dwCallback = msip32a->dwCallback;
2252 msip16->lpstrReturn = MapLS( msip32a->lpstrReturn );
2253 msip16->dwRetSize = msip32a->dwRetSize;
2254 msip16->dwNumber = msip32a->dwNumber;
2255 msip16->wDeviceType = msip32a->wDeviceType;
2257 return WINMM_MAP_NOMEM;
2259 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_SYSINFO_PARMSA);
2261 return WINMM_MAP_OKMEM;
2262 /* case MCI_UNDO: */
2265 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; break;
2266 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; break;
2267 default: size = sizeof(MCI_GENERIC_PARMS); break;
2272 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_UPDATE_PARMS16); map = 0x000B1111B; break;
2273 default: size = sizeof(MCI_GENERIC_PARMS); break;
2278 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; keep = TRUE; break;
2279 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; keep = TRUE; break;
2280 default: size = sizeof(MCI_GENERIC_PARMS); break;
2285 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_WINDOW_PARMS16); if (dwFlags & MCI_DGV_WINDOW_TEXT) map = 0x7FB; break;
2286 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_WINDOW_PARMS16); if (dwFlags & MCI_OVLY_WINDOW_TEXT) map = 0x7FB; break;
2287 default: size = sizeof(MCI_GENERIC_PARMS); break;
2292 LPMCI_OPEN_DRIVER_PARMSA modp32a = (LPMCI_OPEN_DRIVER_PARMSA)(*lParam);
2293 LPMCI_OPEN_DRIVER_PARMS16 modp16;
2294 char *ptr = HeapAlloc( GetProcessHeap(), 0,
2295 sizeof(LPMCI_OPEN_DRIVER_PARMSA) + sizeof(MCI_OPEN_DRIVER_PARMS16));
2298 *(LPMCI_OPEN_DRIVER_PARMSA*)(ptr) = modp32a;
2299 modp16 = (LPMCI_OPEN_DRIVER_PARMS16)(ptr + sizeof(LPMCI_OPEN_DRIVER_PARMSA));
2300 modp16->wDeviceID = modp32a->wDeviceID;
2301 modp16->lpstrParams = MapLS( modp32a->lpstrParams );
2302 /* other fields are gonna be filled by the driver, don't copy them */
2304 return WINMM_MAP_NOMEM;
2306 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_OPEN_DRIVER_PARMSA);
2308 return WINMM_MAP_OKMEM;
2315 case DRV_QUERYCONFIGURE:
2318 case DRV_EXITSESSION:
2319 case DRV_EXITAPPLICATION:
2321 return WINMM_MAP_OK;
2324 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg));
2325 return WINMM_MAP_MSGERROR;
2327 return MCI_MsgMapper32ATo16_Create((void**)lParam, size, map, keep);
2330 /**************************************************************************
2331 * MCI_UnMapMsg32ATo16 [internal]
2333 static WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD lParam)
2336 BOOLEAN kept = FALSE; /* there is no need to compute size when kept is FALSE */
2342 /* case MCI_CAPTURE */
2344 case MCI_CLOSE_DRIVER:
2347 /* case MCI_COPY: */
2353 /* case MCI_ESCAPE: */
2356 case MCI_GETDEVCAPS:
2358 size = sizeof(MCI_GETDEVCAPS_PARMS);
2360 /* case MCI_INDEX: */
2363 LPMCI_INFO_PARMS16 mip16 = (LPMCI_INFO_PARMS16)MapSL(lParam);
2365 UnMapLS( mip16->lpstrReturn );
2366 HeapFree( GetProcessHeap(), 0, mip16 );
2368 return WINMM_MAP_OK;
2369 /* case MCI_MARK: */
2370 /* case MCI_MONITOR: */
2372 case MCI_OPEN_DRIVER:
2374 LPMCI_OPEN_PARMS16 mop16 = (LPMCI_OPEN_PARMS16)MapSL(lParam);
2375 LPMCI_OPEN_PARMSA mop32a = *(LPMCI_OPEN_PARMSA*)((char*)mop16 - sizeof(LPMCI_OPEN_PARMSA));
2377 mop32a->wDeviceID = mop16->wDeviceID;
2378 if ((dwFlags & MCI_OPEN_TYPE) && !(dwFlags & MCI_OPEN_TYPE_ID))
2379 UnMapLS( mop16->lpstrDeviceType );
2380 if ((dwFlags & MCI_OPEN_ELEMENT) && !(dwFlags & MCI_OPEN_ELEMENT_ID))
2381 UnMapLS( mop16->lpstrElementName );
2382 if (dwFlags & MCI_OPEN_ALIAS)
2383 UnMapLS( mop16->lpstrAlias );
2384 HeapFree( GetProcessHeap(), 0, (char*)mop16 - sizeof(LPMCI_OPEN_PARMSA) );
2386 return WINMM_MAP_OK;
2387 /* case MCI_PASTE:*/
2406 case MCI_DEVTYPE_DIGITAL_VIDEO: map = 0x0000077FF; break;
2407 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2410 /* case MCI_SETTIMECODE:*/
2411 /* case MCI_SIGNAL:*/
2412 /* case MCI_SOUND:*/
2418 case MCI_DEVTYPE_DIGITAL_VIDEO:
2420 LPMCI_DGV_STATUS_PARMS16 mdsp16 = (LPMCI_DGV_STATUS_PARMS16)MapSL(lParam);
2421 LPMCI_DGV_STATUS_PARMSA mdsp32a = *(LPMCI_DGV_STATUS_PARMSA*)((char*)mdsp16 - sizeof(LPMCI_DGV_STATUS_PARMSA));
2425 mdsp32a->dwReturn = mdsp16->dwReturn;
2426 if (dwFlags & MCI_DGV_STATUS_DISKSPACE) {
2427 TRACE("MCI_STATUS (DGV) lpstrDrive=%08lx\n", mdsp16->lpstrDrive);
2428 TRACE("MCI_STATUS (DGV) lpstrDrive=%s\n", (LPSTR)MapSL(mdsp16->lpstrDrive));
2429 UnMapLS( mdsp16->lpstrDrive );
2431 HeapFree( GetProcessHeap(), 0, (char*)mdsp16 - sizeof(LPMCI_DGV_STATUS_PARMSA) );
2433 return WINMM_MAP_NOMEM;
2436 return WINMM_MAP_OKMEM;
2437 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
2438 default: size = sizeof(MCI_STATUS_PARMS); break;
2447 LPMCI_SYSINFO_PARMS16 msip16 = (LPMCI_SYSINFO_PARMS16)MapSL(lParam);
2448 LPMCI_SYSINFO_PARMSA msip32a = *(LPMCI_SYSINFO_PARMSA*)((char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSA));
2452 msip16->dwCallback = msip32a->dwCallback;
2453 UnMapLS( msip16->lpstrReturn );
2454 HeapFree( GetProcessHeap(), 0, (char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSA) );
2456 return WINMM_MAP_NOMEM;
2459 return WINMM_MAP_OKMEM;
2460 /* case MCI_UNDO: */
2467 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; kept = TRUE; break;
2468 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; kept = TRUE; break;
2474 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_WINDOW_PARMS16); if (dwFlags & MCI_DGV_WINDOW_TEXT) map = 0x7666; break;
2475 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_WINDOW_PARMS16); if (dwFlags & MCI_OVLY_WINDOW_TEXT) map = 0x7666; break;
2478 /* FIXME: see map function */
2483 LPMCI_OPEN_DRIVER_PARMS16 modp16 = (LPMCI_OPEN_DRIVER_PARMS16)MapSL(lParam);
2484 LPMCI_OPEN_DRIVER_PARMSA modp32a = *(LPMCI_OPEN_DRIVER_PARMSA*)((char*)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSA));
2487 modp32a->wCustomCommandTable = modp16->wCustomCommandTable;
2488 modp32a->wType = modp16->wType;
2489 UnMapLS( modp16->lpstrParams );
2490 HeapFree( GetProcessHeap(), 0, (char *)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSA) );
2492 return WINMM_MAP_OK;
2499 case DRV_QUERYCONFIGURE:
2502 case DRV_EXITSESSION:
2503 case DRV_EXITAPPLICATION:
2505 FIXME("This is a hack\n");
2506 return WINMM_MAP_OK;
2508 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg));
2509 return WINMM_MAP_MSGERROR;
2511 return MCI_MsgMapper32ATo16_Destroy((void*)lParam, size, map, kept);
2515 /**************************************************************************
2516 * MCI_MapMsg16To32W [internal]
2518 static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD_PTR* lParam)
2521 return WINMM_MAP_OK;
2522 /* FIXME: to add also (with seg/linear modifications to do):
2523 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
2524 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
2527 /* case MCI_CAPTURE */
2529 case MCI_CLOSE_DRIVER:
2536 case MCI_GETDEVCAPS:
2537 /* case MCI_INDEX: */
2538 /* case MCI_MARK: */
2539 /* case MCI_MONITOR: */
2549 /* case MCI_SETTIMECODE:*/
2550 /* case MCI_SIGNAL:*/
2552 case MCI_STATUS: /* FIXME: is wrong for digital video */
2555 /* case MCI_UNDO: */
2559 *lParam = (DWORD)MapSL(*lParam);
2560 return WINMM_MAP_OK;
2562 /* in fact, I would also need the dwFlags... to see
2563 * which members of lParam are effectively used
2565 *lParam = (DWORD)MapSL(*lParam);
2566 FIXME("Current mapping may be wrong\n");
2570 LPMCI_BREAK_PARMS mbp32 = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_BREAK_PARMS));
2571 LPMCI_BREAK_PARMS16 mbp16 = MapSL(*lParam);
2574 mbp32->dwCallback = mbp16->dwCallback;
2575 mbp32->nVirtKey = mbp16->nVirtKey;
2576 mbp32->hwndBreak = HWND_32(mbp16->hwndBreak);
2578 return WINMM_MAP_NOMEM;
2580 *lParam = (DWORD)mbp32;
2582 return WINMM_MAP_OKMEM;
2585 LPMCI_VD_ESCAPE_PARMSW mvep32w = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_VD_ESCAPE_PARMSW));
2586 LPMCI_VD_ESCAPE_PARMS16 mvep16 = MapSL(*lParam);
2589 mvep32w->dwCallback = mvep16->dwCallback;
2590 mvep32w->lpstrCommand = MCI_strdupAtoW(MapSL(mvep16->lpstrCommand));
2592 return WINMM_MAP_NOMEM;
2594 *lParam = (DWORD)mvep32w;
2596 return WINMM_MAP_OKMEM;
2599 LPMCI_INFO_PARMSW mip32w = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_INFO_PARMSW));
2600 LPMCI_INFO_PARMS16 mip16 = MapSL(*lParam);
2602 /* FIXME this is wrong if device is of type
2603 * MCI_DEVTYPE_DIGITAL_VIDEO, some members are not mapped
2606 *(LPMCI_INFO_PARMS16*)(mip32w) = mip16;
2607 mip32w = (LPMCI_INFO_PARMSW)((char*)mip32w + sizeof(LPMCI_INFO_PARMS16));
2608 mip32w->dwCallback = mip16->dwCallback;
2609 mip32w->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, mip16->dwRetSize * sizeof(WCHAR));
2610 mip32w->dwRetSize = mip16->dwRetSize * sizeof(WCHAR);
2612 return WINMM_MAP_NOMEM;
2614 *lParam = (DWORD)mip32w;
2616 return WINMM_MAP_OKMEM;
2618 case MCI_OPEN_DRIVER:
2620 LPMCI_OPEN_PARMSW mop32w = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_OPEN_PARMSW) + 2 * sizeof(DWORD));
2621 LPMCI_OPEN_PARMS16 mop16 = MapSL(*lParam);
2624 *(LPMCI_OPEN_PARMS16*)(mop32w) = mop16;
2625 mop32w = (LPMCI_OPEN_PARMSW)((char*)mop32w + sizeof(LPMCI_OPEN_PARMS16));
2626 mop32w->dwCallback = mop16->dwCallback;
2627 mop32w->wDeviceID = mop16->wDeviceID;
2628 if( ( dwFlags & ( MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID)) == MCI_OPEN_TYPE)
2629 mop32w->lpstrDeviceType = MCI_strdupAtoW(MapSL(mop16->lpstrDeviceType));
2631 mop32w->lpstrDeviceType = (LPWSTR) mop16->lpstrDeviceType;
2632 if( ( dwFlags & ( MCI_OPEN_ELEMENT | MCI_OPEN_ELEMENT_ID)) == MCI_OPEN_ELEMENT)
2633 mop32w->lpstrElementName = MCI_strdupAtoW(MapSL(mop16->lpstrElementName));
2635 mop32w->lpstrElementName = (LPWSTR) mop16->lpstrElementName;
2636 if( ( dwFlags & MCI_OPEN_ALIAS))
2637 mop32w->lpstrAlias = MCI_strdupAtoW(MapSL(mop16->lpstrAlias));
2639 mop32w->lpstrAlias = (LPWSTR) mop16->lpstrAlias;
2640 /* copy extended information if any...
2641 * FIXME: this may seg fault if initial structure does not contain them and
2642 * the reads after msip16 fail under LDT limits...
2643 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
2644 * should not take care of extended parameters, and should be used by MCI_Open
2645 * to fetch uDevType. When, this is known, the mapping for sending the
2646 * MCI_OPEN_DRIVER shall be done depending on uDevType.
2648 memcpy(mop32w + 1, mop16 + 1, 2 * sizeof(DWORD));
2650 return WINMM_MAP_NOMEM;
2652 *lParam = (DWORD)mop32w;
2654 return WINMM_MAP_OKMEM;
2657 LPMCI_SYSINFO_PARMSW msip32w = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_SYSINFO_PARMSW));
2658 LPMCI_SYSINFO_PARMS16 msip16 = MapSL(*lParam);
2661 *(LPMCI_SYSINFO_PARMS16*)(msip32w) = msip16;
2662 msip32w = (LPMCI_SYSINFO_PARMSW)((char*)msip32w + sizeof(LPMCI_OPEN_PARMS16));
2663 msip32w->dwCallback = msip16->dwCallback;
2664 msip32w->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, msip16->dwRetSize * sizeof(WCHAR));
2665 msip32w->dwRetSize = msip16->dwRetSize;
2666 msip32w->dwNumber = msip16->dwNumber;
2667 msip32w->wDeviceType = msip16->wDeviceType;
2669 return WINMM_MAP_NOMEM;
2671 *lParam = (DWORD)msip32w;
2673 return WINMM_MAP_OKMEM;
2676 LPMCI_SOUND_PARMSW mbp32 = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_SOUND_PARMSW));
2677 LPMCI_SOUND_PARMS16 mbp16 = MapSL(*lParam);
2680 mbp32->dwCallback = mbp16->dwCallback;
2681 mbp32->lpstrSoundName = MCI_strdupAtoW(MapSL(mbp16->lpstrSoundName));
2683 return WINMM_MAP_NOMEM;
2685 *lParam = (DWORD)mbp32;
2687 return WINMM_MAP_OKMEM;
2695 case DRV_QUERYCONFIGURE:
2698 case DRV_EXITSESSION:
2699 case DRV_EXITAPPLICATION:
2701 FIXME("This is a hack\n");
2702 return WINMM_MAP_OK;
2704 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg));
2706 return WINMM_MAP_MSGERROR;
2709 /**************************************************************************
2710 * MCI_UnMapMsg16To32W [internal]
2712 static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD_PTR lParam)
2715 /* case MCI_CAPTURE */
2717 case MCI_CLOSE_DRIVER:
2724 case MCI_GETDEVCAPS:
2725 /* case MCI_INDEX: */
2726 /* case MCI_MARK: */
2727 /* case MCI_MONITOR: */
2737 /* case MCI_SETTIMECODE:*/
2738 /* case MCI_SIGNAL:*/
2743 /* case MCI_UNDO: */
2747 return WINMM_MAP_OK;
2750 /* FIXME ?? see Map function */
2751 return WINMM_MAP_OK;
2754 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
2755 return WINMM_MAP_OK;
2758 LPMCI_VD_ESCAPE_PARMSW mvep32W = (LPMCI_VD_ESCAPE_PARMSW)lParam;
2759 HeapFree(GetProcessHeap(), 0, (LPVOID)mvep32W->lpstrCommand);
2760 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
2762 return WINMM_MAP_OK;
2765 LPMCI_INFO_PARMSW mip32w = (LPMCI_INFO_PARMSW)lParam;
2766 LPMCI_INFO_PARMS16 mip16 = *(LPMCI_INFO_PARMS16*)((char*)mip32w - sizeof(LPMCI_INFO_PARMS16));
2768 WideCharToMultiByte(CP_ACP, 0,
2769 mip32w->lpstrReturn, mip32w->dwRetSize / sizeof(WCHAR),
2770 MapSL(mip16->lpstrReturn), mip16->dwRetSize,
2772 HeapFree(GetProcessHeap(), 0, (LPVOID)mip32w->lpstrReturn);
2773 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
2775 return WINMM_MAP_OK;
2778 LPMCI_SYSINFO_PARMSW msip32w = (LPMCI_SYSINFO_PARMSW)lParam;
2779 LPMCI_SYSINFO_PARMS16 msip16 = *(LPMCI_SYSINFO_PARMS16*)((char*)msip32w - sizeof(LPMCI_SYSINFO_PARMS16));
2781 WideCharToMultiByte(CP_ACP, 0,
2782 msip32w->lpstrReturn, msip32w->dwRetSize,
2783 MapSL(msip16->lpstrReturn), msip16->dwRetSize,
2785 HeapFree(GetProcessHeap(), 0, (LPVOID)msip32w->lpstrReturn);
2786 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
2788 return WINMM_MAP_OK;
2791 LPMCI_SOUND_PARMSW msp32W = (LPMCI_SOUND_PARMSW)lParam;
2792 HeapFree(GetProcessHeap(), 0, (LPVOID)msp32W->lpstrSoundName);
2793 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
2795 return WINMM_MAP_OK;
2797 case MCI_OPEN_DRIVER:
2799 LPMCI_OPEN_PARMSW mop32w = (LPMCI_OPEN_PARMSW)lParam;
2800 LPMCI_OPEN_PARMS16 mop16 = *(LPMCI_OPEN_PARMS16*)((char*)mop32w - sizeof(LPMCI_OPEN_PARMS16));
2802 mop16->wDeviceID = mop32w->wDeviceID;
2803 if( ( dwFlags & ( MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID)) == MCI_OPEN_TYPE)
2804 HeapFree(GetProcessHeap(), 0, (LPWSTR)mop32w->lpstrDeviceType);
2805 if( ( dwFlags & ( MCI_OPEN_ELEMENT | MCI_OPEN_ELEMENT_ID)) == MCI_OPEN_ELEMENT)
2806 HeapFree(GetProcessHeap(), 0, (LPWSTR)mop32w->lpstrElementName);
2807 if( ( dwFlags & MCI_OPEN_ALIAS))
2808 HeapFree(GetProcessHeap(), 0, (LPWSTR)mop32w->lpstrAlias);
2809 if (!HeapFree(GetProcessHeap(), 0, (LPVOID)(lParam - sizeof(LPMCI_OPEN_PARMS16))))
2810 FIXME("bad free line=%d\n", __LINE__);
2812 return WINMM_MAP_OK;
2820 case DRV_QUERYCONFIGURE:
2823 case DRV_EXITSESSION:
2824 case DRV_EXITAPPLICATION:
2826 FIXME("This is a hack\n");
2827 return WINMM_MAP_OK;
2829 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg));
2831 return WINMM_MAP_MSGERROR;
2836 * 0001 squeeze signed 4 bytes to 2 bytes *( LPINT16)D = ( INT16)*( LPINT16)S; D += 2; S += 4
2837 * 0010 squeeze unsigned 4 bytes to 2 bytes *(LPUINT16)D = (UINT16)*(LPUINT16)S; D += 2; S += 4
2840 * 0110 zero 4 bytes *(DWORD)D = 0 D += 4; S += 4
2841 * 0111 copy string *(LPSTR*)D = seg dup(*(LPSTR*)S) D += 4; S += 4
2842 * 1xxx copy xxx + 1 bytes memcpy(D, S, xxx + 1); D += xxx+1; S += xxx+1
2845 /**************************************************************************
2846 * MCI_MsgMapper32WTo16_Create [internal]
2848 * Helper for MCI_MapMsg32WTo16.
2849 * Maps the 32 bit pointer (*ptr), of size bytes, to an allocated 16 bit
2850 * segmented pointer.
2851 * map contains a list of action to be performed for the mapping (see list
2853 * if keep is TRUE, keeps track of in 32 bit ptr in allocated 16 bit area.
2855 static WINMM_MapType MCI_MsgMapper32WTo16_Create(void** ptr, int size16, DWORD map, BOOLEAN keep)
2857 void* lp = HeapAlloc( GetProcessHeap(), 0, (keep ? sizeof(void**) : 0) + size16 );
2861 return WINMM_MAP_NOMEM;
2863 p32 = (LPBYTE)(*ptr);
2866 p16 = (LPBYTE)lp + sizeof(void**);
2867 *ptr = (char*)MapLS(lp) + sizeof(void**);
2870 *ptr = (void*)MapLS(lp);
2874 memcpy(p16, p32, size16);
2882 sz = (nibble & 7) + 1;
2883 memcpy(p16, p32, sz);
2886 size16 -= sz; /* DEBUG only */
2890 *(LPINT16)p16 = *(LPINT)p32;
2891 p16 += sizeof(INT16);
2893 size16 -= sizeof(INT16);
2896 *(LPUINT16)p16 = *(LPUINT)p32;
2897 p16 += sizeof(UINT16);
2898 p32 += sizeof(UINT);
2899 size16 -= sizeof(UINT16);
2903 p16 += sizeof(DWORD);
2904 p32 += sizeof(DWORD);
2905 size16 -= sizeof(DWORD);
2908 *(SEGPTR *)p16 = MapLS( MCI_strdupWtoA( *(LPCWSTR *)p32 ) );
2909 p16 += sizeof(SEGPTR);
2910 p32 += sizeof(LPSTR);
2911 size16 -= sizeof(SEGPTR);
2914 FIXME("Unknown nibble for mapping (%x)\n", nibble);
2919 if (size16 != 0) /* DEBUG only */
2920 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
2922 return WINMM_MAP_OKMEM;
2925 /**************************************************************************
2926 * MCI_MsgMapper32WTo16_Destroy [internal]
2928 * Helper for MCI_UnMapMsg32WTo16.
2930 static WINMM_MapType MCI_MsgMapper32WTo16_Destroy(void* ptr, int size16, DWORD map, BOOLEAN kept)
2933 void* msg16 = MapSL((SEGPTR)ptr);
2938 UnMapLS( (SEGPTR)ptr );
2940 alloc = (char*)msg16 - sizeof(void**);
2941 p32 = *(void**)alloc;
2945 memcpy(p32, p16, size16);
2950 memcpy(p32, p16, (nibble & 7) + 1);
2951 p16 += (nibble & 7) + 1;
2952 p32 += (nibble & 7) + 1;
2953 size16 -= (nibble & 7) + 1;
2957 *(LPINT)p32 = *(LPINT16)p16;
2958 p16 += sizeof(INT16);
2960 size16 -= sizeof(INT16);
2963 *(LPUINT)p32 = *(LPUINT16)p16;
2964 p16 += sizeof(UINT16);
2965 p32 += sizeof(UINT);
2966 size16 -= sizeof(UINT16);
2969 p16 += sizeof(UINT);
2970 p32 += sizeof(UINT);
2971 size16 -= sizeof(UINT);
2974 HeapFree(GetProcessHeap(), 0, MapSL(*(SEGPTR *)p16));
2975 UnMapLS( *(SEGPTR *)p16 );
2976 p16 += sizeof(SEGPTR);
2977 p32 += sizeof(char*);
2978 size16 -= sizeof(SEGPTR);
2981 FIXME("Unknown nibble for mapping (%x)\n", nibble);
2986 if (size16 != 0) /* DEBUG only */
2987 FIXME("Mismatch between 16 bit struct size and map nibbles serie\n");
2993 HeapFree( GetProcessHeap(), 0, alloc );
2995 return WINMM_MAP_OK;
2998 /**************************************************************************
2999 * MCI_MapMsg32WTo16 [internal]
3001 * Map a 32W bit MCI message to a 16 bit MCI message.
3003 static WINMM_MapType MCI_MapMsg32WTo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD_PTR* lParam)
3006 BOOLEAN keep = FALSE;
3010 return WINMM_MAP_OK;
3012 /* FIXME: to add also (with seg/linear modifications to do):
3013 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
3014 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
3018 size = sizeof(MCI_BREAK_PARMS);
3020 /* case MCI_CAPTURE */
3022 case MCI_CLOSE_DRIVER:
3024 size = sizeof(MCI_GENERIC_PARMS);
3026 /* case MCI_COPY: */
3029 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_CUE_PARMS); break;
3030 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_CUE_PARMS); break;*/ FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3031 default: size = sizeof(MCI_GENERIC_PARMS); break;
3037 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_DELETE_PARMS16); map = 0x0F1111FB; break;
3038 case MCI_DEVTYPE_WAVEFORM_AUDIO:size = sizeof(MCI_WAVE_DELETE_PARMS); break;
3039 default: size = sizeof(MCI_GENERIC_PARMS); break;
3042 /* case MCI_ESCAPE: */
3045 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_FREEZE_PARMS); map = 0x0001111B; break;
3046 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS); map = 0x0001111B; break;
3047 default: size = sizeof(MCI_GENERIC_PARMS); break;
3050 case MCI_GETDEVCAPS:
3052 size = sizeof(MCI_GETDEVCAPS_PARMS);
3054 /* case MCI_INDEX: */
3057 LPMCI_INFO_PARMSW mip32w = (LPMCI_INFO_PARMSW)(*lParam);
3059 LPMCI_INFO_PARMS16 mip16;
3062 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_INFO_PARMS16); break;
3063 default: size = sizeof(MCI_INFO_PARMS16); break;
3065 ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMCI_INFO_PARMSW) + size);
3068 *(LPMCI_INFO_PARMSW*)ptr = mip32w;
3069 mip16 = (LPMCI_INFO_PARMS16)(ptr + sizeof(LPMCI_INFO_PARMSW));
3070 mip16->dwCallback = mip32w->dwCallback;
3071 mip16->lpstrReturn = MapLS( HeapAlloc(GetProcessHeap(), 0, mip32w->dwRetSize / sizeof(WCHAR)) );
3072 mip16->dwRetSize = mip32w->dwRetSize / sizeof(WCHAR);
3073 if (uDevType == MCI_DEVTYPE_DIGITAL_VIDEO) {
3074 ((LPMCI_DGV_INFO_PARMS16)mip16)->dwItem = ((LPMCI_DGV_INFO_PARMSW)mip32w)->dwItem;
3077 return WINMM_MAP_NOMEM;
3079 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_INFO_PARMSW);
3081 return WINMM_MAP_OKMEM;
3082 /* case MCI_MARK: */
3083 /* case MCI_MONITOR: */
3085 case MCI_OPEN_DRIVER:
3087 LPMCI_OPEN_PARMSW mop32w = (LPMCI_OPEN_PARMSW)(*lParam);
3088 char* ptr = HeapAlloc( GetProcessHeap(), 0,
3089 sizeof(LPMCI_OPEN_PARMSW) + sizeof(MCI_OPEN_PARMS16) + 2 * sizeof(DWORD));
3090 LPMCI_OPEN_PARMS16 mop16;
3094 *(LPMCI_OPEN_PARMSW*)(ptr) = mop32w;
3095 mop16 = (LPMCI_OPEN_PARMS16)(ptr + sizeof(LPMCI_OPEN_PARMSW));
3096 mop16->dwCallback = mop32w->dwCallback;
3097 mop16->wDeviceID = mop32w->wDeviceID;
3098 if (dwFlags & MCI_OPEN_TYPE) {
3099 if (dwFlags & MCI_OPEN_TYPE_ID) {
3100 /* dword "transparent" value */
3101 mop16->lpstrDeviceType = (SEGPTR)mop32w->lpstrDeviceType;
3104 mop16->lpstrDeviceType = MapLS( MCI_strdupWtoA(mop32w->lpstrDeviceType) );
3108 mop16->lpstrDeviceType = 0;
3110 if (dwFlags & MCI_OPEN_ELEMENT) {
3111 if (dwFlags & MCI_OPEN_ELEMENT_ID) {
3112 mop16->lpstrElementName = (SEGPTR)mop32w->lpstrElementName;
3114 mop16->lpstrElementName = MapLS( MCI_strdupWtoA(mop32w->lpstrElementName) );
3117 mop16->lpstrElementName = 0;
3119 if (dwFlags & MCI_OPEN_ALIAS) {
3120 mop16->lpstrAlias = MapLS( MCI_strdupWtoA(mop32w->lpstrAlias) );
3122 mop16->lpstrAlias = 0;
3124 /* copy extended information if any...
3125 * FIXME: this may seg fault if initial structure does not contain them and
3126 * the reads after msip16 fail under LDT limits...
3127 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
3128 * should not take care of extended parameters, and should be used by MCI_Open
3129 * to fetch uDevType. When, this is known, the mapping for sending the
3130 * MCI_OPEN_DRIVER shall be done depending on uDevType.
3132 memcpy(mop16 + 1, mop32w + 1, 2 * sizeof(DWORD));
3134 return WINMM_MAP_NOMEM;
3136 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_OPEN_PARMSW);
3138 return WINMM_MAP_OKMEM;
3139 /* case MCI_PASTE:*/
3141 size = sizeof(MCI_GENERIC_PARMS);
3144 size = sizeof(MCI_PLAY_PARMS);
3148 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; break;
3149 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS); map = 0x0001111B; break;
3150 default: size = sizeof(MCI_GENERIC_PARMS); break;
3154 size = sizeof(MCI_GENERIC_PARMS);
3158 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECORD_PARMS16); map = 0x0F1111FB; break;
3159 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_RECORD_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3160 default: size = sizeof(MCI_RECORD_PARMS); break;
3164 size = sizeof(MCI_GENERIC_PARMS);
3168 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SEEK_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3169 default: size = sizeof(MCI_SEEK_PARMS); break;
3174 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_SET_PARMS); break;
3175 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SET_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3176 case MCI_DEVTYPE_SEQUENCER: size = sizeof(MCI_SEQ_SET_PARMS); break;
3177 /* FIXME: normally the 16 and 32 bit structures are byte by byte aligned,
3178 * so not doing anything should work...
3180 case MCI_DEVTYPE_WAVEFORM_AUDIO:size = sizeof(MCI_WAVE_SET_PARMS); break;
3181 default: size = sizeof(MCI_SET_PARMS); break;
3186 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_SETAUDIO_PARMS16);map = 0x0000077FF; break;
3187 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3188 default: size = sizeof(MCI_GENERIC_PARMS); break;
3191 /* case MCI_SETTIMECODE:*/
3192 /* case MCI_SIGNAL:*/
3193 /* case MCI_SOUND:*/
3195 size = sizeof(MCI_SET_PARMS);
3201 * don't know if buffer for value is the one passed through lpstrDevice
3202 * or is provided by MCI driver.
3203 * Assuming solution 2: provided by MCI driver, so zeroing on entry
3205 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_STATUS_PARMS16); map = 0x0B6FF; break;
3206 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3207 default: size = sizeof(MCI_STATUS_PARMS); break;
3212 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_STEP_PARMS); break;
3213 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STEP_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3214 case MCI_DEVTYPE_VIDEODISC: size = sizeof(MCI_VD_STEP_PARMS); break;
3215 default: size = sizeof(MCI_GENERIC_PARMS); break;
3219 size = sizeof(MCI_SET_PARMS);
3223 LPMCI_SYSINFO_PARMSW msip32w = (LPMCI_SYSINFO_PARMSW)(*lParam);
3224 LPMCI_SYSINFO_PARMS16 msip16;
3225 char* ptr = HeapAlloc( GetProcessHeap(), 0,
3226 sizeof(LPMCI_SYSINFO_PARMSW) + sizeof(MCI_SYSINFO_PARMS16) );
3229 *(LPMCI_SYSINFO_PARMSW*)(ptr) = msip32w;
3230 msip16 = (LPMCI_SYSINFO_PARMS16)(ptr + sizeof(LPMCI_SYSINFO_PARMSW));
3232 msip16->dwCallback = msip32w->dwCallback;
3233 msip16->lpstrReturn = MapLS( HeapAlloc(GetProcessHeap(), 0, msip32w->dwRetSize) );
3234 msip16->dwRetSize = msip32w->dwRetSize;
3235 msip16->dwNumber = msip32w->dwNumber;
3236 msip16->wDeviceType = msip32w->wDeviceType;
3238 return WINMM_MAP_NOMEM;
3240 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_SYSINFO_PARMSW);
3242 return WINMM_MAP_OKMEM;
3243 /* case MCI_UNDO: */
3246 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; break;
3247 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; break;
3248 default: size = sizeof(MCI_GENERIC_PARMS); break;
3253 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_UPDATE_PARMS16); map = 0x000B1111B; break;
3254 default: size = sizeof(MCI_GENERIC_PARMS); break;
3259 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; keep = TRUE; break;
3260 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; keep = TRUE; break;
3261 default: size = sizeof(MCI_GENERIC_PARMS); break;
3266 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_WINDOW_PARMS16); if (dwFlags & MCI_DGV_WINDOW_TEXT) map = 0x7FB; break;
3267 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_WINDOW_PARMS16); if (dwFlags & MCI_OVLY_WINDOW_TEXT) map = 0x7FB; break;
3268 default: size = sizeof(MCI_GENERIC_PARMS); break;
3273 LPMCI_OPEN_DRIVER_PARMSW modp32w = (LPMCI_OPEN_DRIVER_PARMSW)(*lParam);
3274 LPMCI_OPEN_DRIVER_PARMS16 modp16;
3275 char *ptr = HeapAlloc( GetProcessHeap(), 0,
3276 sizeof(LPMCI_OPEN_DRIVER_PARMSW) + sizeof(MCI_OPEN_DRIVER_PARMS16));
3279 *(LPMCI_OPEN_DRIVER_PARMSW*)(ptr) = modp32w;
3280 modp16 = (LPMCI_OPEN_DRIVER_PARMS16)(ptr + sizeof(LPMCI_OPEN_DRIVER_PARMSW));
3281 modp16->wDeviceID = modp32w->wDeviceID;
3282 modp16->lpstrParams = MapLS( MCI_strdupWtoA(modp32w->lpstrParams) );
3283 /* other fields are gonna be filled by the driver, don't copy them */
3285 return WINMM_MAP_NOMEM;
3287 *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_OPEN_DRIVER_PARMSW);
3289 return WINMM_MAP_OKMEM;
3296 case DRV_QUERYCONFIGURE:
3299 case DRV_EXITSESSION:
3300 case DRV_EXITAPPLICATION:
3302 return WINMM_MAP_OK;
3305 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg));
3306 return WINMM_MAP_MSGERROR;
3308 return MCI_MsgMapper32WTo16_Create((void**)lParam, size, map, keep);
3311 /**************************************************************************
3312 * MCI_UnMapMsg32WTo16 [internal]
3314 static WINMM_MapType MCI_UnMapMsg32WTo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD_PTR lParam)
3317 BOOLEAN kept = FALSE; /* there is no need to compute size when kept is FALSE */
3323 /* case MCI_CAPTURE */
3325 case MCI_CLOSE_DRIVER:
3328 /* case MCI_COPY: */
3334 /* case MCI_ESCAPE: */
3337 case MCI_GETDEVCAPS:
3339 size = sizeof(MCI_GETDEVCAPS_PARMS);
3341 /* case MCI_INDEX: */
3344 LPMCI_INFO_PARMS16 mip16 = (LPMCI_INFO_PARMS16)MapSL(lParam);
3345 LPMCI_INFO_PARMSW mip32w = *(LPMCI_INFO_PARMSW*)((char*)mip16 - sizeof(LPMCI_INFO_PARMSW));
3347 MultiByteToWideChar(CP_ACP, 0, MapSL(mip16->lpstrReturn), mip16->dwRetSize,
3348 mip32w->lpstrReturn, mip32w->dwRetSize / sizeof(WCHAR));
3350 UnMapLS( mip16->lpstrReturn );
3351 HeapFree( GetProcessHeap(), 0, (void*)MapSL(mip16->lpstrReturn) );
3352 HeapFree( GetProcessHeap(), 0, (char*)mip16 - sizeof(LPMCI_OPEN_PARMSW) );
3354 return WINMM_MAP_OK;
3355 /* case MCI_MARK: */
3356 /* case MCI_MONITOR: */
3358 case MCI_OPEN_DRIVER:
3360 LPMCI_OPEN_PARMS16 mop16 = (LPMCI_OPEN_PARMS16)MapSL(lParam);
3361 LPMCI_OPEN_PARMSW mop32w = *(LPMCI_OPEN_PARMSW*)((char*)mop16 - sizeof(LPMCI_OPEN_PARMSW));
3363 mop32w->wDeviceID = mop16->wDeviceID;
3364 if ((dwFlags & MCI_OPEN_TYPE) && !(dwFlags & MCI_OPEN_TYPE_ID))
3366 HeapFree(GetProcessHeap(), 0, MapSL(mop16->lpstrDeviceType));
3367 UnMapLS( mop16->lpstrDeviceType );
3369 if ((dwFlags & MCI_OPEN_ELEMENT) && !(dwFlags & MCI_OPEN_ELEMENT_ID))
3371 HeapFree(GetProcessHeap(), 0, MapSL(mop16->lpstrElementName));
3372 UnMapLS( mop16->lpstrElementName );
3374 if (dwFlags & MCI_OPEN_ALIAS)
3376 HeapFree(GetProcessHeap(), 0, MapSL(mop16->lpstrAlias));
3377 UnMapLS( mop16->lpstrAlias );
3379 HeapFree( GetProcessHeap(), 0, (char*)mop16 - sizeof(LPMCI_OPEN_PARMSW) );
3381 return WINMM_MAP_OK;
3382 /* case MCI_PASTE:*/
3401 case MCI_DEVTYPE_DIGITAL_VIDEO: map = 0x0000077FF; break;
3402 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3405 /* case MCI_SETTIMECODE:*/
3406 /* case MCI_SIGNAL:*/
3407 /* case MCI_SOUND:*/
3413 case MCI_DEVTYPE_DIGITAL_VIDEO:
3415 LPMCI_DGV_STATUS_PARMS16 mdsp16 = (LPMCI_DGV_STATUS_PARMS16)MapSL(lParam);
3416 LPMCI_DGV_STATUS_PARMSA mdsp32a = *(LPMCI_DGV_STATUS_PARMSA*)((char*)mdsp16 - sizeof(LPMCI_DGV_STATUS_PARMSA));
3420 mdsp32a->dwReturn = mdsp16->dwReturn;
3421 if (dwFlags & MCI_DGV_STATUS_DISKSPACE) {
3422 TRACE("MCI_STATUS (DGV) lpstrDrive=%08x\n", mdsp16->lpstrDrive);
3423 TRACE("MCI_STATUS (DGV) lpstrDrive=%s\n", (LPSTR)MapSL(mdsp16->lpstrDrive));
3424 UnMapLS( mdsp16->lpstrDrive );
3426 HeapFree( GetProcessHeap(), 0, (char*)mdsp16 - sizeof(LPMCI_DGV_STATUS_PARMSA) );
3428 return WINMM_MAP_NOMEM;
3431 return WINMM_MAP_OKMEM;
3432 case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM;
3433 default: size = sizeof(MCI_STATUS_PARMS); break;
3442 LPMCI_SYSINFO_PARMS16 msip16 = (LPMCI_SYSINFO_PARMS16)MapSL(lParam);
3443 LPMCI_SYSINFO_PARMSW msip32w = *(LPMCI_SYSINFO_PARMSW*)((char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSW));
3447 MultiByteToWideChar(CP_ACP, 0, MapSL(msip16->lpstrReturn), msip16->dwRetSize,
3448 msip32w->lpstrReturn, msip32w->dwRetSize/sizeof(WCHAR));
3449 UnMapLS( msip16->lpstrReturn );
3450 HeapFree( GetProcessHeap(), 0, MapSL(msip16->lpstrReturn) );
3451 HeapFree( GetProcessHeap(), 0, (char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSW) );
3453 return WINMM_MAP_NOMEM;
3456 return WINMM_MAP_OKMEM;
3457 /* case MCI_UNDO: */
3464 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; kept = TRUE; break;
3465 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; kept = TRUE; break;
3471 case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_WINDOW_PARMS16); if (dwFlags & MCI_DGV_WINDOW_TEXT) map = 0x7666; break;
3472 case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_WINDOW_PARMS16); if (dwFlags & MCI_OVLY_WINDOW_TEXT) map = 0x7666; break;
3475 /* FIXME: see map function */
3479 LPMCI_OPEN_DRIVER_PARMS16 modp16 = (LPMCI_OPEN_DRIVER_PARMS16)MapSL(lParam);
3480 LPMCI_OPEN_DRIVER_PARMSW modp32w = *(LPMCI_OPEN_DRIVER_PARMSW*)((char*)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSW));
3483 modp32w->wCustomCommandTable = modp16->wCustomCommandTable;
3484 modp32w->wType = modp16->wType;
3485 HeapFree(GetProcessHeap(), 0, MapSL(modp16->lpstrParams));
3486 UnMapLS( modp16->lpstrParams );
3487 HeapFree( GetProcessHeap(), 0, (char *)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSW) );
3489 return WINMM_MAP_OK;
3496 case DRV_QUERYCONFIGURE:
3499 case DRV_EXITSESSION:
3500 case DRV_EXITAPPLICATION:
3502 FIXME("This is a hack\n");
3503 return WINMM_MAP_OK;
3506 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg));
3507 return WINMM_MAP_MSGERROR;
3509 return MCI_MsgMapper32WTo16_Destroy((void*)lParam, size, map, kept);
3512 void MMDRV_Init16(void)
3514 #define A(_x,_y) MMDRV_InstallMap(_x, \
3515 MMDRV_##_y##_Map16To32W, MMDRV_##_y##_UnMap16To32W, \
3516 MMDRV_##_y##_Map32WTo16, MMDRV_##_y##_UnMap32WTo16, \
3517 MMDRV_##_y##_Callback)
3519 A(MMDRV_MIXER, Mixer);
3520 A(MMDRV_MIDIIN, MidiIn);
3521 A(MMDRV_MIDIOUT, MidiOut);
3522 A(MMDRV_WAVEIN, WaveIn);
3523 A(MMDRV_WAVEOUT, WaveOut);
3526 pFnCallMMDrvFunc16 = MMDRV_CallMMDrvFunc16;
3527 pFnLoadMMDrvFunc16 = MMDRV_LoadMMDrvFunc16;
3529 pFnMciMapMsg16To32W = MCI_MapMsg16To32W;
3530 pFnMciUnMapMsg16To32W = MCI_UnMapMsg16To32W;
3531 pFnMciMapMsg32WTo16 = MCI_MapMsg32WTo16;
3532 pFnMciUnMapMsg32WTo16 = MCI_UnMapMsg32WTo16;