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
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
, HINSTANCE16 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 * timeGetSystemTime [MMSYSTEM.601]
110 MMRESULT16 WINAPI
timeGetSystemTime16(LPMMTIME16 lpTime
, UINT16 wSize
)
112 if (wSize
>= sizeof(*lpTime
)) {
113 lpTime
->wType
= TIME_MS
;
114 lpTime
->u
.ms
= GetTickCount();
116 TRACE("=> %lu\n", lpTime
->u
.ms
);
125 LPTIMECALLBACK16 func16
;
129 static struct list timer_list
= LIST_INIT(timer_list
);
131 static void CALLBACK
timeCB3216(UINT id
, UINT uMsg
, DWORD_PTR user
, DWORD_PTR dw1
, DWORD_PTR dw2
)
133 struct timer_entry
* te
= (void*)user
;
137 args
[7] = LOWORD(id
);
138 args
[6] = LOWORD(uMsg
);
139 args
[5] = HIWORD(te
->user
);
140 args
[4] = LOWORD(te
->user
);
141 args
[3] = HIWORD(dw1
);
142 args
[2] = LOWORD(dw2
);
143 args
[1] = HIWORD(dw2
);
144 args
[0] = LOWORD(dw2
);
145 WOWCallback16Ex((DWORD
)te
->func16
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
148 /**************************************************************************
149 * timeSetEvent [MMSYSTEM.602]
151 MMRESULT16 WINAPI
timeSetEvent16(UINT16 wDelay
, UINT16 wResol
, LPTIMECALLBACK16 lpFunc
,
152 DWORD dwUser
, UINT16 wFlags
)
155 struct timer_entry
* te
;
157 switch (wFlags
& (TIME_CALLBACK_EVENT_SET
|TIME_CALLBACK_EVENT_PULSE
))
159 case TIME_CALLBACK_EVENT_SET
:
160 case TIME_CALLBACK_EVENT_PULSE
:
161 id
= timeSetEvent(wDelay
, wResol
, (LPTIMECALLBACK
)lpFunc
, dwUser
, wFlags
);
163 case TIME_CALLBACK_FUNCTION
:
164 te
= HeapAlloc(GetProcessHeap(), 0, sizeof(*te
));
168 id
= te
->id
= timeSetEvent(wDelay
, wResol
, timeCB3216
, (DWORD_PTR
)te
, wFlags
);
171 EnterCriticalSection(&mmdrv_cs
);
172 list_add_tail(&timer_list
, &te
->entry
);
173 LeaveCriticalSection(&mmdrv_cs
);
175 else HeapFree(GetProcessHeap(), 0, te
);
184 /**************************************************************************
185 * timeKillEvent [MMSYSTEM.603]
187 MMRESULT16 WINAPI
timeKillEvent16(UINT16 wID
)
189 MMRESULT16 ret
= timeKillEvent(wID
);
190 struct timer_entry
* te
;
192 if (ret
== TIMERR_NOERROR
)
194 EnterCriticalSection(&mmdrv_cs
);
195 LIST_FOR_EACH_ENTRY(te
, &timer_list
, struct timer_entry
, entry
)
199 list_remove(&te
->entry
);
200 HeapFree(GetProcessHeap(), 0, te
);
204 LeaveCriticalSection(&mmdrv_cs
);
209 /**************************************************************************
210 * timeGetDevCaps [MMSYSTEM.604]
212 MMRESULT16 WINAPI
timeGetDevCaps16(LPTIMECAPS16 lpCaps
, UINT16 wSize
)
216 TRACE("(%p, %u) !\n", lpCaps
, wSize
);
218 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
220 ret
= timeGetDevCaps(&caps
, sizeof(caps
));
221 if (ret
== MMSYSERR_NOERROR
) {
223 tc16
.wPeriodMin
= caps
.wPeriodMin
;
224 tc16
.wPeriodMax
= caps
.wPeriodMax
;
225 memcpy(lpCaps
, &tc16
, min(wSize
, sizeof(tc16
)));
230 /**************************************************************************
231 * timeBeginPeriod [MMSYSTEM.605]
233 MMRESULT16 WINAPI
timeBeginPeriod16(UINT16 wPeriod
)
235 TRACE("(%u) !\n", wPeriod
);
237 return timeBeginPeriod(wPeriod
);
240 /**************************************************************************
241 * timeEndPeriod [MMSYSTEM.606]
243 MMRESULT16 WINAPI
timeEndPeriod16(UINT16 wPeriod
)
245 TRACE("(%u) !\n", wPeriod
);
247 return timeEndPeriod(wPeriod
);
250 /**************************************************************************
251 * timeGetTime [MMSYSTEM.607]
253 DWORD WINAPI
timeGetTime16(void)
255 return timeGetTime();
258 /* ###################################################
260 * ###################################################
263 /**************************************************************************
264 * PlaySound [MMSYSTEM.3]
266 BOOL16 WINAPI
PlaySound16(LPCSTR pszSound
, HMODULE16 hmod
, DWORD fdwSound
)
271 if ((fdwSound
& SND_RESOURCE
) == SND_RESOURCE
)
276 if (!(res
= FindResource16( hmod
, pszSound
, "WAVE" ))) return FALSE
;
277 if (!(handle
= LoadResource16( hmod
, res
))) return FALSE
;
278 pszSound
= LockResource16(handle
);
279 fdwSound
= (fdwSound
& ~SND_RESOURCE
) | SND_MEMORY
;
280 /* FIXME: FreeResource16 */
283 ReleaseThunkLock(&lc
);
284 retv
= PlaySoundA(pszSound
, 0, fdwSound
);
285 RestoreThunkLock(lc
);
290 /**************************************************************************
291 * sndPlaySound [MMSYSTEM.2]
293 BOOL16 WINAPI
sndPlaySound16(LPCSTR lpszSoundName
, UINT16 uFlags
)
298 ReleaseThunkLock(&lc
);
299 retv
= sndPlaySoundA(lpszSoundName
, uFlags
);
300 RestoreThunkLock(lc
);
305 /* ###################################################
307 * ###################################################
310 /**************************************************************************
311 * mmsystemGetVersion [MMSYSTEM.5]
314 UINT16 WINAPI
mmsystemGetVersion16(void)
316 return mmsystemGetVersion();
319 /**************************************************************************
320 * DriverCallback [MMSYSTEM.31]
322 BOOL16 WINAPI
DriverCallback16(DWORD dwCallBack
, UINT16 uFlags
, HDRVR16 hDev
,
323 WORD wMsg
, DWORD dwUser
, DWORD dwParam1
,
326 return DriverCallback(dwCallBack
, uFlags
, HDRVR_32(hDev
), wMsg
, dwUser
, dwParam1
, dwParam2
);
329 /**************************************************************************
330 * OutputDebugStr [MMSYSTEM.30]
332 void WINAPI
OutputDebugStr16(LPCSTR str
)
334 OutputDebugStringA( str
);
337 /* ###################################################
339 * ###################################################
342 /**************************************************************************
343 * Mixer devices. New to Win95
346 /**************************************************************************
347 * mixerGetNumDevs [MMSYSTEM.800]
349 UINT16 WINAPI
mixerGetNumDevs16(void)
351 return mixerGetNumDevs();
354 /**************************************************************************
355 * mixerGetDevCaps [MMSYSTEM.801]
357 UINT16 WINAPI
mixerGetDevCaps16(UINT16 uDeviceID
, LPMIXERCAPS16 lpCaps
,
363 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
365 ret
= mixerGetDevCapsA(uDeviceID
, &micA
, sizeof(micA
));
366 if (ret
== MMSYSERR_NOERROR
) {
368 mic16
.wMid
= micA
.wMid
;
369 mic16
.wPid
= micA
.wPid
;
370 mic16
.vDriverVersion
= micA
.vDriverVersion
;
371 strcpy(mic16
.szPname
, micA
.szPname
);
372 mic16
.fdwSupport
= micA
.fdwSupport
;
373 mic16
.cDestinations
= micA
.cDestinations
;
374 memcpy(lpCaps
, &mic16
, min(uSize
, sizeof(mic16
)));
379 /**************************************************************************
380 * mixerOpen [MMSYSTEM.802]
382 UINT16 WINAPI
mixerOpen16(LPHMIXER16 lphmix
, UINT16 uDeviceID
, DWORD dwCallback
,
383 DWORD dwInstance
, DWORD fdwOpen
)
387 struct mmsystdrv_thunk
* thunk
;
389 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, fdwOpen
, MMSYSTDRV_MIXER
)))
391 return MMSYSERR_NOMEM
;
393 if ((fdwOpen
& CALLBACK_TYPEMASK
) != CALLBACK_NULL
)
394 fdwOpen
= (fdwOpen
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
395 ret
= mixerOpen(&hmix
, uDeviceID
, (DWORD
)thunk
, dwInstance
, fdwOpen
);
396 if (ret
== MMSYSERR_NOERROR
)
398 if (lphmix
) *lphmix
= HMIXER_16(hmix
);
399 if (thunk
) MMSYSTDRV_SetHandle(thunk
, hmix
);
401 else MMSYSTDRV_DeleteThunk(thunk
);
405 /**************************************************************************
406 * mixerClose [MMSYSTEM.803]
408 UINT16 WINAPI
mixerClose16(HMIXER16 hMix
)
410 UINT ret
= mixerClose(HMIXER_32(hMix
));
412 if (ret
== MMSYSERR_NOERROR
)
413 MMSYSTDRV_CloseHandle((void*)HMIXER_32(hMix
));
417 /**************************************************************************
418 * mixerGetID (MMSYSTEM.806)
420 UINT16 WINAPI
mixerGetID16(HMIXEROBJ16 hmix
, LPUINT16 lpid
, DWORD fdwID
)
423 UINT ret
= mixerGetID(HMIXEROBJ_32(hmix
), &xid
, fdwID
);
430 /**************************************************************************
431 * mixerGetControlDetails [MMSYSTEM.808]
433 UINT16 WINAPI
mixerGetControlDetails16(HMIXEROBJ16 hmix
,
434 LPMIXERCONTROLDETAILS16 lpmcd
,
437 DWORD ret
= MMSYSERR_NOTENABLED
;
440 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
442 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
443 return MMSYSERR_INVALPARAM
;
445 sppaDetails
= (SEGPTR
)lpmcd
->paDetails
;
446 lpmcd
->paDetails
= MapSL(sppaDetails
);
447 ret
= mixerGetControlDetailsA(HMIXEROBJ_32(hmix
),
448 (LPMIXERCONTROLDETAILS
)lpmcd
, fdwDetails
);
449 lpmcd
->paDetails
= (LPVOID
)sppaDetails
;
454 /**************************************************************************
455 * mixerGetLineControls [MMSYSTEM.807]
457 UINT16 WINAPI
mixerGetLineControls16(HMIXEROBJ16 hmix
,
458 LPMIXERLINECONTROLS16 lpmlc16
,
461 MIXERLINECONTROLSA mlcA
;
464 LPMIXERCONTROL16 lpmc16
;
466 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlc16
, fdwControls
);
468 if (lpmlc16
== NULL
|| lpmlc16
->cbStruct
!= sizeof(*lpmlc16
) ||
469 lpmlc16
->cbmxctrl
!= sizeof(MIXERCONTROL16
))
470 return MMSYSERR_INVALPARAM
;
472 mlcA
.cbStruct
= sizeof(mlcA
);
473 mlcA
.dwLineID
= lpmlc16
->dwLineID
;
474 mlcA
.u
.dwControlID
= lpmlc16
->u
.dwControlID
;
475 mlcA
.u
.dwControlType
= lpmlc16
->u
.dwControlType
;
476 mlcA
.cControls
= lpmlc16
->cControls
;
477 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
478 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0,
479 mlcA
.cControls
* mlcA
.cbmxctrl
);
481 ret
= mixerGetLineControlsA(HMIXEROBJ_32(hmix
), &mlcA
, fdwControls
);
483 if (ret
== MMSYSERR_NOERROR
) {
484 lpmlc16
->dwLineID
= mlcA
.dwLineID
;
485 lpmlc16
->u
.dwControlID
= mlcA
.u
.dwControlID
;
486 lpmlc16
->u
.dwControlType
= mlcA
.u
.dwControlType
;
487 lpmlc16
->cControls
= mlcA
.cControls
;
489 lpmc16
= MapSL(lpmlc16
->pamxctrl
);
491 for (i
= 0; i
< mlcA
.cControls
; i
++) {
492 lpmc16
[i
].cbStruct
= sizeof(MIXERCONTROL16
);
493 lpmc16
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
494 lpmc16
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
495 lpmc16
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
496 lpmc16
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
497 strcpy(lpmc16
[i
].szShortName
, mlcA
.pamxctrl
[i
].szShortName
);
498 strcpy(lpmc16
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
499 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
500 memcpy(&lpmc16
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
,
501 sizeof(mlcA
.pamxctrl
[i
].Bounds
));
502 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
503 memcpy(&lpmc16
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
,
504 sizeof(mlcA
.pamxctrl
[i
].Metrics
));
508 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
513 /**************************************************************************
514 * mixerGetLineInfo [MMSYSTEM.805]
516 UINT16 WINAPI
mixerGetLineInfo16(HMIXEROBJ16 hmix
, LPMIXERLINE16 lpmli16
,
522 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmli16
, fdwInfo
);
524 if (lpmli16
== NULL
|| lpmli16
->cbStruct
!= sizeof(*lpmli16
))
525 return MMSYSERR_INVALPARAM
;
527 mliA
.cbStruct
= sizeof(mliA
);
528 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
529 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
530 mliA
.dwComponentType
= lpmli16
->dwComponentType
;
532 case MIXER_GETLINEINFOF_DESTINATION
:
533 mliA
.dwDestination
= lpmli16
->dwDestination
;
535 case MIXER_GETLINEINFOF_LINEID
:
536 mliA
.dwLineID
= lpmli16
->dwLineID
;
538 case MIXER_GETLINEINFOF_SOURCE
:
539 mliA
.dwDestination
= lpmli16
->dwDestination
;
540 mliA
.dwSource
= lpmli16
->dwSource
;
542 case MIXER_GETLINEINFOF_TARGETTYPE
:
543 mliA
.Target
.dwType
= lpmli16
->Target
.dwType
;
544 mliA
.Target
.wMid
= lpmli16
->Target
.wMid
;
545 mliA
.Target
.wPid
= lpmli16
->Target
.wPid
;
546 mliA
.Target
.vDriverVersion
= lpmli16
->Target
.vDriverVersion
;
547 strcpy(mliA
.Target
.szPname
, lpmli16
->Target
.szPname
);
550 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo
);
553 ret
= mixerGetLineInfoA(HMIXEROBJ_32(hmix
), &mliA
, fdwInfo
);
555 lpmli16
->dwDestination
= mliA
.dwDestination
;
556 lpmli16
->dwSource
= mliA
.dwSource
;
557 lpmli16
->dwLineID
= mliA
.dwLineID
;
558 lpmli16
->fdwLine
= mliA
.fdwLine
;
559 lpmli16
->dwUser
= mliA
.dwUser
;
560 lpmli16
->dwComponentType
= mliA
.dwComponentType
;
561 lpmli16
->cChannels
= mliA
.cChannels
;
562 lpmli16
->cConnections
= mliA
.cConnections
;
563 lpmli16
->cControls
= mliA
.cControls
;
564 strcpy(lpmli16
->szShortName
, mliA
.szShortName
);
565 strcpy(lpmli16
->szName
, mliA
.szName
);
566 lpmli16
->Target
.dwType
= mliA
.Target
.dwType
;
567 lpmli16
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
568 lpmli16
->Target
.wMid
= mliA
.Target
.wMid
;
569 lpmli16
->Target
.wPid
= mliA
.Target
.wPid
;
570 lpmli16
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
571 strcpy(lpmli16
->Target
.szPname
, mliA
.Target
.szPname
);
576 /**************************************************************************
577 * mixerSetControlDetails [MMSYSTEM.809]
579 UINT16 WINAPI
mixerSetControlDetails16(HMIXEROBJ16 hmix
,
580 LPMIXERCONTROLDETAILS16 lpmcd
,
583 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
584 return MMSYSERR_NOTENABLED
;
587 /**************************************************************************
588 * mixerMessage [MMSYSTEM.804]
590 DWORD WINAPI
mixerMessage16(HMIXER16 hmix
, UINT16 uMsg
, DWORD dwParam1
,
593 return mixerMessage(HMIXER_32(hmix
), uMsg
, dwParam1
, dwParam2
);
596 /* ###################################################
598 * ###################################################
601 /**************************************************************************
602 * auxGetNumDevs [MMSYSTEM.350]
604 UINT16 WINAPI
auxGetNumDevs16(void)
606 return auxGetNumDevs();
609 /**************************************************************************
610 * auxGetDevCaps [MMSYSTEM.351]
612 UINT16 WINAPI
auxGetDevCaps16(UINT16 uDeviceID
, LPAUXCAPS16 lpCaps
, UINT16 uSize
)
617 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
619 ret
= auxGetDevCapsA(uDeviceID
, &acA
, sizeof(acA
));
620 if (ret
== MMSYSERR_NOERROR
) {
622 ac16
.wMid
= acA
.wMid
;
623 ac16
.wPid
= acA
.wPid
;
624 ac16
.vDriverVersion
= acA
.vDriverVersion
;
625 strcpy(ac16
.szPname
, acA
.szPname
);
626 ac16
.wTechnology
= acA
.wTechnology
;
627 ac16
.dwSupport
= acA
.dwSupport
;
628 memcpy(lpCaps
, &ac16
, min(uSize
, sizeof(ac16
)));
633 /**************************************************************************
634 * auxGetVolume [MMSYSTEM.352]
636 UINT16 WINAPI
auxGetVolume16(UINT16 uDeviceID
, LPDWORD lpdwVolume
)
638 return auxGetVolume(uDeviceID
, lpdwVolume
);
641 /**************************************************************************
642 * auxSetVolume [MMSYSTEM.353]
644 UINT16 WINAPI
auxSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
646 return auxSetVolume(uDeviceID
, dwVolume
);
649 /**************************************************************************
650 * auxOutMessage [MMSYSTEM.354]
652 DWORD WINAPI
auxOutMessage16(UINT16 uDeviceID
, UINT16 uMessage
, DWORD dw1
, DWORD dw2
)
654 TRACE("(%04X, %04X, %08lX, %08lX)\n", uDeviceID
, uMessage
, dw1
, dw2
);
657 case AUXDM_GETNUMDEVS
:
658 case AUXDM_SETVOLUME
:
659 /* no argument conversion needed */
661 case AUXDM_GETVOLUME
:
662 return auxGetVolume(uDeviceID
, MapSL(dw1
));
663 case AUXDM_GETDEVCAPS
:
664 return auxGetDevCaps16(uDeviceID
, MapSL(dw1
), dw2
);
666 TRACE("(%04x, %04x, %08lx, %08lx): unhandled message\n",
667 uDeviceID
, uMessage
, dw1
, dw2
);
670 return auxOutMessage(uDeviceID
, uMessage
, dw1
, dw2
);
673 /* ###################################################
675 * ###################################################
678 /**************************************************************************
679 * midiOutGetNumDevs [MMSYSTEM.201]
681 UINT16 WINAPI
midiOutGetNumDevs16(void)
683 return midiOutGetNumDevs();
686 /**************************************************************************
687 * midiOutGetDevCaps [MMSYSTEM.202]
689 UINT16 WINAPI
midiOutGetDevCaps16(UINT16 uDeviceID
, LPMIDIOUTCAPS16 lpCaps
,
695 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
697 ret
= midiOutGetDevCapsA(uDeviceID
, &mocA
, sizeof(mocA
));
698 if (ret
== MMSYSERR_NOERROR
) {
700 moc16
.wMid
= mocA
.wMid
;
701 moc16
.wPid
= mocA
.wPid
;
702 moc16
.vDriverVersion
= mocA
.vDriverVersion
;
703 strcpy(moc16
.szPname
, mocA
.szPname
);
704 moc16
.wTechnology
= mocA
.wTechnology
;
705 moc16
.wVoices
= mocA
.wVoices
;
706 moc16
.wNotes
= mocA
.wNotes
;
707 moc16
.wChannelMask
= mocA
.wChannelMask
;
708 moc16
.dwSupport
= mocA
.dwSupport
;
709 memcpy(lpCaps
, &moc16
, min(uSize
, sizeof(moc16
)));
714 /**************************************************************************
715 * midiOutGetErrorText [MMSYSTEM.203]
716 * midiInGetErrorText [MMSYSTEM.303]
718 UINT16 WINAPI
midiOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
720 return midiOutGetErrorTextA(uError
, lpText
, uSize
);
723 /**************************************************************************
724 * midiOutOpen [MMSYSTEM.204]
726 UINT16 WINAPI
midiOutOpen16(HMIDIOUT16
* lphMidiOut
, UINT16 uDeviceID
,
727 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
731 struct mmsystdrv_thunk
* thunk
;
733 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, dwFlags
, MMSYSTDRV_MIDIOUT
)))
735 return MMSYSERR_NOMEM
;
737 dwFlags
= (dwFlags
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
738 ret
= midiOutOpen(&hmo
, uDeviceID
, (DWORD
)thunk
, dwInstance
, dwFlags
);
739 if (ret
== MMSYSERR_NOERROR
)
741 if (lphMidiOut
!= NULL
) *lphMidiOut
= HMIDIOUT_16(hmo
);
742 MMSYSTDRV_SetHandle(thunk
, (void*)hmo
);
744 else MMSYSTDRV_DeleteThunk(thunk
);
748 /**************************************************************************
749 * midiOutClose [MMSYSTEM.205]
751 UINT16 WINAPI
midiOutClose16(HMIDIOUT16 hMidiOut
)
753 UINT ret
= midiOutClose(HMIDIOUT_32(hMidiOut
));
755 if (ret
== MMSYSERR_NOERROR
)
756 MMSYSTDRV_CloseHandle((void*)HMIDIOUT_32(hMidiOut
));
760 /**************************************************************************
761 * midiOutPrepareHeader [MMSYSTEM.206]
763 UINT16 WINAPI
midiOutPrepareHeader16(HMIDIOUT16 hMidiOut
, /* [in] */
764 SEGPTR lpsegMidiOutHdr
, /* [???] */
765 UINT16 uSize
) /* [in] */
767 TRACE("(%04X, %08lx, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
769 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_PREPARE
, lpsegMidiOutHdr
, uSize
);
772 /**************************************************************************
773 * midiOutUnprepareHeader [MMSYSTEM.207]
775 UINT16 WINAPI
midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut
, /* [in] */
776 SEGPTR lpsegMidiOutHdr
, /* [???] */
777 UINT16 uSize
) /* [in] */
779 LPMIDIHDR16 lpMidiOutHdr
= MapSL(lpsegMidiOutHdr
);
781 TRACE("(%04X, %08lx, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
783 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
784 return MMSYSERR_NOERROR
;
787 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_UNPREPARE
, lpsegMidiOutHdr
, uSize
);
790 /**************************************************************************
791 * midiOutShortMsg [MMSYSTEM.208]
793 UINT16 WINAPI
midiOutShortMsg16(HMIDIOUT16 hMidiOut
, DWORD dwMsg
)
795 return midiOutShortMsg(HMIDIOUT_32(hMidiOut
), dwMsg
);
798 /**************************************************************************
799 * midiOutLongMsg [MMSYSTEM.209]
801 UINT16 WINAPI
midiOutLongMsg16(HMIDIOUT16 hMidiOut
, /* [in] */
802 SEGPTR lpsegMidiOutHdr
, /* [???] */
803 UINT16 uSize
) /* [in] */
805 TRACE("(%04X, %08lx, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
807 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), MODM_LONGDATA
, lpsegMidiOutHdr
, uSize
);
810 /**************************************************************************
811 * midiOutReset [MMSYSTEM.210]
813 UINT16 WINAPI
midiOutReset16(HMIDIOUT16 hMidiOut
)
815 return midiOutReset(HMIDIOUT_32(hMidiOut
));
818 /**************************************************************************
819 * midiOutGetVolume [MMSYSTEM.211]
821 UINT16 WINAPI
midiOutGetVolume16(UINT16 uDeviceID
, DWORD
* lpdwVolume
)
823 return midiOutGetVolume(HMIDIOUT_32(uDeviceID
), lpdwVolume
);
826 /**************************************************************************
827 * midiOutSetVolume [MMSYSTEM.212]
829 UINT16 WINAPI
midiOutSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
831 return midiOutSetVolume(HMIDIOUT_32(uDeviceID
), dwVolume
);
834 /**************************************************************************
835 * midiOutCachePatches [MMSYSTEM.213]
837 UINT16 WINAPI
midiOutCachePatches16(HMIDIOUT16 hMidiOut
, UINT16 uBank
,
838 WORD
* lpwPatchArray
, UINT16 uFlags
)
840 return midiOutCachePatches(HMIDIOUT_32(hMidiOut
), uBank
, lpwPatchArray
,
844 /**************************************************************************
845 * midiOutCacheDrumPatches [MMSYSTEM.214]
847 UINT16 WINAPI
midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut
, UINT16 uPatch
,
848 WORD
* lpwKeyArray
, UINT16 uFlags
)
850 return midiOutCacheDrumPatches(HMIDIOUT_32(hMidiOut
), uPatch
, lpwKeyArray
, uFlags
);
853 /**************************************************************************
854 * midiOutGetID [MMSYSTEM.215]
856 UINT16 WINAPI
midiOutGetID16(HMIDIOUT16 hMidiOut
, UINT16
* lpuDeviceID
)
861 ret
= midiOutGetID(HMIDIOUT_32(hMidiOut
), &devid
);
862 if (ret
!= MMSYSERR_NOERROR
) return ret
;
863 *lpuDeviceID
= devid
;
867 /**************************************************************************
868 * midiOutMessage [MMSYSTEM.216]
870 DWORD WINAPI
midiOutMessage16(HMIDIOUT16 hMidiOut
, UINT16 uMessage
,
871 DWORD dwParam1
, DWORD dwParam2
)
873 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
878 FIXME("can't handle OPEN or CLOSE message!\n");
879 return MMSYSERR_NOTSUPPORTED
;
882 return midiOutGetVolume16(hMidiOut
, MapSL(dwParam1
));
883 /* lpMidiOutHdr is still a segmented pointer for these functions */
885 return midiOutLongMsg16(hMidiOut
, dwParam1
, dwParam2
);
887 return midiOutPrepareHeader16(hMidiOut
, dwParam1
, dwParam2
);
889 return midiOutUnprepareHeader16(hMidiOut
, dwParam1
, dwParam2
);
891 return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut
), uMessage
, dwParam1
, dwParam2
);
894 /**************************************************************************
895 * midiInGetNumDevs [MMSYSTEM.301]
897 UINT16 WINAPI
midiInGetNumDevs16(void)
899 return midiInGetNumDevs();
902 /**************************************************************************
903 * midiInGetDevCaps [MMSYSTEM.302]
905 UINT16 WINAPI
midiInGetDevCaps16(UINT16 uDeviceID
, LPMIDIINCAPS16 lpCaps
,
911 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
913 ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
914 if (ret
== MMSYSERR_NOERROR
) {
916 mic16
.wMid
= micA
.wMid
;
917 mic16
.wPid
= micA
.wPid
;
918 mic16
.vDriverVersion
= micA
.vDriverVersion
;
919 strcpy(mic16
.szPname
, micA
.szPname
);
920 mic16
.dwSupport
= micA
.dwSupport
;
921 memcpy(lpCaps
, &mic16
, min(uSize
, sizeof(mic16
)));
926 /**************************************************************************
927 * midiInOpen [MMSYSTEM.304]
929 UINT16 WINAPI
midiInOpen16(HMIDIIN16
* lphMidiIn
, UINT16 uDeviceID
,
930 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
934 struct mmsystdrv_thunk
* thunk
;
936 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, dwFlags
, MMSYSTDRV_MIDIIN
)))
938 return MMSYSERR_NOMEM
;
940 dwFlags
= (dwFlags
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
941 ret
= midiInOpen(&hmid
, uDeviceID
, (DWORD
)thunk
, dwInstance
, dwFlags
);
942 if (ret
== MMSYSERR_NOERROR
)
944 if (lphMidiIn
) *lphMidiIn
= HMIDIIN_16(hmid
);
945 MMSYSTDRV_SetHandle(thunk
, (void*)hmid
);
947 else MMSYSTDRV_DeleteThunk(thunk
);
951 /**************************************************************************
952 * midiInClose [MMSYSTEM.305]
954 UINT16 WINAPI
midiInClose16(HMIDIIN16 hMidiIn
)
956 UINT ret
= midiInClose(HMIDIIN_32(hMidiIn
));
958 if (ret
== MMSYSERR_NOERROR
)
959 MMSYSTDRV_CloseHandle((void*)HMIDIIN_32(hMidiIn
));
963 /**************************************************************************
964 * midiInPrepareHeader [MMSYSTEM.306]
966 UINT16 WINAPI
midiInPrepareHeader16(HMIDIIN16 hMidiIn
, /* [in] */
967 SEGPTR lpsegMidiInHdr
, /* [???] */
968 UINT16 uSize
) /* [in] */
970 TRACE("(%04X, %08lx, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
972 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_PREPARE
, lpsegMidiInHdr
, uSize
);
975 /**************************************************************************
976 * midiInUnprepareHeader [MMSYSTEM.307]
978 UINT16 WINAPI
midiInUnprepareHeader16(HMIDIIN16 hMidiIn
, /* [in] */
979 SEGPTR lpsegMidiInHdr
, /* [???] */
980 UINT16 uSize
) /* [in] */
982 LPMIDIHDR16 lpMidiInHdr
= MapSL(lpsegMidiInHdr
);
984 TRACE("(%04X, %08lx, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
986 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
987 return MMSYSERR_NOERROR
;
990 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_UNPREPARE
, lpsegMidiInHdr
, uSize
);
993 /**************************************************************************
994 * midiInAddBuffer [MMSYSTEM.308]
996 UINT16 WINAPI
midiInAddBuffer16(HMIDIIN16 hMidiIn
, /* [in] */
997 SEGPTR lpsegMidiInHdr
, /* [???] */
998 UINT16 uSize
) /* [in] */
1000 TRACE("(%04X, %08lx, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
1002 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), MIDM_ADDBUFFER
, lpsegMidiInHdr
, uSize
);
1005 /**************************************************************************
1006 * midiInStart [MMSYSTEM.309]
1008 UINT16 WINAPI
midiInStart16(HMIDIIN16 hMidiIn
)
1010 return midiInStart(HMIDIIN_32(hMidiIn
));
1013 /**************************************************************************
1014 * midiInStop [MMSYSTEM.310]
1016 UINT16 WINAPI
midiInStop16(HMIDIIN16 hMidiIn
)
1018 return midiInStop(HMIDIIN_32(hMidiIn
));
1021 /**************************************************************************
1022 * midiInReset [MMSYSTEM.311]
1024 UINT16 WINAPI
midiInReset16(HMIDIIN16 hMidiIn
)
1026 return midiInReset(HMIDIIN_32(hMidiIn
));
1029 /**************************************************************************
1030 * midiInGetID [MMSYSTEM.312]
1032 UINT16 WINAPI
midiInGetID16(HMIDIIN16 hMidiIn
, UINT16
* lpuDeviceID
)
1037 ret
= midiInGetID(HMIDIIN_32(hMidiIn
), &devid
);
1038 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1039 *lpuDeviceID
= devid
;
1043 /**************************************************************************
1044 * midiInMessage [MMSYSTEM.313]
1046 DWORD WINAPI
midiInMessage16(HMIDIIN16 hMidiIn
, UINT16 uMessage
,
1047 DWORD dwParam1
, DWORD dwParam2
)
1049 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
1054 FIXME("can't handle OPEN or CLOSE message!\n");
1055 return MMSYSERR_NOTSUPPORTED
;
1057 case MIDM_GETDEVCAPS
:
1058 return midiInGetDevCaps16(hMidiIn
, MapSL(dwParam1
), dwParam2
);
1060 return midiInPrepareHeader16(hMidiIn
, dwParam1
, dwParam2
);
1061 case MIDM_UNPREPARE
:
1062 return midiInUnprepareHeader16(hMidiIn
, dwParam1
, dwParam2
);
1063 case MIDM_ADDBUFFER
:
1064 return midiInAddBuffer16(hMidiIn
, dwParam1
, dwParam2
);
1066 return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn
), uMessage
, dwParam1
, dwParam2
);
1069 /**************************************************************************
1070 * midiStreamClose [MMSYSTEM.252]
1072 MMRESULT16 WINAPI
midiStreamClose16(HMIDISTRM16 hMidiStrm
)
1074 UINT ret
= midiStreamClose(HMIDISTRM_32(hMidiStrm
));
1075 if (ret
== MMSYSERR_NOERROR
)
1076 MMSYSTDRV_CloseHandle((void*)HMIDISTRM_32(hMidiStrm
));
1080 /**************************************************************************
1081 * midiStreamOpen [MMSYSTEM.251]
1083 MMRESULT16 WINAPI
midiStreamOpen16(HMIDISTRM16
* phMidiStrm
, LPUINT16 devid
,
1084 DWORD cMidi
, DWORD dwCallback
,
1085 DWORD dwInstance
, DWORD fdwOpen
)
1087 HMIDISTRM hMidiStrm32
;
1090 struct mmsystdrv_thunk
* thunk
;
1092 if (!phMidiStrm
|| !devid
)
1093 return MMSYSERR_INVALPARAM
;
1096 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, fdwOpen
, MMSYSTDRV_MIDIOUT
)))
1098 return MMSYSERR_NOMEM
;
1100 fdwOpen
= (fdwOpen
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
1101 ret
= midiStreamOpen(&hMidiStrm32
, &devid32
, cMidi
, (DWORD
)thunk
, dwInstance
, fdwOpen
);
1102 if (ret
== MMSYSERR_NOERROR
)
1104 *phMidiStrm
= HMIDISTRM_16(hMidiStrm32
);
1106 MMSYSTDRV_SetHandle(thunk
, hMidiStrm32
);
1108 else MMSYSTDRV_DeleteThunk(thunk
);
1112 /**************************************************************************
1113 * midiStreamOut [MMSYSTEM.254]
1115 MMRESULT16 WINAPI
midiStreamOut16(HMIDISTRM16 hMidiStrm
, LPMIDIHDR16 lpMidiHdr
, UINT16 cbMidiHdr
)
1117 return midiStreamOut(HMIDISTRM_32(hMidiStrm
), (LPMIDIHDR
)lpMidiHdr
,
1121 /**************************************************************************
1122 * midiStreamPause [MMSYSTEM.255]
1124 MMRESULT16 WINAPI
midiStreamPause16(HMIDISTRM16 hMidiStrm
)
1126 return midiStreamPause(HMIDISTRM_32(hMidiStrm
));
1129 /**************************************************************************
1130 * midiStreamPosition [MMSYSTEM.253]
1132 MMRESULT16 WINAPI
midiStreamPosition16(HMIDISTRM16 hMidiStrm
, LPMMTIME16 lpmmt16
, UINT16 cbmmt
)
1138 return MMSYSERR_INVALPARAM
;
1139 mmt32
.wType
= lpmmt16
->wType
;
1140 ret
= midiStreamPosition(HMIDISTRM_32(hMidiStrm
), &mmt32
, sizeof(MMTIME
));
1141 MMSYSTEM_MMTIME32to16(lpmmt16
, &mmt32
);
1145 /**************************************************************************
1146 * midiStreamProperty [MMSYSTEM.250]
1148 MMRESULT16 WINAPI
midiStreamProperty16(HMIDISTRM16 hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
1150 return midiStreamProperty(HMIDISTRM_32(hMidiStrm
), lpPropData
, dwProperty
);
1153 /**************************************************************************
1154 * midiStreamRestart [MMSYSTEM.256]
1156 MMRESULT16 WINAPI
midiStreamRestart16(HMIDISTRM16 hMidiStrm
)
1158 return midiStreamRestart(HMIDISTRM_32(hMidiStrm
));
1161 /**************************************************************************
1162 * midiStreamStop [MMSYSTEM.257]
1164 MMRESULT16 WINAPI
midiStreamStop16(HMIDISTRM16 hMidiStrm
)
1166 return midiStreamStop(HMIDISTRM_32(hMidiStrm
));
1169 /* ###################################################
1171 * ###################################################
1174 /**************************************************************************
1175 * waveOutGetNumDevs [MMSYSTEM.401]
1177 UINT16 WINAPI
waveOutGetNumDevs16(void)
1179 return waveOutGetNumDevs();
1182 /**************************************************************************
1183 * waveOutGetDevCaps [MMSYSTEM.402]
1185 UINT16 WINAPI
waveOutGetDevCaps16(UINT16 uDeviceID
,
1186 LPWAVEOUTCAPS16 lpCaps
, UINT16 uSize
)
1190 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
1192 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1194 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
1195 if (ret
== MMSYSERR_NOERROR
) {
1196 WAVEOUTCAPS16 woc16
;
1197 woc16
.wMid
= wocA
.wMid
;
1198 woc16
.wPid
= wocA
.wPid
;
1199 woc16
.vDriverVersion
= wocA
.vDriverVersion
;
1200 strcpy(woc16
.szPname
, wocA
.szPname
);
1201 woc16
.dwFormats
= wocA
.dwFormats
;
1202 woc16
.wChannels
= wocA
.wChannels
;
1203 woc16
.dwSupport
= wocA
.dwSupport
;
1204 memcpy(lpCaps
, &woc16
, min(uSize
, sizeof(woc16
)));
1209 /**************************************************************************
1210 * waveOutGetErrorText [MMSYSTEM.403]
1211 * waveInGetErrorText [MMSYSTEM.503]
1213 UINT16 WINAPI
waveOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
1215 return waveOutGetErrorTextA(uError
, lpText
, uSize
);
1218 /**************************************************************************
1219 * waveOutOpen [MMSYSTEM.404]
1221 UINT16 WINAPI
waveOutOpen16(HWAVEOUT16
* lphWaveOut
, UINT16 uDeviceID
,
1222 LPCWAVEFORMATEX lpFormat
, DWORD dwCallback
,
1223 DWORD dwInstance
, DWORD dwFlags
)
1227 struct mmsystdrv_thunk
* thunk
;
1229 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, dwFlags
, MMSYSTDRV_WAVEOUT
)))
1231 return MMSYSERR_NOMEM
;
1233 dwFlags
= (dwFlags
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
1234 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1235 * call the 32 bit version
1236 * however, we need to promote correctly the wave mapper id
1237 * (0xFFFFFFFF and not 0x0000FFFF)
1239 ret
= waveOutOpen(&hWaveOut
, (uDeviceID
== (UINT16
)-1) ? (UINT
)-1 : uDeviceID
,
1240 lpFormat
, (DWORD
)thunk
, dwInstance
, dwFlags
);
1242 if (ret
== MMSYSERR_NOERROR
&& !(dwFlags
& WAVE_FORMAT_QUERY
))
1244 MMSYSTDRV_SetHandle(thunk
, (void*)hWaveOut
);
1245 if (lphWaveOut
!= NULL
)
1246 *lphWaveOut
= HWAVEOUT_16(hWaveOut
);
1247 } else MMSYSTDRV_DeleteThunk(thunk
);
1251 /**************************************************************************
1252 * waveOutClose [MMSYSTEM.405]
1254 UINT16 WINAPI
waveOutClose16(HWAVEOUT16 hWaveOut
)
1259 ReleaseThunkLock(&level
);
1260 ret
= waveOutClose(HWAVEOUT_32(hWaveOut
));
1261 RestoreThunkLock(level
);
1262 if (ret
== MMSYSERR_NOERROR
)
1263 MMSYSTDRV_CloseHandle((void*)HWAVEOUT_32(hWaveOut
));
1267 /**************************************************************************
1268 * waveOutPrepareHeader [MMSYSTEM.406]
1270 UINT16 WINAPI
waveOutPrepareHeader16(HWAVEOUT16 hWaveOut
, /* [in] */
1271 SEGPTR lpsegWaveOutHdr
, /* [???] */
1272 UINT16 uSize
) /* [in] */
1274 TRACE("(%04X, %08lx, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1276 if (lpsegWaveOutHdr
== 0) return MMSYSERR_INVALPARAM
;
1278 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_PREPARE
, lpsegWaveOutHdr
, uSize
);
1281 /**************************************************************************
1282 * waveOutUnprepareHeader [MMSYSTEM.407]
1284 UINT16 WINAPI
waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut
, /* [in] */
1285 SEGPTR lpsegWaveOutHdr
, /* [???] */
1286 UINT16 uSize
) /* [in] */
1288 LPWAVEHDR lpWaveOutHdr
= MapSL(lpsegWaveOutHdr
);
1290 TRACE("(%04X, %08lx, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1292 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
1293 return MMSYSERR_NOERROR
;
1296 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_UNPREPARE
, lpsegWaveOutHdr
, uSize
);
1299 /**************************************************************************
1300 * waveOutWrite [MMSYSTEM.408]
1302 UINT16 WINAPI
waveOutWrite16(HWAVEOUT16 hWaveOut
, /* [in] */
1303 SEGPTR lpsegWaveOutHdr
, /* [???] */
1304 UINT16 uSize
) /* [in] */
1306 TRACE("(%04X, %08lx, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
1308 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), WODM_WRITE
, lpsegWaveOutHdr
, uSize
);
1311 /**************************************************************************
1312 * waveOutBreakLoop [MMSYSTEM.419]
1314 UINT16 WINAPI
waveOutBreakLoop16(HWAVEOUT16 hWaveOut16
)
1319 ReleaseThunkLock(&level
);
1320 ret
= waveOutBreakLoop(HWAVEOUT_32(hWaveOut16
));
1321 RestoreThunkLock(level
);
1325 /**************************************************************************
1326 * waveOutPause [MMSYSTEM.409]
1328 UINT16 WINAPI
waveOutPause16(HWAVEOUT16 hWaveOut16
)
1333 ReleaseThunkLock(&level
);
1334 ret
= waveOutPause(HWAVEOUT_32(hWaveOut16
));
1335 RestoreThunkLock(level
);
1339 /**************************************************************************
1340 * waveOutReset [MMSYSTEM.411]
1342 UINT16 WINAPI
waveOutReset16(HWAVEOUT16 hWaveOut16
)
1347 ReleaseThunkLock(&level
);
1348 ret
= waveOutReset(HWAVEOUT_32(hWaveOut16
));
1349 RestoreThunkLock(level
);
1353 /**************************************************************************
1354 * waveOutRestart [MMSYSTEM.410]
1356 UINT16 WINAPI
waveOutRestart16(HWAVEOUT16 hWaveOut16
)
1361 ReleaseThunkLock(&level
);
1362 ret
= waveOutRestart(HWAVEOUT_32(hWaveOut16
));
1363 RestoreThunkLock(level
);
1367 /**************************************************************************
1368 * waveOutGetPosition [MMSYSTEM.412]
1370 UINT16 WINAPI
waveOutGetPosition16(HWAVEOUT16 hWaveOut
, LPMMTIME16 lpTime
,
1376 mmt
.wType
= lpTime
->wType
;
1377 ret
= waveOutGetPosition(HWAVEOUT_32(hWaveOut
), &mmt
, sizeof(mmt
));
1378 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
1382 /**************************************************************************
1383 * waveOutGetPitch [MMSYSTEM.413]
1385 UINT16 WINAPI
waveOutGetPitch16(HWAVEOUT16 hWaveOut16
, LPDWORD lpdw
)
1387 return waveOutGetPitch(HWAVEOUT_32(hWaveOut16
), lpdw
);
1390 /**************************************************************************
1391 * waveOutSetPitch [MMSYSTEM.414]
1393 UINT16 WINAPI
waveOutSetPitch16(HWAVEOUT16 hWaveOut16
, DWORD dw
)
1395 return waveOutSetPitch(HWAVEOUT_32(hWaveOut16
), dw
);
1398 /**************************************************************************
1399 * waveOutGetPlaybackRate [MMSYSTEM.417]
1401 UINT16 WINAPI
waveOutGetPlaybackRate16(HWAVEOUT16 hWaveOut16
, LPDWORD lpdw
)
1403 return waveOutGetPlaybackRate(HWAVEOUT_32(hWaveOut16
), lpdw
);
1406 /**************************************************************************
1407 * waveOutSetPlaybackRate [MMSYSTEM.418]
1409 UINT16 WINAPI
waveOutSetPlaybackRate16(HWAVEOUT16 hWaveOut16
, DWORD dw
)
1411 return waveOutSetPlaybackRate(HWAVEOUT_32(hWaveOut16
), dw
);
1414 /**************************************************************************
1415 * waveOutGetVolume [MMSYSTEM.415]
1417 UINT16 WINAPI
waveOutGetVolume16(UINT16 devid
, LPDWORD lpdw
)
1419 return waveOutGetVolume(HWAVEOUT_32(devid
), lpdw
);
1422 /**************************************************************************
1423 * waveOutSetVolume [MMSYSTEM.416]
1425 UINT16 WINAPI
waveOutSetVolume16(UINT16 devid
, DWORD dw
)
1427 return waveOutSetVolume(HWAVEOUT_32(devid
), dw
);
1430 /**************************************************************************
1431 * waveOutGetID [MMSYSTEM.420]
1433 UINT16 WINAPI
waveOutGetID16(HWAVEOUT16 hWaveOut
, UINT16
* lpuDeviceID
)
1438 ret
= waveOutGetID(HWAVEOUT_32(hWaveOut
), &devid
);
1439 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1440 *lpuDeviceID
= devid
;
1444 /**************************************************************************
1445 * waveOutMessage [MMSYSTEM.421]
1447 DWORD WINAPI
waveOutMessage16(HWAVEOUT16 hWaveOut
, UINT16 uMessage
,
1448 DWORD dwParam1
, DWORD dwParam2
)
1450 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
1452 if ((DWORD_PTR
)hWaveOut
< waveOutGetNumDevs())
1454 if (uMessage
== DRV_QUERYDRVENTRY
|| uMessage
== DRV_QUERYDEVNODE
)
1455 dwParam1
= (DWORD
)MapSL(dwParam1
);
1457 else if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
1459 return MMSYSERR_INVALPARAM
;
1461 return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut
), uMessage
, dwParam1
, dwParam2
);
1464 /**************************************************************************
1465 * waveInGetNumDevs [MMSYSTEM.501]
1467 UINT16 WINAPI
waveInGetNumDevs16(void)
1469 return waveInGetNumDevs();
1472 /**************************************************************************
1473 * waveInGetDevCaps [MMSYSTEM.502]
1475 UINT16 WINAPI
waveInGetDevCaps16(UINT16 uDeviceID
, LPWAVEINCAPS16 lpCaps
,
1481 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1483 ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, sizeof(wicA
));
1484 if (ret
== MMSYSERR_NOERROR
) {
1486 wic16
.wMid
= wicA
.wMid
;
1487 wic16
.wPid
= wicA
.wPid
;
1488 wic16
.vDriverVersion
= wicA
.vDriverVersion
;
1489 strcpy(wic16
.szPname
, wicA
.szPname
);
1490 wic16
.dwFormats
= wicA
.dwFormats
;
1491 wic16
.wChannels
= wicA
.wChannels
;
1492 memcpy(lpCaps
, &wic16
, min(uSize
, sizeof(wic16
)));
1497 /**************************************************************************
1498 * waveInOpen [MMSYSTEM.504]
1500 UINT16 WINAPI
waveInOpen16(HWAVEIN16
* lphWaveIn
, UINT16 uDeviceID
,
1501 LPCWAVEFORMATEX lpFormat
, DWORD dwCallback
,
1502 DWORD dwInstance
, DWORD dwFlags
)
1506 struct mmsystdrv_thunk
* thunk
;
1508 if (!(thunk
= MMSYSTDRV_AddThunk(dwCallback
, dwFlags
, MMSYSTDRV_WAVEIN
)))
1510 return MMSYSERR_NOMEM
;
1512 dwFlags
= (dwFlags
& ~CALLBACK_TYPEMASK
) | CALLBACK_FUNCTION
;
1513 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1514 * call the 32 bit version
1515 * however, we need to promote correctly the wave mapper id
1516 * (0xFFFFFFFF and not 0x0000FFFF)
1518 ret
= waveInOpen(&hWaveIn
, (uDeviceID
== (UINT16
)-1) ? (UINT
)-1 : uDeviceID
,
1519 lpFormat
, (DWORD
)thunk
, dwInstance
, dwFlags
);
1521 if (ret
== MMSYSERR_NOERROR
&& !(dwFlags
& WAVE_FORMAT_QUERY
))
1523 MMSYSTDRV_SetHandle(thunk
, (void*)hWaveIn
);
1524 if (lphWaveIn
!= NULL
)
1525 *lphWaveIn
= HWAVEOUT_16(hWaveIn
);
1526 } else MMSYSTDRV_DeleteThunk(thunk
);
1530 /**************************************************************************
1531 * waveInClose [MMSYSTEM.505]
1533 UINT16 WINAPI
waveInClose16(HWAVEIN16 hWaveIn
)
1538 ReleaseThunkLock(&level
);
1539 ret
= waveInClose(HWAVEIN_32(hWaveIn
));
1540 RestoreThunkLock(level
);
1541 if (ret
== MMSYSERR_NOERROR
)
1542 MMSYSTDRV_CloseHandle((void*)HWAVEIN_32(hWaveIn
));
1546 /**************************************************************************
1547 * waveInPrepareHeader [MMSYSTEM.506]
1549 UINT16 WINAPI
waveInPrepareHeader16(HWAVEIN16 hWaveIn
, /* [in] */
1550 SEGPTR lpsegWaveInHdr
, /* [???] */
1551 UINT16 uSize
) /* [in] */
1553 LPWAVEHDR lpWaveInHdr
= MapSL(lpsegWaveInHdr
);
1555 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
1557 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
1559 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_PREPARE
, lpsegWaveInHdr
, uSize
);
1562 /**************************************************************************
1563 * waveInUnprepareHeader [MMSYSTEM.507]
1565 UINT16 WINAPI
waveInUnprepareHeader16(HWAVEIN16 hWaveIn
, /* [in] */
1566 SEGPTR lpsegWaveInHdr
, /* [???] */
1567 UINT16 uSize
) /* [in] */
1569 LPWAVEHDR lpWaveInHdr
= MapSL(lpsegWaveInHdr
);
1571 TRACE("(%04X, %08lx, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
1573 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
1575 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
1576 return MMSYSERR_NOERROR
;
1579 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_UNPREPARE
, lpsegWaveInHdr
, uSize
);
1582 /**************************************************************************
1583 * waveInAddBuffer [MMSYSTEM.508]
1585 UINT16 WINAPI
waveInAddBuffer16(HWAVEIN16 hWaveIn
, /* [in] */
1586 SEGPTR lpsegWaveInHdr
, /* [???] */
1587 UINT16 uSize
) /* [in] */
1589 TRACE("(%04X, %08lx, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
1591 if (lpsegWaveInHdr
== 0) return MMSYSERR_INVALPARAM
;
1593 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), WIDM_ADDBUFFER
, lpsegWaveInHdr
, uSize
);
1596 /**************************************************************************
1597 * waveInReset [MMSYSTEM.511]
1599 UINT16 WINAPI
waveInReset16(HWAVEIN16 hWaveIn16
)
1604 ReleaseThunkLock(&level
);
1605 ret
= waveInReset(HWAVEIN_32(hWaveIn16
));
1606 RestoreThunkLock(level
);
1610 /**************************************************************************
1611 * waveInStart [MMSYSTEM.509]
1613 UINT16 WINAPI
waveInStart16(HWAVEIN16 hWaveIn16
)
1618 ReleaseThunkLock(&level
);
1619 ret
= waveInStart(HWAVEIN_32(hWaveIn16
));
1620 RestoreThunkLock(level
);
1624 /**************************************************************************
1625 * waveInStop [MMSYSTEM.510]
1627 UINT16 WINAPI
waveInStop16(HWAVEIN16 hWaveIn16
)
1632 ReleaseThunkLock(&level
);
1633 ret
= waveInStop(HWAVEIN_32(hWaveIn16
));
1634 RestoreThunkLock(level
);
1638 /**************************************************************************
1639 * waveInGetPosition [MMSYSTEM.512]
1641 UINT16 WINAPI
waveInGetPosition16(HWAVEIN16 hWaveIn
, LPMMTIME16 lpTime
,
1647 mmt
.wType
= lpTime
->wType
;
1648 ret
= waveInGetPosition(HWAVEIN_32(hWaveIn
), &mmt
, sizeof(mmt
));
1649 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
1653 /**************************************************************************
1654 * waveInGetID [MMSYSTEM.513]
1656 UINT16 WINAPI
waveInGetID16(HWAVEIN16 hWaveIn
, UINT16
* lpuDeviceID
)
1661 ret
= waveInGetID(HWAVEIN_32(hWaveIn
), &devid
);
1662 if (ret
!= MMSYSERR_NOERROR
) return ret
;
1663 *lpuDeviceID
= devid
;
1667 /**************************************************************************
1668 * waveInMessage [MMSYSTEM.514]
1670 DWORD WINAPI
waveInMessage16(HWAVEIN16 hWaveIn
, UINT16 uMessage
,
1671 DWORD dwParam1
, DWORD dwParam2
)
1673 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
1675 if ((DWORD_PTR
)hWaveIn
< waveInGetNumDevs())
1677 if (uMessage
== DRV_QUERYDRVENTRY
|| uMessage
== DRV_QUERYDEVNODE
)
1678 dwParam1
= (DWORD
)MapSL(dwParam1
);
1680 else if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
1682 return MMSYSERR_INVALPARAM
;
1684 return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn
), uMessage
, dwParam1
, dwParam2
);
1687 /* ###################################################
1689 * ###################################################
1692 /*#define USE_MM_TSK_WINE*/
1694 /**************************************************************************
1695 * mmTaskCreate [MMSYSTEM.900]
1697 * Creates a 16 bit MM task. Its entry point is lpFunc, and it should be
1698 * called upon creation with dwPmt as parameter.
1700 HINSTANCE16 WINAPI
mmTaskCreate16(SEGPTR spProc
, HINSTANCE16
*lphMmTask
, DWORD dwPmt
)
1705 DWORD showCmd
= 0x40002;
1708 TRACE("(%08lx, %p, %08lx);\n", spProc
, lphMmTask
, dwPmt
);
1709 /* This to work requires NE modules to be started with a binary command line
1710 * which is not currently the case. A patch exists but has never been committed.
1711 * A workaround would be to integrate code for mmtask.tsk into Wine, but
1712 * this requires tremendous work (starting with patching tools/build to
1713 * create NE executables (and not only DLLs) for builtins modules.
1716 FIXME("This is currently broken. It will fail\n");
1719 *(LPDWORD
)(cmdline
+ 1) = (DWORD
)spProc
;
1720 *(LPDWORD
)(cmdline
+ 5) = dwPmt
;
1721 *(LPDWORD
)(cmdline
+ 9) = 0;
1723 lp
.hEnvironment
= 0;
1724 lp
.cmdLine
= MapLS(cmdline
);
1725 lp
.showCmd
= MapLS(&showCmd
);
1728 #ifndef USE_MM_TSK_WINE
1729 handle
= LoadModule16("c:\\windows\\system\\mmtask.tsk", &lp
);
1731 handle
= LoadModule16("mmtask.tsk", &lp
);
1734 ret
= (handle
) ? 1 : 2;
1740 *lphMmTask
= handle
;
1742 UnMapLS( lp
.cmdLine
);
1743 UnMapLS( lp
.showCmd
);
1744 TRACE("=> 0x%04x/%d\n", handle
, ret
);
1748 #ifdef USE_MM_TSK_WINE
1749 /* C equivalent to mmtask.tsk binary content */
1750 void mmTaskEntryPoint16(LPSTR cmdLine
, WORD di
, WORD si
)
1752 int len
= cmdLine
[0x80];
1755 void (*fpProc
)(DWORD
) = MapSL(*((DWORD
*)(cmdLine
+ 1)));
1756 DWORD dwPmt
= *((DWORD
*)(cmdLine
+ 5));
1759 InitTask16(); /* FIXME: pmts / from context ? */
1762 if (SetMessageQueue16(0x40)) {
1764 if (HIWORD(fpProc
)) {
1766 /* EPP StackEnter16(); */
1778 /**************************************************************************
1779 * mmTaskBlock [MMSYSTEM.902]
1781 void WINAPI
mmTaskBlock16(HINSTANCE16 hInst
)
1786 GetMessageA(&msg
, 0, 0, 0);
1788 TranslateMessage(&msg
);
1789 DispatchMessageA(&msg
);
1791 } while (msg
.message
< 0x3A0);
1794 /**************************************************************************
1795 * mmTaskSignal [MMSYSTEM.903]
1797 LRESULT WINAPI
mmTaskSignal16(HTASK16 ht
)
1799 TRACE("(%04x);\n", ht
);
1800 return PostThreadMessageW( HTASK_32(ht
), WM_USER
, 0, 0 );
1803 /**************************************************************************
1804 * mmGetCurrentTask [MMSYSTEM.904]
1806 HTASK16 WINAPI
mmGetCurrentTask16(void)
1808 return GetCurrentTask();
1811 /**************************************************************************
1812 * mmTaskYield [MMSYSTEM.905]
1814 void WINAPI
mmTaskYield16(void)
1818 if (PeekMessageA(&msg
, 0, 0, 0, 0)) {
1823 /******************************************************************
1828 static WINE_MMTHREAD
* WINMM_GetmmThread(HANDLE16 h
)
1830 return MapSL(MAKESEGPTR(h
, 0));
1833 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD
* lpMMThd
)
1838 if (lpMMThd
->dwThreadID
!= GetCurrentThreadId())
1839 ERR("Not called by thread itself\n");
1842 ResetEvent(lpMMThd
->hEvent
);
1843 if (InterlockedDecrement(&lpMMThd
->dwSignalCount
) >= 0)
1845 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
1849 ret
= MsgWaitForMultipleObjects(1, &lpMMThd
->hEvent
, FALSE
, INFINITE
, QS_ALLINPUT
);
1851 case WAIT_OBJECT_0
: /* Event */
1854 case WAIT_OBJECT_0
+ 1: /* Msg */
1856 if (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
1857 TranslateMessage(&msg
);
1858 DispatchMessageA(&msg
);
1862 WARN("S2.x unsupported ret val 0x%08lx\n", ret
);
1868 /**************************************************************************
1869 * mmThreadBlock [MMSYSTEM.1122]
1871 void WINAPI
mmThreadBlock16(HANDLE16 hndl
)
1873 TRACE("(%04x)!\n", hndl
);
1876 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
1878 if (lpMMThd
->hThread
!= 0) {
1881 ReleaseThunkLock(&lc
);
1882 MMSYSTEM_ThreadBlock(lpMMThd
);
1883 RestoreThunkLock(lc
);
1885 mmTaskBlock16(lpMMThd
->hTask
);
1891 /**************************************************************************
1892 * __wine_mmThreadEntryPoint (MMSYSTEM.2047)
1894 DWORD WINAPI
WINE_mmThreadEntryPoint(LPVOID p
)
1896 HANDLE16 hndl
= (HANDLE16
)(DWORD_PTR
)p
;
1897 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
1899 TRACE("(%04x %p)\n", hndl
, lpMMThd
);
1901 lpMMThd
->hTask
= LOWORD(GetCurrentTask());
1902 TRACE("[10-%p] setting hTask to 0x%08x\n", lpMMThd
->hThread
, lpMMThd
->hTask
);
1903 lpMMThd
->dwStatus
= 0x10;
1904 MMSYSTEM_ThreadBlock(lpMMThd
);
1905 TRACE("[20-%p]\n", lpMMThd
->hThread
);
1906 lpMMThd
->dwStatus
= 0x20;
1907 if (lpMMThd
->fpThread
) {
1908 WOWCallback16(lpMMThd
->fpThread
, lpMMThd
->dwThreadPmt
);
1910 lpMMThd
->dwStatus
= 0x30;
1911 TRACE("[30-%p]\n", lpMMThd
->hThread
);
1912 while (lpMMThd
->dwCounter
) {
1916 TRACE("[XX-%p]\n", lpMMThd
->hThread
);
1918 lpMMThd
->dwSignature
= WINE_MMTHREAD_DELETED
;
1919 /* close lpMMThread->hVxD directIO */
1920 if (lpMMThd
->hEvent
)
1921 CloseHandle(lpMMThd
->hEvent
);
1928 extern DWORD WINAPI
GetProcessFlags(DWORD
);
1930 /**************************************************************************
1931 * mmThreadCreate [MMSYSTEM.1120]
1934 * Creates a MM thread, calling fpThreadAddr(dwPmt).
1936 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
1937 * bit.1 set means to open a VxD for this thread (unsupported)
1939 LRESULT WINAPI
mmThreadCreate16(FARPROC16 fpThreadAddr
, LPHANDLE16 lpHndl
, DWORD dwPmt
, DWORD dwFlags
)
1944 TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr
, lpHndl
, dwPmt
, dwFlags
);
1946 hndl
= GlobalAlloc16(GMEM_SHARE
|GMEM_ZEROINIT
, sizeof(WINE_MMTHREAD
));
1951 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
1954 /* force mmtask routines even if mmthread is required */
1955 /* this will work only if the patch about binary cmd line and NE tasks
1961 lpMMThd
->dwSignature
= WINE_MMTHREAD_CREATED
;
1962 lpMMThd
->dwCounter
= 0;
1963 lpMMThd
->hThread
= 0;
1964 lpMMThd
->dwThreadID
= 0;
1965 lpMMThd
->fpThread
= (DWORD
)fpThreadAddr
;
1966 lpMMThd
->dwThreadPmt
= dwPmt
;
1967 lpMMThd
->dwSignalCount
= 0;
1968 lpMMThd
->hEvent
= 0;
1970 lpMMThd
->dwStatus
= 0;
1971 lpMMThd
->dwFlags
= dwFlags
;
1974 if ((dwFlags
& 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
1975 lpMMThd
->hEvent
= CreateEventW(NULL
, FALSE
, TRUE
, NULL
);
1977 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd
);
1978 if (lpMMThd
->dwFlags
& 2) {
1979 /* as long as we don't support MM VxD in wine, we don't need
1980 * to care about this flag
1982 /* FIXME("Don't know how to properly open VxD handles\n"); */
1983 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
1986 lpMMThd
->hThread
= CreateThread(0, 0, WINE_mmThreadEntryPoint
,
1987 (LPVOID
)(DWORD_PTR
)hndl
, CREATE_SUSPENDED
, &lpMMThd
->dwThreadID
);
1988 if (lpMMThd
->hThread
== 0) {
1989 WARN("Couldn't create thread\n");
1990 /* clean-up(VxDhandle...); devicedirectio... */
1991 if (lpMMThd
->hEvent
!= 0)
1992 CloseHandle(lpMMThd
->hEvent
);
1995 SetThreadPriority(lpMMThd
->hThread
, THREAD_PRIORITY_TIME_CRITICAL
);
1996 TRACE("Got a nice thread hndl=%p id=0x%08lx\n", lpMMThd
->hThread
, lpMMThd
->dwThreadID
);
2000 /* get WINE_mmThreadEntryPoint()
2001 * 2047 is its ordinal in mmsystem.spec
2003 FARPROC16 fp
= GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (LPCSTR
)2047);
2005 TRACE("farproc seg=0x%p lin=%p\n", fp
, MapSL((SEGPTR
)fp
));
2007 ret
= (fp
== 0) ? 2 : mmTaskCreate16((DWORD
)fp
, 0, hndl
);
2011 if (lpMMThd
->hThread
&& !ResumeThread(lpMMThd
->hThread
))
2012 WARN("Couldn't resume thread\n");
2014 while (lpMMThd
->dwStatus
!= 0x10) { /* test also HIWORD of dwStatus */
2016 PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
2029 TRACE("ok => %Id\n", ret
);
2033 /**************************************************************************
2034 * mmThreadSignal [MMSYSTEM.1121]
2036 void WINAPI
mmThreadSignal16(HANDLE16 hndl
)
2038 TRACE("(%04x)!\n", hndl
);
2041 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2043 lpMMThd
->dwCounter
++;
2044 if (lpMMThd
->hThread
!= 0) {
2045 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
2046 SetEvent(lpMMThd
->hEvent
);
2048 mmTaskSignal16(lpMMThd
->hTask
);
2050 lpMMThd
->dwCounter
--;
2054 /**************************************************************************
2055 * mmThreadIsCurrent [MMSYSTEM.1123]
2057 BOOL16 WINAPI
mmThreadIsCurrent16(HANDLE16 hndl
)
2061 TRACE("(%04x)!\n", hndl
);
2063 if (hndl
&& mmThreadIsValid16(hndl
)) {
2064 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2065 ret
= (GetCurrentThreadId() == lpMMThd
->dwThreadID
);
2067 TRACE("=> %d\n", ret
);
2071 /**************************************************************************
2072 * mmThreadIsValid [MMSYSTEM.1124]
2074 BOOL16 WINAPI
mmThreadIsValid16(HANDLE16 hndl
)
2078 TRACE("(%04x)!\n", hndl
);
2081 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2083 if (!IsBadWritePtr(lpMMThd
, sizeof(WINE_MMTHREAD
)) &&
2084 lpMMThd
->dwSignature
== WINE_MMTHREAD_CREATED
&&
2085 IsTask16(lpMMThd
->hTask
)) {
2086 lpMMThd
->dwCounter
++;
2087 if (lpMMThd
->hThread
!= 0) {
2089 if (GetExitCodeThread(lpMMThd
->hThread
, &dwThreadRet
) &&
2090 dwThreadRet
== STATUS_PENDING
) {
2096 lpMMThd
->dwCounter
--;
2099 TRACE("=> %d\n", ret
);
2103 /**************************************************************************
2104 * mmThreadGetTask [MMSYSTEM.1125]
2106 HANDLE16 WINAPI
mmThreadGetTask16(HANDLE16 hndl
)
2110 TRACE("(%04x)\n", hndl
);
2112 if (mmThreadIsValid16(hndl
)) {
2113 WINE_MMTHREAD
* lpMMThd
= WINMM_GetmmThread(hndl
);
2114 ret
= lpMMThd
->hTask
;
2119 typedef BOOL16 (WINAPI
*MMCPLCALLBACK
)(HWND
, LPCSTR
, LPCSTR
, LPCSTR
);
2121 /**************************************************************************
2122 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
2124 BOOL16 WINAPI
mmShowMMCPLPropertySheet16(HWND hWnd
, LPCSTR lpStrDevice
,
2125 LPCSTR lpStrTab
, LPCSTR lpStrTitle
)
2130 TRACE("(%p \"%s\" \"%s\" \"%s\")\n", hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
2132 hndl
= LoadLibraryA("MMSYS.CPL");
2134 MMCPLCALLBACK fp
= (MMCPLCALLBACK
)GetProcAddress(hndl
, "ShowMMCPLPropertySheet");
2137 ReleaseThunkLock(&lc
);
2138 ret
= (fp
)(hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
2139 RestoreThunkLock(lc
);
2147 /**************************************************************************
2148 * StackEnter [MMSYSTEM.32]
2150 void WINAPI
StackEnter16(void)
2153 /* mmsystem.dll from Win 95 does only this: so does Wine */
2158 /**************************************************************************
2159 * StackLeave [MMSYSTEM.33]
2161 void WINAPI
StackLeave16(void)
2164 /* mmsystem.dll from Win 95 does only this: so does Wine */
2169 /**************************************************************************
2170 * WMMMidiRunOnce [MMSYSTEM.8]
2172 void WINAPI
WMMMidiRunOnce16(void)
2174 FIXME("(), stub!\n");
2179 /* ###################################################
2181 * ###################################################
2184 /**************************************************************************
2185 * joyGetNumDevs [MMSYSTEM.101]
2187 UINT16 WINAPI
joyGetNumDevs16(void)
2189 return joyGetNumDevs();
2192 /**************************************************************************
2193 * joyGetDevCaps [MMSYSTEM.102]
2195 MMRESULT16 WINAPI
joyGetDevCaps16(UINT16 wID
, LPJOYCAPS16 lpCaps
, UINT16 wSize
)
2200 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
2202 ret
= joyGetDevCapsA(wID
, &jca
, sizeof(jca
));
2204 if (ret
!= JOYERR_NOERROR
) return ret
;
2205 lpCaps
->wMid
= jca
.wMid
;
2206 lpCaps
->wPid
= jca
.wPid
;
2207 strcpy(lpCaps
->szPname
, jca
.szPname
);
2208 lpCaps
->wXmin
= jca
.wXmin
;
2209 lpCaps
->wXmax
= jca
.wXmax
;
2210 lpCaps
->wYmin
= jca
.wYmin
;
2211 lpCaps
->wYmax
= jca
.wYmax
;
2212 lpCaps
->wZmin
= jca
.wZmin
;
2213 lpCaps
->wZmax
= jca
.wZmax
;
2214 lpCaps
->wNumButtons
= jca
.wNumButtons
;
2215 lpCaps
->wPeriodMin
= jca
.wPeriodMin
;
2216 lpCaps
->wPeriodMax
= jca
.wPeriodMax
;
2218 if (wSize
>= sizeof(JOYCAPS16
)) { /* Win95 extensions ? */
2219 lpCaps
->wRmin
= jca
.wRmin
;
2220 lpCaps
->wRmax
= jca
.wRmax
;
2221 lpCaps
->wUmin
= jca
.wUmin
;
2222 lpCaps
->wUmax
= jca
.wUmax
;
2223 lpCaps
->wVmin
= jca
.wVmin
;
2224 lpCaps
->wVmax
= jca
.wVmax
;
2225 lpCaps
->wCaps
= jca
.wCaps
;
2226 lpCaps
->wMaxAxes
= jca
.wMaxAxes
;
2227 lpCaps
->wNumAxes
= jca
.wNumAxes
;
2228 lpCaps
->wMaxButtons
= jca
.wMaxButtons
;
2229 strcpy(lpCaps
->szRegKey
, jca
.szRegKey
);
2230 strcpy(lpCaps
->szOEMVxD
, jca
.szOEMVxD
);
2236 /**************************************************************************
2237 * joyGetPosEx [MMSYSTEM.110]
2239 MMRESULT16 WINAPI
joyGetPosEx16(UINT16 wID
, LPJOYINFOEX lpInfo
)
2241 return joyGetPosEx(wID
, lpInfo
);
2244 /**************************************************************************
2245 * joyGetPos [MMSYSTEM.103]
2247 MMRESULT16 WINAPI
joyGetPos16(UINT16 wID
, LPJOYINFO16 lpInfo
)
2252 TRACE("(%d, %p);\n", wID
, lpInfo
);
2254 if ((ret
= joyGetPos(wID
, &ji
)) == JOYERR_NOERROR
) {
2255 lpInfo
->wXpos
= ji
.wXpos
;
2256 lpInfo
->wYpos
= ji
.wYpos
;
2257 lpInfo
->wZpos
= ji
.wZpos
;
2258 lpInfo
->wButtons
= ji
.wButtons
;
2263 /**************************************************************************
2264 * joyGetThreshold [MMSYSTEM.104]
2266 MMRESULT16 WINAPI
joyGetThreshold16(UINT16 wID
, LPUINT16 lpThreshold
)
2271 ret
= joyGetThreshold(wID
, &t
);
2272 if (ret
== JOYERR_NOERROR
)
2277 /**************************************************************************
2278 * joyReleaseCapture [MMSYSTEM.105]
2280 MMRESULT16 WINAPI
joyReleaseCapture16(UINT16 wID
)
2282 return joyReleaseCapture(wID
);
2285 /**************************************************************************
2286 * joySetCapture [MMSYSTEM.106]
2288 MMRESULT16 WINAPI
joySetCapture16(HWND16 hWnd
, UINT16 wID
, UINT16 wPeriod
, BOOL16 bChanged
)
2290 return joySetCapture(HWND_32(hWnd
), wID
, wPeriod
, bChanged
);
2293 /**************************************************************************
2294 * joySetThreshold [MMSYSTEM.107]
2296 MMRESULT16 WINAPI
joySetThreshold16(UINT16 wID
, UINT16 wThreshold
)
2298 return joySetThreshold(wID
,wThreshold
);
2301 /**************************************************************************
2302 * joySetCalibration [MMSYSTEM.109]
2304 MMRESULT16 WINAPI
joySetCalibration16(UINT16 wID
)
2306 FIXME("(%04X): stub.\n", wID
);
2307 return JOYERR_NOCANDO
;