1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1993 Martin Ayotte
7 * 1998-2003 Eric Pouech
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 * 99/4 added mmTask and mmThread functions support
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
41 #include "wine/list.h"
42 #include "wine/winuser16.h"
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(mmsys
);
50 static CRITICAL_SECTION_DEBUG mmdrv_critsect_debug
=
53 { &mmdrv_critsect_debug
.ProcessLocksList
, &mmdrv_critsect_debug
.ProcessLocksList
},
54 0, 0, { (DWORD_PTR
)(__FILE__
": mmsystem_mmdrv_cs") }
56 CRITICAL_SECTION mmdrv_cs
= { &mmdrv_critsect_debug
, -1, 0, 0, 0, 0 };
58 /* ###################################################
60 * ###################################################
63 /**************************************************************************
64 * DllEntryPoint (MMSYSTEM.4)
66 * MMSYSTEM DLL entry point
69 BOOL WINAPI
MMSYSTEM_LibMain(DWORD fdwReason
, HINSTANCE hinstDLL
, WORD ds
,
70 WORD wHeapSize
, DWORD dwReserved1
, WORD wReserved2
)
74 if (!done
++) LoadLibrary16( "sound.drv" );
78 /**************************************************************************
81 int WINAPI
MMSYSTEM_WEP(HINSTANCE16 hInstance
, WORD wDataSeg
,
82 WORD cbHeapSize
, LPSTR lpCmdLine
)
84 TRACE("STUB: Unloading MMSystem DLL ... hInst=%04X\n", hInstance
);
88 /* ###################################################
90 * ###################################################
93 /******************************************************************
94 * MMSYSTEM_MMTIME32to16
98 void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16
, const MMTIME
* mmt32
)
100 mmt16
->wType
= mmt32
->wType
;
101 /* layout of rest is the same for 32/16,
102 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
104 memcpy(&(mmt16
->u
), &(mmt32
->u
), sizeof(mmt16
->u
));
107 /******************************************************************
108 * MMSYSTEM_MMTIME16to32
112 static void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32
, const MMTIME16
* mmt16
)
114 mmt32
->wType
= mmt16
->wType
;
115 /* layout of rest is the same for 32/16,
116 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
118 memcpy(&(mmt32
->u
), &(mmt16
->u
), sizeof(mmt16
->u
));
121 /**************************************************************************
122 * timeGetSystemTime [MMSYSTEM.601]
124 MMRESULT16 WINAPI
timeGetSystemTime16(LPMMTIME16 lpTime
, UINT16 wSize
)
126 if (wSize
>= sizeof(*lpTime
)) {
127 lpTime
->wType
= TIME_MS
;
128 lpTime
->u
.ms
= GetTickCount();
130 TRACE("=> %u\n", lpTime
->u
.ms
);
139 LPTIMECALLBACK16 func16
;
143 static struct list timer_list
= LIST_INIT(timer_list
);
145 static void CALLBACK
timeCB3216(UINT id
, UINT uMsg
, DWORD_PTR user
, DWORD_PTR dw1
, DWORD_PTR dw2
)
147 struct timer_entry
* te
= (void*)user
;
151 args
[7] = LOWORD(id
);
152 args
[6] = LOWORD(uMsg
);
153 args
[5] = HIWORD(te
->user
);
154 args
[4] = LOWORD(te
->user
);
155 args
[3] = HIWORD(dw1
);
156 args
[2] = LOWORD(dw2
);
157 args
[1] = HIWORD(dw2
);
158 args
[0] = LOWORD(dw2
);
159 WOWCallback16Ex((DWORD
)te
->func16
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
162 /**************************************************************************
163 * timeSetEvent [MMSYSTEM.602]
165 MMRESULT16 WINAPI
timeSetEvent16(UINT16 wDelay
, UINT16 wResol
, LPTIMECALLBACK16 lpFunc
,
166 DWORD dwUser
, UINT16 wFlags
)
169 struct timer_entry
* te
;
171 switch (wFlags
& (TIME_CALLBACK_EVENT_SET
|TIME_CALLBACK_EVENT_PULSE
))
173 case TIME_CALLBACK_EVENT_SET
:
174 case TIME_CALLBACK_EVENT_PULSE
:
175 id
= timeSetEvent(wDelay
, wResol
, (LPTIMECALLBACK
)lpFunc
, dwUser
, wFlags
);
177 case TIME_CALLBACK_FUNCTION
:
178 te
= HeapAlloc(GetProcessHeap(), 0, sizeof(*te
));
182 id
= te
->id
= timeSetEvent(wDelay
, wResol
, timeCB3216
, (DWORD_PTR
)te
, wFlags
);
185 EnterCriticalSection(&mmdrv_cs
);
186 list_add_tail(&timer_list
, &te
->entry
);
187 LeaveCriticalSection(&mmdrv_cs
);
189 else HeapFree(GetProcessHeap(), 0, te
);
198 /**************************************************************************
199 * timeKillEvent [MMSYSTEM.603]
201 MMRESULT16 WINAPI
timeKillEvent16(UINT16 wID
)
203 MMRESULT16 ret
= timeKillEvent(wID
);
204 struct timer_entry
* te
;
206 if (ret
== TIMERR_NOERROR
)
208 EnterCriticalSection(&mmdrv_cs
);
209 LIST_FOR_EACH_ENTRY(te
, &timer_list
, struct timer_entry
, entry
)
213 list_remove(&te
->entry
);
214 HeapFree(GetProcessHeap(), 0, te
);
218 LeaveCriticalSection(&mmdrv_cs
);
223 /**************************************************************************
224 * timeGetDevCaps [MMSYSTEM.604]
226 MMRESULT16 WINAPI
timeGetDevCaps16(LPTIMECAPS16 lpCaps
, UINT16 wSize
)
230 TRACE("(%p, %u) !\n", lpCaps
, wSize
);
232 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
234 ret
= timeGetDevCaps(&caps
, sizeof(caps
));
235 if (ret
== MMSYSERR_NOERROR
) {
237 tc16
.wPeriodMin
= caps
.wPeriodMin
;
238 tc16
.wPeriodMax
= caps
.wPeriodMax
;
239 memcpy(lpCaps
, &tc16
, min(wSize
, sizeof(tc16
)));
244 /**************************************************************************
245 * timeBeginPeriod [MMSYSTEM.605]
247 MMRESULT16 WINAPI
timeBeginPeriod16(UINT16 wPeriod
)
249 TRACE("(%u) !\n", wPeriod
);
251 return timeBeginPeriod(wPeriod
);
254 /**************************************************************************
255 * timeEndPeriod [MMSYSTEM.606]
257 MMRESULT16 WINAPI
timeEndPeriod16(UINT16 wPeriod
)
259 TRACE("(%u) !\n", wPeriod
);
261 return timeEndPeriod(wPeriod
);
264 /**************************************************************************
265 * timeGetTime [MMSYSTEM.607]
267 DWORD WINAPI
timeGetTime16(void)
269 return timeGetTime();
272 /* ###################################################
274 * ###################################################
277 /**************************************************************************
278 * PlaySound [MMSYSTEM.3]
280 BOOL16 WINAPI
PlaySound16(LPCSTR pszSound
, HMODULE16 hmod
, DWORD fdwSound
)
285 if ((fdwSound
& SND_RESOURCE
) == SND_RESOURCE
)
290 if (!(res
= FindResource16( hmod
, pszSound
, "WAVE" ))) return FALSE
;
291 if (!(handle
= LoadResource16( hmod
, res
))) return FALSE
;
292 pszSound
= LockResource16(handle
);
293 fdwSound
= (fdwSound
& ~SND_RESOURCE
) | SND_MEMORY
;
294 /* FIXME: FreeResource16 */
297 ReleaseThunkLock(&lc
);
298 retv
= PlaySoundA(pszSound
, 0, fdwSound
);
299 RestoreThunkLock(lc
);
304 /**************************************************************************
305 * sndPlaySound [MMSYSTEM.2]
307 BOOL16 WINAPI
sndPlaySound16(LPCSTR lpszSoundName
, UINT16 uFlags
)
312 ReleaseThunkLock(&lc
);
313 retv
= sndPlaySoundA(lpszSoundName
, uFlags
);
314 RestoreThunkLock(lc
);
319 /* ###################################################
321 * ###################################################
324 /**************************************************************************
325 * mmsystemGetVersion [MMSYSTEM.5]
328 UINT16 WINAPI
mmsystemGetVersion16(void)
330 return mmsystemGetVersion();
333 /**************************************************************************
334 * DriverCallback [MMSYSTEM.31]
336 BOOL16 WINAPI
DriverCallback16(DWORD dwCallBack
, UINT16 uFlags
, HDRVR16 hDev
,
337 WORD wMsg
, DWORD dwUser
, DWORD dwParam1
,
340 return DriverCallback(dwCallBack
, uFlags
, HDRVR_32(hDev
), wMsg
, dwUser
, dwParam1
, dwParam2
);
343 /**************************************************************************
344 * OutputDebugStr [MMSYSTEM.30]
346 void WINAPI
OutputDebugStr16(LPCSTR str
)
348 OutputDebugStringA( str
);
351 /* ###################################################
353 * ###################################################
356 /**************************************************************************
357 * Mixer devices. New to Win95
360 /**************************************************************************
361 * mixerGetNumDevs [MMSYSTEM.800]
363 UINT16 WINAPI
mixerGetNumDevs16(void)
365 return mixerGetNumDevs();
368 /**************************************************************************
369 * mixerGetDevCaps [MMSYSTEM.801]
371 UINT16 WINAPI
mixerGetDevCaps16(UINT16 uDeviceID
, LPMIXERCAPS16 lpCaps
,
377 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
379 ret
= mixerGetDevCapsA(uDeviceID
, &micA
, sizeof(micA
));
380 if (ret
== MMSYSERR_NOERROR
) {
382 mic16
.wMid
= micA
.wMid
;
383 mic16
.wPid
= micA
.wPid
;
384 mic16
.vDriverVersion
= micA
.vDriverVersion
;
385 strcpy(mic16
.szPname
, micA
.szPname
);
386 mic16
.fdwSupport
= micA
.fdwSupport
;
387 mic16
.cDestinations
= micA
.cDestinations
;
388 memcpy(lpCaps
, &mic16
, min(uSize
, sizeof(mic16
)));
393 /**************************************************************************
394 * mixerOpen [MMSYSTEM.802]
396 UINT16 WINAPI
mixerOpen16(LPHMIXER16 lphmix
, UINT16 uDeviceID
, DWORD dwCallback
,
397 DWORD dwInstance
, DWORD fdwOpen
)
401 struct mmsystdrv_thunk
* thunk
;
403 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, fdwOpen
, MMSYSTDRV_MIXER
)))
405 return MMSYSERR_NOMEM
;
407 if ((fdwOpen
& CALLBACK_TYPEMASK
) != CALLBACK_NULL
)
408 fdwOpen
= (fdwOpen
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
409 ret
= mixerOpen(&hmix
, uDeviceID
, (DWORD
)thunk
, dwInstance
, fdwOpen
);
410 if (ret
== MMSYSERR_NOERROR
)
412 if (lphmix
) *lphmix
= HMIXER_16(hmix
);
413 if (thunk
) MMSYSTDRV_SetHandle(thunk
, hmix
);
415 else MMSYSTDRV_DeleteThunk(thunk
);
419 /**************************************************************************
420 * mixerClose [MMSYSTEM.803]
422 UINT16 WINAPI
mixerClose16(HMIXER16 hMix
)
424 UINT ret
= mixerClose(HMIXER_32(hMix
));
426 if (ret
== MMSYSERR_NOERROR
)
427 MMSYSTDRV_CloseHandle((void*)HMIXER_32(hMix
));
431 /**************************************************************************
432 * mixerGetID (MMSYSTEM.806)
434 UINT16 WINAPI
mixerGetID16(HMIXEROBJ16 hmix
, LPUINT16 lpid
, DWORD fdwID
)
437 UINT ret
= mixerGetID(HMIXEROBJ_32(hmix
), &xid
, fdwID
);
444 /**************************************************************************
445 * mixerGetControlDetails [MMSYSTEM.808]
447 UINT16 WINAPI
mixerGetControlDetails16(HMIXEROBJ16 hmix
,
448 LPMIXERCONTROLDETAILS16 lpmcd
,
451 DWORD ret
= MMSYSERR_NOTENABLED
;
454 TRACE("(%04x, %p, %08x)\n", hmix
, lpmcd
, fdwDetails
);
456 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
457 return MMSYSERR_INVALPARAM
;
459 sppaDetails
= (SEGPTR
)lpmcd
->paDetails
;
460 lpmcd
->paDetails
= MapSL(sppaDetails
);
461 ret
= mixerGetControlDetailsA(HMIXEROBJ_32(hmix
),
462 (LPMIXERCONTROLDETAILS
)lpmcd
, fdwDetails
);
463 lpmcd
->paDetails
= (LPVOID
)sppaDetails
;
468 /**************************************************************************
469 * mixerGetLineControls [MMSYSTEM.807]
471 UINT16 WINAPI
mixerGetLineControls16(HMIXEROBJ16 hmix
,
472 LPMIXERLINECONTROLS16 lpmlc16
,
475 MIXERLINECONTROLSA mlcA
;
478 LPMIXERCONTROL16 lpmc16
;
480 TRACE("(%04x, %p, %08x)\n", hmix
, lpmlc16
, fdwControls
);
482 if (lpmlc16
== NULL
|| lpmlc16
->cbStruct
!= sizeof(*lpmlc16
) ||
483 lpmlc16
->cbmxctrl
!= sizeof(MIXERCONTROL16
))
484 return MMSYSERR_INVALPARAM
;
486 mlcA
.cbStruct
= sizeof(mlcA
);
487 mlcA
.dwLineID
= lpmlc16
->dwLineID
;
488 mlcA
.u
.dwControlID
= lpmlc16
->u
.dwControlID
;
489 mlcA
.u
.dwControlType
= lpmlc16
->u
.dwControlType
;
490 mlcA
.cControls
= lpmlc16
->cControls
;
491 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
492 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0,
493 mlcA
.cControls
* mlcA
.cbmxctrl
);
495 ret
= mixerGetLineControlsA(HMIXEROBJ_32(hmix
), &mlcA
, fdwControls
);
497 if (ret
== MMSYSERR_NOERROR
) {
498 lpmlc16
->dwLineID
= mlcA
.dwLineID
;
499 lpmlc16
->u
.dwControlID
= mlcA
.u
.dwControlID
;
500 lpmlc16
->u
.dwControlType
= mlcA
.u
.dwControlType
;
501 lpmlc16
->cControls
= mlcA
.cControls
;
503 lpmc16
= MapSL(lpmlc16
->pamxctrl
);
505 for (i
= 0; i
< mlcA
.cControls
; i
++) {
506 lpmc16
[i
].cbStruct
= sizeof(MIXERCONTROL16
);
507 lpmc16
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
508 lpmc16
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
509 lpmc16
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
510 lpmc16
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
511 strcpy(lpmc16
[i
].szShortName
, mlcA
.pamxctrl
[i
].szShortName
);
512 strcpy(lpmc16
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
513 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
514 memcpy(&lpmc16
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
,
515 sizeof(mlcA
.pamxctrl
[i
].Bounds
));
516 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
517 memcpy(&lpmc16
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
,
518 sizeof(mlcA
.pamxctrl
[i
].Metrics
));
522 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
527 /**************************************************************************
528 * mixerGetLineInfo [MMSYSTEM.805]
530 UINT16 WINAPI
mixerGetLineInfo16(HMIXEROBJ16 hmix
, LPMIXERLINE16 lpmli16
,
536 TRACE("(%04x, %p, %08x)\n", hmix
, lpmli16
, fdwInfo
);
538 if (lpmli16
== NULL
|| lpmli16
->cbStruct
!= sizeof(*lpmli16
))
539 return MMSYSERR_INVALPARAM
;
541 mliA
.cbStruct
= sizeof(mliA
);
542 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
543 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
544 mliA
.dwComponentType
= lpmli16
->dwComponentType
;
546 case MIXER_GETLINEINFOF_DESTINATION
:
547 mliA
.dwDestination
= lpmli16
->dwDestination
;
549 case MIXER_GETLINEINFOF_LINEID
:
550 mliA
.dwLineID
= lpmli16
->dwLineID
;
552 case MIXER_GETLINEINFOF_SOURCE
:
553 mliA
.dwDestination
= lpmli16
->dwDestination
;
554 mliA
.dwSource
= lpmli16
->dwSource
;
556 case MIXER_GETLINEINFOF_TARGETTYPE
:
557 mliA
.Target
.dwType
= lpmli16
->Target
.dwType
;
558 mliA
.Target
.wMid
= lpmli16
->Target
.wMid
;
559 mliA
.Target
.wPid
= lpmli16
->Target
.wPid
;
560 mliA
.Target
.vDriverVersion
= lpmli16
->Target
.vDriverVersion
;
561 strcpy(mliA
.Target
.szPname
, lpmli16
->Target
.szPname
);
564 FIXME("Unsupported fdwControls=0x%08x\n", fdwInfo
);
567 ret
= mixerGetLineInfoA(HMIXEROBJ_32(hmix
), &mliA
, fdwInfo
);
569 lpmli16
->dwDestination
= mliA
.dwDestination
;
570 lpmli16
->dwSource
= mliA
.dwSource
;
571 lpmli16
->dwLineID
= mliA
.dwLineID
;
572 lpmli16
->fdwLine
= mliA
.fdwLine
;
573 lpmli16
->dwUser
= mliA
.dwUser
;
574 lpmli16
->dwComponentType
= mliA
.dwComponentType
;
575 lpmli16
->cChannels
= mliA
.cChannels
;
576 lpmli16
->cConnections
= mliA
.cConnections
;
577 lpmli16
->cControls
= mliA
.cControls
;
578 strcpy(lpmli16
->szShortName
, mliA
.szShortName
);
579 strcpy(lpmli16
->szName
, mliA
.szName
);
580 lpmli16
->Target
.dwType
= mliA
.Target
.dwType
;
581 lpmli16
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
582 lpmli16
->Target
.wMid
= mliA
.Target
.wMid
;
583 lpmli16
->Target
.wPid
= mliA
.Target
.wPid
;
584 lpmli16
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
585 strcpy(lpmli16
->Target
.szPname
, mliA
.Target
.szPname
);
590 /**************************************************************************
591 * mixerSetControlDetails [MMSYSTEM.809]
593 UINT16 WINAPI
mixerSetControlDetails16(HMIXEROBJ16 hmix
,
594 LPMIXERCONTROLDETAILS16 lpmcd
,
597 TRACE("(%04x, %p, %08x)\n", hmix
, lpmcd
, fdwDetails
);
598 return MMSYSERR_NOTENABLED
;
601 /**************************************************************************
602 * mixerMessage [MMSYSTEM.804]
604 DWORD WINAPI
mixerMessage16(HMIXER16 hmix
, UINT16 uMsg
, DWORD dwParam1
,
607 return mixerMessage(HMIXER_32(hmix
), uMsg
, dwParam1
, dwParam2
);
610 /* ###################################################
612 * ###################################################
615 /**************************************************************************
616 * auxGetNumDevs [MMSYSTEM.350]
618 UINT16 WINAPI
auxGetNumDevs16(void)
620 return auxGetNumDevs();
623 /**************************************************************************
624 * auxGetDevCaps [MMSYSTEM.351]
626 UINT16 WINAPI
auxGetDevCaps16(UINT16 uDeviceID
, LPAUXCAPS16 lpCaps
, UINT16 uSize
)
631 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
633 ret
= auxGetDevCapsA(uDeviceID
, &acA
, sizeof(acA
));
634 if (ret
== MMSYSERR_NOERROR
) {
636 ac16
.wMid
= acA
.wMid
;
637 ac16
.wPid
= acA
.wPid
;
638 ac16
.vDriverVersion
= acA
.vDriverVersion
;
639 strcpy(ac16
.szPname
, acA
.szPname
);
640 ac16
.wTechnology
= acA
.wTechnology
;
641 ac16
.dwSupport
= acA
.dwSupport
;
642 memcpy(lpCaps
, &ac16
, min(uSize
, sizeof(ac16
)));
647 /**************************************************************************
648 * auxGetVolume [MMSYSTEM.352]
650 UINT16 WINAPI
auxGetVolume16(UINT16 uDeviceID
, LPDWORD lpdwVolume
)
652 return auxGetVolume(uDeviceID
, lpdwVolume
);
655 /**************************************************************************
656 * auxSetVolume [MMSYSTEM.353]
658 UINT16 WINAPI
auxSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
660 return auxSetVolume(uDeviceID
, dwVolume
);
663 /**************************************************************************
664 * auxOutMessage [MMSYSTEM.354]
666 DWORD WINAPI
auxOutMessage16(UINT16 uDeviceID
, UINT16 uMessage
, DWORD dw1
, DWORD dw2
)
668 TRACE("(%04X, %04X, %08X, %08X)\n", uDeviceID
, uMessage
, dw1
, dw2
);
671 case AUXDM_GETNUMDEVS
:
672 case AUXDM_SETVOLUME
:
673 /* no argument conversion needed */
675 case AUXDM_GETVOLUME
:
676 return auxGetVolume(uDeviceID
, MapSL(dw1
));
677 case AUXDM_GETDEVCAPS
:
678 return auxGetDevCaps16(uDeviceID
, MapSL(dw1
), dw2
);
680 TRACE("(%04x, %04x, %08x, %08x): unhandled message\n",
681 uDeviceID
, uMessage
, dw1
, dw2
);
684 return auxOutMessage(uDeviceID
, uMessage
, dw1
, dw2
);
687 /* ###################################################
689 * ###################################################
692 /**************************************************************************
693 * midiOutGetNumDevs [MMSYSTEM.201]
695 UINT16 WINAPI
midiOutGetNumDevs16(void)
697 return midiOutGetNumDevs();
700 /**************************************************************************
701 * midiOutGetDevCaps [MMSYSTEM.202]
703 UINT16 WINAPI
midiOutGetDevCaps16(UINT16 uDeviceID
, LPMIDIOUTCAPS16 lpCaps
,
709 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
711 ret
= midiOutGetDevCapsA(uDeviceID
, &mocA
, sizeof(mocA
));
712 if (ret
== MMSYSERR_NOERROR
) {
714 moc16
.wMid
= mocA
.wMid
;
715 moc16
.wPid
= mocA
.wPid
;
716 moc16
.vDriverVersion
= mocA
.vDriverVersion
;
717 strcpy(moc16
.szPname
, mocA
.szPname
);
718 moc16
.wTechnology
= mocA
.wTechnology
;
719 moc16
.wVoices
= mocA
.wVoices
;
720 moc16
.wNotes
= mocA
.wNotes
;
721 moc16
.wChannelMask
= mocA
.wChannelMask
;
722 moc16
.dwSupport
= mocA
.dwSupport
;
723 memcpy(lpCaps
, &moc16
, min(uSize
, sizeof(moc16
)));
728 /**************************************************************************
729 * midiOutGetErrorText [MMSYSTEM.203]
730 * midiInGetErrorText [MMSYSTEM.303]
732 UINT16 WINAPI
midiOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
734 return midiOutGetErrorTextA(uError
, lpText
, uSize
);
737 /**************************************************************************
738 * midiOutOpen [MMSYSTEM.204]
740 UINT16 WINAPI
midiOutOpen16(HMIDIOUT16
* lphMidiOut
, UINT16 uDeviceID
,
741 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
745 struct mmsystdrv_thunk
* thunk
;
747 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, dwFlags
, MMSYSTDRV_MIDIOUT
)))
749 return MMSYSERR_NOMEM
;
751 if ((dwFlags
& CALLBACK_TYPEMASK
) != CALLBACK_NULL
)
752 dwFlags
= (dwFlags
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
753 ret
= midiOutOpen(&hmo
, uDeviceID
, (DWORD
)thunk
, dwInstance
, dwFlags
);
754 if (ret
== MMSYSERR_NOERROR
)
756 if (lphMidiOut
!= NULL
) *lphMidiOut
= HMIDIOUT_16(hmo
);
757 MMSYSTDRV_SetHandle(thunk
, (void*)hmo
);
759 else MMSYSTDRV_DeleteThunk(thunk
);
763 /**************************************************************************
764 * midiOutClose [MMSYSTEM.205]
766 UINT16 WINAPI
midiOutClose16(HMIDIOUT16 hMidiOut
)
768 UINT ret
= midiOutClose(HMIDIOUT_32(hMidiOut
));
770 if (ret
== MMSYSERR_NOERROR
)
771 MMSYSTDRV_CloseHandle((void*)HMIDIOUT_32(hMidiOut
));
775 /**************************************************************************
776 * midiOutPrepareHeader [MMSYSTEM.206]
778 UINT16 WINAPI
midiOutPrepareHeader16(HMIDIOUT16 hMidiOut
, /* [in] */
779 SEGPTR lpsegMidiOutHdr
, /* [???] */
780 UINT16 uSize
) /* [in] */
782 TRACE("(%04X, %08x, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
784 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_PREPARE
, lpsegMidiOutHdr
, uSize
);
787 /**************************************************************************
788 * midiOutUnprepareHeader [MMSYSTEM.207]
790 UINT16 WINAPI
midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut
, /* [in] */
791 SEGPTR lpsegMidiOutHdr
, /* [???] */
792 UINT16 uSize
) /* [in] */
794 LPMIDIHDR16 lpMidiOutHdr
= MapSL(lpsegMidiOutHdr
);
796 TRACE("(%04X, %08x, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
798 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
799 return MMSYSERR_NOERROR
;
802 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_UNPREPARE
, lpsegMidiOutHdr
, uSize
);
805 /**************************************************************************
806 * midiOutShortMsg [MMSYSTEM.208]
808 UINT16 WINAPI
midiOutShortMsg16(HMIDIOUT16 hMidiOut
, DWORD dwMsg
)
810 return midiOutShortMsg(HMIDIOUT_32(hMidiOut
), dwMsg
);
813 /**************************************************************************
814 * midiOutLongMsg [MMSYSTEM.209]
816 UINT16 WINAPI
midiOutLongMsg16(HMIDIOUT16 hMidiOut
, /* [in] */
817 LPMIDIHDR16 lpsegMidiOutHdr
, /* [???] NOTE: SEGPTR */
818 UINT16 uSize
) /* [in] */
820 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
822 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_LONGDATA
, (DWORD_PTR
)lpsegMidiOutHdr
, uSize
);
825 /**************************************************************************
826 * midiOutReset [MMSYSTEM.210]
828 UINT16 WINAPI
midiOutReset16(HMIDIOUT16 hMidiOut
)
830 return midiOutReset(HMIDIOUT_32(hMidiOut
));
833 /**************************************************************************
834 * midiOutGetVolume [MMSYSTEM.211]
836 UINT16 WINAPI
midiOutGetVolume16(UINT16 uDeviceID
, DWORD
* lpdwVolume
)
838 return midiOutGetVolume(HMIDIOUT_32(uDeviceID
), lpdwVolume
);
841 /**************************************************************************
842 * midiOutSetVolume [MMSYSTEM.212]
844 UINT16 WINAPI
midiOutSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
846 return midiOutSetVolume(HMIDIOUT_32(uDeviceID
), dwVolume
);
849 /**************************************************************************
850 * midiOutCachePatches [MMSYSTEM.213]
852 UINT16 WINAPI
midiOutCachePatches16(HMIDIOUT16 hMidiOut
, UINT16 uBank
,
853 WORD
* lpwPatchArray
, UINT16 uFlags
)
855 return midiOutCachePatches(HMIDIOUT_32(hMidiOut
), uBank
, lpwPatchArray
,
859 /**************************************************************************
860 * midiOutCacheDrumPatches [MMSYSTEM.214]
862 UINT16 WINAPI
midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut
, UINT16 uPatch
,
863 WORD
* lpwKeyArray
, UINT16 uFlags
)
865 return midiOutCacheDrumPatches(HMIDIOUT_32(hMidiOut
), uPatch
, lpwKeyArray
, uFlags
);
868 /**************************************************************************
869 * midiOutGetID [MMSYSTEM.215]
871 UINT16 WINAPI
midiOutGetID16(HMIDIOUT16 hMidiOut
, UINT16
* lpuDeviceID
)
876 ret
= midiOutGetID(HMIDIOUT_32(hMidiOut
), &devid
);
877 if (ret
!= MMSYSERR_NOERROR
) return ret
;
878 *lpuDeviceID
= devid
;
882 /**************************************************************************
883 * midiOutMessage [MMSYSTEM.216]
885 DWORD WINAPI
midiOutMessage16(HMIDIOUT16 hMidiOut
, UINT16 uMessage
,
886 DWORD dwParam1
, DWORD dwParam2
)
888 TRACE("(%04X, %04X, %08X, %08X)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
893 FIXME("can't handle OPEN or CLOSE message!\n");
894 return MMSYSERR_NOTSUPPORTED
;
897 return midiOutGetVolume16(hMidiOut
, MapSL(dwParam1
));
899 return midiOutLongMsg16(hMidiOut
, MapSL(dwParam1
), dwParam2
);
901 /* lpMidiOutHdr is still a segmented pointer for this function */
902 return midiOutPrepareHeader16(hMidiOut
, dwParam1
, dwParam2
);
904 return midiOutUnprepareHeader16(hMidiOut
, dwParam1
, dwParam2
);
906 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), uMessage
, dwParam1
, dwParam2
);
909 /**************************************************************************
910 * midiInGetNumDevs [MMSYSTEM.301]
912 UINT16 WINAPI
midiInGetNumDevs16(void)
914 return midiInGetNumDevs();
917 /**************************************************************************
918 * midiInGetDevCaps [MMSYSTEM.302]
920 UINT16 WINAPI
midiInGetDevCaps16(UINT16 uDeviceID
, LPMIDIINCAPS16 lpCaps
,
926 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
928 ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
929 if (ret
== MMSYSERR_NOERROR
) {
931 mic16
.wMid
= micA
.wMid
;
932 mic16
.wPid
= micA
.wPid
;
933 mic16
.vDriverVersion
= micA
.vDriverVersion
;
934 strcpy(mic16
.szPname
, micA
.szPname
);
935 mic16
.dwSupport
= micA
.dwSupport
;
936 memcpy(lpCaps
, &mic16
, min(uSize
, sizeof(mic16
)));
941 /**************************************************************************
942 * midiInOpen [MMSYSTEM.304]
944 UINT16 WINAPI
midiInOpen16(HMIDIIN16
* lphMidiIn
, UINT16 uDeviceID
,
945 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
949 struct mmsystdrv_thunk
* thunk
;
951 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, dwFlags
, MMSYSTDRV_MIDIIN
)))
953 return MMSYSERR_NOMEM
;
955 if ((dwFlags
& CALLBACK_TYPEMASK
) != CALLBACK_NULL
)
956 dwFlags
= (dwFlags
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
957 ret
= midiInOpen(&hmid
, uDeviceID
, (DWORD
)thunk
, dwInstance
, dwFlags
);
958 if (ret
== MMSYSERR_NOERROR
)
960 if (lphMidiIn
) *lphMidiIn
= HMIDIIN_16(hmid
);
961 MMSYSTDRV_SetHandle(thunk
, (void*)hmid
);
963 else MMSYSTDRV_DeleteThunk(thunk
);
967 /**************************************************************************
968 * midiInClose [MMSYSTEM.305]
970 UINT16 WINAPI
midiInClose16(HMIDIIN16 hMidiIn
)
972 UINT ret
= midiInClose(HMIDIIN_32(hMidiIn
));
974 if (ret
== MMSYSERR_NOERROR
)
975 MMSYSTDRV_CloseHandle((void*)HMIDIIN_32(hMidiIn
));
979 /**************************************************************************
980 * midiInPrepareHeader [MMSYSTEM.306]
982 UINT16 WINAPI
midiInPrepareHeader16(HMIDIIN16 hMidiIn
, /* [in] */
983 SEGPTR lpsegMidiInHdr
, /* [???] */
984 UINT16 uSize
) /* [in] */
986 TRACE("(%04X, %08x, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
988 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_PREPARE
, lpsegMidiInHdr
, uSize
);
991 /**************************************************************************
992 * midiInUnprepareHeader [MMSYSTEM.307]
994 UINT16 WINAPI
midiInUnprepareHeader16(HMIDIIN16 hMidiIn
, /* [in] */
995 SEGPTR lpsegMidiInHdr
, /* [???] */
996 UINT16 uSize
) /* [in] */
998 LPMIDIHDR16 lpMidiInHdr
= MapSL(lpsegMidiInHdr
);
1000 TRACE("(%04X, %08x, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
1002 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
1003 return MMSYSERR_NOERROR
;
1006 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_UNPREPARE
, lpsegMidiInHdr
, uSize
);
1009 /**************************************************************************
1010 * midiInAddBuffer [MMSYSTEM.308]
1012 UINT16 WINAPI
midiInAddBuffer16(HMIDIIN16 hMidiIn
, /* [in] */
1013 MIDIHDR16
* lpsegMidiInHdr
, /* [???] NOTE: SEGPTR */
1014 UINT16 uSize
) /* [in] */
1016 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
1018 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_ADDBUFFER
, (DWORD_PTR
)lpsegMidiInHdr
, uSize
);
1021 /**************************************************************************
1022 * midiInStart [MMSYSTEM.309]
1024 UINT16 WINAPI
midiInStart16(HMIDIIN16 hMidiIn
)
1026 return midiInStart(HMIDIIN_32(hMidiIn
));
1029 /**************************************************************************
1030 * midiInStop [MMSYSTEM.310]
1032 UINT16 WINAPI
midiInStop16(HMIDIIN16 hMidiIn
)
1034 return midiInStop(HMIDIIN_32(hMidiIn
));
1037 /**************************************************************************
1038 * midiInReset [MMSYSTEM.311]
1040 UINT16 WINAPI
midiInReset16(HMIDIIN16 hMidiIn
)
1042 return midiInReset(HMIDIIN_32(hMidiIn
));
1045 /**************************************************************************
1046 * midiInGetID [MMSYSTEM.312]
1048 UINT16 WINAPI
midiInGetID16(HMIDIIN16 hMidiIn
, UINT16
* lpuDeviceID
)
1053 ret
= midiInGetID(HMIDIIN_32(hMidiIn
), &devid
);
1054 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1055 *lpuDeviceID
= devid
;
1059 /**************************************************************************
1060 * midiInMessage [MMSYSTEM.313]
1062 DWORD WINAPI
midiInMessage16(HMIDIIN16 hMidiIn
, UINT16 uMessage
,
1063 DWORD dwParam1
, DWORD dwParam2
)
1065 TRACE("(%04X, %04X, %08X, %08X)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
1070 FIXME("can't handle OPEN or CLOSE message!\n");
1071 return MMSYSERR_NOTSUPPORTED
;
1073 case MIDM_GETDEVCAPS
:
1074 return midiInGetDevCaps16(hMidiIn
, MapSL(dwParam1
), dwParam2
);
1076 return midiInPrepareHeader16(hMidiIn
, dwParam1
, dwParam2
);
1077 case MIDM_UNPREPARE
:
1078 return midiInUnprepareHeader16(hMidiIn
, dwParam1
, dwParam2
);
1079 case MIDM_ADDBUFFER
:
1080 return midiInAddBuffer16(hMidiIn
, MapSL(dwParam1
), dwParam2
);
1082 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), uMessage
, dwParam1
, dwParam2
);
1085 /**************************************************************************
1086 * midiStreamClose [MMSYSTEM.252]
1088 MMRESULT16 WINAPI
midiStreamClose16(HMIDISTRM16 hMidiStrm
)
1090 UINT ret
= midiStreamClose(HMIDISTRM_32(hMidiStrm
));
1091 if (ret
== MMSYSERR_NOERROR
)
1092 MMSYSTDRV_CloseHandle((void*)HMIDISTRM_32(hMidiStrm
));
1096 /**************************************************************************
1097 * midiStreamOpen [MMSYSTEM.251]
1099 MMRESULT16 WINAPI
midiStreamOpen16(HMIDISTRM16
* phMidiStrm
, LPUINT16 devid
,
1100 DWORD cMidi
, DWORD dwCallback
,
1101 DWORD dwInstance
, DWORD fdwOpen
)
1103 HMIDISTRM hMidiStrm32
;
1106 struct mmsystdrv_thunk
* thunk
;
1108 if (!phMidiStrm
|| !devid
)
1109 return MMSYSERR_INVALPARAM
;
1112 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, fdwOpen
, MMSYSTDRV_MIDIOUT
)))
1114 return MMSYSERR_NOMEM
;
1116 if ((fdwOpen
& CALLBACK_TYPEMASK
) != CALLBACK_NULL
)
1117 fdwOpen
= (fdwOpen
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
1118 ret
= midiStreamOpen(&hMidiStrm32
, &devid32
, cMidi
, (DWORD
)thunk
, dwInstance
, fdwOpen
);
1119 if (ret
== MMSYSERR_NOERROR
)
1121 *phMidiStrm
= HMIDISTRM_16(hMidiStrm32
);
1123 MMSYSTDRV_SetHandle(thunk
, hMidiStrm32
);
1125 else MMSYSTDRV_DeleteThunk(thunk
);
1129 /**************************************************************************
1130 * midiStreamOut [MMSYSTEM.254]
1132 MMRESULT16 WINAPI
midiStreamOut16(HMIDISTRM16 hMidiStrm
, LPMIDIHDR16 lpMidiHdr
, UINT16 cbMidiHdr
)
1134 return midiStreamOut(HMIDISTRM_32(hMidiStrm
), (LPMIDIHDR
)lpMidiHdr
,
1138 /**************************************************************************
1139 * midiStreamPause [MMSYSTEM.255]
1141 MMRESULT16 WINAPI
midiStreamPause16(HMIDISTRM16 hMidiStrm
)
1143 return midiStreamPause(HMIDISTRM_32(hMidiStrm
));
1146 /**************************************************************************
1147 * midiStreamPosition [MMSYSTEM.253]
1149 MMRESULT16 WINAPI
midiStreamPosition16(HMIDISTRM16 hMidiStrm
, LPMMTIME16 lpmmt16
, UINT16 cbmmt
)
1155 return MMSYSERR_INVALPARAM
;
1156 MMSYSTEM_MMTIME16to32(&mmt32
, lpmmt16
);
1157 ret
= midiStreamPosition(HMIDISTRM_32(hMidiStrm
), &mmt32
, sizeof(MMTIME
));
1158 MMSYSTEM_MMTIME32to16(lpmmt16
, &mmt32
);
1162 /**************************************************************************
1163 * midiStreamProperty [MMSYSTEM.250]
1165 MMRESULT16 WINAPI
midiStreamProperty16(HMIDISTRM16 hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
1167 return midiStreamProperty(HMIDISTRM_32(hMidiStrm
), lpPropData
, dwProperty
);
1170 /**************************************************************************
1171 * midiStreamRestart [MMSYSTEM.256]
1173 MMRESULT16 WINAPI
midiStreamRestart16(HMIDISTRM16 hMidiStrm
)
1175 return midiStreamRestart(HMIDISTRM_32(hMidiStrm
));
1178 /**************************************************************************
1179 * midiStreamStop [MMSYSTEM.257]
1181 MMRESULT16 WINAPI
midiStreamStop16(HMIDISTRM16 hMidiStrm
)
1183 return midiStreamStop(HMIDISTRM_32(hMidiStrm
));
1186 /* ###################################################
1188 * ###################################################
1191 /**************************************************************************
1192 * waveOutGetNumDevs [MMSYSTEM.401]
1194 UINT16 WINAPI
waveOutGetNumDevs16(void)
1196 return waveOutGetNumDevs();
1199 /**************************************************************************
1200 * waveOutGetDevCaps [MMSYSTEM.402]
1202 UINT16 WINAPI
waveOutGetDevCaps16(UINT16 uDeviceID
,
1203 LPWAVEOUTCAPS16 lpCaps
, UINT16 uSize
)
1207 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
1209 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1211 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
1212 if (ret
== MMSYSERR_NOERROR
) {
1213 WAVEOUTCAPS16 woc16
;
1214 woc16
.wMid
= wocA
.wMid
;
1215 woc16
.wPid
= wocA
.wPid
;
1216 woc16
.vDriverVersion
= wocA
.vDriverVersion
;
1217 strcpy(woc16
.szPname
, wocA
.szPname
);
1218 woc16
.dwFormats
= wocA
.dwFormats
;
1219 woc16
.wChannels
= wocA
.wChannels
;
1220 woc16
.dwSupport
= wocA
.dwSupport
;
1221 memcpy(lpCaps
, &woc16
, min(uSize
, sizeof(woc16
)));
1226 /**************************************************************************
1227 * waveOutGetErrorText [MMSYSTEM.403]
1228 * waveInGetErrorText [MMSYSTEM.503]
1230 UINT16 WINAPI
waveOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
1232 return waveOutGetErrorTextA(uError
, lpText
, uSize
);
1235 /**************************************************************************
1236 * waveOutOpen [MMSYSTEM.404]
1238 UINT16 WINAPI
waveOutOpen16(HWAVEOUT16
* lphWaveOut
, UINT16 uDeviceID
,
1239 LPCWAVEFORMATEX lpFormat
, DWORD dwCallback
,
1240 DWORD dwInstance
, DWORD dwFlags
)
1244 struct mmsystdrv_thunk
* thunk
;
1246 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, dwFlags
, MMSYSTDRV_WAVEOUT
)))
1248 return MMSYSERR_NOMEM
;
1250 if ((dwFlags
& CALLBACK_TYPEMASK
) != CALLBACK_NULL
)
1251 dwFlags
= (dwFlags
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
1252 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1253 * call the 32 bit version
1254 * however, we need to promote correctly the wave mapper id
1255 * (0xFFFFFFFF and not 0x0000FFFF)
1257 ret
= waveOutOpen(&hWaveOut
, (uDeviceID
== (UINT16
)-1) ? (UINT
)-1 : uDeviceID
,
1258 lpFormat
, (DWORD
)thunk
, dwInstance
, dwFlags
);
1260 if (ret
== MMSYSERR_NOERROR
)
1262 if (lphWaveOut
!= NULL
) *lphWaveOut
= HWAVEOUT_16(hWaveOut
);
1263 MMSYSTDRV_SetHandle(thunk
, (void*)hWaveOut
);
1265 else MMSYSTDRV_DeleteThunk(thunk
);
1269 /**************************************************************************
1270 * waveOutClose [MMSYSTEM.405]
1272 UINT16 WINAPI
waveOutClose16(HWAVEOUT16 hWaveOut
)
1277 ReleaseThunkLock(&level
);
1278 ret
= waveOutClose(HWAVEOUT_32(hWaveOut
));
1279 RestoreThunkLock(level
);
1280 if (ret
== MMSYSERR_NOERROR
)
1281 MMSYSTDRV_CloseHandle((void*)HWAVEOUT_32(hWaveOut
));
1285 /**************************************************************************
1286 * waveOutPrepareHeader [MMSYSTEM.406]
1288 UINT16 WINAPI
waveOutPrepareHeader16(HWAVEOUT16 hWaveOut
, /* [in] */
1289 SEGPTR lpsegWaveOutHdr
, /* [???] */
1290 UINT16 uSize
) /* [in] */
1292 LPWAVEHDR lpWaveOutHdr
= MapSL(lpsegWaveOutHdr
);
1295 TRACE("(%04X, %08x, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1297 if (lpWaveOutHdr
== NULL
) return MMSYSERR_INVALPARAM
;
1299 if ((result
= MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_PREPARE
, lpsegWaveOutHdr
,
1300 uSize
)) != MMSYSERR_NOTSUPPORTED
)
1303 if (lpWaveOutHdr
->dwFlags
& WHDR_INQUEUE
)
1304 return WAVERR_STILLPLAYING
;
1306 lpWaveOutHdr
->dwFlags
|= WHDR_PREPARED
;
1307 lpWaveOutHdr
->dwFlags
&= ~WHDR_DONE
;
1309 return MMSYSERR_NOERROR
;
1312 /**************************************************************************
1313 * waveOutUnprepareHeader [MMSYSTEM.407]
1315 UINT16 WINAPI
waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut
, /* [in] */
1316 SEGPTR lpsegWaveOutHdr
, /* [???] */
1317 UINT16 uSize
) /* [in] */
1319 LPWAVEHDR lpWaveOutHdr
= MapSL(lpsegWaveOutHdr
);
1321 TRACE("(%04X, %08x, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1323 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
1324 return MMSYSERR_NOERROR
;
1327 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_UNPREPARE
, lpsegWaveOutHdr
, uSize
);
1330 /**************************************************************************
1331 * waveOutWrite [MMSYSTEM.408]
1333 UINT16 WINAPI
waveOutWrite16(HWAVEOUT16 hWaveOut
, /* [in] */
1334 LPWAVEHDR lpsegWaveOutHdr
, /* [???] NOTE: SEGPTR */
1335 UINT16 uSize
) /* [in] */
1337 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1339 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_WRITE
, (DWORD_PTR
)lpsegWaveOutHdr
, uSize
);
1342 /**************************************************************************
1343 * waveOutBreakLoop [MMSYSTEM.419]
1345 UINT16 WINAPI
waveOutBreakLoop16(HWAVEOUT16 hWaveOut16
)
1350 ReleaseThunkLock(&level
);
1351 ret
= waveOutBreakLoop(HWAVEOUT_32(hWaveOut16
));
1352 RestoreThunkLock(level
);
1356 /**************************************************************************
1357 * waveOutPause [MMSYSTEM.409]
1359 UINT16 WINAPI
waveOutPause16(HWAVEOUT16 hWaveOut16
)
1364 ReleaseThunkLock(&level
);
1365 ret
= waveOutPause(HWAVEOUT_32(hWaveOut16
));
1366 RestoreThunkLock(level
);
1370 /**************************************************************************
1371 * waveOutReset [MMSYSTEM.411]
1373 UINT16 WINAPI
waveOutReset16(HWAVEOUT16 hWaveOut16
)
1378 ReleaseThunkLock(&level
);
1379 ret
= waveOutReset(HWAVEOUT_32(hWaveOut16
));
1380 RestoreThunkLock(level
);
1384 /**************************************************************************
1385 * waveOutRestart [MMSYSTEM.410]
1387 UINT16 WINAPI
waveOutRestart16(HWAVEOUT16 hWaveOut16
)
1392 ReleaseThunkLock(&level
);
1393 ret
= waveOutRestart(HWAVEOUT_32(hWaveOut16
));
1394 RestoreThunkLock(level
);
1398 /**************************************************************************
1399 * waveOutGetPosition [MMSYSTEM.412]
1401 UINT16 WINAPI
waveOutGetPosition16(HWAVEOUT16 hWaveOut
, LPMMTIME16 lpTime
,
1407 mmt
.wType
= lpTime
->wType
;
1408 ret
= waveOutGetPosition(HWAVEOUT_32(hWaveOut
), &mmt
, sizeof(mmt
));
1409 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
1413 /**************************************************************************
1414 * waveOutGetPitch [MMSYSTEM.413]
1416 UINT16 WINAPI
waveOutGetPitch16(HWAVEOUT16 hWaveOut16
, LPDWORD lpdw
)
1418 return waveOutGetPitch(HWAVEOUT_32(hWaveOut16
), lpdw
);
1421 /**************************************************************************
1422 * waveOutSetPitch [MMSYSTEM.414]
1424 UINT16 WINAPI
waveOutSetPitch16(HWAVEOUT16 hWaveOut16
, DWORD dw
)
1426 return waveOutSetPitch(HWAVEOUT_32(hWaveOut16
), dw
);
1429 /**************************************************************************
1430 * waveOutGetPlaybackRate [MMSYSTEM.417]
1432 UINT16 WINAPI
waveOutGetPlaybackRate16(HWAVEOUT16 hWaveOut16
, LPDWORD lpdw
)
1434 return waveOutGetPlaybackRate(HWAVEOUT_32(hWaveOut16
), lpdw
);
1437 /**************************************************************************
1438 * waveOutSetPlaybackRate [MMSYSTEM.418]
1440 UINT16 WINAPI
waveOutSetPlaybackRate16(HWAVEOUT16 hWaveOut16
, DWORD dw
)
1442 return waveOutSetPlaybackRate(HWAVEOUT_32(hWaveOut16
), dw
);
1445 /**************************************************************************
1446 * waveOutGetVolume [MMSYSTEM.415]
1448 UINT16 WINAPI
waveOutGetVolume16(UINT16 devid
, LPDWORD lpdw
)
1450 return waveOutGetVolume(HWAVEOUT_32(devid
), lpdw
);
1453 /**************************************************************************
1454 * waveOutSetVolume [MMSYSTEM.416]
1456 UINT16 WINAPI
waveOutSetVolume16(UINT16 devid
, DWORD dw
)
1458 return waveOutSetVolume(HWAVEOUT_32(devid
), dw
);
1461 /**************************************************************************
1462 * waveOutGetID [MMSYSTEM.420]
1464 UINT16 WINAPI
waveOutGetID16(HWAVEOUT16 hWaveOut
, UINT16
* lpuDeviceID
)
1469 ret
= waveOutGetID(HWAVEOUT_32(hWaveOut
), &devid
);
1470 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1471 *lpuDeviceID
= devid
;
1475 /**************************************************************************
1476 * waveOutMessage [MMSYSTEM.421]
1478 DWORD WINAPI
waveOutMessage16(HWAVEOUT16 hWaveOut
, UINT16 uMessage
,
1479 DWORD dwParam1
, DWORD dwParam2
)
1481 TRACE("(%04x, %u, %d, %d)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
1483 if ((DWORD_PTR
)hWaveOut
< waveOutGetNumDevs())
1485 if (uMessage
== DRV_QUERYDRVENTRY
|| uMessage
== DRV_QUERYDEVNODE
)
1486 dwParam1
= (DWORD
)MapSL(dwParam1
);
1488 else if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
1490 return MMSYSERR_INVALPARAM
;
1492 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), uMessage
, dwParam1
, dwParam2
);
1495 /**************************************************************************
1496 * waveInGetNumDevs [MMSYSTEM.501]
1498 UINT16 WINAPI
waveInGetNumDevs16(void)
1500 return waveInGetNumDevs();
1503 /**************************************************************************
1504 * waveInGetDevCaps [MMSYSTEM.502]
1506 UINT16 WINAPI
waveInGetDevCaps16(UINT16 uDeviceID
, LPWAVEINCAPS16 lpCaps
,
1512 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1514 ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, sizeof(wicA
));
1515 if (ret
== MMSYSERR_NOERROR
) {
1517 wic16
.wMid
= wicA
.wMid
;
1518 wic16
.wPid
= wicA
.wPid
;
1519 wic16
.vDriverVersion
= wicA
.vDriverVersion
;
1520 strcpy(wic16
.szPname
, wicA
.szPname
);
1521 wic16
.dwFormats
= wicA
.dwFormats
;
1522 wic16
.wChannels
= wicA
.wChannels
;
1523 memcpy(lpCaps
, &wic16
, min(uSize
, sizeof(wic16
)));
1528 /**************************************************************************
1529 * waveInOpen [MMSYSTEM.504]
1531 UINT16 WINAPI
waveInOpen16(HWAVEIN16
* lphWaveIn
, UINT16 uDeviceID
,
1532 LPCWAVEFORMATEX lpFormat
, DWORD dwCallback
,
1533 DWORD dwInstance
, DWORD dwFlags
)
1537 struct mmsystdrv_thunk
* thunk
;
1539 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, dwFlags
, MMSYSTDRV_WAVEIN
)))
1541 return MMSYSERR_NOMEM
;
1543 if ((dwFlags
& CALLBACK_TYPEMASK
) != CALLBACK_NULL
)
1544 dwFlags
= (dwFlags
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
1545 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1546 * call the 32 bit version
1547 * however, we need to promote correctly the wave mapper id
1548 * (0xFFFFFFFF and not 0x0000FFFF)
1550 ret
= waveInOpen(&hWaveIn
, (uDeviceID
== (UINT16
)-1) ? (UINT
)-1 : uDeviceID
,
1551 lpFormat
, (DWORD
)thunk
, dwInstance
, dwFlags
);
1553 if (ret
== MMSYSERR_NOERROR
)
1555 if (lphWaveIn
!= NULL
) *lphWaveIn
= HWAVEIN_16(hWaveIn
);
1556 MMSYSTDRV_SetHandle(thunk
, (void*)hWaveIn
);
1558 else MMSYSTDRV_DeleteThunk(thunk
);
1562 /**************************************************************************
1563 * waveInClose [MMSYSTEM.505]
1565 UINT16 WINAPI
waveInClose16(HWAVEIN16 hWaveIn
)
1570 ReleaseThunkLock(&level
);
1571 ret
= waveInClose(HWAVEIN_32(hWaveIn
));
1572 RestoreThunkLock(level
);
1573 if (ret
== MMSYSERR_NOERROR
)
1574 MMSYSTDRV_CloseHandle((void*)HWAVEIN_32(hWaveIn
));
1578 /**************************************************************************
1579 * waveInPrepareHeader [MMSYSTEM.506]
1581 UINT16 WINAPI
waveInPrepareHeader16(HWAVEIN16 hWaveIn
, /* [in] */
1582 SEGPTR lpsegWaveInHdr
, /* [???] */
1583 UINT16 uSize
) /* [in] */
1585 LPWAVEHDR lpWaveInHdr
= MapSL(lpsegWaveInHdr
);
1588 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
1590 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
1591 lpWaveInHdr
->dwBytesRecorded
= 0;
1593 ret
= MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_PREPARE
, lpsegWaveInHdr
, uSize
);
1597 /**************************************************************************
1598 * waveInUnprepareHeader [MMSYSTEM.507]
1600 UINT16 WINAPI
waveInUnprepareHeader16(HWAVEIN16 hWaveIn
, /* [in] */
1601 SEGPTR lpsegWaveInHdr
, /* [???] */
1602 UINT16 uSize
) /* [in] */
1604 LPWAVEHDR lpWaveInHdr
= MapSL(lpsegWaveInHdr
);
1606 TRACE("(%04X, %08x, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
1608 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
1610 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
1611 return MMSYSERR_NOERROR
;
1614 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_UNPREPARE
, lpsegWaveInHdr
, uSize
);
1617 /**************************************************************************
1618 * waveInAddBuffer [MMSYSTEM.508]
1620 UINT16 WINAPI
waveInAddBuffer16(HWAVEIN16 hWaveIn
, /* [in] */
1621 WAVEHDR
* lpsegWaveInHdr
, /* [???] NOTE: SEGPTR */
1622 UINT16 uSize
) /* [in] */
1624 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
1626 if (lpsegWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
1628 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_ADDBUFFER
, (DWORD_PTR
)lpsegWaveInHdr
, uSize
);
1631 /**************************************************************************
1632 * waveInReset [MMSYSTEM.511]
1634 UINT16 WINAPI
waveInReset16(HWAVEIN16 hWaveIn16
)
1639 ReleaseThunkLock(&level
);
1640 ret
= waveInReset(HWAVEIN_32(hWaveIn16
));
1641 RestoreThunkLock(level
);
1645 /**************************************************************************
1646 * waveInStart [MMSYSTEM.509]
1648 UINT16 WINAPI
waveInStart16(HWAVEIN16 hWaveIn16
)
1653 ReleaseThunkLock(&level
);
1654 ret
= waveInStart(HWAVEIN_32(hWaveIn16
));
1655 RestoreThunkLock(level
);
1659 /**************************************************************************
1660 * waveInStop [MMSYSTEM.510]
1662 UINT16 WINAPI
waveInStop16(HWAVEIN16 hWaveIn16
)
1667 ReleaseThunkLock(&level
);
1668 ret
= waveInStop(HWAVEIN_32(hWaveIn16
));
1669 RestoreThunkLock(level
);
1673 /**************************************************************************
1674 * waveInGetPosition [MMSYSTEM.512]
1676 UINT16 WINAPI
waveInGetPosition16(HWAVEIN16 hWaveIn
, LPMMTIME16 lpTime
,
1682 mmt
.wType
= lpTime
->wType
;
1683 ret
= waveInGetPosition(HWAVEIN_32(hWaveIn
), &mmt
, sizeof(mmt
));
1684 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
1688 /**************************************************************************
1689 * waveInGetID [MMSYSTEM.513]
1691 UINT16 WINAPI
waveInGetID16(HWAVEIN16 hWaveIn
, UINT16
* lpuDeviceID
)
1696 ret
= waveInGetID(HWAVEIN_32(hWaveIn
), &devid
);
1697 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1698 *lpuDeviceID
= devid
;
1702 /**************************************************************************
1703 * waveInMessage [MMSYSTEM.514]
1705 DWORD WINAPI
waveInMessage16(HWAVEIN16 hWaveIn
, UINT16 uMessage
,
1706 DWORD dwParam1
, DWORD dwParam2
)
1708 TRACE("(%04x, %u, %d, %d)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
1710 if ((DWORD_PTR
)hWaveIn
< waveInGetNumDevs())
1712 if (uMessage
== DRV_QUERYDRVENTRY
|| uMessage
== DRV_QUERYDEVNODE
)
1713 dwParam1
= (DWORD
)MapSL(dwParam1
);
1715 else if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
1717 return MMSYSERR_INVALPARAM
;
1719 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), uMessage
, dwParam1
, dwParam2
);
1722 /* ###################################################
1724 * ###################################################
1727 /*#define USE_MM_TSK_WINE*/
1729 /**************************************************************************
1730 * mmTaskCreate [MMSYSTEM.900]
1732 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
1733 * called upon creation with dwPmt as parameter.
1735 HINSTANCE16 WINAPI
mmTaskCreate16(SEGPTR spProc
, HINSTANCE16
*lphMmTask
, DWORD dwPmt
)
1740 DWORD showCmd
= 0x40002;
1743 TRACE("(%08x, %p, %08x);\n", spProc
, lphMmTask
, dwPmt
);
1744 /* This to work requires NE modules to be started with a binary command line
1745 * which is not currently the case. A patch exists but has never been committed.
1746 * A workaround would be to integrate code for mmtask.tsk into Wine, but
1747 * this requires tremendous work (starting with patching tools/build to
1748 * create NE executables (and not only DLLs) for builtins modules.
1751 FIXME("This is currently broken. It will fail\n");
1754 *(LPDWORD
)(cmdline
+ 1) = (DWORD
)spProc
;
1755 *(LPDWORD
)(cmdline
+ 5) = dwPmt
;
1756 *(LPDWORD
)(cmdline
+ 9) = 0;
1758 lp
.hEnvironment
= 0;
1759 lp
.cmdLine
= MapLS(cmdline
);
1760 lp
.showCmd
= MapLS(&showCmd
);
1763 #ifndef USE_MM_TSK_WINE
1764 handle
= LoadModule16("c:\\windows\\system\\mmtask.tsk", &lp
);
1766 handle
= LoadModule16("mmtask.tsk", &lp
);
1769 ret
= (handle
) ? 1 : 2;
1775 *lphMmTask
= handle
;
1777 UnMapLS( lp
.cmdLine
);
1778 UnMapLS( lp
.showCmd
);
1779 TRACE("=> 0x%04x/%d\n", handle
, ret
);
1783 #ifdef USE_MM_TSK_WINE
1784 /* C equivalent to mmtask.tsk binary content */
1785 void mmTaskEntryPoint16(LPSTR cmdLine
, WORD di
, WORD si
)
1787 int len
= cmdLine
[0x80];
1790 void (*fpProc
)(DWORD
) = MapSL(*((DWORD
*)(cmdLine
+ 1)));
1791 DWORD dwPmt
= *((DWORD
*)(cmdLine
+ 5));
1794 InitTask16(); /* FIXME: pmts / from context ? */
1797 if (SetMessageQueue16(0x40)) {
1799 if (HIWORD(fpProc
)) {
1801 /* EPP StackEnter16(); */
1813 /**************************************************************************
1814 * mmTaskBlock [MMSYSTEM.902]
1816 void WINAPI
mmTaskBlock16(HINSTANCE16 hInst
)
1821 GetMessageA(&msg
, 0, 0, 0);
1823 TranslateMessage(&msg
);
1824 DispatchMessageA(&msg
);
1826 } while (msg
.message
< 0x3A0);
1829 /**************************************************************************
1830 * mmTaskSignal [MMSYSTEM.903]
1832 LRESULT WINAPI
mmTaskSignal16(HTASK16 ht
)
1834 TRACE("(%04x);\n", ht
);
1835 return PostThreadMessageW( HTASK_32(ht
), WM_USER
, 0, 0 );
1838 /**************************************************************************
1839 * mmGetCurrentTask [MMSYSTEM.904]
1841 HTASK16 WINAPI
mmGetCurrentTask16(void)
1843 return GetCurrentTask();
1846 /**************************************************************************
1847 * mmTaskYield [MMSYSTEM.905]
1849 void WINAPI
mmTaskYield16(void)
1853 if (PeekMessageA(&msg
, 0, 0, 0, 0)) {
1858 /******************************************************************
1863 static WINE_MMTHREAD
* WINMM_GetmmThread(HANDLE16 h
)
1865 return MapSL(MAKESEGPTR(h
, 0));
1868 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD
* lpMMThd
)
1873 if (lpMMThd
->dwThreadID
!= GetCurrentThreadId())
1874 ERR("Not called by thread itself\n");
1877 ResetEvent(lpMMThd
->hEvent
);
1878 if (InterlockedDecrement(&lpMMThd
->dwSignalCount
) >= 0)
1880 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
1884 ret
= MsgWaitForMultipleObjects(1, &lpMMThd
->hEvent
, FALSE
, INFINITE
, QS_ALLINPUT
);
1886 case WAIT_OBJECT_0
: /* Event */
1889 case WAIT_OBJECT_0
+ 1: /* Msg */
1891 if (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
1892 TranslateMessage(&msg
);
1893 DispatchMessageA(&msg
);
1897 WARN("S2.x unsupported ret val 0x%08x\n", ret
);
1903 /**************************************************************************
1904 * mmThreadBlock [MMSYSTEM.1122]
1906 void WINAPI
mmThreadBlock16(HANDLE16 hndl
)
1908 TRACE("(%04x)!\n", hndl
);
1911 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
1913 if (lpMMThd
->hThread
!= 0) {
1916 ReleaseThunkLock(&lc
);
1917 MMSYSTEM_ThreadBlock(lpMMThd
);
1918 RestoreThunkLock(lc
);
1920 mmTaskBlock16(lpMMThd
->hTask
);
1926 /**************************************************************************
1927 * __wine_mmThreadEntryPoint (MMSYSTEM.2047)
1929 DWORD WINAPI
WINE_mmThreadEntryPoint(LPVOID p
)
1931 HANDLE16 hndl
= (HANDLE16
)(DWORD_PTR
)p
;
1932 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
1934 TRACE("(%04x %p)\n", hndl
, lpMMThd
);
1936 lpMMThd
->hTask
= LOWORD(GetCurrentTask());
1937 TRACE("[10-%p] setting hTask to 0x%08x\n", lpMMThd
->hThread
, lpMMThd
->hTask
);
1938 lpMMThd
->dwStatus
= 0x10;
1939 MMSYSTEM_ThreadBlock(lpMMThd
);
1940 TRACE("[20-%p]\n", lpMMThd
->hThread
);
1941 lpMMThd
->dwStatus
= 0x20;
1942 if (lpMMThd
->fpThread
) {
1943 WOWCallback16(lpMMThd
->fpThread
, lpMMThd
->dwThreadPmt
);
1945 lpMMThd
->dwStatus
= 0x30;
1946 TRACE("[30-%p]\n", lpMMThd
->hThread
);
1947 while (lpMMThd
->dwCounter
) {
1951 TRACE("[XX-%p]\n", lpMMThd
->hThread
);
1953 lpMMThd
->dwSignature
= WINE_MMTHREAD_DELETED
;
1954 /* close lpMMThread->hVxD directIO */
1955 if (lpMMThd
->hEvent
)
1956 CloseHandle(lpMMThd
->hEvent
);
1963 extern DWORD WINAPI
GetProcessFlags(DWORD
);
1965 /**************************************************************************
1966 * mmThreadCreate [MMSYSTEM.1120]
1969 * Creates a MM thread, calling fpThreadAddr(dwPmt).
1971 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
1972 * bit.1 set means to open a VxD for this thread (unsupported)
1974 LRESULT WINAPI
mmThreadCreate16(FARPROC16 fpThreadAddr
, LPHANDLE16 lpHndl
, DWORD dwPmt
, DWORD dwFlags
)
1979 TRACE("(%p, %p, %08x, %08x)!\n", fpThreadAddr
, lpHndl
, dwPmt
, dwFlags
);
1981 hndl
= GlobalAlloc16(sizeof(WINE_MMTHREAD
), GMEM_SHARE
|GMEM_ZEROINIT
);
1986 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
1989 /* force mmtask routines even if mmthread is required */
1990 /* this will work only if the patch about binary cmd line and NE tasks
1996 lpMMThd
->dwSignature
= WINE_MMTHREAD_CREATED
;
1997 lpMMThd
->dwCounter
= 0;
1998 lpMMThd
->hThread
= 0;
1999 lpMMThd
->dwThreadID
= 0;
2000 lpMMThd
->fpThread
= (DWORD
)fpThreadAddr
;
2001 lpMMThd
->dwThreadPmt
= dwPmt
;
2002 lpMMThd
->dwSignalCount
= 0;
2003 lpMMThd
->hEvent
= 0;
2005 lpMMThd
->dwStatus
= 0;
2006 lpMMThd
->dwFlags
= dwFlags
;
2009 if ((dwFlags
& 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
2010 lpMMThd
->hEvent
= CreateEventW(NULL
, FALSE
, TRUE
, NULL
);
2012 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd
);
2013 if (lpMMThd
->dwFlags
& 2) {
2014 /* as long as we don't support MM VxD in wine, we don't need
2015 * to care about this flag
2017 /* FIXME("Don't know how to properly open VxD handles\n"); */
2018 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
2021 lpMMThd
->hThread
= CreateThread(0, 0, WINE_mmThreadEntryPoint
,
2022 (LPVOID
)(DWORD_PTR
)hndl
, CREATE_SUSPENDED
, &lpMMThd
->dwThreadID
);
2023 if (lpMMThd
->hThread
== 0) {
2024 WARN("Couldn't create thread\n");
2025 /* clean-up(VxDhandle...); devicedirectio... */
2026 if (lpMMThd
->hEvent
!= 0)
2027 CloseHandle(lpMMThd
->hEvent
);
2030 SetThreadPriority(lpMMThd
->hThread
, THREAD_PRIORITY_TIME_CRITICAL
);
2031 TRACE("Got a nice thread hndl=%p id=0x%08x\n", lpMMThd
->hThread
, lpMMThd
->dwThreadID
);
2035 /* get WINE_mmThreadEntryPoint()
2036 * 2047 is its ordinal in mmsystem.spec
2038 FARPROC16 fp
= GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (LPCSTR
)2047);
2040 TRACE("farproc seg=0x%p lin=%p\n", fp
, MapSL((SEGPTR
)fp
));
2042 ret
= (fp
== 0) ? 2 : mmTaskCreate16((DWORD
)fp
, 0, hndl
);
2046 if (lpMMThd
->hThread
&& !ResumeThread(lpMMThd
->hThread
))
2047 WARN("Couldn't resume thread\n");
2049 while (lpMMThd
->dwStatus
!= 0x10) { /* test also HIWORD of dwStatus */
2051 PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
2064 TRACE("ok => %ld\n", ret
);
2068 /**************************************************************************
2069 * mmThreadSignal [MMSYSTEM.1121]
2071 void WINAPI
mmThreadSignal16(HANDLE16 hndl
)
2073 TRACE("(%04x)!\n", hndl
);
2076 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2078 lpMMThd
->dwCounter
++;
2079 if (lpMMThd
->hThread
!= 0) {
2080 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
2081 SetEvent(lpMMThd
->hEvent
);
2083 mmTaskSignal16(lpMMThd
->hTask
);
2085 lpMMThd
->dwCounter
--;
2089 /**************************************************************************
2090 * mmThreadIsCurrent [MMSYSTEM.1123]
2092 BOOL16 WINAPI
mmThreadIsCurrent16(HANDLE16 hndl
)
2096 TRACE("(%04x)!\n", hndl
);
2098 if (hndl
&& mmThreadIsValid16(hndl
)) {
2099 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2100 ret
= (GetCurrentThreadId() == lpMMThd
->dwThreadID
);
2102 TRACE("=> %d\n", ret
);
2106 /**************************************************************************
2107 * mmThreadIsValid [MMSYSTEM.1124]
2109 BOOL16 WINAPI
mmThreadIsValid16(HANDLE16 hndl
)
2113 TRACE("(%04x)!\n", hndl
);
2116 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2118 if (!IsBadWritePtr(lpMMThd
, sizeof(WINE_MMTHREAD
)) &&
2119 lpMMThd
->dwSignature
== WINE_MMTHREAD_CREATED
&&
2120 IsTask16(lpMMThd
->hTask
)) {
2121 lpMMThd
->dwCounter
++;
2122 if (lpMMThd
->hThread
!= 0) {
2124 if (GetExitCodeThread(lpMMThd
->hThread
, &dwThreadRet
) &&
2125 dwThreadRet
== STATUS_PENDING
) {
2131 lpMMThd
->dwCounter
--;
2134 TRACE("=> %d\n", ret
);
2138 /**************************************************************************
2139 * mmThreadGetTask [MMSYSTEM.1125]
2141 HANDLE16 WINAPI
mmThreadGetTask16(HANDLE16 hndl
)
2145 TRACE("(%04x)\n", hndl
);
2147 if (mmThreadIsValid16(hndl
)) {
2148 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2149 ret
= lpMMThd
->hTask
;
2154 typedef BOOL16 (WINAPI
*MMCPLCALLBACK
)(HWND
, LPCSTR
, LPCSTR
, LPCSTR
);
2156 /**************************************************************************
2157 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
2159 BOOL16 WINAPI
mmShowMMCPLPropertySheet16(HWND hWnd
, LPCSTR lpStrDevice
,
2160 LPCSTR lpStrTab
, LPCSTR lpStrTitle
)
2165 TRACE("(%p \"%s\" \"%s\" \"%s\")\n", hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
2167 hndl
= LoadLibraryA("MMSYS.CPL");
2169 MMCPLCALLBACK fp
= (MMCPLCALLBACK
)GetProcAddress(hndl
, "ShowMMCPLPropertySheet");
2172 ReleaseThunkLock(&lc
);
2173 ret
= (fp
)(hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
2174 RestoreThunkLock(lc
);
2182 /**************************************************************************
2183 * StackEnter [MMSYSTEM.32]
2185 void WINAPI
StackEnter16(void)
2188 /* mmsystem.dll from Win 95 does only this: so does Wine */
2193 /**************************************************************************
2194 * StackLeave [MMSYSTEM.33]
2196 void WINAPI
StackLeave16(void)
2199 /* mmsystem.dll from Win 95 does only this: so does Wine */
2204 /**************************************************************************
2205 * WMMMidiRunOnce [MMSYSTEM.8]
2207 void WINAPI
WMMMidiRunOnce16(void)
2209 FIXME("(), stub!\n");
2214 /* ###################################################
2216 * ###################################################
2219 /**************************************************************************
2220 * joyGetNumDevs [MMSYSTEM.101]
2222 UINT16 WINAPI
joyGetNumDevs16(void)
2224 return joyGetNumDevs();
2227 /**************************************************************************
2228 * joyGetDevCaps [MMSYSTEM.102]
2230 MMRESULT16 WINAPI
joyGetDevCaps16(UINT16 wID
, LPJOYCAPS16 lpCaps
, UINT16 wSize
)
2235 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
2237 ret
= joyGetDevCapsA(wID
, &jca
, sizeof(jca
));
2239 if (ret
!= JOYERR_NOERROR
) return ret
;
2240 lpCaps
->wMid
= jca
.wMid
;
2241 lpCaps
->wPid
= jca
.wPid
;
2242 strcpy(lpCaps
->szPname
, jca
.szPname
);
2243 lpCaps
->wXmin
= jca
.wXmin
;
2244 lpCaps
->wXmax
= jca
.wXmax
;
2245 lpCaps
->wYmin
= jca
.wYmin
;
2246 lpCaps
->wYmax
= jca
.wYmax
;
2247 lpCaps
->wZmin
= jca
.wZmin
;
2248 lpCaps
->wZmax
= jca
.wZmax
;
2249 lpCaps
->wNumButtons
= jca
.wNumButtons
;
2250 lpCaps
->wPeriodMin
= jca
.wPeriodMin
;
2251 lpCaps
->wPeriodMax
= jca
.wPeriodMax
;
2253 if (wSize
>= sizeof(JOYCAPS16
)) { /* Win95 extensions ? */
2254 lpCaps
->wRmin
= jca
.wRmin
;
2255 lpCaps
->wRmax
= jca
.wRmax
;
2256 lpCaps
->wUmin
= jca
.wUmin
;
2257 lpCaps
->wUmax
= jca
.wUmax
;
2258 lpCaps
->wVmin
= jca
.wVmin
;
2259 lpCaps
->wVmax
= jca
.wVmax
;
2260 lpCaps
->wCaps
= jca
.wCaps
;
2261 lpCaps
->wMaxAxes
= jca
.wMaxAxes
;
2262 lpCaps
->wNumAxes
= jca
.wNumAxes
;
2263 lpCaps
->wMaxButtons
= jca
.wMaxButtons
;
2264 strcpy(lpCaps
->szRegKey
, jca
.szRegKey
);
2265 strcpy(lpCaps
->szOEMVxD
, jca
.szOEMVxD
);
2271 /**************************************************************************
2272 * joyGetPosEx [MMSYSTEM.110]
2274 MMRESULT16 WINAPI
joyGetPosEx16(UINT16 wID
, LPJOYINFOEX lpInfo
)
2276 return joyGetPosEx(wID
, lpInfo
);
2279 /**************************************************************************
2280 * joyGetPos [MMSYSTEM.103]
2282 MMRESULT16 WINAPI
joyGetPos16(UINT16 wID
, LPJOYINFO16 lpInfo
)
2287 TRACE("(%d, %p);\n", wID
, lpInfo
);
2289 if ((ret
= joyGetPos(wID
, &ji
)) == JOYERR_NOERROR
) {
2290 lpInfo
->wXpos
= ji
.wXpos
;
2291 lpInfo
->wYpos
= ji
.wYpos
;
2292 lpInfo
->wZpos
= ji
.wZpos
;
2293 lpInfo
->wButtons
= ji
.wButtons
;
2298 /**************************************************************************
2299 * joyGetThreshold [MMSYSTEM.104]
2301 MMRESULT16 WINAPI
joyGetThreshold16(UINT16 wID
, LPUINT16 lpThreshold
)
2306 ret
= joyGetThreshold(wID
, &t
);
2307 if (ret
== JOYERR_NOERROR
)
2312 /**************************************************************************
2313 * joyReleaseCapture [MMSYSTEM.105]
2315 MMRESULT16 WINAPI
joyReleaseCapture16(UINT16 wID
)
2317 return joyReleaseCapture(wID
);
2320 /**************************************************************************
2321 * joySetCapture [MMSYSTEM.106]
2323 MMRESULT16 WINAPI
joySetCapture16(HWND16 hWnd
, UINT16 wID
, UINT16 wPeriod
, BOOL16 bChanged
)
2325 return joySetCapture(HWND_32(hWnd
), wID
, wPeriod
, bChanged
);
2328 /**************************************************************************
2329 * joySetThreshold [MMSYSTEM.107]
2331 MMRESULT16 WINAPI
joySetThreshold16(UINT16 wID
, UINT16 wThreshold
)
2333 return joySetThreshold(wID
,wThreshold
);
2336 /**************************************************************************
2337 * joySetCalibration [MMSYSTEM.109]
2339 MMRESULT16 WINAPI
joySetCalibration16(UINT16 wID
)
2341 FIXME("(%04X): stub.\n", wID
);
2342 return JOYERR_NOCANDO
;