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
, MMSYSTDRV_MIXER
)))
405 return MMSYSERR_NOMEM
;
407 if ((fdwOpen
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
)
409 dwCallback
= (DWORD
)thunk
;
412 ret
= mixerOpen(&hmix
, uDeviceID
, dwCallback
, dwInstance
, fdwOpen
);
413 if (ret
== MMSYSERR_NOERROR
)
415 if (lphmix
) *lphmix
= HMIXER_16(hmix
);
416 if (thunk
) MMSYSTDRV_SetHandle(thunk
, hmix
);
418 else MMSYSTDRV_DeleteThunk(thunk
);
422 /**************************************************************************
423 * mixerClose [MMSYSTEM.803]
425 UINT16 WINAPI
mixerClose16(HMIXER16 hMix
)
427 UINT ret
= mixerClose(HMIXER_32(hMix
));
429 if (ret
== MMSYSERR_NOERROR
)
430 MMSYSTDRV_CloseHandle((void*)HMIXER_32(hMix
));
434 /**************************************************************************
435 * mixerGetID (MMSYSTEM.806)
437 UINT16 WINAPI
mixerGetID16(HMIXEROBJ16 hmix
, LPUINT16 lpid
, DWORD fdwID
)
440 UINT ret
= mixerGetID(HMIXEROBJ_32(hmix
), &xid
, fdwID
);
447 /**************************************************************************
448 * mixerGetControlDetails [MMSYSTEM.808]
450 UINT16 WINAPI
mixerGetControlDetails16(HMIXEROBJ16 hmix
,
451 LPMIXERCONTROLDETAILS16 lpmcd
,
454 DWORD ret
= MMSYSERR_NOTENABLED
;
457 TRACE("(%04x, %p, %08x)\n", hmix
, lpmcd
, fdwDetails
);
459 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
460 return MMSYSERR_INVALPARAM
;
462 sppaDetails
= (SEGPTR
)lpmcd
->paDetails
;
463 lpmcd
->paDetails
= MapSL(sppaDetails
);
464 ret
= mixerGetControlDetailsA(HMIXEROBJ_32(hmix
),
465 (LPMIXERCONTROLDETAILS
)lpmcd
, fdwDetails
);
466 lpmcd
->paDetails
= (LPVOID
)sppaDetails
;
471 /**************************************************************************
472 * mixerGetLineControls [MMSYSTEM.807]
474 UINT16 WINAPI
mixerGetLineControls16(HMIXEROBJ16 hmix
,
475 LPMIXERLINECONTROLS16 lpmlc16
,
478 MIXERLINECONTROLSA mlcA
;
481 LPMIXERCONTROL16 lpmc16
;
483 TRACE("(%04x, %p, %08x)\n", hmix
, lpmlc16
, fdwControls
);
485 if (lpmlc16
== NULL
|| lpmlc16
->cbStruct
!= sizeof(*lpmlc16
) ||
486 lpmlc16
->cbmxctrl
!= sizeof(MIXERCONTROL16
))
487 return MMSYSERR_INVALPARAM
;
489 mlcA
.cbStruct
= sizeof(mlcA
);
490 mlcA
.dwLineID
= lpmlc16
->dwLineID
;
491 mlcA
.u
.dwControlID
= lpmlc16
->u
.dwControlID
;
492 mlcA
.u
.dwControlType
= lpmlc16
->u
.dwControlType
;
493 mlcA
.cControls
= lpmlc16
->cControls
;
494 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
495 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0,
496 mlcA
.cControls
* mlcA
.cbmxctrl
);
498 ret
= mixerGetLineControlsA(HMIXEROBJ_32(hmix
), &mlcA
, fdwControls
);
500 if (ret
== MMSYSERR_NOERROR
) {
501 lpmlc16
->dwLineID
= mlcA
.dwLineID
;
502 lpmlc16
->u
.dwControlID
= mlcA
.u
.dwControlID
;
503 lpmlc16
->u
.dwControlType
= mlcA
.u
.dwControlType
;
504 lpmlc16
->cControls
= mlcA
.cControls
;
506 lpmc16
= MapSL(lpmlc16
->pamxctrl
);
508 for (i
= 0; i
< mlcA
.cControls
; i
++) {
509 lpmc16
[i
].cbStruct
= sizeof(MIXERCONTROL16
);
510 lpmc16
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
511 lpmc16
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
512 lpmc16
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
513 lpmc16
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
514 strcpy(lpmc16
[i
].szShortName
, mlcA
.pamxctrl
[i
].szShortName
);
515 strcpy(lpmc16
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
516 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
517 memcpy(&lpmc16
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
,
518 sizeof(mlcA
.pamxctrl
[i
].Bounds
));
519 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
520 memcpy(&lpmc16
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
,
521 sizeof(mlcA
.pamxctrl
[i
].Metrics
));
525 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
530 /**************************************************************************
531 * mixerGetLineInfo [MMSYSTEM.805]
533 UINT16 WINAPI
mixerGetLineInfo16(HMIXEROBJ16 hmix
, LPMIXERLINE16 lpmli16
,
539 TRACE("(%04x, %p, %08x)\n", hmix
, lpmli16
, fdwInfo
);
541 if (lpmli16
== NULL
|| lpmli16
->cbStruct
!= sizeof(*lpmli16
))
542 return MMSYSERR_INVALPARAM
;
544 mliA
.cbStruct
= sizeof(mliA
);
545 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
546 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
547 mliA
.dwComponentType
= lpmli16
->dwComponentType
;
549 case MIXER_GETLINEINFOF_DESTINATION
:
550 mliA
.dwDestination
= lpmli16
->dwDestination
;
552 case MIXER_GETLINEINFOF_LINEID
:
553 mliA
.dwLineID
= lpmli16
->dwLineID
;
555 case MIXER_GETLINEINFOF_SOURCE
:
556 mliA
.dwDestination
= lpmli16
->dwDestination
;
557 mliA
.dwSource
= lpmli16
->dwSource
;
559 case MIXER_GETLINEINFOF_TARGETTYPE
:
560 mliA
.Target
.dwType
= lpmli16
->Target
.dwType
;
561 mliA
.Target
.wMid
= lpmli16
->Target
.wMid
;
562 mliA
.Target
.wPid
= lpmli16
->Target
.wPid
;
563 mliA
.Target
.vDriverVersion
= lpmli16
->Target
.vDriverVersion
;
564 strcpy(mliA
.Target
.szPname
, lpmli16
->Target
.szPname
);
567 FIXME("Unsupported fdwControls=0x%08x\n", fdwInfo
);
570 ret
= mixerGetLineInfoA(HMIXEROBJ_32(hmix
), &mliA
, fdwInfo
);
572 lpmli16
->dwDestination
= mliA
.dwDestination
;
573 lpmli16
->dwSource
= mliA
.dwSource
;
574 lpmli16
->dwLineID
= mliA
.dwLineID
;
575 lpmli16
->fdwLine
= mliA
.fdwLine
;
576 lpmli16
->dwUser
= mliA
.dwUser
;
577 lpmli16
->dwComponentType
= mliA
.dwComponentType
;
578 lpmli16
->cChannels
= mliA
.cChannels
;
579 lpmli16
->cConnections
= mliA
.cConnections
;
580 lpmli16
->cControls
= mliA
.cControls
;
581 strcpy(lpmli16
->szShortName
, mliA
.szShortName
);
582 strcpy(lpmli16
->szName
, mliA
.szName
);
583 lpmli16
->Target
.dwType
= mliA
.Target
.dwType
;
584 lpmli16
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
585 lpmli16
->Target
.wMid
= mliA
.Target
.wMid
;
586 lpmli16
->Target
.wPid
= mliA
.Target
.wPid
;
587 lpmli16
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
588 strcpy(lpmli16
->Target
.szPname
, mliA
.Target
.szPname
);
593 /**************************************************************************
594 * mixerSetControlDetails [MMSYSTEM.809]
596 UINT16 WINAPI
mixerSetControlDetails16(HMIXEROBJ16 hmix
,
597 LPMIXERCONTROLDETAILS16 lpmcd
,
600 TRACE("(%04x, %p, %08x)\n", hmix
, lpmcd
, fdwDetails
);
601 return MMSYSERR_NOTENABLED
;
604 /**************************************************************************
605 * mixerMessage [MMSYSTEM.804]
607 DWORD WINAPI
mixerMessage16(HMIXER16 hmix
, UINT16 uMsg
, DWORD dwParam1
,
610 return mixerMessage(HMIXER_32(hmix
), uMsg
, dwParam1
, dwParam2
);
613 /* ###################################################
615 * ###################################################
618 /**************************************************************************
619 * auxGetNumDevs [MMSYSTEM.350]
621 UINT16 WINAPI
auxGetNumDevs16(void)
623 return auxGetNumDevs();
626 /**************************************************************************
627 * auxGetDevCaps [MMSYSTEM.351]
629 UINT16 WINAPI
auxGetDevCaps16(UINT16 uDeviceID
, LPAUXCAPS16 lpCaps
, UINT16 uSize
)
634 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
636 ret
= auxGetDevCapsA(uDeviceID
, &acA
, sizeof(acA
));
637 if (ret
== MMSYSERR_NOERROR
) {
639 ac16
.wMid
= acA
.wMid
;
640 ac16
.wPid
= acA
.wPid
;
641 ac16
.vDriverVersion
= acA
.vDriverVersion
;
642 strcpy(ac16
.szPname
, acA
.szPname
);
643 ac16
.wTechnology
= acA
.wTechnology
;
644 ac16
.dwSupport
= acA
.dwSupport
;
645 memcpy(lpCaps
, &ac16
, min(uSize
, sizeof(ac16
)));
650 /**************************************************************************
651 * auxGetVolume [MMSYSTEM.352]
653 UINT16 WINAPI
auxGetVolume16(UINT16 uDeviceID
, LPDWORD lpdwVolume
)
655 return auxGetVolume(uDeviceID
, lpdwVolume
);
658 /**************************************************************************
659 * auxSetVolume [MMSYSTEM.353]
661 UINT16 WINAPI
auxSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
663 return auxSetVolume(uDeviceID
, dwVolume
);
666 /**************************************************************************
667 * auxOutMessage [MMSYSTEM.354]
669 DWORD WINAPI
auxOutMessage16(UINT16 uDeviceID
, UINT16 uMessage
, DWORD dw1
, DWORD dw2
)
671 TRACE("(%04X, %04X, %08X, %08X)\n", uDeviceID
, uMessage
, dw1
, dw2
);
674 case AUXDM_GETNUMDEVS
:
675 case AUXDM_SETVOLUME
:
676 /* no argument conversion needed */
678 case AUXDM_GETVOLUME
:
679 return auxGetVolume(uDeviceID
, MapSL(dw1
));
680 case AUXDM_GETDEVCAPS
:
681 return auxGetDevCaps16(uDeviceID
, MapSL(dw1
), dw2
);
683 TRACE("(%04x, %04x, %08x, %08x): unhandled message\n",
684 uDeviceID
, uMessage
, dw1
, dw2
);
687 return auxOutMessage(uDeviceID
, uMessage
, dw1
, dw2
);
690 /* ###################################################
692 * ###################################################
695 /**************************************************************************
696 * midiOutGetNumDevs [MMSYSTEM.201]
698 UINT16 WINAPI
midiOutGetNumDevs16(void)
700 return midiOutGetNumDevs();
703 /**************************************************************************
704 * midiOutGetDevCaps [MMSYSTEM.202]
706 UINT16 WINAPI
midiOutGetDevCaps16(UINT16 uDeviceID
, LPMIDIOUTCAPS16 lpCaps
,
712 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
714 ret
= midiOutGetDevCapsA(uDeviceID
, &mocA
, sizeof(mocA
));
715 if (ret
== MMSYSERR_NOERROR
) {
717 moc16
.wMid
= mocA
.wMid
;
718 moc16
.wPid
= mocA
.wPid
;
719 moc16
.vDriverVersion
= mocA
.vDriverVersion
;
720 strcpy(moc16
.szPname
, mocA
.szPname
);
721 moc16
.wTechnology
= mocA
.wTechnology
;
722 moc16
.wVoices
= mocA
.wVoices
;
723 moc16
.wNotes
= mocA
.wNotes
;
724 moc16
.wChannelMask
= mocA
.wChannelMask
;
725 moc16
.dwSupport
= mocA
.dwSupport
;
726 memcpy(lpCaps
, &moc16
, min(uSize
, sizeof(moc16
)));
731 /**************************************************************************
732 * midiOutGetErrorText [MMSYSTEM.203]
733 * midiInGetErrorText [MMSYSTEM.303]
735 UINT16 WINAPI
midiOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
737 return midiOutGetErrorTextA(uError
, lpText
, uSize
);
740 /**************************************************************************
741 * midiOutOpen [MMSYSTEM.204]
743 UINT16 WINAPI
midiOutOpen16(HMIDIOUT16
* lphMidiOut
, UINT16 uDeviceID
,
744 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
748 struct mmsystdrv_thunk
* thunk
;
750 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, MMSYSTDRV_MIDIOUT
)))
752 return MMSYSERR_NOMEM
;
754 if ((dwFlags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
)
756 dwCallback
= (DWORD
)thunk
;
758 ret
= midiOutOpen(&hmo
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
759 if (ret
== MMSYSERR_NOERROR
)
761 if (lphMidiOut
!= NULL
) *lphMidiOut
= HMIDIOUT_16(hmo
);
762 MMSYSTDRV_SetHandle(thunk
, (void*)hmo
);
764 else MMSYSTDRV_DeleteThunk(thunk
);
768 /**************************************************************************
769 * midiOutClose [MMSYSTEM.205]
771 UINT16 WINAPI
midiOutClose16(HMIDIOUT16 hMidiOut
)
773 UINT ret
= midiOutClose(HMIDIOUT_32(hMidiOut
));
775 if (ret
== MMSYSERR_NOERROR
)
776 MMSYSTDRV_CloseHandle((void*)HMIDIOUT_32(hMidiOut
));
780 /**************************************************************************
781 * midiOutPrepareHeader [MMSYSTEM.206]
783 UINT16 WINAPI
midiOutPrepareHeader16(HMIDIOUT16 hMidiOut
, /* [in] */
784 SEGPTR lpsegMidiOutHdr
, /* [???] */
785 UINT16 uSize
) /* [in] */
787 TRACE("(%04X, %08x, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
789 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_PREPARE
, lpsegMidiOutHdr
, uSize
);
792 /**************************************************************************
793 * midiOutUnprepareHeader [MMSYSTEM.207]
795 UINT16 WINAPI
midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut
, /* [in] */
796 SEGPTR lpsegMidiOutHdr
, /* [???] */
797 UINT16 uSize
) /* [in] */
799 LPMIDIHDR16 lpMidiOutHdr
= MapSL(lpsegMidiOutHdr
);
801 TRACE("(%04X, %08x, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
803 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
804 return MMSYSERR_NOERROR
;
807 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_UNPREPARE
, lpsegMidiOutHdr
, uSize
);
810 /**************************************************************************
811 * midiOutShortMsg [MMSYSTEM.208]
813 UINT16 WINAPI
midiOutShortMsg16(HMIDIOUT16 hMidiOut
, DWORD dwMsg
)
815 return midiOutShortMsg(HMIDIOUT_32(hMidiOut
), dwMsg
);
818 /**************************************************************************
819 * midiOutLongMsg [MMSYSTEM.209]
821 UINT16 WINAPI
midiOutLongMsg16(HMIDIOUT16 hMidiOut
, /* [in] */
822 LPMIDIHDR16 lpsegMidiOutHdr
, /* [???] NOTE: SEGPTR */
823 UINT16 uSize
) /* [in] */
825 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
827 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_LONGDATA
, (DWORD_PTR
)lpsegMidiOutHdr
, uSize
);
830 /**************************************************************************
831 * midiOutReset [MMSYSTEM.210]
833 UINT16 WINAPI
midiOutReset16(HMIDIOUT16 hMidiOut
)
835 return midiOutReset(HMIDIOUT_32(hMidiOut
));
838 /**************************************************************************
839 * midiOutGetVolume [MMSYSTEM.211]
841 UINT16 WINAPI
midiOutGetVolume16(UINT16 uDeviceID
, DWORD
* lpdwVolume
)
843 return midiOutGetVolume(HMIDIOUT_32(uDeviceID
), lpdwVolume
);
846 /**************************************************************************
847 * midiOutSetVolume [MMSYSTEM.212]
849 UINT16 WINAPI
midiOutSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
851 return midiOutSetVolume(HMIDIOUT_32(uDeviceID
), dwVolume
);
854 /**************************************************************************
855 * midiOutCachePatches [MMSYSTEM.213]
857 UINT16 WINAPI
midiOutCachePatches16(HMIDIOUT16 hMidiOut
, UINT16 uBank
,
858 WORD
* lpwPatchArray
, UINT16 uFlags
)
860 return midiOutCachePatches(HMIDIOUT_32(hMidiOut
), uBank
, lpwPatchArray
,
864 /**************************************************************************
865 * midiOutCacheDrumPatches [MMSYSTEM.214]
867 UINT16 WINAPI
midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut
, UINT16 uPatch
,
868 WORD
* lpwKeyArray
, UINT16 uFlags
)
870 return midiOutCacheDrumPatches(HMIDIOUT_32(hMidiOut
), uPatch
, lpwKeyArray
, uFlags
);
873 /**************************************************************************
874 * midiOutGetID [MMSYSTEM.215]
876 UINT16 WINAPI
midiOutGetID16(HMIDIOUT16 hMidiOut
, UINT16
* lpuDeviceID
)
881 ret
= midiOutGetID(HMIDIOUT_32(hMidiOut
), &devid
);
882 if (ret
!= MMSYSERR_NOERROR
) return ret
;
883 *lpuDeviceID
= devid
;
887 /**************************************************************************
888 * midiOutMessage [MMSYSTEM.216]
890 DWORD WINAPI
midiOutMessage16(HMIDIOUT16 hMidiOut
, UINT16 uMessage
,
891 DWORD dwParam1
, DWORD dwParam2
)
893 TRACE("(%04X, %04X, %08X, %08X)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
898 FIXME("can't handle OPEN or CLOSE message!\n");
899 return MMSYSERR_NOTSUPPORTED
;
902 return midiOutGetVolume16(hMidiOut
, MapSL(dwParam1
));
904 return midiOutLongMsg16(hMidiOut
, MapSL(dwParam1
), dwParam2
);
906 /* lpMidiOutHdr is still a segmented pointer for this function */
907 return midiOutPrepareHeader16(hMidiOut
, dwParam1
, dwParam2
);
909 return midiOutUnprepareHeader16(hMidiOut
, dwParam1
, dwParam2
);
911 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), uMessage
, dwParam1
, dwParam2
);
914 /**************************************************************************
915 * midiInGetNumDevs [MMSYSTEM.301]
917 UINT16 WINAPI
midiInGetNumDevs16(void)
919 return midiInGetNumDevs();
922 /**************************************************************************
923 * midiInGetDevCaps [MMSYSTEM.302]
925 UINT16 WINAPI
midiInGetDevCaps16(UINT16 uDeviceID
, LPMIDIINCAPS16 lpCaps
,
931 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
933 ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
934 if (ret
== MMSYSERR_NOERROR
) {
936 mic16
.wMid
= micA
.wMid
;
937 mic16
.wPid
= micA
.wPid
;
938 mic16
.vDriverVersion
= micA
.vDriverVersion
;
939 strcpy(mic16
.szPname
, micA
.szPname
);
940 mic16
.dwSupport
= micA
.dwSupport
;
941 memcpy(lpCaps
, &mic16
, min(uSize
, sizeof(mic16
)));
946 /**************************************************************************
947 * midiInOpen [MMSYSTEM.304]
949 UINT16 WINAPI
midiInOpen16(HMIDIIN16
* lphMidiIn
, UINT16 uDeviceID
,
950 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
954 struct mmsystdrv_thunk
* thunk
;
956 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, MMSYSTDRV_MIDIIN
)))
958 return MMSYSERR_NOMEM
;
960 if ((dwFlags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
)
962 dwCallback
= (DWORD
)thunk
;
964 ret
= midiInOpen(&hmid
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
965 if (ret
== MMSYSERR_NOERROR
)
967 if (lphMidiIn
) *lphMidiIn
= HMIDIIN_16(hmid
);
968 MMSYSTDRV_SetHandle(thunk
, (void*)hmid
);
970 else MMSYSTDRV_DeleteThunk(thunk
);
974 /**************************************************************************
975 * midiInClose [MMSYSTEM.305]
977 UINT16 WINAPI
midiInClose16(HMIDIIN16 hMidiIn
)
979 UINT ret
= midiInClose(HMIDIIN_32(hMidiIn
));
981 if (ret
== MMSYSERR_NOERROR
)
982 MMSYSTDRV_CloseHandle((void*)HMIDIIN_32(hMidiIn
));
986 /**************************************************************************
987 * midiInPrepareHeader [MMSYSTEM.306]
989 UINT16 WINAPI
midiInPrepareHeader16(HMIDIIN16 hMidiIn
, /* [in] */
990 SEGPTR lpsegMidiInHdr
, /* [???] */
991 UINT16 uSize
) /* [in] */
993 TRACE("(%04X, %08x, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
995 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_PREPARE
, lpsegMidiInHdr
, uSize
);
998 /**************************************************************************
999 * midiInUnprepareHeader [MMSYSTEM.307]
1001 UINT16 WINAPI
midiInUnprepareHeader16(HMIDIIN16 hMidiIn
, /* [in] */
1002 SEGPTR lpsegMidiInHdr
, /* [???] */
1003 UINT16 uSize
) /* [in] */
1005 LPMIDIHDR16 lpMidiInHdr
= MapSL(lpsegMidiInHdr
);
1007 TRACE("(%04X, %08x, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
1009 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
1010 return MMSYSERR_NOERROR
;
1013 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_UNPREPARE
, lpsegMidiInHdr
, uSize
);
1016 /**************************************************************************
1017 * midiInAddBuffer [MMSYSTEM.308]
1019 UINT16 WINAPI
midiInAddBuffer16(HMIDIIN16 hMidiIn
, /* [in] */
1020 MIDIHDR16
* lpsegMidiInHdr
, /* [???] NOTE: SEGPTR */
1021 UINT16 uSize
) /* [in] */
1023 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
1025 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_ADDBUFFER
, (DWORD_PTR
)lpsegMidiInHdr
, uSize
);
1028 /**************************************************************************
1029 * midiInStart [MMSYSTEM.309]
1031 UINT16 WINAPI
midiInStart16(HMIDIIN16 hMidiIn
)
1033 return midiInStart(HMIDIIN_32(hMidiIn
));
1036 /**************************************************************************
1037 * midiInStop [MMSYSTEM.310]
1039 UINT16 WINAPI
midiInStop16(HMIDIIN16 hMidiIn
)
1041 return midiInStop(HMIDIIN_32(hMidiIn
));
1044 /**************************************************************************
1045 * midiInReset [MMSYSTEM.311]
1047 UINT16 WINAPI
midiInReset16(HMIDIIN16 hMidiIn
)
1049 return midiInReset(HMIDIIN_32(hMidiIn
));
1052 /**************************************************************************
1053 * midiInGetID [MMSYSTEM.312]
1055 UINT16 WINAPI
midiInGetID16(HMIDIIN16 hMidiIn
, UINT16
* lpuDeviceID
)
1060 ret
= midiInGetID(HMIDIIN_32(hMidiIn
), &devid
);
1061 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1062 *lpuDeviceID
= devid
;
1066 /**************************************************************************
1067 * midiInMessage [MMSYSTEM.313]
1069 DWORD WINAPI
midiInMessage16(HMIDIIN16 hMidiIn
, UINT16 uMessage
,
1070 DWORD dwParam1
, DWORD dwParam2
)
1072 TRACE("(%04X, %04X, %08X, %08X)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
1077 FIXME("can't handle OPEN or CLOSE message!\n");
1078 return MMSYSERR_NOTSUPPORTED
;
1080 case MIDM_GETDEVCAPS
:
1081 return midiInGetDevCaps16(hMidiIn
, MapSL(dwParam1
), dwParam2
);
1083 return midiInPrepareHeader16(hMidiIn
, dwParam1
, dwParam2
);
1084 case MIDM_UNPREPARE
:
1085 return midiInUnprepareHeader16(hMidiIn
, dwParam1
, dwParam2
);
1086 case MIDM_ADDBUFFER
:
1087 return midiInAddBuffer16(hMidiIn
, MapSL(dwParam1
), dwParam2
);
1089 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), uMessage
, dwParam1
, dwParam2
);
1092 /**************************************************************************
1093 * midiStreamClose [MMSYSTEM.252]
1095 MMRESULT16 WINAPI
midiStreamClose16(HMIDISTRM16 hMidiStrm
)
1097 UINT ret
= midiStreamClose(HMIDISTRM_32(hMidiStrm
));
1098 if (ret
== MMSYSERR_NOERROR
)
1099 MMSYSTDRV_CloseHandle((void*)HMIDISTRM_32(hMidiStrm
));
1103 /**************************************************************************
1104 * midiStreamOpen [MMSYSTEM.251]
1106 MMRESULT16 WINAPI
midiStreamOpen16(HMIDISTRM16
* phMidiStrm
, LPUINT16 devid
,
1107 DWORD cMidi
, DWORD dwCallback
,
1108 DWORD dwInstance
, DWORD fdwOpen
)
1110 HMIDISTRM hMidiStrm32
;
1113 struct mmsystdrv_thunk
* thunk
;
1115 if (!phMidiStrm
|| !devid
)
1116 return MMSYSERR_INVALPARAM
;
1119 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, MMSYSTDRV_MIDIOUT
)))
1121 return MMSYSERR_NOMEM
;
1123 if ((fdwOpen
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
)
1125 dwCallback
= (DWORD
)thunk
;
1127 ret
= midiStreamOpen(&hMidiStrm32
, &devid32
, cMidi
, dwCallback
, dwInstance
, fdwOpen
);
1128 if (ret
== MMSYSERR_NOERROR
)
1130 *phMidiStrm
= HMIDISTRM_16(hMidiStrm32
);
1132 MMSYSTDRV_SetHandle(thunk
, hMidiStrm32
);
1134 else MMSYSTDRV_DeleteThunk(thunk
);
1138 /**************************************************************************
1139 * midiStreamOut [MMSYSTEM.254]
1141 MMRESULT16 WINAPI
midiStreamOut16(HMIDISTRM16 hMidiStrm
, LPMIDIHDR16 lpMidiHdr
, UINT16 cbMidiHdr
)
1143 return midiStreamOut(HMIDISTRM_32(hMidiStrm
), (LPMIDIHDR
)lpMidiHdr
,
1147 /**************************************************************************
1148 * midiStreamPause [MMSYSTEM.255]
1150 MMRESULT16 WINAPI
midiStreamPause16(HMIDISTRM16 hMidiStrm
)
1152 return midiStreamPause(HMIDISTRM_32(hMidiStrm
));
1155 /**************************************************************************
1156 * midiStreamPosition [MMSYSTEM.253]
1158 MMRESULT16 WINAPI
midiStreamPosition16(HMIDISTRM16 hMidiStrm
, LPMMTIME16 lpmmt16
, UINT16 cbmmt
)
1164 return MMSYSERR_INVALPARAM
;
1165 MMSYSTEM_MMTIME16to32(&mmt32
, lpmmt16
);
1166 ret
= midiStreamPosition(HMIDISTRM_32(hMidiStrm
), &mmt32
, sizeof(MMTIME
));
1167 MMSYSTEM_MMTIME32to16(lpmmt16
, &mmt32
);
1171 /**************************************************************************
1172 * midiStreamProperty [MMSYSTEM.250]
1174 MMRESULT16 WINAPI
midiStreamProperty16(HMIDISTRM16 hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
1176 return midiStreamProperty(HMIDISTRM_32(hMidiStrm
), lpPropData
, dwProperty
);
1179 /**************************************************************************
1180 * midiStreamRestart [MMSYSTEM.256]
1182 MMRESULT16 WINAPI
midiStreamRestart16(HMIDISTRM16 hMidiStrm
)
1184 return midiStreamRestart(HMIDISTRM_32(hMidiStrm
));
1187 /**************************************************************************
1188 * midiStreamStop [MMSYSTEM.257]
1190 MMRESULT16 WINAPI
midiStreamStop16(HMIDISTRM16 hMidiStrm
)
1192 return midiStreamStop(HMIDISTRM_32(hMidiStrm
));
1195 /* ###################################################
1197 * ###################################################
1200 /**************************************************************************
1201 * waveOutGetNumDevs [MMSYSTEM.401]
1203 UINT16 WINAPI
waveOutGetNumDevs16(void)
1205 return waveOutGetNumDevs();
1208 /**************************************************************************
1209 * waveOutGetDevCaps [MMSYSTEM.402]
1211 UINT16 WINAPI
waveOutGetDevCaps16(UINT16 uDeviceID
,
1212 LPWAVEOUTCAPS16 lpCaps
, UINT16 uSize
)
1216 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
1218 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1220 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
1221 if (ret
== MMSYSERR_NOERROR
) {
1222 WAVEOUTCAPS16 woc16
;
1223 woc16
.wMid
= wocA
.wMid
;
1224 woc16
.wPid
= wocA
.wPid
;
1225 woc16
.vDriverVersion
= wocA
.vDriverVersion
;
1226 strcpy(woc16
.szPname
, wocA
.szPname
);
1227 woc16
.dwFormats
= wocA
.dwFormats
;
1228 woc16
.wChannels
= wocA
.wChannels
;
1229 woc16
.dwSupport
= wocA
.dwSupport
;
1230 memcpy(lpCaps
, &woc16
, min(uSize
, sizeof(woc16
)));
1235 /**************************************************************************
1236 * waveOutGetErrorText [MMSYSTEM.403]
1237 * waveInGetErrorText [MMSYSTEM.503]
1239 UINT16 WINAPI
waveOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
1241 return waveOutGetErrorTextA(uError
, lpText
, uSize
);
1244 /**************************************************************************
1245 * waveOutOpen [MMSYSTEM.404]
1247 UINT16 WINAPI
waveOutOpen16(HWAVEOUT16
* lphWaveOut
, UINT16 uDeviceID
,
1248 LPCWAVEFORMATEX lpFormat
, DWORD dwCallback
,
1249 DWORD dwInstance
, DWORD dwFlags
)
1253 struct mmsystdrv_thunk
* thunk
;
1255 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, MMSYSTDRV_WAVEOUT
)))
1257 return MMSYSERR_NOMEM
;
1259 if ((dwFlags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
)
1261 dwCallback
= (DWORD
)thunk
;
1263 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1264 * call the 32 bit version
1265 * however, we need to promote correctly the wave mapper id
1266 * (0xFFFFFFFF and not 0x0000FFFF)
1268 ret
= waveOutOpen(&hWaveOut
, (uDeviceID
== (UINT16
)-1) ? (UINT
)-1 : uDeviceID
,
1269 lpFormat
, dwCallback
, dwInstance
, dwFlags
);
1271 if (ret
== MMSYSERR_NOERROR
)
1273 if (lphWaveOut
!= NULL
) *lphWaveOut
= HWAVEOUT_16(hWaveOut
);
1274 MMSYSTDRV_SetHandle(thunk
, (void*)hWaveOut
);
1276 else MMSYSTDRV_DeleteThunk(thunk
);
1280 /**************************************************************************
1281 * waveOutClose [MMSYSTEM.405]
1283 UINT16 WINAPI
waveOutClose16(HWAVEOUT16 hWaveOut
)
1288 ReleaseThunkLock(&level
);
1289 ret
= waveOutClose(HWAVEOUT_32(hWaveOut
));
1290 RestoreThunkLock(level
);
1291 if (ret
== MMSYSERR_NOERROR
)
1292 MMSYSTDRV_CloseHandle((void*)HWAVEOUT_32(hWaveOut
));
1296 /**************************************************************************
1297 * waveOutPrepareHeader [MMSYSTEM.406]
1299 UINT16 WINAPI
waveOutPrepareHeader16(HWAVEOUT16 hWaveOut
, /* [in] */
1300 SEGPTR lpsegWaveOutHdr
, /* [???] */
1301 UINT16 uSize
) /* [in] */
1303 LPWAVEHDR lpWaveOutHdr
= MapSL(lpsegWaveOutHdr
);
1306 TRACE("(%04X, %08x, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1308 if (lpWaveOutHdr
== NULL
) return MMSYSERR_INVALPARAM
;
1310 if ((result
= MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_PREPARE
, lpsegWaveOutHdr
,
1311 uSize
)) != MMSYSERR_NOTSUPPORTED
)
1314 if (lpWaveOutHdr
->dwFlags
& WHDR_INQUEUE
)
1315 return WAVERR_STILLPLAYING
;
1317 lpWaveOutHdr
->dwFlags
|= WHDR_PREPARED
;
1318 lpWaveOutHdr
->dwFlags
&= ~WHDR_DONE
;
1320 return MMSYSERR_NOERROR
;
1323 /**************************************************************************
1324 * waveOutUnprepareHeader [MMSYSTEM.407]
1326 UINT16 WINAPI
waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut
, /* [in] */
1327 SEGPTR lpsegWaveOutHdr
, /* [???] */
1328 UINT16 uSize
) /* [in] */
1330 LPWAVEHDR lpWaveOutHdr
= MapSL(lpsegWaveOutHdr
);
1332 TRACE("(%04X, %08x, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1334 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
1335 return MMSYSERR_NOERROR
;
1338 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_UNPREPARE
, lpsegWaveOutHdr
, uSize
);
1341 /**************************************************************************
1342 * waveOutWrite [MMSYSTEM.408]
1344 UINT16 WINAPI
waveOutWrite16(HWAVEOUT16 hWaveOut
, /* [in] */
1345 LPWAVEHDR lpsegWaveOutHdr
, /* [???] NOTE: SEGPTR */
1346 UINT16 uSize
) /* [in] */
1348 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1350 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_WRITE
, (DWORD_PTR
)lpsegWaveOutHdr
, uSize
);
1353 /**************************************************************************
1354 * waveOutBreakLoop [MMSYSTEM.419]
1356 UINT16 WINAPI
waveOutBreakLoop16(HWAVEOUT16 hWaveOut16
)
1361 ReleaseThunkLock(&level
);
1362 ret
= waveOutBreakLoop(HWAVEOUT_32(hWaveOut16
));
1363 RestoreThunkLock(level
);
1367 /**************************************************************************
1368 * waveOutPause [MMSYSTEM.409]
1370 UINT16 WINAPI
waveOutPause16(HWAVEOUT16 hWaveOut16
)
1375 ReleaseThunkLock(&level
);
1376 ret
= waveOutPause(HWAVEOUT_32(hWaveOut16
));
1377 RestoreThunkLock(level
);
1381 /**************************************************************************
1382 * waveOutReset [MMSYSTEM.411]
1384 UINT16 WINAPI
waveOutReset16(HWAVEOUT16 hWaveOut16
)
1389 ReleaseThunkLock(&level
);
1390 ret
= waveOutReset(HWAVEOUT_32(hWaveOut16
));
1391 RestoreThunkLock(level
);
1395 /**************************************************************************
1396 * waveOutRestart [MMSYSTEM.410]
1398 UINT16 WINAPI
waveOutRestart16(HWAVEOUT16 hWaveOut16
)
1403 ReleaseThunkLock(&level
);
1404 ret
= waveOutRestart(HWAVEOUT_32(hWaveOut16
));
1405 RestoreThunkLock(level
);
1409 /**************************************************************************
1410 * waveOutGetPosition [MMSYSTEM.412]
1412 UINT16 WINAPI
waveOutGetPosition16(HWAVEOUT16 hWaveOut
, LPMMTIME16 lpTime
,
1418 mmt
.wType
= lpTime
->wType
;
1419 ret
= waveOutGetPosition(HWAVEOUT_32(hWaveOut
), &mmt
, sizeof(mmt
));
1420 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
1424 /**************************************************************************
1425 * waveOutGetPitch [MMSYSTEM.413]
1427 UINT16 WINAPI
waveOutGetPitch16(HWAVEOUT16 hWaveOut16
, LPDWORD lpdw
)
1429 return waveOutGetPitch(HWAVEOUT_32(hWaveOut16
), lpdw
);
1432 /**************************************************************************
1433 * waveOutSetPitch [MMSYSTEM.414]
1435 UINT16 WINAPI
waveOutSetPitch16(HWAVEOUT16 hWaveOut16
, DWORD dw
)
1437 return waveOutSetPitch(HWAVEOUT_32(hWaveOut16
), dw
);
1440 /**************************************************************************
1441 * waveOutGetPlaybackRate [MMSYSTEM.417]
1443 UINT16 WINAPI
waveOutGetPlaybackRate16(HWAVEOUT16 hWaveOut16
, LPDWORD lpdw
)
1445 return waveOutGetPlaybackRate(HWAVEOUT_32(hWaveOut16
), lpdw
);
1448 /**************************************************************************
1449 * waveOutSetPlaybackRate [MMSYSTEM.418]
1451 UINT16 WINAPI
waveOutSetPlaybackRate16(HWAVEOUT16 hWaveOut16
, DWORD dw
)
1453 return waveOutSetPlaybackRate(HWAVEOUT_32(hWaveOut16
), dw
);
1456 /**************************************************************************
1457 * waveOutGetVolume [MMSYSTEM.415]
1459 UINT16 WINAPI
waveOutGetVolume16(UINT16 devid
, LPDWORD lpdw
)
1461 return waveOutGetVolume(HWAVEOUT_32(devid
), lpdw
);
1464 /**************************************************************************
1465 * waveOutSetVolume [MMSYSTEM.416]
1467 UINT16 WINAPI
waveOutSetVolume16(UINT16 devid
, DWORD dw
)
1469 return waveOutSetVolume(HWAVEOUT_32(devid
), dw
);
1472 /**************************************************************************
1473 * waveOutGetID [MMSYSTEM.420]
1475 UINT16 WINAPI
waveOutGetID16(HWAVEOUT16 hWaveOut
, UINT16
* lpuDeviceID
)
1480 ret
= waveOutGetID(HWAVEOUT_32(hWaveOut
), &devid
);
1481 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1482 *lpuDeviceID
= devid
;
1486 /**************************************************************************
1487 * waveOutMessage [MMSYSTEM.421]
1489 DWORD WINAPI
waveOutMessage16(HWAVEOUT16 hWaveOut
, UINT16 uMessage
,
1490 DWORD dwParam1
, DWORD dwParam2
)
1492 TRACE("(%04x, %u, %d, %d)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
1494 if ((DWORD_PTR
)hWaveOut
< waveOutGetNumDevs())
1496 if (uMessage
== DRV_QUERYDRVENTRY
|| uMessage
== DRV_QUERYDEVNODE
)
1497 dwParam1
= (DWORD
)MapSL(dwParam1
);
1499 else if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
1501 return MMSYSERR_INVALPARAM
;
1503 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), uMessage
, dwParam1
, dwParam2
);
1506 /**************************************************************************
1507 * waveInGetNumDevs [MMSYSTEM.501]
1509 UINT16 WINAPI
waveInGetNumDevs16(void)
1511 return waveInGetNumDevs();
1514 /**************************************************************************
1515 * waveInGetDevCaps [MMSYSTEM.502]
1517 UINT16 WINAPI
waveInGetDevCaps16(UINT16 uDeviceID
, LPWAVEINCAPS16 lpCaps
,
1523 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1525 ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, sizeof(wicA
));
1526 if (ret
== MMSYSERR_NOERROR
) {
1528 wic16
.wMid
= wicA
.wMid
;
1529 wic16
.wPid
= wicA
.wPid
;
1530 wic16
.vDriverVersion
= wicA
.vDriverVersion
;
1531 strcpy(wic16
.szPname
, wicA
.szPname
);
1532 wic16
.dwFormats
= wicA
.dwFormats
;
1533 wic16
.wChannels
= wicA
.wChannels
;
1534 memcpy(lpCaps
, &wic16
, min(uSize
, sizeof(wic16
)));
1539 /**************************************************************************
1540 * waveInOpen [MMSYSTEM.504]
1542 UINT16 WINAPI
waveInOpen16(HWAVEIN16
* lphWaveIn
, UINT16 uDeviceID
,
1543 LPCWAVEFORMATEX lpFormat
, DWORD dwCallback
,
1544 DWORD dwInstance
, DWORD dwFlags
)
1548 struct mmsystdrv_thunk
* thunk
;
1550 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, MMSYSTDRV_WAVEIN
)))
1552 return MMSYSERR_NOMEM
;
1554 if ((dwFlags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
)
1556 dwCallback
= (DWORD
)thunk
;
1558 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1559 * call the 32 bit version
1560 * however, we need to promote correctly the wave mapper id
1561 * (0xFFFFFFFF and not 0x0000FFFF)
1563 ret
= waveInOpen(&hWaveIn
, (uDeviceID
== (UINT16
)-1) ? (UINT
)-1 : uDeviceID
,
1564 lpFormat
, dwCallback
, dwInstance
, dwFlags
);
1566 if (ret
== MMSYSERR_NOERROR
)
1568 if (lphWaveIn
!= NULL
) *lphWaveIn
= HWAVEIN_16(hWaveIn
);
1569 MMSYSTDRV_SetHandle(thunk
, (void*)hWaveIn
);
1571 else MMSYSTDRV_DeleteThunk(thunk
);
1575 /**************************************************************************
1576 * waveInClose [MMSYSTEM.505]
1578 UINT16 WINAPI
waveInClose16(HWAVEIN16 hWaveIn
)
1583 ReleaseThunkLock(&level
);
1584 ret
= waveInClose(HWAVEIN_32(hWaveIn
));
1585 RestoreThunkLock(level
);
1586 if (ret
== MMSYSERR_NOERROR
)
1587 MMSYSTDRV_CloseHandle((void*)HWAVEIN_32(hWaveIn
));
1591 /**************************************************************************
1592 * waveInPrepareHeader [MMSYSTEM.506]
1594 UINT16 WINAPI
waveInPrepareHeader16(HWAVEIN16 hWaveIn
, /* [in] */
1595 SEGPTR lpsegWaveInHdr
, /* [???] */
1596 UINT16 uSize
) /* [in] */
1598 LPWAVEHDR lpWaveInHdr
= MapSL(lpsegWaveInHdr
);
1601 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
1603 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
1604 lpWaveInHdr
->dwBytesRecorded
= 0;
1606 ret
= MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_PREPARE
, lpsegWaveInHdr
, uSize
);
1610 /**************************************************************************
1611 * waveInUnprepareHeader [MMSYSTEM.507]
1613 UINT16 WINAPI
waveInUnprepareHeader16(HWAVEIN16 hWaveIn
, /* [in] */
1614 SEGPTR lpsegWaveInHdr
, /* [???] */
1615 UINT16 uSize
) /* [in] */
1617 LPWAVEHDR lpWaveInHdr
= MapSL(lpsegWaveInHdr
);
1619 TRACE("(%04X, %08x, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
1621 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
1623 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
1624 return MMSYSERR_NOERROR
;
1627 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_UNPREPARE
, lpsegWaveInHdr
, uSize
);
1630 /**************************************************************************
1631 * waveInAddBuffer [MMSYSTEM.508]
1633 UINT16 WINAPI
waveInAddBuffer16(HWAVEIN16 hWaveIn
, /* [in] */
1634 WAVEHDR
* lpsegWaveInHdr
, /* [???] NOTE: SEGPTR */
1635 UINT16 uSize
) /* [in] */
1637 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
1639 if (lpsegWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
1641 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_ADDBUFFER
, (DWORD_PTR
)lpsegWaveInHdr
, uSize
);
1644 /**************************************************************************
1645 * waveInReset [MMSYSTEM.511]
1647 UINT16 WINAPI
waveInReset16(HWAVEIN16 hWaveIn16
)
1652 ReleaseThunkLock(&level
);
1653 ret
= waveInReset(HWAVEIN_32(hWaveIn16
));
1654 RestoreThunkLock(level
);
1658 /**************************************************************************
1659 * waveInStart [MMSYSTEM.509]
1661 UINT16 WINAPI
waveInStart16(HWAVEIN16 hWaveIn16
)
1666 ReleaseThunkLock(&level
);
1667 ret
= waveInStart(HWAVEIN_32(hWaveIn16
));
1668 RestoreThunkLock(level
);
1672 /**************************************************************************
1673 * waveInStop [MMSYSTEM.510]
1675 UINT16 WINAPI
waveInStop16(HWAVEIN16 hWaveIn16
)
1680 ReleaseThunkLock(&level
);
1681 ret
= waveInStop(HWAVEIN_32(hWaveIn16
));
1682 RestoreThunkLock(level
);
1686 /**************************************************************************
1687 * waveInGetPosition [MMSYSTEM.512]
1689 UINT16 WINAPI
waveInGetPosition16(HWAVEIN16 hWaveIn
, LPMMTIME16 lpTime
,
1695 mmt
.wType
= lpTime
->wType
;
1696 ret
= waveInGetPosition(HWAVEIN_32(hWaveIn
), &mmt
, sizeof(mmt
));
1697 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
1701 /**************************************************************************
1702 * waveInGetID [MMSYSTEM.513]
1704 UINT16 WINAPI
waveInGetID16(HWAVEIN16 hWaveIn
, UINT16
* lpuDeviceID
)
1709 ret
= waveInGetID(HWAVEIN_32(hWaveIn
), &devid
);
1710 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1711 *lpuDeviceID
= devid
;
1715 /**************************************************************************
1716 * waveInMessage [MMSYSTEM.514]
1718 DWORD WINAPI
waveInMessage16(HWAVEIN16 hWaveIn
, UINT16 uMessage
,
1719 DWORD dwParam1
, DWORD dwParam2
)
1721 TRACE("(%04x, %u, %d, %d)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
1723 if ((DWORD_PTR
)hWaveIn
< waveInGetNumDevs())
1725 if (uMessage
== DRV_QUERYDRVENTRY
|| uMessage
== DRV_QUERYDEVNODE
)
1726 dwParam1
= (DWORD
)MapSL(dwParam1
);
1728 else if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
1730 return MMSYSERR_INVALPARAM
;
1732 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), uMessage
, dwParam1
, dwParam2
);
1735 /* ###################################################
1737 * ###################################################
1740 /*#define USE_MM_TSK_WINE*/
1742 /**************************************************************************
1743 * mmTaskCreate [MMSYSTEM.900]
1745 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
1746 * called upon creation with dwPmt as parameter.
1748 HINSTANCE16 WINAPI
mmTaskCreate16(SEGPTR spProc
, HINSTANCE16
*lphMmTask
, DWORD dwPmt
)
1753 DWORD showCmd
= 0x40002;
1756 TRACE("(%08x, %p, %08x);\n", spProc
, lphMmTask
, dwPmt
);
1757 /* This to work requires NE modules to be started with a binary command line
1758 * which is not currently the case. A patch exists but has never been committed.
1759 * A workaround would be to integrate code for mmtask.tsk into Wine, but
1760 * this requires tremendous work (starting with patching tools/build to
1761 * create NE executables (and not only DLLs) for builtins modules.
1764 FIXME("This is currently broken. It will fail\n");
1767 *(LPDWORD
)(cmdline
+ 1) = (DWORD
)spProc
;
1768 *(LPDWORD
)(cmdline
+ 5) = dwPmt
;
1769 *(LPDWORD
)(cmdline
+ 9) = 0;
1771 lp
.hEnvironment
= 0;
1772 lp
.cmdLine
= MapLS(cmdline
);
1773 lp
.showCmd
= MapLS(&showCmd
);
1776 #ifndef USE_MM_TSK_WINE
1777 handle
= LoadModule16("c:\\windows\\system\\mmtask.tsk", &lp
);
1779 handle
= LoadModule16("mmtask.tsk", &lp
);
1782 ret
= (handle
) ? 1 : 2;
1788 *lphMmTask
= handle
;
1790 UnMapLS( lp
.cmdLine
);
1791 UnMapLS( lp
.showCmd
);
1792 TRACE("=> 0x%04x/%d\n", handle
, ret
);
1796 #ifdef USE_MM_TSK_WINE
1797 /* C equivalent to mmtask.tsk binary content */
1798 void mmTaskEntryPoint16(LPSTR cmdLine
, WORD di
, WORD si
)
1800 int len
= cmdLine
[0x80];
1803 void (*fpProc
)(DWORD
) = MapSL(*((DWORD
*)(cmdLine
+ 1)));
1804 DWORD dwPmt
= *((DWORD
*)(cmdLine
+ 5));
1807 InitTask16(); /* FIXME: pmts / from context ? */
1810 if (SetMessageQueue16(0x40)) {
1812 if (HIWORD(fpProc
)) {
1814 /* EPP StackEnter16(); */
1826 /**************************************************************************
1827 * mmTaskBlock [MMSYSTEM.902]
1829 void WINAPI
mmTaskBlock16(HINSTANCE16 hInst
)
1834 GetMessageA(&msg
, 0, 0, 0);
1836 TranslateMessage(&msg
);
1837 DispatchMessageA(&msg
);
1839 } while (msg
.message
< 0x3A0);
1842 /**************************************************************************
1843 * mmTaskSignal [MMSYSTEM.903]
1845 LRESULT WINAPI
mmTaskSignal16(HTASK16 ht
)
1847 TRACE("(%04x);\n", ht
);
1848 return PostThreadMessageW( HTASK_32(ht
), WM_USER
, 0, 0 );
1851 /**************************************************************************
1852 * mmGetCurrentTask [MMSYSTEM.904]
1854 HTASK16 WINAPI
mmGetCurrentTask16(void)
1856 return GetCurrentTask();
1859 /**************************************************************************
1860 * mmTaskYield [MMSYSTEM.905]
1862 void WINAPI
mmTaskYield16(void)
1866 if (PeekMessageA(&msg
, 0, 0, 0, 0)) {
1871 /******************************************************************
1876 static WINE_MMTHREAD
* WINMM_GetmmThread(HANDLE16 h
)
1878 return MapSL(MAKESEGPTR(h
, 0));
1881 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD
* lpMMThd
)
1886 if (lpMMThd
->dwThreadID
!= GetCurrentThreadId())
1887 ERR("Not called by thread itself\n");
1890 ResetEvent(lpMMThd
->hEvent
);
1891 if (InterlockedDecrement(&lpMMThd
->dwSignalCount
) >= 0)
1893 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
1897 ret
= MsgWaitForMultipleObjects(1, &lpMMThd
->hEvent
, FALSE
, INFINITE
, QS_ALLINPUT
);
1899 case WAIT_OBJECT_0
: /* Event */
1902 case WAIT_OBJECT_0
+ 1: /* Msg */
1904 if (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
1905 TranslateMessage(&msg
);
1906 DispatchMessageA(&msg
);
1910 WARN("S2.x unsupported ret val 0x%08x\n", ret
);
1916 /**************************************************************************
1917 * mmThreadBlock [MMSYSTEM.1122]
1919 void WINAPI
mmThreadBlock16(HANDLE16 hndl
)
1921 TRACE("(%04x)!\n", hndl
);
1924 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
1926 if (lpMMThd
->hThread
!= 0) {
1929 ReleaseThunkLock(&lc
);
1930 MMSYSTEM_ThreadBlock(lpMMThd
);
1931 RestoreThunkLock(lc
);
1933 mmTaskBlock16(lpMMThd
->hTask
);
1939 /**************************************************************************
1940 * __wine_mmThreadEntryPoint (MMSYSTEM.2047)
1942 DWORD WINAPI
WINE_mmThreadEntryPoint(LPVOID p
)
1944 HANDLE16 hndl
= (HANDLE16
)(DWORD_PTR
)p
;
1945 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
1947 TRACE("(%04x %p)\n", hndl
, lpMMThd
);
1949 lpMMThd
->hTask
= LOWORD(GetCurrentTask());
1950 TRACE("[10-%p] setting hTask to 0x%08x\n", lpMMThd
->hThread
, lpMMThd
->hTask
);
1951 lpMMThd
->dwStatus
= 0x10;
1952 MMSYSTEM_ThreadBlock(lpMMThd
);
1953 TRACE("[20-%p]\n", lpMMThd
->hThread
);
1954 lpMMThd
->dwStatus
= 0x20;
1955 if (lpMMThd
->fpThread
) {
1956 WOWCallback16(lpMMThd
->fpThread
, lpMMThd
->dwThreadPmt
);
1958 lpMMThd
->dwStatus
= 0x30;
1959 TRACE("[30-%p]\n", lpMMThd
->hThread
);
1960 while (lpMMThd
->dwCounter
) {
1964 TRACE("[XX-%p]\n", lpMMThd
->hThread
);
1966 lpMMThd
->dwSignature
= WINE_MMTHREAD_DELETED
;
1967 /* close lpMMThread->hVxD directIO */
1968 if (lpMMThd
->hEvent
)
1969 CloseHandle(lpMMThd
->hEvent
);
1976 extern DWORD WINAPI
GetProcessFlags(DWORD
);
1978 /**************************************************************************
1979 * mmThreadCreate [MMSYSTEM.1120]
1982 * Creates a MM thread, calling fpThreadAddr(dwPmt).
1984 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
1985 * bit.1 set means to open a VxD for this thread (unsupported)
1987 LRESULT WINAPI
mmThreadCreate16(FARPROC16 fpThreadAddr
, LPHANDLE16 lpHndl
, DWORD dwPmt
, DWORD dwFlags
)
1992 TRACE("(%p, %p, %08x, %08x)!\n", fpThreadAddr
, lpHndl
, dwPmt
, dwFlags
);
1994 hndl
= GlobalAlloc16(sizeof(WINE_MMTHREAD
), GMEM_SHARE
|GMEM_ZEROINIT
);
1999 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2002 /* force mmtask routines even if mmthread is required */
2003 /* this will work only if the patch about binary cmd line and NE tasks
2009 lpMMThd
->dwSignature
= WINE_MMTHREAD_CREATED
;
2010 lpMMThd
->dwCounter
= 0;
2011 lpMMThd
->hThread
= 0;
2012 lpMMThd
->dwThreadID
= 0;
2013 lpMMThd
->fpThread
= (DWORD
)fpThreadAddr
;
2014 lpMMThd
->dwThreadPmt
= dwPmt
;
2015 lpMMThd
->dwSignalCount
= 0;
2016 lpMMThd
->hEvent
= 0;
2018 lpMMThd
->dwStatus
= 0;
2019 lpMMThd
->dwFlags
= dwFlags
;
2022 if ((dwFlags
& 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
2023 lpMMThd
->hEvent
= CreateEventW(NULL
, FALSE
, TRUE
, NULL
);
2025 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd
);
2026 if (lpMMThd
->dwFlags
& 2) {
2027 /* as long as we don't support MM VxD in wine, we don't need
2028 * to care about this flag
2030 /* FIXME("Don't know how to properly open VxD handles\n"); */
2031 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
2034 lpMMThd
->hThread
= CreateThread(0, 0, WINE_mmThreadEntryPoint
,
2035 (LPVOID
)(DWORD_PTR
)hndl
, CREATE_SUSPENDED
, &lpMMThd
->dwThreadID
);
2036 if (lpMMThd
->hThread
== 0) {
2037 WARN("Couldn't create thread\n");
2038 /* clean-up(VxDhandle...); devicedirectio... */
2039 if (lpMMThd
->hEvent
!= 0)
2040 CloseHandle(lpMMThd
->hEvent
);
2043 SetThreadPriority(lpMMThd
->hThread
, THREAD_PRIORITY_TIME_CRITICAL
);
2044 TRACE("Got a nice thread hndl=%p id=0x%08x\n", lpMMThd
->hThread
, lpMMThd
->dwThreadID
);
2048 /* get WINE_mmThreadEntryPoint()
2049 * 2047 is its ordinal in mmsystem.spec
2051 FARPROC16 fp
= GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (LPCSTR
)2047);
2053 TRACE("farproc seg=0x%p lin=%p\n", fp
, MapSL((SEGPTR
)fp
));
2055 ret
= (fp
== 0) ? 2 : mmTaskCreate16((DWORD
)fp
, 0, hndl
);
2059 if (lpMMThd
->hThread
&& !ResumeThread(lpMMThd
->hThread
))
2060 WARN("Couldn't resume thread\n");
2062 while (lpMMThd
->dwStatus
!= 0x10) { /* test also HIWORD of dwStatus */
2064 PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
2077 TRACE("ok => %ld\n", ret
);
2081 /**************************************************************************
2082 * mmThreadSignal [MMSYSTEM.1121]
2084 void WINAPI
mmThreadSignal16(HANDLE16 hndl
)
2086 TRACE("(%04x)!\n", hndl
);
2089 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2091 lpMMThd
->dwCounter
++;
2092 if (lpMMThd
->hThread
!= 0) {
2093 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
2094 SetEvent(lpMMThd
->hEvent
);
2096 mmTaskSignal16(lpMMThd
->hTask
);
2098 lpMMThd
->dwCounter
--;
2102 /**************************************************************************
2103 * mmThreadIsCurrent [MMSYSTEM.1123]
2105 BOOL16 WINAPI
mmThreadIsCurrent16(HANDLE16 hndl
)
2109 TRACE("(%04x)!\n", hndl
);
2111 if (hndl
&& mmThreadIsValid16(hndl
)) {
2112 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2113 ret
= (GetCurrentThreadId() == lpMMThd
->dwThreadID
);
2115 TRACE("=> %d\n", ret
);
2119 /**************************************************************************
2120 * mmThreadIsValid [MMSYSTEM.1124]
2122 BOOL16 WINAPI
mmThreadIsValid16(HANDLE16 hndl
)
2126 TRACE("(%04x)!\n", hndl
);
2129 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2131 if (!IsBadWritePtr(lpMMThd
, sizeof(WINE_MMTHREAD
)) &&
2132 lpMMThd
->dwSignature
== WINE_MMTHREAD_CREATED
&&
2133 IsTask16(lpMMThd
->hTask
)) {
2134 lpMMThd
->dwCounter
++;
2135 if (lpMMThd
->hThread
!= 0) {
2137 if (GetExitCodeThread(lpMMThd
->hThread
, &dwThreadRet
) &&
2138 dwThreadRet
== STATUS_PENDING
) {
2144 lpMMThd
->dwCounter
--;
2147 TRACE("=> %d\n", ret
);
2151 /**************************************************************************
2152 * mmThreadGetTask [MMSYSTEM.1125]
2154 HANDLE16 WINAPI
mmThreadGetTask16(HANDLE16 hndl
)
2158 TRACE("(%04x)\n", hndl
);
2160 if (mmThreadIsValid16(hndl
)) {
2161 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2162 ret
= lpMMThd
->hTask
;
2167 typedef BOOL16 (WINAPI
*MMCPLCALLBACK
)(HWND
, LPCSTR
, LPCSTR
, LPCSTR
);
2169 /**************************************************************************
2170 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
2172 BOOL16 WINAPI
mmShowMMCPLPropertySheet16(HWND hWnd
, LPCSTR lpStrDevice
,
2173 LPCSTR lpStrTab
, LPCSTR lpStrTitle
)
2178 TRACE("(%p \"%s\" \"%s\" \"%s\")\n", hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
2180 hndl
= LoadLibraryA("MMSYS.CPL");
2182 MMCPLCALLBACK fp
= (MMCPLCALLBACK
)GetProcAddress(hndl
, "ShowMMCPLPropertySheet");
2185 ReleaseThunkLock(&lc
);
2186 ret
= (fp
)(hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
2187 RestoreThunkLock(lc
);
2195 /**************************************************************************
2196 * StackEnter [MMSYSTEM.32]
2198 void WINAPI
StackEnter16(void)
2201 /* mmsystem.dll from Win 95 does only this: so does Wine */
2206 /**************************************************************************
2207 * StackLeave [MMSYSTEM.33]
2209 void WINAPI
StackLeave16(void)
2212 /* mmsystem.dll from Win 95 does only this: so does Wine */
2217 /**************************************************************************
2218 * WMMMidiRunOnce [MMSYSTEM.8]
2220 void WINAPI
WMMMidiRunOnce16(void)
2222 FIXME("(), stub!\n");
2227 /* ###################################################
2229 * ###################################################
2232 /**************************************************************************
2233 * joyGetNumDevs [MMSYSTEM.101]
2235 UINT16 WINAPI
joyGetNumDevs16(void)
2237 return joyGetNumDevs();
2240 /**************************************************************************
2241 * joyGetDevCaps [MMSYSTEM.102]
2243 MMRESULT16 WINAPI
joyGetDevCaps16(UINT16 wID
, LPJOYCAPS16 lpCaps
, UINT16 wSize
)
2248 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
2250 ret
= joyGetDevCapsA(wID
, &jca
, sizeof(jca
));
2252 if (ret
!= JOYERR_NOERROR
) return ret
;
2253 lpCaps
->wMid
= jca
.wMid
;
2254 lpCaps
->wPid
= jca
.wPid
;
2255 strcpy(lpCaps
->szPname
, jca
.szPname
);
2256 lpCaps
->wXmin
= jca
.wXmin
;
2257 lpCaps
->wXmax
= jca
.wXmax
;
2258 lpCaps
->wYmin
= jca
.wYmin
;
2259 lpCaps
->wYmax
= jca
.wYmax
;
2260 lpCaps
->wZmin
= jca
.wZmin
;
2261 lpCaps
->wZmax
= jca
.wZmax
;
2262 lpCaps
->wNumButtons
= jca
.wNumButtons
;
2263 lpCaps
->wPeriodMin
= jca
.wPeriodMin
;
2264 lpCaps
->wPeriodMax
= jca
.wPeriodMax
;
2266 if (wSize
>= sizeof(JOYCAPS16
)) { /* Win95 extensions ? */
2267 lpCaps
->wRmin
= jca
.wRmin
;
2268 lpCaps
->wRmax
= jca
.wRmax
;
2269 lpCaps
->wUmin
= jca
.wUmin
;
2270 lpCaps
->wUmax
= jca
.wUmax
;
2271 lpCaps
->wVmin
= jca
.wVmin
;
2272 lpCaps
->wVmax
= jca
.wVmax
;
2273 lpCaps
->wCaps
= jca
.wCaps
;
2274 lpCaps
->wMaxAxes
= jca
.wMaxAxes
;
2275 lpCaps
->wNumAxes
= jca
.wNumAxes
;
2276 lpCaps
->wMaxButtons
= jca
.wMaxButtons
;
2277 strcpy(lpCaps
->szRegKey
, jca
.szRegKey
);
2278 strcpy(lpCaps
->szOEMVxD
, jca
.szOEMVxD
);
2284 /**************************************************************************
2285 * joyGetPosEx [MMSYSTEM.110]
2287 MMRESULT16 WINAPI
joyGetPosEx16(UINT16 wID
, LPJOYINFOEX lpInfo
)
2289 return joyGetPosEx(wID
, lpInfo
);
2292 /**************************************************************************
2293 * joyGetPos [MMSYSTEM.103]
2295 MMRESULT16 WINAPI
joyGetPos16(UINT16 wID
, LPJOYINFO16 lpInfo
)
2300 TRACE("(%d, %p);\n", wID
, lpInfo
);
2302 if ((ret
= joyGetPos(wID
, &ji
)) == JOYERR_NOERROR
) {
2303 lpInfo
->wXpos
= ji
.wXpos
;
2304 lpInfo
->wYpos
= ji
.wYpos
;
2305 lpInfo
->wZpos
= ji
.wZpos
;
2306 lpInfo
->wButtons
= ji
.wButtons
;
2311 /**************************************************************************
2312 * joyGetThreshold [MMSYSTEM.104]
2314 MMRESULT16 WINAPI
joyGetThreshold16(UINT16 wID
, LPUINT16 lpThreshold
)
2319 ret
= joyGetThreshold(wID
, &t
);
2320 if (ret
== JOYERR_NOERROR
)
2325 /**************************************************************************
2326 * joyReleaseCapture [MMSYSTEM.105]
2328 MMRESULT16 WINAPI
joyReleaseCapture16(UINT16 wID
)
2330 return joyReleaseCapture(wID
);
2333 /**************************************************************************
2334 * joySetCapture [MMSYSTEM.106]
2336 MMRESULT16 WINAPI
joySetCapture16(HWND16 hWnd
, UINT16 wID
, UINT16 wPeriod
, BOOL16 bChanged
)
2338 return joySetCapture(HWND_32(hWnd
), wID
, wPeriod
, bChanged
);
2341 /**************************************************************************
2342 * joySetThreshold [MMSYSTEM.107]
2344 MMRESULT16 WINAPI
joySetThreshold16(UINT16 wID
, UINT16 wThreshold
)
2346 return joySetThreshold(wID
,wThreshold
);
2349 /**************************************************************************
2350 * joySetCalibration [MMSYSTEM.109]
2352 MMRESULT16 WINAPI
joySetCalibration16(UINT16 wID
)
2354 FIXME("(%04X): stub.\n", wID
);
2355 return JOYERR_NOCANDO
;