1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1993 Martin Ayotte
11 * 98/9 added Win32 MCI support
12 * 99/4 added mmTask and mmThread functions support
13 * added midiStream support
16 /* FIXME: I think there are some segmented vs. linear pointer weirdnesses
17 * and long term pointers to 16 bit space in here
24 #include <sys/ioctl.h>
28 #include "wine/winbase16.h"
32 #include "multimedia.h"
35 #include "selectors.h"
37 #include "debugtools.h"
39 DEFAULT_DEBUG_CHANNEL(mmsys
)
41 UINT16 WINAPI
midiGetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
);
42 static UINT16
waveGetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
);
43 LONG WINAPI
DrvDefDriverProc(DWORD dwDevID
, HDRVR16 hDrv
, WORD wMsg
,
44 DWORD dwParam1
, DWORD dwParam2
);
46 static LPWINE_MM_IDATA lpFirstIData
= 0;
48 /**************************************************************************
49 * MULTIMEDIA_GetIData [internal]
51 LPWINE_MM_IDATA
MULTIMEDIA_GetIData(void)
53 DWORD pid
= GetCurrentProcessId();
54 LPWINE_MM_IDATA iData
;
56 for (iData
= lpFirstIData
; iData
; iData
= iData
->lpNextIData
) {
57 if (iData
->dwThisProcess
== pid
)
63 /**************************************************************************
64 * WINMM_LibMain [EntryPoint]
66 * WINMM DLL entry point
69 BOOL WINAPI
WINMM_LibMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
71 static BOOL bInitDone
= FALSE
;
72 LPWINE_MM_IDATA iData
;
74 TRACE("0x%x 0x%lx %p\n", hinstDLL
, fdwReason
, fImpLoad
);
77 case DLL_PROCESS_ATTACH
:
78 if (!bInitDone
) { /* to be done only once */
79 if (!MULTIMEDIA_MidiInit() || !MULTIMEDIA_MciInit()) {
84 iData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINE_MM_IDATA
));
87 iData
->hWinMM32Instance
= hinstDLL
;
88 iData
->dwThisProcess
= GetCurrentProcessId();
89 iData
->lpNextIData
= lpFirstIData
;
92 case DLL_PROCESS_DETACH
:
93 iData
= MULTIMEDIA_GetIData();
94 if (!iData
) {ERR("Idata is NULL, please report\n"); return FALSE
;}
96 LPWINE_MM_IDATA
* ppid
;
98 for (ppid
= &lpFirstIData
; *ppid
; ppid
= &(*ppid
)->lpNextIData
) {
100 *ppid
= iData
->lpNextIData
;
105 /* FIXME: should also free content and resources allocated inside iData */
106 HeapFree(GetProcessHeap(), 0, iData
);
108 case DLL_THREAD_ATTACH
:
109 case DLL_THREAD_DETACH
:
115 /**************************************************************************
116 * MMSYSTEM_LibMain [EntryPoint]
118 * MMSYSTEM DLL entry point
121 BOOL WINAPI
MMSYSTEM_LibMain(DWORD fdwReason
, HINSTANCE hinstDLL
, WORD ds
,
122 WORD wHeapSize
, DWORD dwReserved1
, WORD wReserved2
)
125 LPWINE_MM_IDATA iData
;
127 TRACE("0x%x 0x%lx\n", hinstDLL
, fdwReason
);
130 case DLL_PROCESS_ATTACH
:
131 /* need to load WinMM in order to:
132 * - correctly initiates shared variables (MULTIMEDIA_Init())
133 * - correctly creates the per process WINE_MM_IDATA chunk
135 hndl
= LoadLibraryA("WINMM.DLL");
138 ERR("Could not load sibling WinMM.dll\n");
141 iData
= MULTIMEDIA_GetIData();
142 if (!iData
) {ERR("Idata is NULL, please report\n"); return FALSE
;}
143 iData
->hWinMM16Instance
= hinstDLL
;
144 iData
->h16Module32
= hndl
;
146 case DLL_PROCESS_DETACH
:
147 iData
= MULTIMEDIA_GetIData();
148 if (!iData
) {ERR("Idata is NULL, please report\n"); return FALSE
;}
149 FreeLibrary(iData
->h16Module32
);
151 case DLL_THREAD_ATTACH
:
152 case DLL_THREAD_DETACH
:
158 /**************************************************************************
159 * MMSYSTEM_WEP [MMSYSTEM.1]
161 int WINAPI
MMSYSTEM_WEP(HINSTANCE16 hInstance
, WORD wDataSeg
,
162 WORD cbHeapSize
, LPSTR lpCmdLine
)
164 FIXME("STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance
);
168 static void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16
, const MMTIME
* mmt32
)
170 mmt16
->wType
= mmt32
->wType
;
171 /* layout of rest is the same for 32/16,
172 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
174 memcpy(&(mmt16
->u
), &(mmt32
->u
), sizeof(mmt16
->u
));
177 static void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32
, const MMTIME16
* mmt16
)
179 mmt32
->wType
= mmt16
->wType
;
180 /* layout of rest is the same for 32/16,
181 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
183 memcpy(&(mmt32
->u
), &(mmt16
->u
), sizeof(mmt16
->u
));
186 static HANDLE PlaySound_hThread
= 0;
187 static HANDLE PlaySound_hPlayEvent
= 0;
188 static HANDLE PlaySound_hReadyEvent
= 0;
189 static HANDLE PlaySound_hMiddleEvent
= 0;
190 static BOOL PlaySound_Result
= FALSE
;
191 static int PlaySound_Stop
= FALSE
;
192 static int PlaySound_Playing
= FALSE
;
194 static LPCSTR PlaySound_pszSound
= NULL
;
195 static HMODULE PlaySound_hmod
= 0;
196 static DWORD PlaySound_fdwSound
= 0;
197 static int PlaySound_Loop
= FALSE
;
198 static int PlaySound_SearchMode
= 0; /* 1 - sndPlaySound search order
199 2 - PlaySound order */
201 static HMMIO16
get_mmioFromFile(LPCSTR lpszName
)
203 return mmioOpen16((LPSTR
)lpszName
, NULL
,
204 MMIO_ALLOCBUF
| MMIO_READ
| MMIO_DENYWRITE
);
207 static HMMIO16
get_mmioFromProfile(UINT uFlags
, LPCSTR lpszName
)
213 TRACE("searching in SystemSound List !\n");
214 GetProfileStringA("Sounds", (LPSTR
)lpszName
, "", str
, sizeof(str
));
215 if (strlen(str
) == 0) {
216 if (uFlags
& SND_NODEFAULT
) return 0;
217 GetProfileStringA("Sounds", "Default", "", str
, sizeof(str
));
218 if (strlen(str
) == 0) return 0;
220 if ((ptr
= (LPSTR
)strchr(str
, ',')) != NULL
) *ptr
= '\0';
221 hmmio
= get_mmioFromFile(str
);
223 WARN("can't find SystemSound='%s' !\n", str
);
229 static BOOL16 WINAPI
proc_PlaySound(LPCSTR lpszSoundName
, UINT uFlags
)
235 TRACE("SoundName='%s' uFlags=%04X !\n", lpszSoundName
, uFlags
);
236 if (lpszSoundName
== NULL
) {
240 if (uFlags
& SND_MEMORY
) {
242 memset(&mminfo
, 0, sizeof(mminfo
));
243 mminfo
.fccIOProc
= FOURCC_MEM
;
244 mminfo
.pchBuffer
= (LPSTR
)lpszSoundName
;
245 mminfo
.cchBuffer
= -1;
246 TRACE("Memory sound %p\n", lpszSoundName
);
247 hmmio
= mmioOpen16(NULL
, &mminfo
, MMIO_READ
);
250 if (uFlags
& SND_ALIAS
)
251 if ((hmmio
=get_mmioFromProfile(uFlags
, lpszSoundName
)) == 0)
254 if (uFlags
& SND_FILENAME
)
255 if ((hmmio
=get_mmioFromFile(lpszSoundName
)) == 0) return FALSE
;
257 if (PlaySound_SearchMode
== 1) {
258 PlaySound_SearchMode
= 0;
259 if ((hmmio
=get_mmioFromFile(lpszSoundName
)) == 0)
260 if ((hmmio
=get_mmioFromProfile(uFlags
, lpszSoundName
)) == 0)
264 if (PlaySound_SearchMode
== 2) {
265 PlaySound_SearchMode
= 0;
266 if ((hmmio
=get_mmioFromProfile(uFlags
| SND_NODEFAULT
, lpszSoundName
)) == 0)
267 if ((hmmio
=get_mmioFromFile(lpszSoundName
)) == 0)
268 if ((hmmio
=get_mmioFromProfile(uFlags
, lpszSoundName
)) == 0) return FALSE
;
272 if (mmioDescend(hmmio
, &ckMainRIFF
, NULL
, 0) == 0) {
273 DWORD dwPos
= mmioSeek(hmmio
, 0, SEEK_CUR
);
275 TRACE("ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX \n",
276 (LPSTR
)&ckMainRIFF
.ckid
, (LPSTR
)&ckMainRIFF
.fccType
,
279 mmioSeek(hmmio
, dwPos
, SEEK_SET
);
281 if ((ckMainRIFF
.ckid
== FOURCC_RIFF
) &&
282 (ckMainRIFF
.fccType
== mmioFOURCC('W', 'A', 'V', 'E'))) {
285 mmckInfo
.ckid
= mmioFOURCC('f', 'm', 't', ' ');
287 if (mmioDescend(hmmio
, &mmckInfo
, &ckMainRIFF
, MMIO_FINDCHUNK
) == 0) {
288 PCMWAVEFORMAT pcmWaveFormat
;
290 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n",
291 (LPSTR
)&mmckInfo
.ckid
, (LPSTR
)&mmckInfo
.fccType
, mmckInfo
.cksize
);
293 if (mmioRead(hmmio
, (HPSTR
)&pcmWaveFormat
,
294 (long) sizeof(PCMWAVEFORMAT
)) == (long) sizeof(PCMWAVEFORMAT
)) {
295 TRACE("wFormatTag=%04X !\n", pcmWaveFormat
.wf
.wFormatTag
);
296 TRACE("nChannels=%d \n", pcmWaveFormat
.wf
.nChannels
);
297 TRACE("nSamplesPerSec=%ld\n", pcmWaveFormat
.wf
.nSamplesPerSec
);
298 TRACE("nAvgBytesPerSec=%ld\n", pcmWaveFormat
.wf
.nAvgBytesPerSec
);
299 TRACE("nBlockAlign=%d \n", pcmWaveFormat
.wf
.nBlockAlign
);
300 TRACE("wBitsPerSample=%u !\n", pcmWaveFormat
.wBitsPerSample
);
302 mmckInfo
.ckid
= mmioFOURCC('d', 'a', 't', 'a');
303 /* move to end of 'fmt ' chunk */
304 mmioSeek(hmmio
, mmckInfo
.dwDataOffset
+ ((mmckInfo
.cksize
+ 1) & ~1), SEEK_SET
);
306 if (mmioDescend(hmmio
, &mmckInfo
, &ckMainRIFF
, MMIO_FINDCHUNK
) == 0) {
307 WAVEOPENDESC waveDesc
;
310 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n",
311 (LPSTR
)&mmckInfo
.ckid
, (LPSTR
)&mmckInfo
.fccType
, mmckInfo
.cksize
);
313 pcmWaveFormat
.wf
.nAvgBytesPerSec
= pcmWaveFormat
.wf
.nSamplesPerSec
*
314 pcmWaveFormat
.wf
.nBlockAlign
;
316 waveDesc
.lpFormat
= (LPWAVEFORMAT
)&pcmWaveFormat
;
318 dwRet
= wodMessage(0, WODM_OPEN
, 0, (DWORD
)&waveDesc
, CALLBACK_NULL
);
319 if (dwRet
== MMSYSERR_NOERROR
) {
322 INT count
, bufsize
, left
= mmckInfo
.cksize
;
325 hData
= GlobalAlloc16(GMEM_MOVEABLE
, bufsize
);
326 waveHdr
.lpData
= (LPSTR
)GlobalLock16(hData
);
327 waveHdr
.dwBufferLength
= bufsize
;
329 waveHdr
.dwFlags
= 0L;
330 waveHdr
.dwLoops
= 0L;
332 dwRet
= wodMessage(0, WODM_PREPARE
, 0, (DWORD
)&waveHdr
, sizeof(WAVEHDR
));
333 if (dwRet
== MMSYSERR_NOERROR
) {
335 if (PlaySound_Stop
) {
336 PlaySound_Stop
= FALSE
;
337 PlaySound_Loop
= FALSE
;
340 if (bufsize
> left
) bufsize
= left
;
341 count
= mmioRead(hmmio
, waveHdr
.lpData
,bufsize
);
342 if (count
< 1) break;
344 waveHdr
.dwBufferLength
= count
;
346 waveHdr
.reserved
= (DWORD
)&waveHdr
;
347 /* waveHdr.dwBytesRecorded = count; */
348 /* FIXME: doesn't expect async ops */
349 wodMessage(0, WODM_WRITE
, 0, (DWORD
)&waveHdr
, sizeof(WAVEHDR
));
350 while (!(waveHdr
.dwFlags
& WHDR_DONE
))
353 wodMessage(0, WODM_UNPREPARE
, 0, (DWORD
)&waveHdr
, sizeof(WAVEHDR
));
354 while (wodMessage(0, WODM_CLOSE
, 0, 0L, 0L) == WAVERR_STILLPLAYING
)
359 WARN("can't prepare WaveOut device !\n");
361 GlobalUnlock16(hData
);
368 } while (PlaySound_Loop
);
371 if (hmmio
!= 0) mmioClose(hmmio
, 0);
375 static DWORD WINAPI
PlaySound_Thread(LPVOID arg
)
380 PlaySound_Playing
= FALSE
;
381 SetEvent(PlaySound_hReadyEvent
);
382 res
= WaitForSingleObject(PlaySound_hPlayEvent
, INFINITE
);
383 ResetEvent(PlaySound_hReadyEvent
);
384 SetEvent(PlaySound_hMiddleEvent
);
385 if (res
== WAIT_FAILED
) ExitThread(2);
386 if (res
!= WAIT_OBJECT_0
) continue;
387 PlaySound_Playing
= TRUE
;
389 if ((PlaySound_fdwSound
& SND_RESOURCE
) == SND_RESOURCE
) {
394 if ((hRES
= FindResourceA(PlaySound_hmod
, PlaySound_pszSound
, "WAVE")) == 0) {
395 PlaySound_Result
= FALSE
;
398 if ((hGLOB
= LoadResource(PlaySound_hmod
, hRES
)) == 0) {
399 PlaySound_Result
= FALSE
;
402 if ((ptr
= LockResource(hGLOB
)) == NULL
) {
404 PlaySound_Result
= FALSE
;
407 PlaySound_Result
= proc_PlaySound(ptr
,
408 ((UINT16
)PlaySound_fdwSound
^ SND_RESOURCE
) | SND_MEMORY
);
412 PlaySound_Result
= proc_PlaySound(PlaySound_pszSound
, (UINT16
)PlaySound_fdwSound
);
416 /**************************************************************************
417 * PlaySoundA [WINMM.1]
419 BOOL WINAPI
PlaySoundA(LPCSTR pszSound
, HMODULE hmod
, DWORD fdwSound
)
421 static LPSTR StrDup
= NULL
;
423 TRACE("pszSound='%p' hmod=%04X fdwSound=%08lX\n",
424 pszSound
, hmod
, fdwSound
);
426 if (PlaySound_hThread
== 0) { /* This is the first time they called us */
428 if ((PlaySound_hReadyEvent
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
)) == 0)
430 if ((PlaySound_hMiddleEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
)) == 0)
432 if ((PlaySound_hPlayEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
)) == 0)
434 if ((PlaySound_hThread
= CreateThread(NULL
, 0, PlaySound_Thread
, 0, 0, &id
)) == 0)
438 /* FIXME? I see no difference between SND_WAIT and SND_NOSTOP ! */
439 if ((fdwSound
& (SND_NOWAIT
| SND_NOSTOP
)) && PlaySound_Playing
)
442 /* Trying to stop if playing */
443 if (PlaySound_Playing
) PlaySound_Stop
= TRUE
;
445 /* Waiting playing thread to get ready. I think 10 secs is ok & if not then leave*/
446 if (WaitForSingleObject(PlaySound_hReadyEvent
, 1000*10) != WAIT_OBJECT_0
)
449 if (!pszSound
|| (fdwSound
& SND_PURGE
))
450 return FALSE
; /* We stoped playing so leaving */
452 if (PlaySound_SearchMode
!= 1) PlaySound_SearchMode
= 2;
453 if (!(fdwSound
& SND_ASYNC
)) {
454 if (fdwSound
& SND_LOOP
)
456 PlaySound_pszSound
= pszSound
;
457 PlaySound_hmod
= hmod
;
458 PlaySound_fdwSound
= fdwSound
;
459 PlaySound_Result
= FALSE
;
460 SetEvent(PlaySound_hPlayEvent
);
461 if (WaitForSingleObject(PlaySound_hMiddleEvent
, INFINITE
) != WAIT_OBJECT_0
)
463 if (WaitForSingleObject(PlaySound_hReadyEvent
, INFINITE
) != WAIT_OBJECT_0
)
465 return PlaySound_Result
;
467 PlaySound_hmod
= hmod
;
468 PlaySound_fdwSound
= fdwSound
;
469 PlaySound_Result
= FALSE
;
471 HeapFree(GetProcessHeap(), 0, StrDup
);
474 if (!((fdwSound
& SND_MEMORY
) || ((fdwSound
& SND_RESOURCE
) &&
475 !((DWORD
)pszSound
>> 16)) || !pszSound
)) {
476 StrDup
= HEAP_strdupA(GetProcessHeap(), 0,pszSound
);
477 PlaySound_pszSound
= StrDup
;
478 } else PlaySound_pszSound
= pszSound
;
479 PlaySound_Loop
= fdwSound
& SND_LOOP
;
480 SetEvent(PlaySound_hPlayEvent
);
481 ResetEvent(PlaySound_hMiddleEvent
);
487 /**************************************************************************
488 * PlaySoundW [WINMM.18]
490 BOOL WINAPI
PlaySoundW(LPCWSTR pszSound
, HMODULE hmod
, DWORD fdwSound
)
495 if (!((fdwSound
& SND_MEMORY
) || ((fdwSound
& SND_RESOURCE
) &&
496 !((DWORD
)pszSound
>> 16)) || !pszSound
)) {
497 pszSoundA
= HEAP_strdupWtoA(GetProcessHeap(), 0,pszSound
);
498 bSound
= PlaySoundA(pszSoundA
, hmod
, fdwSound
);
499 HeapFree(GetProcessHeap(), 0,pszSoundA
);
501 bSound
= PlaySoundA((LPCSTR
)pszSound
, hmod
, fdwSound
);
506 /**************************************************************************
507 * PlaySound16 [MMSYSTEM.3]
509 BOOL16 WINAPI
PlaySound16(LPCSTR pszSound
, HMODULE16 hmod
, DWORD fdwSound
)
513 SYSLEVEL_ReleaseWin16Lock();
514 retv
= PlaySoundA( pszSound
, hmod
, fdwSound
);
515 SYSLEVEL_RestoreWin16Lock();
520 /**************************************************************************
521 * sndPlaySoundA [WINMM135]
523 BOOL WINAPI
sndPlaySoundA(LPCSTR lpszSoundName
, UINT uFlags
)
525 PlaySound_SearchMode
= 1;
526 return PlaySoundA(lpszSoundName
, 0, uFlags
);
529 /**************************************************************************
530 * sndPlaySoundW [WINMM.136]
532 BOOL WINAPI
sndPlaySoundW(LPCWSTR lpszSoundName
, UINT uFlags
)
534 PlaySound_SearchMode
= 1;
535 return PlaySoundW(lpszSoundName
, 0, uFlags
);
538 /**************************************************************************
539 * sndPlaySound16 [MMSYSTEM.2]
541 BOOL16 WINAPI
sndPlaySound16(LPCSTR lpszSoundName
, UINT16 uFlags
)
545 SYSLEVEL_ReleaseWin16Lock();
546 retv
= sndPlaySoundA( lpszSoundName
, uFlags
);
547 SYSLEVEL_RestoreWin16Lock();
553 /**************************************************************************
554 * mmsystemGetVersion [WINMM.134]
556 UINT WINAPI
mmsystemGetVersion()
558 return mmsystemGetVersion16();
561 /**************************************************************************
562 * mmsystemGetVersion [MMSYSTEM.5]
563 * return value borrowed from Win95 winmm.dll ;)
565 UINT16 WINAPI
mmsystemGetVersion16()
567 TRACE("3.10 (Win95?)\n");
571 /**************************************************************************
572 * DriverProc [MMSYSTEM.6]
574 LRESULT WINAPI
DriverProc16(DWORD dwDevID
, HDRVR16 hDrv
, WORD wMsg
,
575 DWORD dwParam1
, DWORD dwParam2
)
577 return DrvDefDriverProc(dwDevID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
580 /**************************************************************************
581 * DriverCallback [MMSYSTEM.31]
583 BOOL16 WINAPI
DriverCallback16(DWORD dwCallBack
, UINT16 uFlags
, HANDLE16 hDev
,
584 WORD wMsg
, DWORD dwUser
, DWORD dwParam1
, DWORD dwParam2
)
586 TRACE("(%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n",
587 dwCallBack
, uFlags
, hDev
, wMsg
, dwUser
, dwParam1
, dwParam2
);
589 switch (uFlags
& DCB_TYPEMASK
) {
594 TRACE("Window(%04lX) handle=%04X!\n", dwCallBack
, hDev
);
595 if (!IsWindow(dwCallBack
) || USER_HEAP_LIN_ADDR(hDev
) == NULL
)
597 Callout
.PostMessageA((HWND16
)dwCallBack
, wMsg
, hDev
, dwParam1
);
599 case DCB_TASK
: /* aka DCB_THREAD */
600 TRACE("Task(%04lx) !\n", dwCallBack
);
601 Callout
.PostThreadMessageA(dwCallBack
, wMsg
, hDev
, dwParam1
);
604 TRACE("Function (16bit) !\n");
605 Callbacks
->CallDriverCallback((FARPROC16
)dwCallBack
, hDev
, wMsg
, dwUser
,
608 case DCB_FUNC32
: /* This is a Wine only value - AKAIF not used yet by MS */
609 TRACE("Function (32bit) !\n");
610 ((LPDRVCALLBACK
)dwCallBack
)(hDev
, wMsg
, dwUser
, dwParam1
, dwParam2
);
613 TRACE("Event(%08lx) !\n", dwCallBack
);
614 SetEvent((HANDLE
)dwCallBack
);
616 case 6: /* I would dub it DCB_MMTHREADSIGNAL */
617 /* this is an undocumented DCB_ value used for mmThreads
618 * loword of dwCallBack contains the handle of the lpMMThd block
619 * which dwSignalCount has to be incremented
622 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(LOWORD(dwCallBack
), 0);
624 TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack
), lpMMThd
);
625 /* same as mmThreadSignal16 */
626 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
627 SetEvent(lpMMThd
->hEvent
);
628 /* some other stuff on lpMMThd->hVxD */
633 /* this is an undocumented DCB_ value for... I don't know */
637 WARN("Unknown callback type %d\n", uFlags
& DCB_TYPEMASK
);
644 /**************************************************************************
645 * Mixer devices. New to Win95
648 /**************************************************************************
649 * find out the real mixer ID depending on hmix (depends on dwFlags)
650 * FIXME: also fix dwInstance passing to mixMessage
652 static UINT
MIXER_GetDevID(HMIXEROBJ hmix
, DWORD dwFlags
)
654 /* FIXME: Check dwFlags for MIXER_OBJSECTF_xxxx entries and modify hmix
655 * accordingly. For now we always use mixerdevice 0.
660 /**************************************************************************
661 * mixerGetNumDevs [WINMM.108]
663 UINT WINAPI
mixerGetNumDevs(void)
665 UINT16 count
= mixMessage(0, MXDM_GETNUMDEVS
, 0L, 0L, 0L);
667 TRACE("mixerGetNumDevs returns %d\n", count
);
671 /**************************************************************************
672 * mixerGetNumDevs [MMSYSTEM.800]
674 UINT16 WINAPI
mixerGetNumDevs16()
676 return mixerGetNumDevs();
679 /**************************************************************************
680 * mixerGetDevCapsA [WINMM.101]
682 UINT WINAPI
mixerGetDevCapsA(UINT devid
, LPMIXERCAPSA mixcaps
, UINT size
)
684 return mixMessage(devid
, MXDM_GETDEVCAPS
, 0L, (DWORD
)mixcaps
, (DWORD
)size
);
687 /**************************************************************************
688 * mixerGetDevCapsW [WINMM.102]
690 UINT WINAPI
mixerGetDevCapsW(UINT devid
, LPMIXERCAPSW mixcaps
, UINT size
)
693 UINT ret
= mixerGetDevCapsA(devid
, &micA
, sizeof(micA
));
695 if (ret
== MMSYSERR_NOERROR
) {
696 mixcaps
->wMid
= micA
.wMid
;
697 mixcaps
->wPid
= micA
.wPid
;
698 mixcaps
->vDriverVersion
= micA
.vDriverVersion
;
699 lstrcpyAtoW(mixcaps
->szPname
, micA
.szPname
);
700 mixcaps
->fdwSupport
= micA
.fdwSupport
;
701 mixcaps
->cDestinations
= micA
.cDestinations
;
706 /**************************************************************************
707 * mixerGetDevCaps [MMSYSTEM.801]
709 UINT16 WINAPI
mixerGetDevCaps16(UINT16 devid
, LPMIXERCAPS16 mixcaps
, UINT16 size
)
712 UINT ret
= mixerGetDevCapsA(devid
, &micA
, sizeof(micA
));
714 if (ret
== MMSYSERR_NOERROR
) {
715 mixcaps
->wMid
= micA
.wMid
;
716 mixcaps
->wPid
= micA
.wPid
;
717 mixcaps
->vDriverVersion
= micA
.vDriverVersion
;
718 strcpy(mixcaps
->szPname
, micA
.szPname
);
719 mixcaps
->fdwSupport
= micA
.fdwSupport
;
720 mixcaps
->cDestinations
= micA
.cDestinations
;
725 /**************************************************************************
726 * mixerOpen [WINMM.110]
728 UINT WINAPI
mixerOpen(LPHMIXER lphmix
, UINT uDeviceID
, DWORD dwCallback
,
729 DWORD dwInstance
, DWORD fdwOpen
)
734 TRACE("(%p, %d, %08lx, %08lx, %08lx)\n",
735 lphmix
, uDeviceID
, dwCallback
, dwInstance
, fdwOpen
);
736 ret
= mixerOpen16(&hmix16
, uDeviceID
, dwCallback
, dwInstance
,fdwOpen
);
737 if (lphmix
) *lphmix
= hmix16
;
741 /**************************************************************************
742 * mixerOpen [MMSYSTEM.803]
744 UINT16 WINAPI
mixerOpen16(LPHMIXER16 lphmix
, UINT16 uDeviceID
, DWORD dwCallback
,
745 DWORD dwInstance
, DWORD fdwOpen
)
748 LPMIXEROPENDESC lpmod
;
749 BOOL mapperflag
= (uDeviceID
== 0);
752 TRACE("(%p, %d, %08lx, %08lx, %08lx)\n",
753 lphmix
, uDeviceID
, dwCallback
, dwInstance
, fdwOpen
);
754 hmix
= USER_HEAP_ALLOC(sizeof(MIXEROPENDESC
));
755 if (lphmix
) *lphmix
= hmix
;
756 lpmod
= (LPMIXEROPENDESC
)USER_HEAP_LIN_ADDR(hmix
);
758 lpmod
->dwCallback
= dwCallback
;
759 lpmod
->dwInstance
= dwInstance
;
760 if (uDeviceID
>= MAXMIXERDRIVERS
)
762 while (uDeviceID
< MAXMIXERDRIVERS
) {
763 dwRet
= mixMessage(uDeviceID
, MXDM_OPEN
, dwInstance
, (DWORD
)lpmod
, fdwOpen
);
764 if (dwRet
== MMSYSERR_NOERROR
) break;
765 if (!mapperflag
) break;
768 lpmod
->uDeviceID
= uDeviceID
;
770 if (dwRet
!= MMSYSERR_NOERROR
) {
771 USER_HEAP_FREE(hmix
);
772 if (lphmix
) *lphmix
= 0;
778 /**************************************************************************
779 * mixerClose [WINMM.98]
781 UINT WINAPI
mixerClose(HMIXER hmix
)
783 LPMIXEROPENDESC lpmod
;
786 TRACE("(%04x)\n", hmix
);
788 lpmod
= (LPMIXEROPENDESC
)USER_HEAP_LIN_ADDR(hmix
);
789 if (lpmod
== NULL
) return MMSYSERR_INVALHANDLE
;
790 dwRet
= mixMessage(lpmod
->uDeviceID
, MXDM_CLOSE
, lpmod
->dwInstance
, 0L, 0L);
791 USER_HEAP_FREE(hmix
);
795 /**************************************************************************
796 * mixerClose [MMSYSTEM.803]
798 UINT16 WINAPI
mixerClose16(HMIXER16 hmix
)
800 return mixerClose(hmix
);
803 /**************************************************************************
804 * mixerGetID [WINMM.103]
806 UINT WINAPI
mixerGetID(HMIXEROBJ hmix
, LPUINT lpid
, DWORD fdwID
)
808 FIXME("(%04x %p %08lx): semi-stub\n", hmix
, lpid
, fdwID
);
811 *lpid
= MIXER_GetDevID(hmix
, fdwID
);
813 return MMSYSERR_NOERROR
; /* FIXME: many error possibilities */
816 /**************************************************************************
819 UINT16 WINAPI
mixerGetID16(HMIXEROBJ16 hmix
, LPUINT16 lpid
, DWORD fdwID
)
822 UINT ret
= mixerGetID(hmix
, &xid
, fdwID
);
829 /**************************************************************************
830 * mixerGetControlDetailsA [WINMM.99]
832 UINT WINAPI
mixerGetControlDetailsA(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcdA
, DWORD fdwDetails
)
836 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcdA
, fdwDetails
);
838 if (lpmcdA
== NULL
|| lpmcdA
->cbStruct
!= sizeof(*lpmcdA
))
839 return MMSYSERR_INVALPARAM
;
841 uDevID
= MIXER_GetDevID(hmix
, fdwDetails
);
843 return mixMessage(uDevID
, MXDM_GETCONTROLDETAILS
, 0, (DWORD
)lpmcdA
, fdwDetails
);
846 /**************************************************************************
847 * mixerGetControlDetailsW [WINMM.100]
849 UINT WINAPI
mixerGetControlDetailsW(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcd
, DWORD fdwDetails
)
851 DWORD ret
= MMSYSERR_NOTENABLED
;
853 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
855 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
856 return MMSYSERR_INVALPARAM
;
858 switch (fdwDetails
& MIXER_GETCONTROLDETAILSF_QUERYMASK
) {
859 case MIXER_GETCONTROLDETAILSF_VALUE
:
860 /* can savely use W structure as it is, no string inside */
861 ret
= mixerGetControlDetailsA(hmix
, lpmcd
, fdwDetails
);
863 case MIXER_GETCONTROLDETAILSF_LISTTEXT
:
865 LPVOID paDetailsW
= lpmcd
->paDetails
;
866 int size
= MAX(1, lpmcd
->cChannels
) * sizeof(MIXERCONTROLDETAILS_LISTTEXTA
);
868 if (lpmcd
->u
.cMultipleItems
!= 0 && lpmcd
->u
.cMultipleItems
!= lpmcd
->u
.hwndOwner
) {
869 size
*= lpmcd
->u
.cMultipleItems
;
871 lpmcd
->paDetails
= HeapAlloc(GetProcessHeap(), 0, size
);
872 /* set up lpmcd->paDetails */
873 ret
= mixerGetControlDetailsA(hmix
, lpmcd
, fdwDetails
);
874 /* copy from lpmcd->paDetails back to paDetailsW; */
875 HeapFree(GetProcessHeap(), 0, lpmcd
->paDetails
);
876 lpmcd
->paDetails
= paDetailsW
;
880 ERR("Unsupported fdwDetails=0x%08lx\n", fdwDetails
);
886 /**************************************************************************
887 * mixerGetControlDetails [MMSYSTEM.808]
889 UINT16 WINAPI
mixerGetControlDetails16(HMIXEROBJ16 hmix
, LPMIXERCONTROLDETAILS16 lpmcd
, DWORD fdwDetails
)
891 DWORD ret
= MMSYSERR_NOTENABLED
;
894 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
896 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
897 return MMSYSERR_INVALPARAM
;
899 sppaDetails
= (SEGPTR
)lpmcd
->paDetails
;
900 lpmcd
->paDetails
= PTR_SEG_TO_LIN(sppaDetails
);
901 ret
= mixerGetControlDetailsA(hmix
, (LPMIXERCONTROLDETAILS
)lpmcd
, fdwDetails
);
902 lpmcd
->paDetails
= (LPVOID
)sppaDetails
;
907 /**************************************************************************
908 * mixerGetLineControlsA [WINMM.104]
910 UINT WINAPI
mixerGetLineControlsA(HMIXEROBJ hmix
, LPMIXERLINECONTROLSA lpmlcA
, DWORD fdwControls
)
914 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlcA
, fdwControls
);
916 if (lpmlcA
== NULL
|| lpmlcA
->cbStruct
!= sizeof(*lpmlcA
))
917 return MMSYSERR_INVALPARAM
;
919 uDevID
= MIXER_GetDevID(hmix
, 0);
921 return mixMessage(uDevID
, MXDM_GETLINECONTROLS
, 0, (DWORD
)lpmlcA
, fdwControls
);
924 /**************************************************************************
925 * mixerGetLineControlsW [WINMM.105]
927 UINT WINAPI
mixerGetLineControlsW(HMIXEROBJ hmix
, LPMIXERLINECONTROLSW lpmlcW
, DWORD fdwControls
)
929 MIXERLINECONTROLSA mlcA
;
933 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlcW
, fdwControls
);
935 if (lpmlcW
== NULL
|| lpmlcW
->cbStruct
!= sizeof(*lpmlcW
) || lpmlcW
->cbmxctrl
!= sizeof(MIXERCONTROLW
))
936 return MMSYSERR_INVALPARAM
;
938 mlcA
.cbStruct
= sizeof(mlcA
);
939 mlcA
.dwLineID
= lpmlcW
->dwLineID
;
940 mlcA
.u
.dwControlID
= lpmlcW
->u
.dwControlID
;
941 mlcA
.u
.dwControlType
= lpmlcW
->u
.dwControlType
;
942 mlcA
.cControls
= lpmlcW
->cControls
;
943 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
944 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0, mlcA
.cControls
* mlcA
.cbmxctrl
);
946 ret
= mixerGetLineControlsA(hmix
, &mlcA
, fdwControls
);
948 if (ret
== MMSYSERR_NOERROR
) {
949 lpmlcW
->dwLineID
= mlcA
.dwLineID
;
950 lpmlcW
->u
.dwControlID
= mlcA
.u
.dwControlID
;
951 lpmlcW
->u
.dwControlType
= mlcA
.u
.dwControlType
;
952 lpmlcW
->cControls
= mlcA
.cControls
;
954 for (i
= 0; i
< mlcA
.cControls
; i
++) {
955 lpmlcW
->pamxctrl
[i
].cbStruct
= sizeof(MIXERCONTROLW
);
956 lpmlcW
->pamxctrl
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
957 lpmlcW
->pamxctrl
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
958 lpmlcW
->pamxctrl
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
959 lpmlcW
->pamxctrl
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
960 lstrcpyAtoW(lpmlcW
->pamxctrl
[i
].szShortName
, mlcA
.pamxctrl
[i
].szShortName
);
961 lstrcpyAtoW(lpmlcW
->pamxctrl
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
962 /* sizeof(lpmlcW->pamxctrl[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
963 memcpy(&lpmlcW
->pamxctrl
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
, sizeof(mlcA
.pamxctrl
[i
].Bounds
));
964 /* sizeof(lpmlcW->pamxctrl[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
965 memcpy(&lpmlcW
->pamxctrl
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
, sizeof(mlcA
.pamxctrl
[i
].Metrics
));
969 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
974 /**************************************************************************
975 * mixerGetLineControls [MMSYSTEM.807]
977 UINT16 WINAPI
mixerGetLineControls16(HMIXEROBJ16 hmix
, LPMIXERLINECONTROLS16 lpmlc16
, DWORD fdwControls
)
979 MIXERLINECONTROLSA mlcA
;
982 LPMIXERCONTROL16 lpmc16
;
984 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlc16
, fdwControls
);
986 if (lpmlc16
== NULL
|| lpmlc16
->cbStruct
!= sizeof(*lpmlc16
) || lpmlc16
->cbmxctrl
!= sizeof(MIXERCONTROL16
))
987 return MMSYSERR_INVALPARAM
;
989 mlcA
.cbStruct
= sizeof(mlcA
);
990 mlcA
.dwLineID
= lpmlc16
->dwLineID
;
991 mlcA
.u
.dwControlID
= lpmlc16
->u
.dwControlID
;
992 mlcA
.u
.dwControlType
= lpmlc16
->u
.dwControlType
;
993 mlcA
.cControls
= lpmlc16
->cControls
;
994 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
995 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0, mlcA
.cControls
* mlcA
.cbmxctrl
);
997 ret
= mixerGetLineControlsA(hmix
, &mlcA
, fdwControls
);
999 if (ret
== MMSYSERR_NOERROR
) {
1000 lpmlc16
->dwLineID
= mlcA
.dwLineID
;
1001 lpmlc16
->u
.dwControlID
= mlcA
.u
.dwControlID
;
1002 lpmlc16
->u
.dwControlType
= mlcA
.u
.dwControlType
;
1003 lpmlc16
->cControls
= mlcA
.cControls
;
1005 lpmc16
= PTR_SEG_TO_LIN(lpmlc16
->pamxctrl
);
1007 for (i
= 0; i
< mlcA
.cControls
; i
++) {
1008 lpmc16
[i
].cbStruct
= sizeof(MIXERCONTROL16
);
1009 lpmc16
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
1010 lpmc16
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
1011 lpmc16
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
1012 lpmc16
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
1013 strcpy(lpmc16
[i
].szShortName
, mlcA
.pamxctrl
[i
].szShortName
);
1014 strcpy(lpmc16
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
1015 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
1016 memcpy(&lpmc16
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
, sizeof(mlcA
.pamxctrl
[i
].Bounds
));
1017 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
1018 memcpy(&lpmc16
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
, sizeof(mlcA
.pamxctrl
[i
].Metrics
));
1022 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
1027 /**************************************************************************
1028 * mixerGetLineInfoA [WINMM.106]
1030 UINT WINAPI
mixerGetLineInfoA(HMIXEROBJ hmix
, LPMIXERLINEA lpmliW
, DWORD fdwInfo
)
1034 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmliW
, fdwInfo
);
1036 /* FIXME: I'm not sure of the flags */
1037 devid
= MIXER_GetDevID(hmix
, fdwInfo
);
1038 return mixMessage(devid
, MXDM_GETLINEINFO
, 0, (DWORD
)lpmliW
, fdwInfo
);
1041 /**************************************************************************
1042 * mixerGetLineInfoW [WINMM.107]
1044 UINT WINAPI
mixerGetLineInfoW(HMIXEROBJ hmix
, LPMIXERLINEW lpmliW
, DWORD fdwInfo
)
1049 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmliW
, fdwInfo
);
1051 if (lpmliW
== NULL
|| lpmliW
->cbStruct
!= sizeof(*lpmliW
))
1052 return MMSYSERR_INVALPARAM
;
1054 mliA
.cbStruct
= sizeof(mliA
);
1055 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
1056 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
1057 mliA
.dwComponentType
= lpmliW
->dwComponentType
;
1059 case MIXER_GETLINEINFOF_DESTINATION
:
1060 mliA
.dwDestination
= lpmliW
->dwDestination
;
1062 case MIXER_GETLINEINFOF_LINEID
:
1063 mliA
.dwLineID
= lpmliW
->dwLineID
;
1065 case MIXER_GETLINEINFOF_SOURCE
:
1066 mliA
.dwDestination
= lpmliW
->dwDestination
;
1067 mliA
.dwSource
= lpmliW
->dwSource
;
1069 case MIXER_GETLINEINFOF_TARGETTYPE
:
1070 mliA
.Target
.dwType
= lpmliW
->Target
.dwType
;
1071 mliA
.Target
.wMid
= lpmliW
->Target
.wMid
;
1072 mliA
.Target
.wPid
= lpmliW
->Target
.wPid
;
1073 mliA
.Target
.vDriverVersion
= lpmliW
->Target
.vDriverVersion
;
1074 lstrcpyWtoA(mliA
.Target
.szPname
, lpmliW
->Target
.szPname
);
1077 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo
);
1080 ret
= mixerGetLineInfoA(hmix
, &mliA
, fdwInfo
);
1082 lpmliW
->dwDestination
= mliA
.dwDestination
;
1083 lpmliW
->dwSource
= mliA
.dwSource
;
1084 lpmliW
->dwLineID
= mliA
.dwLineID
;
1085 lpmliW
->fdwLine
= mliA
.fdwLine
;
1086 lpmliW
->dwUser
= mliA
.dwUser
;
1087 lpmliW
->dwComponentType
= mliA
.dwComponentType
;
1088 lpmliW
->cChannels
= mliA
.cChannels
;
1089 lpmliW
->cConnections
= mliA
.cConnections
;
1090 lpmliW
->cControls
= mliA
.cControls
;
1091 lstrcpyAtoW(lpmliW
->szShortName
, mliA
.szShortName
);
1092 lstrcpyAtoW(lpmliW
->szName
, mliA
.szName
);
1093 lpmliW
->Target
.dwType
= mliA
.Target
.dwType
;
1094 lpmliW
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
1095 lpmliW
->Target
.wMid
= mliA
.Target
.wMid
;
1096 lpmliW
->Target
.wPid
= mliA
.Target
.wPid
;
1097 lpmliW
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
1098 lstrcpyAtoW(lpmliW
->Target
.szPname
, mliA
.Target
.szPname
);
1103 /**************************************************************************
1104 * mixerGetLineInfo [MMSYSTEM.805]
1106 UINT16 WINAPI
mixerGetLineInfo16(HMIXEROBJ16 hmix
, LPMIXERLINE16 lpmli16
, DWORD fdwInfo
)
1111 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmli16
, fdwInfo
);
1113 if (lpmli16
== NULL
|| lpmli16
->cbStruct
!= sizeof(*lpmli16
))
1114 return MMSYSERR_INVALPARAM
;
1116 mliA
.cbStruct
= sizeof(mliA
);
1117 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
1118 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
1119 mliA
.dwComponentType
= lpmli16
->dwComponentType
;
1121 case MIXER_GETLINEINFOF_DESTINATION
:
1122 mliA
.dwDestination
= lpmli16
->dwDestination
;
1124 case MIXER_GETLINEINFOF_LINEID
:
1125 mliA
.dwLineID
= lpmli16
->dwLineID
;
1127 case MIXER_GETLINEINFOF_SOURCE
:
1128 mliA
.dwDestination
= lpmli16
->dwDestination
;
1129 mliA
.dwSource
= lpmli16
->dwSource
;
1131 case MIXER_GETLINEINFOF_TARGETTYPE
:
1132 mliA
.Target
.dwType
= lpmli16
->Target
.dwType
;
1133 mliA
.Target
.wMid
= lpmli16
->Target
.wMid
;
1134 mliA
.Target
.wPid
= lpmli16
->Target
.wPid
;
1135 mliA
.Target
.vDriverVersion
= lpmli16
->Target
.vDriverVersion
;
1136 strcpy(mliA
.Target
.szPname
, lpmli16
->Target
.szPname
);
1139 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo
);
1142 ret
= mixerGetLineInfoA(hmix
, &mliA
, fdwInfo
);
1144 lpmli16
->dwDestination
= mliA
.dwDestination
;
1145 lpmli16
->dwSource
= mliA
.dwSource
;
1146 lpmli16
->dwLineID
= mliA
.dwLineID
;
1147 lpmli16
->fdwLine
= mliA
.fdwLine
;
1148 lpmli16
->dwUser
= mliA
.dwUser
;
1149 lpmli16
->dwComponentType
= mliA
.dwComponentType
;
1150 lpmli16
->cChannels
= mliA
.cChannels
;
1151 lpmli16
->cConnections
= mliA
.cConnections
;
1152 lpmli16
->cControls
= mliA
.cControls
;
1153 strcpy(lpmli16
->szShortName
, mliA
.szShortName
);
1154 strcpy(lpmli16
->szName
, mliA
.szName
);
1155 lpmli16
->Target
.dwType
= mliA
.Target
.dwType
;
1156 lpmli16
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
1157 lpmli16
->Target
.wMid
= mliA
.Target
.wMid
;
1158 lpmli16
->Target
.wPid
= mliA
.Target
.wPid
;
1159 lpmli16
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
1160 strcpy(lpmli16
->Target
.szPname
, mliA
.Target
.szPname
);
1165 /**************************************************************************
1166 * mixerSetControlDetails [WINMM.111]
1168 UINT WINAPI
mixerSetControlDetails(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcdA
, DWORD fdwDetails
)
1172 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcdA
, fdwDetails
);
1174 uDevID
= MIXER_GetDevID(hmix
, fdwDetails
);
1176 return mixMessage(uDevID
, MXDM_SETCONTROLDETAILS
, 0, (DWORD
)lpmcdA
, fdwDetails
);
1179 /**************************************************************************
1180 * mixerSetControlDetails [MMSYSTEM.809]
1182 UINT16 WINAPI
mixerSetControlDetails16(HMIXEROBJ16 hmix
, LPMIXERCONTROLDETAILS16 lpmcd
, DWORD fdwDetails
)
1184 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
1185 return MMSYSERR_NOTENABLED
;
1188 /**************************************************************************
1189 * mixerMessage [WINMM.109]
1191 UINT WINAPI
mixerMessage(HMIXER hmix
, UINT uMsg
, DWORD dwParam1
, DWORD dwParam2
)
1193 LPMIXEROPENDESC lpmod
;
1196 lpmod
= (LPMIXEROPENDESC
)USER_HEAP_LIN_ADDR(hmix
);
1198 uDeviceID
= lpmod
->uDeviceID
;
1201 FIXME("(%04lx, %d, %08lx, %08lx): semi-stub?\n",
1202 (DWORD
)hmix
, uMsg
, dwParam1
, dwParam2
);
1203 return mixMessage(uDeviceID
, uMsg
, 0L, dwParam1
, dwParam2
);
1206 /**************************************************************************
1207 * mixerMessage [MMSYSTEM.804]
1209 UINT16 WINAPI
mixerMessage16(HMIXER16 hmix
, UINT16 uMsg
, DWORD dwParam1
, DWORD dwParam2
)
1211 LPMIXEROPENDESC lpmod
;
1214 lpmod
= (LPMIXEROPENDESC
)USER_HEAP_LIN_ADDR(hmix
);
1215 uDeviceID
= (lpmod
) ? lpmod
->uDeviceID
: 0;
1216 FIXME("(%04x, %d, %08lx, %08lx) - semi-stub?\n",
1217 hmix
, uMsg
, dwParam1
, dwParam2
);
1218 return mixMessage(uDeviceID
, uMsg
, 0L, dwParam1
, dwParam2
);
1221 /**************************************************************************
1222 * auxGetNumDevs [WINMM.22]
1224 UINT WINAPI
auxGetNumDevs()
1226 return auxGetNumDevs16();
1229 /**************************************************************************
1230 * auxGetNumDevs [MMSYSTEM.350]
1232 UINT16 WINAPI
auxGetNumDevs16()
1237 count
= auxMessage(0, AUXDM_GETNUMDEVS
, 0L, 0L, 0L);
1238 TRACE("=> %u\n", count
);
1242 /**************************************************************************
1243 * auxGetDevCaps [WINMM.20]
1245 UINT WINAPI
auxGetDevCapsW(UINT uDeviceID
, LPAUXCAPSW lpCaps
, UINT uSize
)
1248 UINT ret
= auxGetDevCaps16(uDeviceID
, &ac16
, sizeof(ac16
));
1250 lpCaps
->wMid
= ac16
.wMid
;
1251 lpCaps
->wPid
= ac16
.wPid
;
1252 lpCaps
->vDriverVersion
= ac16
.vDriverVersion
;
1253 lstrcpyAtoW(lpCaps
->szPname
, ac16
.szPname
);
1254 lpCaps
->wTechnology
= ac16
.wTechnology
;
1255 lpCaps
->dwSupport
= ac16
.dwSupport
;
1259 /**************************************************************************
1260 * auxGetDevCaps [WINMM.21]
1262 UINT WINAPI
auxGetDevCapsA(UINT uDeviceID
, LPAUXCAPSA lpCaps
, UINT uSize
)
1265 UINT ret
= auxGetDevCaps16(uDeviceID
, &ac16
, sizeof(ac16
));
1267 lpCaps
->wMid
= ac16
.wMid
;
1268 lpCaps
->wPid
= ac16
.wPid
;
1269 lpCaps
->vDriverVersion
= ac16
.vDriverVersion
;
1270 strcpy(lpCaps
->szPname
, ac16
.szPname
);
1271 lpCaps
->wTechnology
= ac16
.wTechnology
;
1272 lpCaps
->dwSupport
= ac16
.dwSupport
;
1276 /**************************************************************************
1277 * auxGetDevCaps [MMSYSTEM.351]
1279 UINT16 WINAPI
auxGetDevCaps16(UINT16 uDeviceID
, LPAUXCAPS16 lpCaps
, UINT16 uSize
)
1281 TRACE("(%04X, %p, %d) !\n", uDeviceID
, lpCaps
, uSize
);
1283 return auxMessage(uDeviceID
, AUXDM_GETDEVCAPS
,
1284 0L, (DWORD
)lpCaps
, (DWORD
)uSize
);
1287 /**************************************************************************
1288 * auxGetVolume [WINM.23]
1290 UINT WINAPI
auxGetVolume(UINT uDeviceID
, DWORD
* lpdwVolume
)
1292 return auxGetVolume16(uDeviceID
, lpdwVolume
);
1295 /**************************************************************************
1296 * auxGetVolume [MMSYSTEM.352]
1298 UINT16 WINAPI
auxGetVolume16(UINT16 uDeviceID
, DWORD
* lpdwVolume
)
1300 TRACE("(%04X, %p) !\n", uDeviceID
, lpdwVolume
);
1302 return auxMessage(uDeviceID
, AUXDM_GETVOLUME
, 0L, (DWORD
)lpdwVolume
, 0L);
1305 /**************************************************************************
1306 * auxSetVolume [WINMM.25]
1308 UINT WINAPI
auxSetVolume(UINT uDeviceID
, DWORD dwVolume
)
1310 return auxSetVolume16(uDeviceID
, dwVolume
);
1313 /**************************************************************************
1314 * auxSetVolume [MMSYSTEM.353]
1316 UINT16 WINAPI
auxSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
1318 TRACE("(%04X, %08lX) !\n", uDeviceID
, dwVolume
);
1320 return auxMessage(uDeviceID
, AUXDM_SETVOLUME
, 0L, dwVolume
, 0L);
1323 /**************************************************************************
1324 * auxOutMessage [MMSYSTEM.354]
1326 DWORD WINAPI
auxOutMessage(UINT uDeviceID
, UINT uMessage
, DWORD dw1
, DWORD dw2
)
1329 case AUXDM_GETNUMDEVS
:
1330 case AUXDM_GETVOLUME
:
1331 case AUXDM_SETVOLUME
:
1332 /* no argument conversion needed */
1334 case AUXDM_GETDEVCAPS
:
1335 return auxGetDevCapsA(uDeviceID
, (LPAUXCAPSA
)dw1
, dw2
);
1337 ERR("(%04x, %04x, %08lx, %08lx): unhandled message\n",
1338 uDeviceID
, uMessage
, dw1
, dw2
);
1341 return auxMessage(uDeviceID
, uMessage
, 0L, dw1
, dw2
);
1344 /**************************************************************************
1345 * auxOutMessage [MMSYSTEM.354]
1347 DWORD WINAPI
auxOutMessage16(UINT16 uDeviceID
, UINT16 uMessage
, DWORD dw1
, DWORD dw2
)
1349 TRACE("(%04X, %04X, %08lX, %08lX)\n", uDeviceID
, uMessage
, dw1
, dw2
);
1352 case AUXDM_GETNUMDEVS
:
1353 case AUXDM_SETVOLUME
:
1354 /* no argument conversion needed */
1356 case AUXDM_GETVOLUME
:
1357 return auxGetVolume16(uDeviceID
, (LPDWORD
)PTR_SEG_TO_LIN(dw1
));
1358 case AUXDM_GETDEVCAPS
:
1359 return auxGetDevCaps16(uDeviceID
, (LPAUXCAPS16
)PTR_SEG_TO_LIN(dw1
), dw2
);
1361 ERR("(%04x, %04x, %08lx, %08lx): unhandled message\n",
1362 uDeviceID
, uMessage
, dw1
, dw2
);
1365 return auxMessage(uDeviceID
, uMessage
, 0L, dw1
, dw2
);
1368 /**************************************************************************
1369 * mciGetErrorStringW [WINMM.46]
1371 BOOL WINAPI
mciGetErrorStringW(DWORD wError
, LPWSTR lpstrBuffer
, UINT uLength
)
1373 LPSTR bufstr
= HeapAlloc(GetProcessHeap(), 0, uLength
);
1374 BOOL ret
= mciGetErrorStringA(wError
, bufstr
, uLength
);
1376 lstrcpyAtoW(lpstrBuffer
, bufstr
);
1377 HeapFree(GetProcessHeap(), 0, bufstr
);
1381 /**************************************************************************
1382 * mciGetErrorStringA [WINMM.45]
1384 BOOL WINAPI
mciGetErrorStringA(DWORD wError
, LPSTR lpstrBuffer
, UINT uLength
)
1386 return mciGetErrorString16(wError
, lpstrBuffer
, uLength
);
1389 /**************************************************************************
1390 * mciGetErrorString [MMSYSTEM.706]
1392 BOOL16 WINAPI
mciGetErrorString16(DWORD dwError
, LPSTR lpstrBuffer
, UINT16 uLength
)
1394 LPSTR msgptr
= NULL
;
1396 TRACE("(%08lX, %p, %d);\n", dwError
, lpstrBuffer
, uLength
);
1398 if ((lpstrBuffer
== NULL
) || (uLength
< 1))
1401 lpstrBuffer
[0] = '\0';
1405 msgptr
= "The specified command has been executed.";
1407 case MCIERR_INVALID_DEVICE_ID
:
1408 msgptr
= "Invalid MCI device ID. Use the ID returned when opening the MCI device.";
1410 case MCIERR_UNRECOGNIZED_KEYWORD
:
1411 msgptr
= "The driver cannot recognize the specified command parameter.";
1413 case MCIERR_UNRECOGNIZED_COMMAND
:
1414 msgptr
= "The driver cannot recognize the specified command.";
1416 case MCIERR_HARDWARE
:
1417 msgptr
= "There is a problem with your media device. Make sure it is working correctly or contact the device manufacturer.";
1419 case MCIERR_INVALID_DEVICE_NAME
:
1420 msgptr
= "The specified device is not open or is not recognized by MCI.";
1422 case MCIERR_OUT_OF_MEMORY
:
1423 msgptr
= "Not enough memory available for this task. \nQuit one or more applications to increase available memory, and then try again.";
1425 case MCIERR_DEVICE_OPEN
:
1426 msgptr
= "The device name is already being used as an alias by this application. Use a unique alias.";
1428 case MCIERR_CANNOT_LOAD_DRIVER
:
1429 msgptr
= "There is an undetectable problem in loading the specified device driver.";
1431 case MCIERR_MISSING_COMMAND_STRING
:
1432 msgptr
= "No command was specified.";
1434 case MCIERR_PARAM_OVERFLOW
:
1435 msgptr
= "The output string was to large to fit in the return buffer. Increase the size of the buffer.";
1437 case MCIERR_MISSING_STRING_ARGUMENT
:
1438 msgptr
= "The specified command requires a character-string parameter. Please provide one.";
1440 case MCIERR_BAD_INTEGER
:
1441 msgptr
= "The specified integer is invalid for this command.";
1443 case MCIERR_PARSER_INTERNAL
:
1444 msgptr
= "The device driver returned an invalid return type. Check with the device manufacturer about obtaining a new driver.";
1446 case MCIERR_DRIVER_INTERNAL
:
1447 msgptr
= "There is a problem with the device driver. Check with the device manufacturer about obtaining a new driver.";
1449 case MCIERR_MISSING_PARAMETER
:
1450 msgptr
= "The specified command requires a parameter. Please supply one.";
1452 case MCIERR_UNSUPPORTED_FUNCTION
:
1453 msgptr
= "The MCI device you are using does not support the specified command.";
1455 case MCIERR_FILE_NOT_FOUND
:
1456 msgptr
= "Cannot find the specified file. Make sure the path and filename are correct.";
1458 case MCIERR_DEVICE_NOT_READY
:
1459 msgptr
= "The device driver is not ready.";
1461 case MCIERR_INTERNAL
:
1462 msgptr
= "A problem occurred in initializing MCI. Try restarting Windows.";
1465 msgptr
= "There is a problem with the device driver. The driver has closed. Cannot access error.";
1467 case MCIERR_CANNOT_USE_ALL
:
1468 msgptr
= "Cannot use 'all' as the device name with the specified command.";
1470 case MCIERR_MULTIPLE
:
1471 msgptr
= "Errors occurred in more than one device. Specify each command and device separately to determine which devices caused the error";
1473 case MCIERR_EXTENSION_NOT_FOUND
:
1474 msgptr
= "Cannot determine the device type from the given filename extension.";
1476 case MCIERR_OUTOFRANGE
:
1477 msgptr
= "The specified parameter is out of range for the specified command.";
1479 case MCIERR_FLAGS_NOT_COMPATIBLE
:
1480 msgptr
= "The specified parameters cannot be used together.";
1482 case MCIERR_FILE_NOT_SAVED
:
1483 msgptr
= "Cannot save the specified file. Make sure you have enough disk space or are still connected to the network.";
1485 case MCIERR_DEVICE_TYPE_REQUIRED
:
1486 msgptr
= "Cannot find the specified device. Make sure it is installed or that the device name is spelled correctly.";
1488 case MCIERR_DEVICE_LOCKED
:
1489 msgptr
= "The specified device is now being closed. Wait a few seconds, and then try again.";
1491 case MCIERR_DUPLICATE_ALIAS
:
1492 msgptr
= "The specified alias is already being used in this application. Use a unique alias.";
1494 case MCIERR_BAD_CONSTANT
:
1495 msgptr
= "The specified parameter is invalid for this command.";
1497 case MCIERR_MUST_USE_SHAREABLE
:
1498 msgptr
= "The device driver is already in use. To share it, use the 'shareable' parameter with each 'open' command.";
1500 case MCIERR_MISSING_DEVICE_NAME
:
1501 msgptr
= "The specified command requires an alias, file, driver, or device name. Please supply one.";
1503 case MCIERR_BAD_TIME_FORMAT
:
1504 msgptr
= "The specified value for the time format is invalid. Refer to the MCI documentation for valid formats.";
1506 case MCIERR_NO_CLOSING_QUOTE
:
1507 msgptr
= "A closing double-quotation mark is missing from the parameter value. Please supply one.";
1509 case MCIERR_DUPLICATE_FLAGS
:
1510 msgptr
= "A parameter or value was specified twice. Only specify it once.";
1512 case MCIERR_INVALID_FILE
:
1513 msgptr
= "The specified file cannot be played on the specified MCI device. The file may be corrupt, or not in the correct format.";
1515 case MCIERR_NULL_PARAMETER_BLOCK
:
1516 msgptr
= "A null parameter block was passed to MCI.";
1518 case MCIERR_UNNAMED_RESOURCE
:
1519 msgptr
= "Cannot save an unnamed file. Supply a filename.";
1521 case MCIERR_NEW_REQUIRES_ALIAS
:
1522 msgptr
= "You must specify an alias when using the 'new' parameter.";
1524 case MCIERR_NOTIFY_ON_AUTO_OPEN
:
1525 msgptr
= "Cannot use the 'notify' flag with auto-opened devices.";
1527 case MCIERR_NO_ELEMENT_ALLOWED
:
1528 msgptr
= "Cannot use a filename with the specified device.";
1530 case MCIERR_NONAPPLICABLE_FUNCTION
:
1531 msgptr
= "Cannot carry out the commands in the order specified. Correct the command sequence, and then try again.";
1533 case MCIERR_ILLEGAL_FOR_AUTO_OPEN
:
1534 msgptr
= "Cannot carry out the specified command on an auto-opened device. Wait until the device is closed, and then try again.";
1536 case MCIERR_FILENAME_REQUIRED
:
1537 msgptr
= "The filename is invalid. Make sure the filename is not longer than 8 characters, followed by a period and an extension.";
1539 case MCIERR_EXTRA_CHARACTERS
:
1540 msgptr
= "Cannot specify extra characters after a string enclosed in quotation marks.";
1542 case MCIERR_DEVICE_NOT_INSTALLED
:
1543 msgptr
= "The specified device is not installed on the system. Use the Drivers option in Control Panel to install the device.";
1546 msgptr
= "Cannot access the specified file or MCI device. Try changing directories or restarting your computer.";
1549 msgptr
= "Cannot access the specified file or MCI device because the application cannot change directories.";
1551 case MCIERR_SET_DRIVE
:
1552 msgptr
= "Cannot access specified file or MCI device because the application cannot change drives.";
1554 case MCIERR_DEVICE_LENGTH
:
1555 msgptr
= "Specify a device or driver name that is less than 79 characters.";
1557 case MCIERR_DEVICE_ORD_LENGTH
:
1558 msgptr
= "Specify a device or driver name that is less than 69 characters.";
1560 case MCIERR_NO_INTEGER
:
1561 msgptr
= "The specified command requires an integer parameter. Please provide one.";
1563 case MCIERR_WAVE_OUTPUTSINUSE
:
1564 msgptr
= "All wave devices that can play files in the current format are in use. Wait until a wave device is free, and then try again.";
1566 case MCIERR_WAVE_SETOUTPUTINUSE
:
1567 msgptr
= "Cannot set the current wave device for play back because it is in use. Wait until the device is free, and then try again.";
1569 case MCIERR_WAVE_INPUTSINUSE
:
1570 msgptr
= "All wave devices that can record files in the current format are in use. Wait until a wave device is free, and then try again.";
1572 case MCIERR_WAVE_SETINPUTINUSE
:
1573 msgptr
= "Cannot set the current wave device for recording because it is in use. Wait until the device is free, and then try again.";
1575 case MCIERR_WAVE_OUTPUTUNSPECIFIED
:
1576 msgptr
= "Any compatible waveform playback device may be used.";
1578 case MCIERR_WAVE_INPUTUNSPECIFIED
:
1579 msgptr
= "Any compatible waveform recording device may be used.";
1581 case MCIERR_WAVE_OUTPUTSUNSUITABLE
:
1582 msgptr
= "No wave device that can play files in the current format is installed. Use the Drivers option to install the wave device.";
1584 case MCIERR_WAVE_SETOUTPUTUNSUITABLE
:
1585 msgptr
= "The device you are trying to play to cannot recognize the current file format.";
1587 case MCIERR_WAVE_INPUTSUNSUITABLE
:
1588 msgptr
= "No wave device that can record files in the current format is installed. Use the Drivers option to install the wave device.";
1590 case MCIERR_WAVE_SETINPUTUNSUITABLE
:
1591 msgptr
= "The device you are trying to record from cannot recognize the current file format.";
1593 case MCIERR_NO_WINDOW
:
1594 msgptr
= "There is no display window.";
1596 case MCIERR_CREATEWINDOW
:
1597 msgptr
= "Could not create or use window.";
1599 case MCIERR_FILE_READ
:
1600 msgptr
= "Cannot read the specified file. Make sure the file is still present, or check your disk or network connection.";
1602 case MCIERR_FILE_WRITE
:
1603 msgptr
= "Cannot write to the specified file. Make sure you have enough disk space or are still connected to the network.";
1605 case MCIERR_SEQ_DIV_INCOMPATIBLE
:
1606 msgptr
= "The time formats of the \"song pointer\" and SMPTE are mutually exclusive. You can't use them together.";
1608 case MCIERR_SEQ_NOMIDIPRESENT
:
1609 msgptr
= "The system has no installed MIDI devices. Use the Drivers option from the Control Panel to install a MIDI driver.";
1611 case MCIERR_SEQ_PORT_INUSE
:
1612 msgptr
= "The specified MIDI port is already in use. Wait until it is free; the try again.";
1614 case MCIERR_SEQ_PORT_MAPNODEVICE
:
1615 msgptr
= "The current MIDI Mapper setup refers to a MIDI device that is not installed on the system. Use the MIDI Mapper option from the Control Panel to edit the setup.";
1617 case MCIERR_SEQ_PORT_MISCERROR
:
1618 msgptr
= "An error occurred with the specified port.";
1620 case MCIERR_SEQ_PORT_NONEXISTENT
:
1621 msgptr
= "The specified MIDI device is not installed on the system. Use the Drivers option from the Control Panel to install a MIDI device.";
1623 case MCIERR_SEQ_PORTUNSPECIFIED
:
1624 msgptr
= "The system doesnot have a current MIDI port specified.";
1626 case MCIERR_SEQ_TIMER
:
1627 msgptr
= "All multimedia timers are being used by other applications. Quit one of these applications; then, try again.";
1632 msg# 514 : videodisc
1637 msg# 519 : animation
1638 msg# 520 : digitalvideo
1640 msg# 522 : waveaudio
1641 msg# 523 : sequencer
1642 msg# 524 : not ready
1645 msg# 527 : recording
1651 msg# 533 : milliseconds
1658 msg# 540 : smpte 30 drop
1664 TRACE("Unknown MCI Error %ld!\n", dwError
);
1667 lstrcpynA(lpstrBuffer
, msgptr
, uLength
);
1668 TRACE("msg = \"%s\";\n", lpstrBuffer
);
1672 /**************************************************************************
1673 * mciDriverNotify [MMSYSTEM.711]
1675 BOOL16 WINAPI
mciDriverNotify16(HWND16 hWndCallBack
, UINT16 wDevID
, UINT16 wStatus
)
1677 TRACE("(%04X, %04x, %04X)\n", hWndCallBack
, wDevID
, wStatus
);
1679 if (!IsWindow(hWndCallBack
)) {
1680 WARN("bad hWnd for call back (0x%04x)\n", hWndCallBack
);
1683 TRACE("before PostMessage\n");
1684 Callout
.PostMessageA(hWndCallBack
, MM_MCINOTIFY
, wStatus
, wDevID
);
1688 /**************************************************************************
1689 * mciDriverNotify [WINMM.36]
1691 BOOL WINAPI
mciDriverNotify(HWND hWndCallBack
, UINT wDevID
, UINT wStatus
)
1694 TRACE("(%08X, %04x, %04X)\n", hWndCallBack
, wDevID
, wStatus
);
1696 if (!IsWindow(hWndCallBack
)) {
1697 WARN("bad hWnd for call back (0x%04x)\n", hWndCallBack
);
1700 TRACE("before PostMessage\n");
1701 Callout
.PostMessageA(hWndCallBack
, MM_MCINOTIFY
, wStatus
, wDevID
);
1705 /**************************************************************************
1706 * mciGetDriverData [MMSYSTEM.708]
1708 DWORD WINAPI
mciGetDriverData16(UINT16 uDeviceID
)
1710 return mciGetDriverData(uDeviceID
);
1713 /**************************************************************************
1714 * mciGetDriverData [WINMM.44]
1716 DWORD WINAPI
mciGetDriverData(UINT uDeviceID
)
1718 TRACE("(%04x)\n", uDeviceID
);
1719 if (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0) {
1720 WARN("Bad uDeviceID\n");
1724 return MCI_GetDrv(uDeviceID
)->dwPrivate
;
1727 /**************************************************************************
1728 * mciSetDriverData [MMSYSTEM.707]
1730 BOOL16 WINAPI
mciSetDriverData16(UINT16 uDeviceID
, DWORD data
)
1732 return mciSetDriverData(uDeviceID
, data
);
1735 /**************************************************************************
1736 * mciSetDriverData [WINMM.53]
1738 BOOL WINAPI
mciSetDriverData(UINT uDeviceID
, DWORD data
)
1740 TRACE("(%04x, %08lx)\n", uDeviceID
, data
);
1741 if (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0) {
1742 WARN("Bad uDeviceID\n");
1746 MCI_GetDrv(uDeviceID
)->dwPrivate
= data
;
1750 /**************************************************************************
1751 * mciLoadCommandResource [MMSYSTEM.705]
1753 UINT16 WINAPI
mciLoadCommandResource16(HANDLE16 hinst
, LPCSTR resname
, UINT16 type
)
1763 static UINT16 mcidevtype
= 0;
1765 FIXME("(%04x, %s, %d): stub!\n", hinst
, resname
, type
);
1766 if (!lstrcmpiA(resname
, "core")) {
1767 FIXME("(...,\"core\",...), have to use internal tables... (not there yet)\n");
1770 return ++mcidevtype
;
1771 /* if file exists "resname.mci", then load resource "resname" from it
1772 * otherwise directly from driver
1774 strcpy(buf
,resname
);
1775 strcat(buf
, ".mci");
1776 if (OpenFile(buf
, &ofs
, OF_EXIST
) != HFILE_ERROR
) {
1777 xhinst
= LoadLibrary16(buf
);
1780 } /* else use passed hinst */
1781 segstr
= SEGPTR_STRDUP(resname
);
1782 hrsrc
= FindResource16(hinst
, SEGPTR_GET(segstr
), type
);
1783 SEGPTR_FREE(segstr
);
1785 WARN("no special commandlist found in resource\n");
1786 return MCI_NO_COMMAND_TABLE
;
1788 hmem
= LoadResource16(hinst
, hrsrc
);
1790 WARN("couldn't load resource??\n");
1791 return MCI_NO_COMMAND_TABLE
;
1793 xmem
= WIN16_LockResource16(hmem
);
1795 WARN("couldn't lock resource??\n");
1796 FreeResource16(hmem
);
1797 return MCI_NO_COMMAND_TABLE
;
1799 lmem
= PTR_SEG_TO_LIN(xmem
);
1800 TRACE("first resource entry is %s\n", (char*)lmem
);
1801 /* parse resource, register stuff, return unique id */
1802 return ++mcidevtype
;
1805 /**************************************************************************
1806 * mciFreeCommandResource [MMSYSTEM.713]
1808 BOOL16 WINAPI
mciFreeCommandResource16(UINT16 uTable
)
1810 FIXME("(%04x) stub\n", uTable
);
1814 /**************************************************************************
1815 * mciFreeCommandResource [WINMM.39]
1817 BOOL WINAPI
mciFreeCommandResource(UINT uTable
)
1819 FIXME("(%08x) stub\n", uTable
);
1823 /**************************************************************************
1824 * mciLoadCommandResource [WINMM.48]
1826 UINT WINAPI
mciLoadCommandResource(HANDLE hinst
, LPCWSTR resname
, UINT type
)
1828 FIXME("(%04x, %s, %d): stub!\n", hinst
, debugstr_w(resname
), type
);
1832 /**************************************************************************
1833 * mciSendCommandA [WINMM.49]
1835 DWORD WINAPI
mciSendCommandA(UINT wDevID
, UINT wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1839 TRACE("(%08x, %s, %08lx, %08lx)\n", wDevID
, MCI_CommandToString(wMsg
), dwParam1
, dwParam2
);
1843 dwRet
= MCI_Open(dwParam1
, (LPMCI_OPEN_PARMSA
)dwParam2
);
1846 dwRet
= MCI_Close(wDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)dwParam2
);
1849 dwRet
= MCI_SysInfo(wDevID
, dwParam1
, (LPMCI_SYSINFO_PARMSA
)dwParam2
);
1852 dwRet
= MCI_Break(wDevID
, dwParam1
, (LPMCI_BREAK_PARMS
)dwParam2
);
1854 /* FIXME: it seems that MCI_BREAK and MCI_SOUND need the same handling */
1856 if (wDevID
== MCI_ALL_DEVICE_ID
) {
1857 FIXME("unhandled MCI_ALL_DEVICE_ID\n");
1858 dwRet
= MCIERR_CANNOT_USE_ALL
;
1860 dwRet
= MCI_SendCommandFrom32(wDevID
, wMsg
, dwParam1
, dwParam2
);
1864 dwRet
= MCI_CleanUp(dwRet
, wMsg
, dwParam2
, TRUE
);
1865 TRACE("=> %08lx\n", dwRet
);
1869 /**************************************************************************
1870 * mciSendCommandW [WINMM.50]
1872 DWORD WINAPI
mciSendCommandW(UINT wDevID
, UINT wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1874 FIXME("(%08x, %s, %08lx, %08lx): stub\n", wDevID
, MCI_CommandToString(wMsg
), dwParam1
, dwParam2
);
1875 return MCIERR_UNSUPPORTED_FUNCTION
;
1878 /**************************************************************************
1879 * mciSendCommand [MMSYSTEM.701]
1881 DWORD WINAPI
mciSendCommand16(UINT16 wDevID
, UINT16 wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1883 DWORD dwRet
= MCIERR_UNRECOGNIZED_COMMAND
;
1885 TRACE("(%04X, %s, %08lX, %08lX)\n",
1886 wDevID
, MCI_CommandToString(wMsg
), dwParam1
, dwParam2
);
1890 switch (MCI_MapMsg16To32A(MCI_GetDrv(wDevID
)->modp
.wType
, wMsg
, &dwParam2
)) {
1893 dwRet
= MCI_Open(dwParam1
, (LPMCI_OPEN_PARMSA
)dwParam2
);
1894 MCI_UnMapMsg16To32A(MCI_GetDrv(wDevID
)->modp
.wType
, wMsg
, dwParam2
);
1896 default: break; /* so that gcc does not bark */
1900 if (wDevID
== MCI_ALL_DEVICE_ID
) {
1901 FIXME("unhandled MCI_ALL_DEVICE_ID\n");
1902 dwRet
= MCIERR_CANNOT_USE_ALL
;
1903 } else if (!MCI_DevIDValid(wDevID
)) {
1904 dwRet
= MCIERR_INVALID_DEVICE_ID
;
1906 switch (MCI_MapMsg16To32A(MCI_GetDrv(wDevID
)->modp
.wType
, wMsg
, &dwParam2
)) {
1909 dwRet
= MCI_Close(wDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)dwParam2
);
1910 MCI_UnMapMsg16To32A(MCI_GetDrv(wDevID
)->modp
.wType
, wMsg
, dwParam2
);
1912 default: break; /* so that gcc does not bark */
1917 switch (MCI_MapMsg16To32A(0, wDevID
, &dwParam2
)) {
1920 dwRet
= MCI_SysInfo(wDevID
, dwParam1
, (LPMCI_SYSINFO_PARMSA
)dwParam2
);
1921 MCI_UnMapMsg16To32A(0, wDevID
, dwParam2
);
1923 default: break; /* so that gcc doesnot bark */
1927 switch (MCI_MapMsg16To32A(0, wDevID
, &dwParam2
)) {
1930 dwRet
= MCI_Break(wDevID
, dwParam1
, (LPMCI_BREAK_PARMS
)dwParam2
);
1931 MCI_UnMapMsg16To32A(0, wDevID
, dwParam2
);
1933 default: break; /* so that gcc does not bark */
1937 /* FIXME: it seems that MCI_BREAK and MCI_SOUND need the same handling */
1939 if (wDevID
== MCI_ALL_DEVICE_ID
) {
1940 FIXME("unhandled MCI_ALL_DEVICE_ID\n");
1941 dwRet
= MCIERR_CANNOT_USE_ALL
;
1943 dwRet
= MCI_SendCommandFrom16(wDevID
, wMsg
, dwParam1
, dwParam2
);
1947 dwRet
= MCI_CleanUp(dwRet
, wMsg
, dwParam2
, FALSE
);
1948 TRACE("=> %ld\n", dwRet
);
1952 /**************************************************************************
1953 * mciGetDeviceID [MMSYSTEM.703]
1955 UINT16 WINAPI
mciGetDeviceID16(LPCSTR lpstrName
)
1958 TRACE("(\"%s\")\n", lpstrName
);
1963 if (!lstrcmpiA(lpstrName
, "ALL"))
1964 return MCI_ALL_DEVICE_ID
;
1966 for (wDevID
= MCI_FirstDevID(); MCI_DevIDValid(wDevID
); wDevID
= MCI_NextDevID(wDevID
)) {
1967 if (MCI_GetDrv(wDevID
)->modp
.wType
) {
1968 FIXME("This is wrong for compound devices\n");
1969 /* FIXME: for compound devices, lpstrName is matched against
1970 * the name of the file, not the name of the device...
1972 if (MCI_GetOpenDrv(wDevID
)->lpstrDeviceType
&&
1973 strcmp(MCI_GetOpenDrv(wDevID
)->lpstrDeviceType
, lpstrName
) == 0)
1976 if (MCI_GetOpenDrv(wDevID
)->lpstrAlias
&&
1977 strcmp(MCI_GetOpenDrv(wDevID
)->lpstrAlias
, lpstrName
) == 0)
1985 /**************************************************************************
1986 * mciGetDeviceIDA [WINMM.41]
1988 UINT WINAPI
mciGetDeviceIDA(LPCSTR lpstrName
)
1990 return mciGetDeviceID16(lpstrName
);
1993 /**************************************************************************
1994 * mciGetDeviceIDW [WINMM.43]
1996 UINT WINAPI
mciGetDeviceIDW(LPCWSTR lpwstrName
)
2001 lpstrName
= HEAP_strdupWtoA(GetProcessHeap(), 0, lpwstrName
);
2002 ret
= mciGetDeviceID16(lpstrName
);
2003 HeapFree(GetProcessHeap(), 0, lpstrName
);
2007 /**************************************************************************
2008 * MCI_DefYieldProc [internal]
2010 UINT16 WINAPI
MCI_DefYieldProc(UINT16 wDevID
, DWORD data
)
2014 TRACE("(0x%04x, 0x%08lx)\n", wDevID
, data
);
2016 if ((HIWORD(data
) != 0 && GetActiveWindow16() != HIWORD(data
)) ||
2017 (GetAsyncKeyState(LOWORD(data
)) & 1) == 0) {
2023 msg
.hwnd
= HIWORD(data
);
2024 while (!PeekMessageA(&msg
, HIWORD(data
), WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
));
2030 /**************************************************************************
2031 * mciSetYieldProc [MMSYSTEM.714]
2033 BOOL16 WINAPI
mciSetYieldProc16(UINT16 uDeviceID
, YIELDPROC fpYieldProc
, DWORD dwYieldData
)
2035 TRACE("(%u, %p, %08lx)\n", uDeviceID
, fpYieldProc
, dwYieldData
);
2037 if (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0) {
2038 WARN("Bad uDeviceID\n");
2042 MCI_GetDrv(uDeviceID
)->lpfnYieldProc
= fpYieldProc
;
2043 MCI_GetDrv(uDeviceID
)->dwYieldData
= dwYieldData
;
2044 MCI_GetDrv(uDeviceID
)->bIs32
= FALSE
;
2049 /**************************************************************************
2050 * mciSetYieldProc [WINMM.54]
2052 BOOL WINAPI
mciSetYieldProc(UINT uDeviceID
, YIELDPROC fpYieldProc
, DWORD dwYieldData
)
2054 TRACE("(%u, %p, %08lx)\n", uDeviceID
, fpYieldProc
, dwYieldData
);
2056 if (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0) {
2057 WARN("Bad uDeviceID\n");
2061 MCI_GetDrv(uDeviceID
)->lpfnYieldProc
= fpYieldProc
;
2062 MCI_GetDrv(uDeviceID
)->dwYieldData
= dwYieldData
;
2063 MCI_GetDrv(uDeviceID
)->bIs32
= TRUE
;
2068 /**************************************************************************
2069 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
2071 UINT16 WINAPI
mciGetDeviceIDFromElementID16(DWORD dwElementID
, LPCSTR lpstrType
)
2073 FIXME("(%lu, %s) stub\n", dwElementID
, lpstrType
);
2077 /**************************************************************************
2078 * mciGetDeviceIDFromElementIDW [WINMM.42]
2080 UINT WINAPI
mciGetDeviceIDFromElementIDW(DWORD dwElementID
, LPCWSTR lpstrType
)
2082 /* FIXME: that's rather strange, there is no
2083 * mciGetDeviceIDFromElementID32A in winmm.spec
2085 FIXME("(%lu, %p) stub\n", dwElementID
, lpstrType
);
2089 /**************************************************************************
2090 * mciGetYieldProc [MMSYSTEM.716]
2092 YIELDPROC WINAPI
mciGetYieldProc16(UINT16 uDeviceID
, DWORD
* lpdwYieldData
)
2094 TRACE("(%u, %p)\n", uDeviceID
, lpdwYieldData
);
2096 if (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0) {
2097 WARN("Bad uDeviceID\n");
2100 if (!MCI_GetDrv(uDeviceID
)->lpfnYieldProc
) {
2101 WARN("No proc set\n");
2104 if (MCI_GetDrv(uDeviceID
)->bIs32
) {
2105 WARN("Proc is 32 bit\n");
2108 return MCI_GetDrv(uDeviceID
)->lpfnYieldProc
;
2111 /**************************************************************************
2112 * mciGetYieldProc [WINMM.47]
2114 YIELDPROC WINAPI
mciGetYieldProc(UINT uDeviceID
, DWORD
* lpdwYieldData
)
2116 TRACE("(%u, %p)\n", uDeviceID
, lpdwYieldData
);
2118 if (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0) {
2119 WARN("Bad uDeviceID\n");
2122 if (!MCI_GetDrv(uDeviceID
)->lpfnYieldProc
) {
2123 WARN("No proc set\n");
2126 if (!MCI_GetDrv(uDeviceID
)->bIs32
) {
2127 WARN("Proc is 32 bit\n");
2130 return MCI_GetDrv(uDeviceID
)->lpfnYieldProc
;
2133 /**************************************************************************
2134 * mciGetCreatorTask [MMSYSTEM.717]
2136 HTASK16 WINAPI
mciGetCreatorTask16(UINT16 uDeviceID
)
2138 return mciGetCreatorTask(uDeviceID
);
2141 /**************************************************************************
2142 * mciGetCreatorTask [WINMM.40]
2144 HTASK WINAPI
mciGetCreatorTask(UINT uDeviceID
)
2148 TRACE("(%u)\n", uDeviceID
);
2150 ret
= (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0) ?
2151 0 : MCI_GetDrv(uDeviceID
)->hCreatorTask
;
2153 TRACE("=> %04x\n", ret
);
2157 /**************************************************************************
2158 * mciDriverYield [MMSYSTEM.710]
2160 UINT16 WINAPI
mciDriverYield16(UINT16 uDeviceID
)
2164 /* TRACE("(%04x)\n", uDeviceID); */
2166 if (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0 ||
2167 !MCI_GetDrv(uDeviceID
)->lpfnYieldProc
|| MCI_GetDrv(uDeviceID
)->bIs32
) {
2170 ret
= MCI_GetDrv(uDeviceID
)->lpfnYieldProc(uDeviceID
, MCI_GetDrv(uDeviceID
)->dwYieldData
);
2176 /**************************************************************************
2177 * mciDriverYield [WINMM.37]
2179 UINT WINAPI
mciDriverYield(UINT uDeviceID
)
2183 TRACE("(%04x)\n", uDeviceID
);
2184 if (!MCI_DevIDValid(uDeviceID
) || MCI_GetDrv(uDeviceID
)->modp
.wType
== 0 ||
2185 !MCI_GetDrv(uDeviceID
)->lpfnYieldProc
|| !MCI_GetDrv(uDeviceID
)->bIs32
) {
2188 ret
= MCI_GetDrv(uDeviceID
)->lpfnYieldProc(uDeviceID
, MCI_GetDrv(uDeviceID
)->dwYieldData
);
2194 /**************************************************************************
2195 * midiOutGetNumDevs [WINMM.80]
2197 UINT WINAPI
midiOutGetNumDevs(void)
2199 return midiOutGetNumDevs16();
2202 /**************************************************************************
2203 * midiOutGetNumDevs [MMSYSTEM.201]
2205 UINT16 WINAPI
midiOutGetNumDevs16(void)
2207 UINT16 count
= modMessage(0, MODM_GETNUMDEVS
, 0L, 0L, 0L);
2209 TRACE("returns %u\n", count
);
2213 /**************************************************************************
2214 * midiOutGetDevCapsW [WINMM.76]
2216 UINT WINAPI
midiOutGetDevCapsW(UINT uDeviceID
, LPMIDIOUTCAPSW lpCaps
, UINT uSize
)
2218 MIDIOUTCAPS16 moc16
;
2221 ret
= midiOutGetDevCaps16(uDeviceID
, &moc16
, sizeof(moc16
));
2222 lpCaps
->wMid
= moc16
.wMid
;
2223 lpCaps
->wPid
= moc16
.wPid
;
2224 lpCaps
->vDriverVersion
= moc16
.vDriverVersion
;
2225 lstrcpyAtoW(lpCaps
->szPname
, moc16
.szPname
);
2226 lpCaps
->wTechnology
= moc16
.wTechnology
;
2227 lpCaps
->wVoices
= moc16
.wVoices
;
2228 lpCaps
->wNotes
= moc16
.wNotes
;
2229 lpCaps
->wChannelMask
= moc16
.wChannelMask
;
2230 lpCaps
->dwSupport
= moc16
.dwSupport
;
2234 /**************************************************************************
2235 * midiOutGetDevCapsA [WINMM.75]
2237 UINT WINAPI
midiOutGetDevCapsA(UINT uDeviceID
, LPMIDIOUTCAPSA lpCaps
, UINT uSize
)
2239 MIDIOUTCAPS16 moc16
;
2242 ret
= midiOutGetDevCaps16(uDeviceID
, &moc16
, sizeof(moc16
));
2243 lpCaps
->wMid
= moc16
.wMid
;
2244 lpCaps
->wPid
= moc16
.wPid
;
2245 lpCaps
->vDriverVersion
= moc16
.vDriverVersion
;
2246 strcpy(lpCaps
->szPname
, moc16
.szPname
);
2247 lpCaps
->wTechnology
= moc16
.wTechnology
;
2248 lpCaps
->wVoices
= moc16
.wVoices
;
2249 lpCaps
->wNotes
= moc16
.wNotes
;
2250 lpCaps
->wChannelMask
= moc16
.wChannelMask
;
2251 lpCaps
->dwSupport
= moc16
.dwSupport
;
2255 /**************************************************************************
2256 * midiOutGetDevCaps [MMSYSTEM.202]
2258 UINT16 WINAPI
midiOutGetDevCaps16(UINT16 uDeviceID
, LPMIDIOUTCAPS16 lpCaps
, UINT16 uSize
)
2260 TRACE("midiOutGetDevCaps\n");
2261 return modMessage(uDeviceID
, MODM_GETDEVCAPS
, 0, (DWORD
)lpCaps
, uSize
);
2264 /**************************************************************************
2265 * midiOutGetErrorTextA [WINMM.77]
2267 UINT WINAPI
midiOutGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
2269 TRACE("midiOutGetErrorText\n");
2270 return midiGetErrorText(uError
, lpText
, uSize
);
2273 /**************************************************************************
2274 * midiOutGetErrorTextW [WINMM.78]
2276 UINT WINAPI
midiOutGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
2278 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
2281 TRACE("midiOutGetErrorText\n");
2282 ret
= midiGetErrorText(uError
, xstr
, uSize
);
2283 lstrcpyAtoW(lpText
, xstr
);
2284 HeapFree(GetProcessHeap(), 0, xstr
);
2288 /**************************************************************************
2289 * midiOutGetErrorText [MMSYSTEM.203]
2291 UINT16 WINAPI
midiOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2293 TRACE("midiOutGetErrorText\n");
2294 return midiGetErrorText(uError
, lpText
, uSize
);
2297 /**************************************************************************
2298 * midiGetErrorText [internal]
2300 UINT16 WINAPI
midiGetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2303 if ((lpText
== NULL
) || (uSize
< 1)) return(FALSE
);
2306 case MIDIERR_UNPREPARED
:
2307 msgptr
= "The MIDI header was not prepared. Use the Prepare function to prepare the header, and then try again.";
2309 case MIDIERR_STILLPLAYING
:
2310 msgptr
= "Cannot perform this operation while media data is still playing. Reset the device, or wait until the data is finished playing.";
2313 msgptr
= "A MIDI map was not found. There may be a problem with the driver, or the MIDIMAP.CFG file may be corrupt or missing.";
2315 case MIDIERR_NOTREADY
:
2316 msgptr
= "The port is transmitting data to the device. Wait until the data has been transmitted, and then try again.";
2318 case MIDIERR_NODEVICE
:
2319 msgptr
= "The current MIDI Mapper setup refers to a MIDI device that is not installed on the system. Use MIDI Mapper to edit the setup.";
2321 case MIDIERR_INVALIDSETUP
:
2322 msgptr
= "The current MIDI setup is damaged. Copy the original MIDIMAP.CFG file to the Windows SYSTEM directory, and then try again.";
2325 msg# 336 : Cannot use the song-pointer time format and the SMPTE time-format together.
2326 msg# 337 : The specified MIDI device is already in use. Wait until it is free, and then try again.
2327 msg# 338 : The specified MIDI device is not installed on the system. Use the Drivers option in Control Panel to install the driver.
2328 msg# 339 : The current MIDI Mapper setup refers to a MIDI device that is not installed on the system. Use MIDI Mapper to edit the setup.
2329 msg# 340 : An error occurred using the specified port.
2330 msg# 341 : All multimedia timers are being used by other applications. Quit one of these applications, and then try again.
2331 msg# 342 : There is no current MIDI port.
2332 msg# 343 : There are no MIDI devices installed on the system. Use the Drivers option in Control Panel to install the driver.
2335 msgptr
= "Unknown MIDI Error !\n";
2338 lstrcpynA(lpText
, msgptr
, uSize
);
2342 static LPMIDIOPENDESC
MIDI_OutAlloc(HMIDIOUT16
* lphMidiOut
, DWORD dwCallback
,
2343 DWORD dwInstance
, DWORD cIDs
, MIDIOPENSTRMID
* lpIDs
)
2346 LPMIDIOPENDESC lpDesc
;
2348 hMidiOut
= USER_HEAP_ALLOC(sizeof(MIDIOPENDESC
) + (cIDs
? (cIDs
- 1) : 0) * sizeof(MIDIOPENSTRMID
));
2350 if (lphMidiOut
!= NULL
)
2351 *lphMidiOut
= hMidiOut
;
2352 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiOut
);
2355 lpDesc
->hMidi
= hMidiOut
;
2356 lpDesc
->dwCallback
= dwCallback
;
2357 lpDesc
->dwInstance
= dwInstance
;
2358 lpDesc
->dnDevNode
= 0;
2359 lpDesc
->cIds
= cIDs
;
2361 memcpy(&(lpDesc
->rgIds
), lpIDs
, cIDs
* sizeof(MIDIOPENSTRMID
));
2366 /**************************************************************************
2367 * midiOutOpen [WINM.84]
2369 UINT WINAPI
midiOutOpen(HMIDIOUT
* lphMidiOut
, UINT uDeviceID
,
2370 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2375 ret
= midiOutOpen16(&hmo16
, uDeviceID
, dwCallback
, dwInstance
,
2376 CALLBACK32CONV(dwFlags
));
2377 if (lphMidiOut
) *lphMidiOut
= hmo16
;
2381 /**************************************************************************
2382 * midiOutOpen [MMSYSTEM.204]
2384 UINT16 WINAPI
midiOutOpen16(HMIDIOUT16
* lphMidiOut
, UINT16 uDeviceID
,
2385 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2387 HMIDIOUT16 hMidiOut
;
2388 LPMIDIOPENDESC lpDesc
;
2390 BOOL bMapperFlg
= FALSE
;
2392 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2393 lphMidiOut
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
2395 if (lphMidiOut
!= NULL
) *lphMidiOut
= 0;
2397 if (uDeviceID
== (UINT16
)MIDI_MAPPER
) {
2398 TRACE("MIDI_MAPPER mode requested !\n");
2403 lpDesc
= MIDI_OutAlloc(&hMidiOut
, dwCallback
, dwInstance
, 0, NULL
);
2406 return MMSYSERR_NOMEM
;
2408 while (uDeviceID
< MAXMIDIDRIVERS
) {
2409 ret
= modMessage(uDeviceID
, MODM_OPEN
,
2410 lpDesc
->dwInstance
, (DWORD
)lpDesc
, dwFlags
);
2411 if (ret
== MMSYSERR_NOERROR
) break;
2412 if (!bMapperFlg
) break;
2414 TRACE("MIDI_MAPPER mode ! try next driver...\n");
2416 TRACE("=> wDevID=%u (%d)\n", uDeviceID
, ret
);
2417 if (ret
!= MMSYSERR_NOERROR
) {
2418 USER_HEAP_FREE(hMidiOut
);
2419 if (lphMidiOut
) *lphMidiOut
= 0;
2421 lpDesc
->wDevID
= uDeviceID
;
2422 if (lphMidiOut
) *lphMidiOut
= hMidiOut
;
2428 /**************************************************************************
2429 * midiOutClose [WINMM.74]
2431 UINT WINAPI
midiOutClose(HMIDIOUT hMidiOut
)
2433 return midiOutClose16(hMidiOut
);
2436 /**************************************************************************
2437 * midiOutClose [MMSYSTEM.205]
2439 UINT16 WINAPI
midiOutClose16(HMIDIOUT16 hMidiOut
)
2441 LPMIDIOPENDESC lpDesc
;
2444 TRACE("(%04X)\n", hMidiOut
);
2446 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiOut
);
2448 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
2449 dwRet
= modMessage(lpDesc
->wDevID
, MODM_CLOSE
, lpDesc
->dwInstance
, 0L, 0L);
2450 USER_HEAP_FREE(hMidiOut
);
2454 /**************************************************************************
2455 * midiOutPrepareHeader [WINMM.85]
2457 UINT WINAPI
midiOutPrepareHeader(HMIDIOUT hMidiOut
,
2458 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2460 LPMIDIOPENDESC lpDesc
;
2462 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2464 lpDesc
= (LPMIDIOPENDESC
)USER_HEAP_LIN_ADDR(hMidiOut
);
2466 return MMSYSERR_INVALHANDLE
;
2467 lpMidiOutHdr
->reserved
= (DWORD
)lpMidiOutHdr
;
2468 return modMessage(lpDesc
->wDevID
, MODM_PREPARE
, lpDesc
->dwInstance
,
2469 (DWORD
)lpMidiOutHdr
, (DWORD
)uSize
);
2472 /**************************************************************************
2473 * midiOutPrepareHeader [MMSYSTEM.206]
2475 UINT16 WINAPI
midiOutPrepareHeader16(HMIDIOUT16 hMidiOut
,
2476 LPMIDIHDR16
/*SEGPTR*/ _lpMidiOutHdr
, UINT16 uSize
)
2478 LPMIDIOPENDESC lpDesc
;
2479 LPMIDIHDR16 lpMidiOutHdr
= (LPMIDIHDR16
)PTR_SEG_TO_LIN(_lpMidiOutHdr
);
2481 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2483 lpDesc
= (LPMIDIOPENDESC
)USER_HEAP_LIN_ADDR(hMidiOut
);
2485 return MMSYSERR_INVALHANDLE
;
2486 lpMidiOutHdr
->reserved
= (DWORD
)_lpMidiOutHdr
;
2487 return modMessage(lpDesc
->wDevID
, MODM_PREPARE
, lpDesc
->dwInstance
,
2488 (DWORD
)lpMidiOutHdr
, (DWORD
)uSize
);
2491 /**************************************************************************
2492 * midiOutUnprepareHeader [WINMM.89]
2494 UINT WINAPI
midiOutUnprepareHeader(HMIDIOUT hMidiOut
,
2495 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2497 return midiOutUnprepareHeader16(hMidiOut
, (MIDIHDR16
*)lpMidiOutHdr
, uSize
);
2500 /**************************************************************************
2501 * midiOutUnprepareHeader [MMSYSTEM.207]
2503 UINT16 WINAPI
midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut
,
2504 MIDIHDR16
* lpMidiOutHdr
, UINT16 uSize
)
2506 LPMIDIOPENDESC lpDesc
;
2508 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2510 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiOut
);
2511 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
2512 return modMessage(lpDesc
->wDevID
, MODM_UNPREPARE
, lpDesc
->dwInstance
,
2513 (DWORD
)lpMidiOutHdr
, (DWORD
)uSize
);
2516 /**************************************************************************
2517 * midiOutShortMsg [WINMM.88]
2519 UINT WINAPI
midiOutShortMsg(HMIDIOUT hMidiOut
, DWORD dwMsg
)
2521 return midiOutShortMsg16(hMidiOut
, dwMsg
);
2524 /**************************************************************************
2525 * midiOutShortMsg [MMSYSTEM.208]
2527 UINT16 WINAPI
midiOutShortMsg16(HMIDIOUT16 hMidiOut
, DWORD dwMsg
)
2529 LPMIDIOPENDESC lpDesc
;
2531 TRACE("(%04X, %08lX)\n", hMidiOut
, dwMsg
);
2533 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiOut
);
2534 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
2535 return modMessage(lpDesc
->wDevID
, MODM_DATA
, lpDesc
->dwInstance
, dwMsg
, 0L);
2538 /**************************************************************************
2539 * midiOutLongMsg [WINMM.82]
2541 UINT WINAPI
midiOutLongMsg(HMIDIOUT hMidiOut
,
2542 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2544 return midiOutLongMsg16(hMidiOut
, (MIDIHDR16
*)lpMidiOutHdr
, uSize
);
2547 /**************************************************************************
2548 * midiOutLongMsg [MMSYSTEM.209]
2550 UINT16 WINAPI
midiOutLongMsg16(HMIDIOUT16 hMidiOut
,
2551 MIDIHDR16
* lpMidiOutHdr
, UINT16 uSize
)
2553 LPMIDIOPENDESC lpDesc
;
2555 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2557 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiOut
);
2558 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
2559 return modMessage(lpDesc
->wDevID
, MODM_LONGDATA
, lpDesc
->dwInstance
,
2560 (DWORD
)lpMidiOutHdr
, (DWORD
)uSize
);
2563 /**************************************************************************
2564 * midiOutReset [WINMM.86]
2566 UINT WINAPI
midiOutReset(HMIDIOUT hMidiOut
)
2568 return midiOutReset16(hMidiOut
);
2571 /**************************************************************************
2572 * midiOutReset [MMSYSTEM.210]
2574 UINT16 WINAPI
midiOutReset16(HMIDIOUT16 hMidiOut
)
2576 LPMIDIOPENDESC lpDesc
;
2578 TRACE("(%04X)\n", hMidiOut
);
2580 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiOut
);
2581 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
2582 return modMessage(lpDesc
->wDevID
, MODM_RESET
, lpDesc
->dwInstance
, 0L, 0L);
2585 /**************************************************************************
2586 * midiOutGetVolume [WINM.81]
2588 UINT WINAPI
midiOutGetVolume(UINT uDeviceID
, DWORD
* lpdwVolume
)
2590 return midiOutGetVolume16(uDeviceID
, lpdwVolume
);
2593 /**************************************************************************
2594 * midiOutGetVolume [MMSYSTEM.211]
2596 UINT16 WINAPI
midiOutGetVolume16(UINT16 uDeviceID
, DWORD
* lpdwVolume
)
2598 TRACE("(%04X, %p);\n", uDeviceID
, lpdwVolume
);
2599 return modMessage(uDeviceID
, MODM_GETVOLUME
, 0L, (DWORD
)lpdwVolume
, 0L);
2602 /**************************************************************************
2603 * midiOutSetVolume [WINMM.87]
2605 UINT WINAPI
midiOutSetVolume(UINT uDeviceID
, DWORD dwVolume
)
2607 return midiOutSetVolume16(uDeviceID
, dwVolume
);
2610 /**************************************************************************
2611 * midiOutSetVolume [MMSYSTEM.212]
2613 UINT16 WINAPI
midiOutSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
2615 TRACE("(%04X, %08lX);\n", uDeviceID
, dwVolume
);
2616 return modMessage(uDeviceID
, MODM_SETVOLUME
, 0L, dwVolume
, 0L);
2619 /**************************************************************************
2620 * midiOutCachePatches [WINMM.73]
2622 UINT WINAPI
midiOutCachePatches(HMIDIOUT hMidiOut
, UINT uBank
,
2623 WORD
* lpwPatchArray
, UINT uFlags
)
2625 return midiOutCachePatches16(hMidiOut
, uBank
, lpwPatchArray
, uFlags
);
2628 /**************************************************************************
2629 * midiOutCachePatches [MMSYSTEM.213]
2631 UINT16 WINAPI
midiOutCachePatches16(HMIDIOUT16 hMidiOut
, UINT16 uBank
,
2632 WORD
* lpwPatchArray
, UINT16 uFlags
)
2634 /* not really necessary to support this */
2635 FIXME("not supported yet\n");
2636 return MMSYSERR_NOTSUPPORTED
;
2639 /**************************************************************************
2640 * midiOutCacheDrumPatches [WINMM.72]
2642 UINT WINAPI
midiOutCacheDrumPatches(HMIDIOUT hMidiOut
, UINT uPatch
,
2643 WORD
* lpwKeyArray
, UINT uFlags
)
2645 return midiOutCacheDrumPatches16(hMidiOut
, uPatch
, lpwKeyArray
, uFlags
);
2648 /**************************************************************************
2649 * midiOutCacheDrumPatches [MMSYSTEM.214]
2651 UINT16 WINAPI
midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut
, UINT16 uPatch
,
2652 WORD
* lpwKeyArray
, UINT16 uFlags
)
2654 FIXME("not supported yet\n");
2655 return MMSYSERR_NOTSUPPORTED
;
2658 /**************************************************************************
2659 * midiOutGetID [WINMM.79]
2661 UINT WINAPI
midiOutGetID(HMIDIOUT hMidiOut
, UINT
* lpuDeviceID
)
2666 ret
= midiOutGetID16(hMidiOut
, &xid
);
2671 /**************************************************************************
2672 * midiOutGetID [MMSYSTEM.215]
2674 UINT16 WINAPI
midiOutGetID16(HMIDIOUT16 hMidiOut
, UINT16
* lpuDeviceID
)
2676 TRACE("midiOutGetID\n");
2680 /**************************************************************************
2681 * midiOutMessage [WINMM.83]
2683 DWORD WINAPI
midiOutMessage(HMIDIOUT hMidiOut
, UINT uMessage
,
2684 DWORD dwParam1
, DWORD dwParam2
)
2686 LPMIDIOPENDESC lpDesc
;
2688 /* Shouldn't we anyway use the functions midiOutXXX ?
2689 * M$ doc says: This function is used only for driver-specific
2690 * messages that are not supported by the MIDI API.
2691 * Clearly not what we are currently doing
2694 TRACE("(%04X, %04X, %08lX, %08lX)\n",
2695 hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2697 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiOut
);
2698 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
2701 FIXME("can't handle MODM_OPEN!\n");
2703 case MODM_GETDEVCAPS
:
2704 return midiOutGetDevCapsA(hMidiOut
, (LPMIDIOUTCAPSA
)dwParam1
, dwParam2
);
2705 case MODM_GETNUMDEVS
:
2708 case MODM_GETVOLUME
:
2709 case MODM_SETVOLUME
:
2712 case MODM_UNPREPARE
:
2713 /* no argument conversion needed */
2716 ERR("(%04x, %04x, %08lx, %08lx): unhandled message\n",
2717 hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2720 return modMessage(lpDesc
->wDevID
, uMessage
, lpDesc
->dwInstance
, dwParam1
, dwParam2
);
2723 /**************************************************************************
2724 * midiOutMessage [MMSYSTEM.216]
2726 DWORD WINAPI
midiOutMessage16(HMIDIOUT16 hMidiOut
, UINT16 uMessage
,
2727 DWORD dwParam1
, DWORD dwParam2
)
2729 LPMIDIOPENDESC lpDesc
;
2731 TRACE("(%04X, %04X, %08lX, %08lX)\n",
2732 hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2733 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiOut
);
2734 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
2737 FIXME("can't handle MODM_OPEN!\n");
2739 case MODM_GETNUMDEVS
:
2742 case MODM_SETVOLUME
:
2743 /* no argument conversion needed */
2745 case MODM_GETVOLUME
:
2746 return midiOutGetVolume16(hMidiOut
, (LPDWORD
)PTR_SEG_TO_LIN(dwParam1
));
2748 return midiOutLongMsg16(hMidiOut
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2750 /* lpMidiOutHdr is still a segmented pointer for this function */
2751 return midiOutPrepareHeader16(hMidiOut
, (LPMIDIHDR16
)dwParam1
, dwParam2
);
2752 case MODM_UNPREPARE
:
2753 return midiOutUnprepareHeader16(hMidiOut
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2755 ERR("(%04x, %04x, %08lx, %08lx): unhandled message\n",
2756 hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2759 return modMessage(lpDesc
->wDevID
, uMessage
, lpDesc
->dwInstance
, dwParam1
, dwParam2
);
2762 /**************************************************************************
2763 * midiInGetNumDevs [WINMM.64]
2765 UINT WINAPI
midiInGetNumDevs(void)
2767 return midiInGetNumDevs16();
2770 /**************************************************************************
2771 * midiInGetNumDevs [MMSYSTEM.301]
2773 UINT16 WINAPI
midiInGetNumDevs16(void)
2776 TRACE("midiInGetNumDevs\n");
2777 count
+= midMessage(0, MIDM_GETNUMDEVS
, 0L, 0L, 0L);
2778 TRACE("midiInGetNumDevs return %u \n", count
);
2782 /**************************************************************************
2783 * midiInGetDevCaps [WINMM.60]
2785 UINT WINAPI
midiInGetDevCapsW(UINT uDeviceID
, LPMIDIINCAPSW lpCaps
, UINT uSize
)
2788 UINT ret
= midiInGetDevCaps16(uDeviceID
, &mic16
, uSize
);
2790 lpCaps
->wMid
= mic16
.wMid
;
2791 lpCaps
->wPid
= mic16
.wPid
;
2792 lpCaps
->vDriverVersion
= mic16
.vDriverVersion
;
2793 lstrcpyAtoW(lpCaps
->szPname
, mic16
.szPname
);
2794 lpCaps
->dwSupport
= mic16
.dwSupport
;
2798 /**************************************************************************
2799 * midiInGetDevCaps [WINMM.59]
2801 UINT WINAPI
midiInGetDevCapsA(UINT uDeviceID
, LPMIDIINCAPSA lpCaps
, UINT uSize
)
2804 UINT ret
= midiInGetDevCaps16(uDeviceID
, &mic16
, uSize
);
2806 lpCaps
->wMid
= mic16
.wMid
;
2807 lpCaps
->wPid
= mic16
.wPid
;
2808 lpCaps
->vDriverVersion
= mic16
.vDriverVersion
;
2809 strcpy(lpCaps
->szPname
, mic16
.szPname
);
2810 lpCaps
->dwSupport
= mic16
.dwSupport
;
2814 /**************************************************************************
2815 * midiInGetDevCaps [MMSYSTEM.302]
2817 UINT16 WINAPI
midiInGetDevCaps16(UINT16 uDeviceID
,
2818 LPMIDIINCAPS16 lpCaps
, UINT16 uSize
)
2820 TRACE("midiInGetDevCaps\n");
2821 return midMessage(uDeviceID
, MIDM_GETDEVCAPS
, 0, (DWORD
)lpCaps
, uSize
);
2824 /**************************************************************************
2825 * midiInGetErrorText [WINMM.62]
2827 UINT WINAPI
midiInGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
2829 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
2830 UINT ret
= midiInGetErrorText16(uError
, xstr
, uSize
);
2831 lstrcpyAtoW(lpText
, xstr
);
2832 HeapFree(GetProcessHeap(), 0, xstr
);
2836 /**************************************************************************
2837 * midiInGetErrorText [WINMM.61]
2839 UINT WINAPI
midiInGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
2841 return midiInGetErrorText16(uError
, lpText
, uSize
);
2844 /**************************************************************************
2845 * midiInGetErrorText [MMSYSTEM.303]
2847 UINT16 WINAPI
midiInGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2849 TRACE("midiInGetErrorText\n");
2850 return (midiGetErrorText(uError
, lpText
, uSize
));
2853 /**************************************************************************
2854 * midiInOpen [WINMM.66]
2856 UINT WINAPI
midiInOpen(HMIDIIN
* lphMidiIn
, UINT uDeviceID
,
2857 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2860 UINT ret
= midiInOpen16(&xhmid16
, uDeviceID
, dwCallback
, dwInstance
,
2861 CALLBACK32CONV(dwFlags
));
2863 *lphMidiIn
= xhmid16
;
2867 /**************************************************************************
2868 * midiInOpen [MMSYSTEM.304]
2870 UINT16 WINAPI
midiInOpen16(HMIDIIN16
* lphMidiIn
, UINT16 uDeviceID
,
2871 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2874 LPMIDIOPENDESC lpDesc
;
2876 BOOL bMapperFlg
= FALSE
;
2878 if (lphMidiIn
!= NULL
)
2880 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2881 lphMidiIn
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
2882 if (uDeviceID
== (UINT16
)MIDI_MAPPER
) {
2883 TRACE("MIDI_MAPPER mode requested !\n");
2887 hMidiIn
= USER_HEAP_ALLOC(sizeof(MIDIOPENDESC
));
2888 if (lphMidiIn
!= NULL
)
2889 *lphMidiIn
= hMidiIn
;
2890 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
2892 return MMSYSERR_NOMEM
;
2893 lpDesc
->hMidi
= hMidiIn
;
2894 lpDesc
->dwCallback
= dwCallback
;
2895 lpDesc
->dwInstance
= dwInstance
;
2897 while (uDeviceID
< MAXMIDIDRIVERS
) {
2898 dwRet
= midMessage(uDeviceID
, MIDM_OPEN
,
2899 lpDesc
->dwInstance
, (DWORD
)lpDesc
, dwFlags
);
2900 if (dwRet
== MMSYSERR_NOERROR
)
2905 TRACE("MIDI_MAPPER mode ! try next driver...\n");
2907 lpDesc
->wDevID
= uDeviceID
;
2909 if (dwRet
!= MMSYSERR_NOERROR
) {
2910 USER_HEAP_FREE(hMidiIn
);
2911 if (lphMidiIn
) *lphMidiIn
= 0;
2917 /**************************************************************************
2918 * midiInClose [WINMM.58]
2920 UINT WINAPI
midiInClose(HMIDIIN hMidiIn
)
2922 return midiInClose16(hMidiIn
);
2925 /**************************************************************************
2926 * midiInClose [MMSYSTEM.305]
2928 UINT16 WINAPI
midiInClose16(HMIDIIN16 hMidiIn
)
2930 LPMIDIOPENDESC lpDesc
;
2933 TRACE("(%04X)\n", hMidiIn
);
2934 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
2936 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
2937 dwRet
= midMessage(lpDesc
->wDevID
, MIDM_CLOSE
, lpDesc
->dwInstance
, 0L, 0L);
2938 USER_HEAP_FREE(hMidiIn
);
2942 /**************************************************************************
2943 * midiInPrepareHeader [WINMM.67]
2945 UINT WINAPI
midiInPrepareHeader(HMIDIIN hMidiIn
,
2946 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2948 LPMIDIOPENDESC lpDesc
;
2950 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2952 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
2954 return MMSYSERR_INVALHANDLE
;
2955 lpMidiInHdr
->reserved
= (DWORD
)lpMidiInHdr
;
2956 return midMessage(lpDesc
->wDevID
, MIDM_PREPARE
, lpDesc
->dwInstance
,
2957 (DWORD
)lpMidiInHdr
, (DWORD
)uSize
);
2960 /**************************************************************************
2961 * midiInPrepareHeader [MMSYSTEM.306]
2963 UINT16 WINAPI
midiInPrepareHeader16(HMIDIIN16 hMidiIn
,
2964 MIDIHDR16
* /*SEGPTR*/ _lpMidiInHdr
, UINT16 uSize
)
2966 LPMIDIOPENDESC lpDesc
;
2967 LPMIDIHDR16 lpMidiInHdr
= (LPMIDIHDR16
)PTR_SEG_TO_LIN(_lpMidiInHdr
);
2969 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2971 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
2973 return MMSYSERR_INVALHANDLE
;
2974 lpMidiInHdr
->reserved
= (DWORD
)_lpMidiInHdr
;
2975 return midMessage(lpDesc
->wDevID
, MIDM_PREPARE
, lpDesc
->dwInstance
,
2976 (DWORD
)lpMidiInHdr
, (DWORD
)uSize
);
2979 /**************************************************************************
2980 * midiInUnprepareHeader [WINMM.71]
2982 UINT WINAPI
midiInUnprepareHeader(HMIDIIN hMidiIn
,
2983 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2985 return midiInUnprepareHeader16(hMidiIn
, (MIDIHDR16
*)lpMidiInHdr
, uSize
);
2988 /**************************************************************************
2989 * midiInUnprepareHeader [MMSYSTEM.307]
2991 UINT16 WINAPI
midiInUnprepareHeader16(HMIDIIN16 hMidiIn
,
2992 MIDIHDR16
* lpMidiInHdr
, UINT16 uSize
)
2994 LPMIDIOPENDESC lpDesc
;
2996 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2998 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
3000 return MMSYSERR_INVALHANDLE
;
3001 return midMessage(lpDesc
->wDevID
, MIDM_UNPREPARE
, lpDesc
->dwInstance
,
3002 (DWORD
)lpMidiInHdr
, (DWORD
)uSize
);
3005 /**************************************************************************
3006 * midiInAddBuffer [WINMM.57]
3008 UINT WINAPI
midiInAddBuffer(HMIDIIN hMidiIn
,
3009 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
3011 return midiInAddBuffer16(hMidiIn
, (MIDIHDR16
*)lpMidiInHdr
, uSize
);
3014 /**************************************************************************
3015 * midiInAddBuffer [MMSYSTEM.308]
3017 UINT16 WINAPI
midiInAddBuffer16(HMIDIIN16 hMidiIn
,
3018 MIDIHDR16
* lpMidiInHdr
, UINT16 uSize
)
3020 TRACE("midiInAddBuffer\n");
3024 /**************************************************************************
3025 * midiInStart [WINMM.69]
3027 UINT WINAPI
midiInStart(HMIDIIN hMidiIn
)
3029 return midiInStart16(hMidiIn
);
3032 /**************************************************************************
3033 * midiInStart [MMSYSTEM.309]
3035 UINT16 WINAPI
midiInStart16(HMIDIIN16 hMidiIn
)
3037 LPMIDIOPENDESC lpDesc
;
3039 TRACE("(%04X)\n", hMidiIn
);
3040 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
3042 return MMSYSERR_INVALHANDLE
;
3043 return midMessage(lpDesc
->wDevID
, MIDM_START
, lpDesc
->dwInstance
, 0L, 0L);
3046 /**************************************************************************
3047 * midiInStop [WINMM.70]
3049 UINT WINAPI
midiInStop(HMIDIIN hMidiIn
)
3051 return midiInStop16(hMidiIn
);
3054 /**************************************************************************
3055 * midiInStop [MMSYSTEM.310]
3057 UINT16 WINAPI
midiInStop16(HMIDIIN16 hMidiIn
)
3059 LPMIDIOPENDESC lpDesc
;
3061 TRACE("(%04X)\n", hMidiIn
);
3062 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
3064 return MMSYSERR_INVALHANDLE
;
3065 return midMessage(lpDesc
->wDevID
, MIDM_STOP
, lpDesc
->dwInstance
, 0L, 0L);
3068 /**************************************************************************
3069 * midiInReset [WINMM.68]
3071 UINT WINAPI
midiInReset(HMIDIIN hMidiIn
)
3073 return midiInReset16(hMidiIn
);
3076 /**************************************************************************
3077 * midiInReset [MMSYSTEM.311]
3079 UINT16 WINAPI
midiInReset16(HMIDIIN16 hMidiIn
)
3081 LPMIDIOPENDESC lpDesc
;
3083 TRACE("(%04X)\n", hMidiIn
);
3084 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
3086 return MMSYSERR_INVALHANDLE
;
3087 return midMessage(lpDesc
->wDevID
, MIDM_RESET
, lpDesc
->dwInstance
, 0L, 0L);
3090 /**************************************************************************
3091 * midiInGetID [WINMM.63]
3093 UINT WINAPI
midiInGetID(HMIDIIN hMidiIn
, UINT
* lpuDeviceID
)
3095 LPMIDIOPENDESC lpDesc
;
3097 TRACE("(%04X, %p)\n", hMidiIn
, lpuDeviceID
);
3098 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
3100 return MMSYSERR_INVALHANDLE
;
3101 if (lpuDeviceID
== NULL
)
3102 return MMSYSERR_INVALPARAM
;
3103 *lpuDeviceID
= lpDesc
->wDevID
;
3105 return MMSYSERR_NOERROR
;
3108 /**************************************************************************
3109 * midiInGetID [MMSYSTEM.312]
3111 UINT16 WINAPI
midiInGetID16(HMIDIIN16 hMidiIn
, UINT16
* lpuDeviceID
)
3113 LPMIDIOPENDESC lpDesc
;
3115 TRACE("(%04X, %p)\n", hMidiIn
, lpuDeviceID
);
3116 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
3118 return MMSYSERR_INVALHANDLE
;
3119 if (lpuDeviceID
== NULL
)
3120 return MMSYSERR_INVALPARAM
;
3121 *lpuDeviceID
= lpDesc
->wDevID
;
3123 return MMSYSERR_NOERROR
;
3126 /**************************************************************************
3127 * midiInMessage [WINMM.65]
3129 DWORD WINAPI
midiInMessage(HMIDIIN hMidiIn
, UINT uMessage
,
3130 DWORD dwParam1
, DWORD dwParam2
)
3132 LPMIDIOPENDESC lpDesc
;
3134 TRACE("(%04X, %04X, %08lX, %08lX)\n",
3135 hMidiIn
, uMessage
, dwParam1
, dwParam2
);
3136 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
3138 return MMSYSERR_INVALHANDLE
;
3142 FIXME("can't handle MIDM_OPEN!\n");
3144 case MIDM_GETDEVCAPS
:
3145 return midiInGetDevCapsA(hMidiIn
, (LPMIDIINCAPSA
)dwParam1
, dwParam2
);
3146 case MIDM_GETNUMDEVS
:
3151 /* no argument conversion needed */
3154 return midiInPrepareHeader(hMidiIn
, (LPMIDIHDR
)dwParam1
, dwParam2
);
3155 case MIDM_UNPREPARE
:
3156 return midiInUnprepareHeader(hMidiIn
, (LPMIDIHDR
)dwParam1
, dwParam2
);
3157 case MIDM_ADDBUFFER
:
3158 return midiInAddBuffer(hMidiIn
, (LPMIDIHDR
)dwParam1
, dwParam2
);
3160 ERR("(%04x, %04x, %08lx, %08lx): unhandled message\n",
3161 hMidiIn
, uMessage
, dwParam1
, dwParam2
);
3164 return midMessage(0, uMessage
, lpDesc
->dwInstance
, dwParam1
, dwParam2
);
3167 /**************************************************************************
3168 * midiInMessage [MMSYSTEM.313]
3170 DWORD WINAPI
midiInMessage16(HMIDIIN16 hMidiIn
, UINT16 uMessage
,
3171 DWORD dwParam1
, DWORD dwParam2
)
3173 LPMIDIOPENDESC lpDesc
;
3175 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
3177 lpDesc
= (LPMIDIOPENDESC
) USER_HEAP_LIN_ADDR(hMidiIn
);
3178 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
3181 WARN("can't handle MIDM_OPEN!\n");
3183 case MIDM_GETDEVCAPS
:
3184 return midiInGetDevCaps16(hMidiIn
, (LPMIDIINCAPS16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
3185 case MIDM_GETNUMDEVS
:
3190 /* no argument conversion needed */
3193 return midiInPrepareHeader16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
3194 case MIDM_UNPREPARE
:
3195 return midiInUnprepareHeader16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
3196 case MIDM_ADDBUFFER
:
3197 return midiInAddBuffer16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
3199 ERR("(%04x, %04x, %08lx, %08lx): unhandled message\n",
3200 hMidiIn
, uMessage
, dwParam1
, dwParam2
);
3203 return midMessage(0, uMessage
, lpDesc
->dwInstance
, dwParam1
, dwParam2
);
3206 typedef struct WINE_MIDIStream
{
3217 LPMIDIHDR lpMidiHdr
;
3220 #define WINE_MSM_HEADER (WM_USER+0)
3221 #define WINE_MSM_STOP (WM_USER+1)
3223 /**************************************************************************
3224 * MMSYSTEM_GetMidiStream [internal]
3226 static BOOL
MMSYSTEM_GetMidiStream(HMIDISTRM hMidiStrm
, WINE_MIDIStream
** lpMidiStrm
, MIDIOPENDESC
** lplpDesc
)
3228 MIDIOPENDESC
* lpDesc
= (LPMIDIOPENDESC
)USER_HEAP_LIN_ADDR(hMidiStrm
);
3233 if (lpDesc
== NULL
) {
3237 *lpMidiStrm
= (WINE_MIDIStream
*)lpDesc
->rgIds
.dwStreamID
;
3239 return *lpMidiStrm
!= NULL
;
3242 /**************************************************************************
3243 * MMSYSTEM_MidiStream_Convert [internal]
3245 static DWORD
MMSYSTEM_MidiStream_Convert(WINE_MIDIStream
* lpMidiStrm
, DWORD pulse
)
3249 if (lpMidiStrm
->dwTimeDiv
== 0) {
3250 FIXME("Shouldn't happen. lpMidiStrm->dwTimeDiv = 0\n");
3251 } else if (lpMidiStrm
->dwTimeDiv
> 0x8000) { /* SMPTE, unchecked FIXME? */
3252 int nf
= -(char)HIBYTE(lpMidiStrm
->dwTimeDiv
); /* number of frames */
3253 int nsf
= LOBYTE(lpMidiStrm
->dwTimeDiv
); /* number of sub-frames */
3254 ret
= (pulse
* 1000) / (nf
* nsf
);
3256 ret
= (DWORD
)((double)pulse
* ((double)lpMidiStrm
->dwTempo
/ 1000) /
3257 (double)lpMidiStrm
->dwTimeDiv
);
3263 /**************************************************************************
3264 * MMSYSTEM_MidiStream_MessageHandler [internal]
3266 static BOOL
MMSYSTEM_MidiStream_MessageHandler(WINE_MIDIStream
* lpMidiStrm
, LPMIDIOPENDESC lpDesc
, LPMSG msg
)
3268 LPMIDIHDR lpMidiHdr
;
3272 switch (msg
->message
) {
3274 SetEvent(lpMidiStrm
->hEvent
);
3278 /* this is not quite what MS doc says... */
3279 midiOutReset(lpMidiStrm
->hDevice
);
3280 /* empty list of already submitted buffers */
3281 for (lpMidiHdr
= lpMidiStrm
->lpMidiHdr
; lpMidiHdr
; lpMidiHdr
= (LPMIDIHDR
)lpMidiHdr
->lpNext
) {
3282 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3283 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3285 DriverCallback16(lpDesc
->dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3286 MM_MOM_DONE
, lpDesc
->dwInstance
, lpMidiHdr
->reserved
, 0L);
3288 lpMidiStrm
->lpMidiHdr
= 0;
3289 SetEvent(lpMidiStrm
->hEvent
);
3291 case WINE_MSM_HEADER
:
3292 /* sets initial tick count for first MIDIHDR */
3293 if (!lpMidiStrm
->dwStartTicks
)
3294 lpMidiStrm
->dwStartTicks
= GetTickCount();
3296 /* FIXME(EPP): "I don't understand the content of the first MIDIHDR sent
3297 * by native mcimidi, it doesn't look like a correct one".
3298 * this trick allows to throw it away... but I don't like it.
3299 * It looks like part of the file I'm trying to play and definitively looks
3300 * like raw midi content
3301 * I'd really like to understand why native mcimidi sends it. Perhaps a bad
3302 * synchronization issue where native mcimidi is still processing raw MIDI
3303 * content before generating MIDIEVENTs ?
3305 * 4c 04 89 3b 00 81 7c 99 3b 43 00 99 23 5e 04 89 L..;..|.;C..#^..
3306 * 3b 00 00 89 23 00 7c 99 3b 45 00 99 28 62 04 89 ;...#.|.;E..(b..
3307 * 3b 00 00 89 28 00 81 7c 99 3b 4e 00 99 23 5e 04 ;...(..|.;N..#^.
3308 * 89 3b 00 00 89 23 00 7c 99 3b 45 00 99 23 78 04 .;...#.|.;E..#x.
3309 * 89 3b 00 00 89 23 00 81 7c 99 3b 48 00 99 23 5e .;...#..|.;H..#^
3310 * 04 89 3b 00 00 89 23 00 7c 99 3b 4e 00 99 28 62 ..;...#.|.;N..(b
3311 * 04 89 3b 00 00 89 28 00 81 7c 99 39 4c 00 99 23 ..;...(..|.9L..#
3312 * 5e 04 89 39 00 00 89 23 00 82 7c 99 3b 4c 00 99 ^..9...#..|.;L..
3313 * 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 00 99 #^..;...#.|.;H..
3314 * 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b 3f 04 (b..;...(..|.;?.
3315 * 89 3b 00 1c 99 23 5e 04 89 23 00 5c 99 3b 45 00 .;...#^..#.\.;E.
3316 * 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 3b 46 .#x..;...#..|.;F
3317 * 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 ..#^..;...#.|.;H
3318 * 00 99 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b ..(b..;...(..|.;
3319 * 46 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b F..#^..;...#.|.;
3320 * 48 00 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 H..#x..;...#..|.
3321 * 3b 4c 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 ;L..#^..;...#.|.
3323 lpMidiHdr
= (LPMIDIHDR
)msg
->lParam
;
3324 lpData
= ((DWORD
)lpMidiHdr
== lpMidiHdr
->reserved
) ?
3325 (LPBYTE
)lpMidiHdr
->lpData
: (LPBYTE
)PTR_SEG_TO_LIN(lpMidiHdr
->lpData
);
3326 TRACE("Adding %s lpMidiHdr=%p [lpData=0x%08lx dwBufferLength=%lu/%lu dwFlags=0x%08lx size=%u]\n",
3327 (lpMidiHdr
->dwFlags
& MHDR_ISSTRM
) ? "stream" : "regular", lpMidiHdr
,
3328 lpMidiHdr
->reserved
, lpMidiHdr
->dwBufferLength
, lpMidiHdr
->dwBytesRecorded
,
3329 lpMidiHdr
->dwFlags
, msg
->wParam
);
3331 /* dumps content of lpMidiHdr->lpData
3332 * FIXME: there should be a debug routine somewhere that already does this
3333 * I hate spreading this type of shit all around the code
3335 for (dwToGo
= 0; dwToGo
< lpMidiHdr
->dwBufferLength
; dwToGo
+= 16) {
3339 for (i
= 0; i
< MIN(16, lpMidiHdr
->dwBufferLength
- dwToGo
); i
++)
3340 printf("%02x ", lpData
[dwToGo
+ i
]);
3343 for (i
= 0; i
< MIN(16, lpMidiHdr
->dwBufferLength
- dwToGo
); i
++) {
3344 ch
= lpData
[dwToGo
+ i
];
3345 printf("%c", (ch
>= 0x20 && ch
<= 0x7F) ? ch
: '.');
3350 if (((LPMIDIEVENT
)lpData
)->dwStreamID
!= 0 &&
3351 ((LPMIDIEVENT
)lpData
)->dwStreamID
!= 0xFFFFFFFF &&
3352 ((LPMIDIEVENT
)lpData
)->dwStreamID
!= (DWORD
)lpMidiStrm
) {
3353 FIXME("Dropping bad %s lpMidiHdr (streamID=%08lx)\n",
3354 (lpMidiHdr
->dwFlags
& MHDR_ISSTRM
) ? "stream" : "regular",
3355 ((LPMIDIEVENT
)lpData
)->dwStreamID
);
3356 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3357 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3359 DriverCallback16(lpDesc
->dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3360 MM_MOM_DONE
, lpDesc
->dwInstance
, lpMidiHdr
->reserved
, 0L);
3364 for (lpmh
= &lpMidiStrm
->lpMidiHdr
; *lpmh
; lpmh
= (LPMIDIHDR
*)&((*lpmh
)->lpNext
));
3366 lpMidiHdr
= (LPMIDIHDR
)msg
->lParam
;
3367 lpMidiHdr
->lpNext
= 0;
3368 lpMidiHdr
->dwFlags
|= MHDR_INQUEUE
;
3369 lpMidiHdr
->dwFlags
&= MHDR_DONE
;
3370 lpMidiHdr
->dwOffset
= 0;
3374 FIXME("Unknown message %d\n", msg
->message
);
3380 /**************************************************************************
3381 * MMSYSTEM_MidiStream_Player [internal]
3383 static DWORD CALLBACK
MMSYSTEM_MidiStream_Player(LPVOID pmt
)
3385 WINE_MIDIStream
* lpMidiStrm
= pmt
;
3386 MIDIOPENDESC
* lpDesc
= USER_HEAP_LIN_ADDR(lpMidiStrm
->hDevice
);
3390 LPMIDIHDR lpMidiHdr
;
3394 TRACE("(%p)!\n", lpMidiStrm
);
3396 /* force thread's queue creation */
3397 /* Used to be InitThreadInput16(0, 5); */
3398 /* but following works also with hack in midiStreamOpen */
3399 Callout
.PeekMessageA(&msg
, 0, 0, 0, 0);
3401 /* FIXME: this next line must be called before midiStreamOut or midiStreamRestart are called */
3402 SetEvent(lpMidiStrm
->hEvent
);
3403 TRACE("Ready to go 1\n");
3404 /* thread is started in paused mode */
3405 SuspendThread(lpMidiStrm
->hThread
);
3406 TRACE("Ready to go 2\n");
3408 lpMidiStrm
->dwStartTicks
= 0;
3409 lpMidiStrm
->dwPulses
= 0;
3411 lpMidiStrm
->lpMidiHdr
= 0;
3414 lpMidiHdr
= lpMidiStrm
->lpMidiHdr
;
3416 /* for first message, block until one arrives, then process all that are available */
3417 Callout
.GetMessageA(&msg
, 0, 0, 0);
3419 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm
, lpDesc
, &msg
))
3421 } while (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
));
3427 * midiOutPrepareHeader(), in Wine, sets the 'reserved' field of MIDIHDR to the
3428 * 16 or 32 bit address of lpMidiHdr (depending if called from 16 to 32 bit code)
3431 lpData
= ((DWORD
)lpMidiHdr
== lpMidiHdr
->reserved
) ?
3432 (LPBYTE
)lpMidiHdr
->lpData
: (LPBYTE
)PTR_SEG_TO_LIN(lpMidiHdr
->lpData
);
3434 me
= (LPMIDIEVENT
)(lpData
+ lpMidiHdr
->dwOffset
);
3436 /* do we have to wait ? */
3437 if (me
->dwDeltaTime
) {
3438 lpMidiStrm
->dwPositionMS
+= MMSYSTEM_MidiStream_Convert(lpMidiStrm
, me
->dwDeltaTime
);
3439 lpMidiStrm
->dwPulses
+= me
->dwDeltaTime
;
3441 dwToGo
= lpMidiStrm
->dwStartTicks
+ lpMidiStrm
->dwPositionMS
;
3443 TRACE("%ld/%ld/%ld\n", dwToGo
, GetTickCount(), me
->dwDeltaTime
);
3444 while ((dwCurrTC
= GetTickCount()) < dwToGo
) {
3445 if (MsgWaitForMultipleObjects(0, NULL
, FALSE
, dwToGo
- dwCurrTC
, QS_ALLINPUT
) == WAIT_OBJECT_0
) {
3446 /* got a message, handle it */
3447 while (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
3448 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm
, lpDesc
, &msg
))
3453 /* timeout, so me->dwDeltaTime is elapsed, can break the while loop */
3458 switch (MEVT_EVENTTYPE(me
->dwEvent
& ~MEVT_F_CALLBACK
)) {
3460 FIXME("NIY: MEVT_COMMENT\n");
3461 /* do nothing, skip bytes */
3464 FIXME("NIY: MEVT_LONGMSG, aka sending Sysex event\n");
3469 midiOutShortMsg(lpMidiStrm
->hDevice
, MEVT_EVENTPARM(me
->dwEvent
));
3472 lpMidiStrm
->dwTempo
= MEVT_EVENTPARM(me
->dwEvent
);
3477 FIXME("Unknown MEVT (0x%02x)\n", MEVT_EVENTTYPE(me
->dwEvent
& ~MEVT_F_CALLBACK
));
3480 if (me
->dwEvent
& MEVT_F_CALLBACK
) {
3481 DriverCallback16(lpDesc
->dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3482 MM_MOM_POSITIONCB
, lpDesc
->dwInstance
, (LPARAM
)lpMidiHdr
, 0L);
3484 lpMidiHdr
->dwOffset
+= sizeof(MIDIEVENT
);
3485 if (me
->dwEvent
& MEVT_F_LONG
)
3486 lpMidiHdr
->dwOffset
+= (MEVT_EVENTPARM(me
->dwEvent
) + 3) & ~3;
3487 if (lpMidiHdr
->dwOffset
>= lpMidiHdr
->dwBufferLength
) {
3488 /* done with this header */
3489 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3490 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3492 lpMidiStrm
->lpMidiHdr
= (LPMIDIHDR
)lpMidiHdr
->lpNext
;
3493 DriverCallback16(lpDesc
->dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3494 MM_MOM_DONE
, lpDesc
->dwInstance
, lpMidiHdr
->reserved
, 0L);
3499 TRACE("End of thread\n");
3501 return 0; /* for removing the warning, never executed */
3504 /**************************************************************************
3505 * MMSYSTEM_MidiStream_PostMessage [internal]
3507 static BOOL
MMSYSTEM_MidiStream_PostMessage(WINE_MIDIStream
* lpMidiStrm
, WORD msg
, DWORD pmt1
, DWORD pmt2
)
3509 if (Callout
.PostThreadMessageA(lpMidiStrm
->dwThreadID
, msg
, pmt1
, pmt2
)) {
3513 /* FIXME: should use the new syslevel APIs */
3514 if ((bHasWin16Lock
= _ConfirmWin16Lock()) != 0) {
3515 ReleaseThunkLock(&count
);
3517 WaitForSingleObject(lpMidiStrm
->hEvent
, INFINITE
);
3518 if (bHasWin16Lock
) {
3519 RestoreThunkLock(count
);
3522 WARN("bad PostThreadMessageA\n");
3528 /**************************************************************************
3529 * midiStreamClose [WINMM.90]
3531 MMRESULT WINAPI
midiStreamClose(HMIDISTRM hMidiStrm
)
3533 WINE_MIDIStream
* lpMidiStrm
;
3535 TRACE("(%08x)!\n", hMidiStrm
);
3537 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
))
3538 return MMSYSERR_INVALHANDLE
;
3540 midiStreamStop(hMidiStrm
);
3541 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm
, WM_QUIT
, 0, 0);
3542 HeapFree(GetProcessHeap(), 0, lpMidiStrm
);
3543 CloseHandle(lpMidiStrm
->hEvent
);
3545 return midiOutClose(hMidiStrm
);
3548 /**************************************************************************
3549 * MMSYSTEM_MidiStream_Open [internal]
3551 static MMRESULT WINAPI
MMSYSTEM_MidiStream_Open(HMIDISTRM
* lphMidiStrm
, LPUINT lpuDeviceID
,
3552 DWORD cMidi
, DWORD dwCallback
,
3553 DWORD dwInstance
, DWORD fdwOpen
)
3555 WINE_MIDIStream
* lpMidiStrm
;
3557 MIDIOPENSTRMID mosm
;
3558 MIDIOPENDESC
* lpDesc
;
3559 HMIDIOUT16 hMidiOut16
;
3561 TRACE("(%p, %p, %ld, 0x%08lx, 0x%08lx, 0x%08lx)!\n",
3562 lphMidiStrm
, lpuDeviceID
, cMidi
, dwCallback
, dwInstance
, fdwOpen
);
3564 if (cMidi
!= 1 || lphMidiStrm
== NULL
|| lpuDeviceID
== NULL
)
3565 return MMSYSERR_INVALPARAM
;
3567 if (*lpuDeviceID
== (UINT16
)MIDI_MAPPER
) {
3568 FIXME("MIDI_MAPPER mode requested ! => forcing devID to 0\n");
3572 lpMidiStrm
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MIDIStream
));
3574 return MMSYSERR_NOMEM
;
3576 lpMidiStrm
->dwTempo
= 500000;
3577 lpMidiStrm
->dwTimeDiv
= 480; /* 480 is 120 quater notes per minute *//* FIXME ??*/
3578 lpMidiStrm
->dwPositionMS
= 0;
3580 mosm
.dwStreamID
= (DWORD
)lpMidiStrm
;
3581 /* FIXME: the correct value is not allocated yet for MAPPER */
3582 mosm
.wDeviceID
= *lpuDeviceID
;
3583 lpDesc
= MIDI_OutAlloc(&hMidiOut16
, dwCallback
, dwInstance
, 1, &mosm
);
3584 lpMidiStrm
->hDevice
= hMidiOut16
;
3586 *lphMidiStrm
= hMidiOut16
;
3588 lpDesc
->wDevID
= *lpuDeviceID
;
3589 ret
= modMessage(lpDesc
->wDevID
, MODM_OPEN
,
3590 lpDesc
->dwInstance
, (DWORD
)lpDesc
, fdwOpen
);
3591 lpMidiStrm
->hEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
);
3592 lpMidiStrm
->wFlags
= HIWORD(fdwOpen
);
3594 lpMidiStrm
->hThread
= CreateThread(NULL
, 0, MMSYSTEM_MidiStream_Player
,
3595 lpMidiStrm
, 0, &(lpMidiStrm
->dwThreadID
));
3597 if (!lpMidiStrm
->hThread
) {
3598 midiStreamClose((HMIDISTRM
)hMidiOut16
);
3599 return MMSYSERR_NOMEM
;
3602 /* wait for thread to have started, and for it's queue to be created */
3607 /* (Release|Restore)ThunkLock() is needed when this method is called from 16 bit code,
3608 * (meaning the Win16Lock is set), so that it's released and the 32 bit thread running
3609 * MMSYSTEM_MidiStreamPlayer can acquire Win16Lock to create its queue.
3611 if ((bHasWin16Lock
= _ConfirmWin16Lock()) != 0) {
3612 ReleaseThunkLock(&count
);
3614 WaitForSingleObject(lpMidiStrm
->hEvent
, INFINITE
);
3615 if (bHasWin16Lock
) {
3616 RestoreThunkLock(count
);
3620 TRACE("=> (%u/%d) hMidi=0x%04x ret=%d lpMidiStrm=%p\n", *lpuDeviceID
, lpDesc
->wDevID
, *lphMidiStrm
, ret
, lpMidiStrm
);
3624 /**************************************************************************
3625 * midiStreamOpen [WINMM.91]
3627 MMRESULT WINAPI
midiStreamOpen(HMIDISTRM
* lphMidiStrm
, LPUINT lpuDeviceID
,
3628 DWORD cMidi
, DWORD dwCallback
,
3629 DWORD dwInstance
, DWORD fdwOpen
)
3631 return MMSYSTEM_MidiStream_Open(lphMidiStrm
, lpuDeviceID
, cMidi
, dwCallback
, dwInstance
, CALLBACK32CONV(fdwOpen
));
3634 /**************************************************************************
3635 * midiStreamOut [WINMM.92]
3637 MMRESULT WINAPI
midiStreamOut(HMIDISTRM hMidiStrm
, LPMIDIHDR lpMidiHdr
, UINT cbMidiHdr
)
3639 WINE_MIDIStream
* lpMidiStrm
;
3640 DWORD ret
= MMSYSERR_NOERROR
;
3642 TRACE("(%08x, %p, %u)!\n", hMidiStrm
, lpMidiHdr
, cbMidiHdr
);
3644 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3645 ret
= MMSYSERR_INVALHANDLE
;
3647 if (!Callout
.PostThreadMessageA(lpMidiStrm
->dwThreadID
, WINE_MSM_HEADER
, cbMidiHdr
, (DWORD
)lpMidiHdr
)) {
3648 WARN("bad PostThreadMessageA\n");
3649 ret
= MMSYSERR_ERROR
;
3655 /**************************************************************************
3656 * midiStreamPause [WINMM.93]
3658 MMRESULT WINAPI
midiStreamPause(HMIDISTRM hMidiStrm
)
3660 WINE_MIDIStream
* lpMidiStrm
;
3661 DWORD ret
= MMSYSERR_NOERROR
;
3663 TRACE("(%08x)!\n", hMidiStrm
);
3665 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3666 ret
= MMSYSERR_INVALHANDLE
;
3668 if (SuspendThread(lpMidiStrm
->hThread
) == 0xFFFFFFFF) {
3669 WARN("bad Suspend (%ld)\n", GetLastError());
3670 ret
= MMSYSERR_ERROR
;
3676 /**************************************************************************
3677 * midiStreamPosition [WINMM.94]
3679 MMRESULT WINAPI
midiStreamPosition(HMIDISTRM hMidiStrm
, LPMMTIME lpMMT
, UINT cbmmt
)
3681 WINE_MIDIStream
* lpMidiStrm
;
3682 DWORD ret
= MMSYSERR_NOERROR
;
3684 TRACE("(%08x, %p, %u)!\n", hMidiStrm
, lpMMT
, cbmmt
);
3686 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3687 ret
= MMSYSERR_INVALHANDLE
;
3688 } else if (lpMMT
== NULL
|| cbmmt
!= sizeof(MMTIME
)) {
3689 ret
= MMSYSERR_INVALPARAM
;
3691 switch (lpMMT
->wType
) {
3693 lpMMT
->u
.ms
= lpMidiStrm
->dwPositionMS
;
3694 TRACE("=> %ld ms\n", lpMMT
->u
.ms
);
3697 lpMMT
->u
.ticks
= lpMidiStrm
->dwPulses
;
3698 TRACE("=> %ld ticks\n", lpMMT
->u
.ticks
);
3701 WARN("Unsupported time type %d\n", lpMMT
->wType
);
3702 lpMMT
->wType
= TIME_MS
;
3703 ret
= MMSYSERR_INVALPARAM
;
3710 /**************************************************************************
3711 * midiStreamProperty [WINMM.95]
3713 MMRESULT WINAPI
midiStreamProperty(HMIDISTRM hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
3715 WINE_MIDIStream
* lpMidiStrm
;
3716 MMRESULT ret
= MMSYSERR_NOERROR
;
3718 TRACE("(%08x, %p, %lx)\n", hMidiStrm
, lpPropData
, dwProperty
);
3720 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3721 ret
= MMSYSERR_INVALHANDLE
;
3722 } else if ((dwProperty
& (MIDIPROP_GET
|MIDIPROP_SET
)) == 0) {
3723 ret
= MMSYSERR_INVALPARAM
;
3724 } else if (dwProperty
& MIDIPROP_TEMPO
) {
3725 MIDIPROPTEMPO
* mpt
= (MIDIPROPTEMPO
*)lpPropData
;
3727 if (sizeof(MIDIPROPTEMPO
) != mpt
->cbStruct
) {
3728 ret
= MMSYSERR_INVALPARAM
;
3729 } else if (dwProperty
& MIDIPROP_SET
) {
3730 lpMidiStrm
->dwTempo
= mpt
->dwTempo
;
3731 TRACE("Setting tempo to %ld\n", mpt
->dwTempo
);
3732 } else if (dwProperty
& MIDIPROP_GET
) {
3733 mpt
->dwTempo
= lpMidiStrm
->dwTempo
;
3734 TRACE("Getting tempo <= %ld\n", mpt
->dwTempo
);
3736 } else if (dwProperty
& MIDIPROP_TIMEDIV
) {
3737 MIDIPROPTIMEDIV
* mptd
= (MIDIPROPTIMEDIV
*)lpPropData
;
3739 if (sizeof(MIDIPROPTIMEDIV
) != mptd
->cbStruct
) {
3740 ret
= MMSYSERR_INVALPARAM
;
3741 } else if (dwProperty
& MIDIPROP_SET
) {
3742 lpMidiStrm
->dwTimeDiv
= mptd
->dwTimeDiv
;
3743 TRACE("Setting time div to %ld\n", mptd
->dwTimeDiv
);
3744 } else if (dwProperty
& MIDIPROP_GET
) {
3745 mptd
->dwTimeDiv
= lpMidiStrm
->dwTimeDiv
;
3746 TRACE("Getting time div <= %ld\n", mptd
->dwTimeDiv
);
3749 ret
= MMSYSERR_INVALPARAM
;
3755 /**************************************************************************
3756 * midiStreamRestart [WINMM.96]
3758 MMRESULT WINAPI
midiStreamRestart(HMIDISTRM hMidiStrm
)
3760 WINE_MIDIStream
* lpMidiStrm
;
3761 MMRESULT ret
= MMSYSERR_NOERROR
;
3763 TRACE("(%08x)!\n", hMidiStrm
);
3765 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3766 ret
= MMSYSERR_INVALHANDLE
;
3768 if (ResumeThread(lpMidiStrm
->hThread
) == 0xFFFFFFFF) {
3769 WARN("bad Resume (%ld)\n", GetLastError());
3770 ret
= MMSYSERR_ERROR
;
3772 lpMidiStrm
->dwStartTicks
= GetTickCount() - lpMidiStrm
->dwPositionMS
;
3778 /**************************************************************************
3779 * midiStreamStop [WINMM.97]
3781 MMRESULT WINAPI
midiStreamStop(HMIDISTRM hMidiStrm
)
3783 WINE_MIDIStream
* lpMidiStrm
;
3784 MMRESULT ret
= MMSYSERR_NOERROR
;
3786 TRACE("(%08x)!\n", hMidiStrm
);
3788 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3789 ret
= MMSYSERR_INVALHANDLE
;
3791 /* in case stream has been paused... FIXME is the current state correct ? */
3792 midiStreamRestart(hMidiStrm
);
3793 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm
, WINE_MSM_STOP
, 0, 0);
3798 /**************************************************************************
3799 * midiStreamClose [MMSYSTEM.252]
3801 MMRESULT16 WINAPI
midiStreamClose16(HMIDISTRM16 hMidiStrm
)
3803 return midiStreamClose(hMidiStrm
);
3806 /**************************************************************************
3807 * midiStreamOpen [MMSYSTEM.251]
3809 MMRESULT16 WINAPI
midiStreamOpen16(HMIDISTRM16
* phMidiStrm
, LPUINT16 devid
,
3810 DWORD cMidi
, DWORD dwCallback
,
3811 DWORD dwInstance
, DWORD fdwOpen
)
3813 HMIDISTRM hMidiStrm32
;
3817 if (!phMidiStrm
|| !devid
)
3818 return MMSYSERR_INVALPARAM
;
3820 ret
= MMSYSTEM_MidiStream_Open(&hMidiStrm32
, &devid32
, cMidi
, dwCallback
, dwInstance
, fdwOpen
);
3821 *phMidiStrm
= hMidiStrm32
;
3826 /**************************************************************************
3827 * midiStreamOut [MMSYSTEM.254]
3829 MMRESULT16 WINAPI
midiStreamOut16(HMIDISTRM16 hMidiStrm
, LPMIDIHDR16 lpMidiHdr
, UINT16 cbMidiHdr
)
3831 return midiStreamOut(hMidiStrm
, (LPMIDIHDR
)lpMidiHdr
, cbMidiHdr
);
3834 /**************************************************************************
3835 * midiStreamPause [MMSYSTEM.255]
3837 MMRESULT16 WINAPI
midiStreamPause16(HMIDISTRM16 hMidiStrm
)
3839 return midiStreamPause(hMidiStrm
);
3842 /**************************************************************************
3843 * midiStreamPosition [MMSYSTEM.253]
3845 MMRESULT16 WINAPI
midiStreamPosition16(HMIDISTRM16 hMidiStrm
, LPMMTIME16 lpmmt16
, UINT16 cbmmt
)
3851 return MMSYSERR_INVALPARAM
;
3852 MMSYSTEM_MMTIME16to32(&mmt32
, lpmmt16
);
3853 ret
= midiStreamPosition(hMidiStrm
, &mmt32
, sizeof(MMTIME
));
3854 MMSYSTEM_MMTIME32to16(lpmmt16
, &mmt32
);
3858 /**************************************************************************
3859 * midiStreamProperty [MMSYSTEM.250]
3861 MMRESULT16 WINAPI
midiStreamProperty16(HMIDISTRM16 hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
3863 return midiStreamProperty(hMidiStrm
, lpPropData
, dwProperty
);
3866 /**************************************************************************
3867 * midiStreamRestart [MMSYSTEM.256]
3869 MMRESULT16 WINAPI
midiStreamRestart16(HMIDISTRM16 hMidiStrm
)
3871 return midiStreamRestart(hMidiStrm
);
3874 /**************************************************************************
3875 * midiStreamStop [MMSYSTEM.257]
3877 MMRESULT16 WINAPI
midiStreamStop16(HMIDISTRM16 hMidiStrm
)
3879 return midiStreamStop(hMidiStrm
);
3882 /**************************************************************************
3883 * waveOutGetNumDevs [MMSYSTEM.401]
3885 UINT WINAPI
waveOutGetNumDevs()
3887 return waveOutGetNumDevs16();
3890 /**************************************************************************
3891 * waveOutGetNumDevs [WINMM.167]
3893 UINT16 WINAPI
waveOutGetNumDevs16()
3896 TRACE("waveOutGetNumDevs\n");
3897 /* FIXME: I'm not sure MCI_FirstDevID() is correct */
3898 count
+= wodMessage(MCI_FirstDevID(), WODM_GETNUMDEVS
, 0L, 0L, 0L);
3899 TRACE("waveOutGetNumDevs return %u \n", count
);
3903 /**************************************************************************
3904 * waveOutGetDevCaps [MMSYSTEM.402]
3906 UINT16 WINAPI
waveOutGetDevCaps16(UINT16 uDeviceID
, LPWAVEOUTCAPS16 lpCaps
,
3909 TRACE("waveOutGetDevCaps\n");
3911 /* FIXME: do we have a wave mapper ? */
3912 if (uDeviceID
== (UINT16
)WAVE_MAPPER
)
3914 /* return MMSYSERR_BADDEVICEID; */
3916 if (uDeviceID
>= waveOutGetNumDevs16()) return MMSYSERR_BADDEVICEID
;
3918 return wodMessage(uDeviceID
, WODM_GETDEVCAPS
, 0L, (DWORD
)lpCaps
, uSize
);
3921 /**************************************************************************
3922 * waveOutGetDevCapsA [WINMM.162]
3924 UINT WINAPI
waveOutGetDevCapsA(UINT uDeviceID
, LPWAVEOUTCAPSA lpCaps
,
3927 WAVEOUTCAPS16 woc16
;
3928 UINT16 ret
= waveOutGetDevCaps16(uDeviceID
, &woc16
, sizeof(woc16
));
3930 lpCaps
->wMid
= woc16
.wMid
;
3931 lpCaps
->wPid
= woc16
.wPid
;
3932 lpCaps
->vDriverVersion
= woc16
.vDriverVersion
;
3933 strcpy(lpCaps
->szPname
, woc16
.szPname
);
3934 lpCaps
->dwFormats
= woc16
.dwFormats
;
3935 lpCaps
->wChannels
= woc16
.wChannels
;
3936 lpCaps
->dwSupport
= woc16
.dwSupport
;
3940 /**************************************************************************
3941 * waveOutGetDevCapsW [WINMM.163]
3943 UINT WINAPI
waveOutGetDevCapsW(UINT uDeviceID
, LPWAVEOUTCAPSW lpCaps
,
3946 WAVEOUTCAPS16 woc16
;
3947 UINT ret
= waveOutGetDevCaps16(uDeviceID
, &woc16
, sizeof(woc16
));
3949 lpCaps
->wMid
= woc16
.wMid
;
3950 lpCaps
->wPid
= woc16
.wPid
;
3951 lpCaps
->vDriverVersion
= woc16
.vDriverVersion
;
3952 lstrcpyAtoW(lpCaps
->szPname
, woc16
.szPname
);
3953 lpCaps
->dwFormats
= woc16
.dwFormats
;
3954 lpCaps
->wChannels
= woc16
.wChannels
;
3955 lpCaps
->dwSupport
= woc16
.dwSupport
;
3959 /**************************************************************************
3960 * waveOutGetErrorText [MMSYSTEM.403]
3962 UINT16 WINAPI
waveOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
3964 TRACE("waveOutGetErrorText\n");
3965 return waveGetErrorText(uError
, lpText
, uSize
);
3968 /**************************************************************************
3969 * waveOutGetErrorTextA [WINMM.164]
3971 UINT WINAPI
waveOutGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
3973 return waveOutGetErrorText16(uError
, lpText
, uSize
);
3976 /**************************************************************************
3977 * waveOutGetErrorTextW [WINMM.165]
3979 UINT WINAPI
waveOutGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
3981 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
3982 UINT ret
= waveOutGetErrorTextA(uError
, xstr
, uSize
);
3984 lstrcpyAtoW(lpText
, xstr
);
3985 HeapFree(GetProcessHeap(), 0, xstr
);
3989 /**************************************************************************
3990 * waveGetErrorText [internal]
3992 static UINT16
waveGetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
3995 TRACE("(%04X, %p, %d);\n",
3996 uError
, lpText
, uSize
);
3997 if ((lpText
== NULL
) || (uSize
< 1)) return(FALSE
);
4000 case MMSYSERR_NOERROR
:
4001 msgptr
= "The specified command was carried out.";
4003 case MMSYSERR_ERROR
:
4004 msgptr
= "Undefined external error.";
4006 case MMSYSERR_BADDEVICEID
:
4007 msgptr
= "A device ID has been used that is out of range for your system.";
4009 case MMSYSERR_NOTENABLED
:
4010 msgptr
= "The driver was not enabled.";
4012 case MMSYSERR_ALLOCATED
:
4013 msgptr
= "The specified device is already in use. Wait until it is free, and then try again.";
4015 case MMSYSERR_INVALHANDLE
:
4016 msgptr
= "The specified device handle is invalid.";
4018 case MMSYSERR_NODRIVER
:
4019 msgptr
= "There is no driver installed on your system !\n";
4021 case MMSYSERR_NOMEM
:
4022 msgptr
= "Not enough memory available for this task. Quit one or more applications to increase available memory, and then try again.";
4024 case MMSYSERR_NOTSUPPORTED
:
4025 msgptr
= "This function is not supported. Use the Capabilities function to determine which functions and messages the driver supports.";
4027 case MMSYSERR_BADERRNUM
:
4028 msgptr
= "An error number was specified that is not defined in the system.";
4030 case MMSYSERR_INVALFLAG
:
4031 msgptr
= "An invalid flag was passed to a system function.";
4033 case MMSYSERR_INVALPARAM
:
4034 msgptr
= "An invalid parameter was passed to a system function.";
4036 case WAVERR_BADFORMAT
:
4037 msgptr
= "The specified format is not supported or cannot be translated. Use the Capabilities function to determine the supported formats";
4039 case WAVERR_STILLPLAYING
:
4040 msgptr
= "Cannot perform this operation while media data is still playing. Reset the device, or wait until the data is finished playing.";
4042 case WAVERR_UNPREPARED
:
4043 msgptr
= "The wave header was not prepared. Use the Prepare function to prepare the header, and then try again.";
4046 msgptr
= "Cannot open the device without using the WAVE_ALLOWSYNC flag. Use the flag, and then try again.";
4049 msgptr
= "Unknown MMSYSTEM Error !\n";
4052 lstrcpynA(lpText
, msgptr
, uSize
);
4056 /**************************************************************************
4057 * waveOutOpen [WINMM.173]
4058 * All the args/structs have the same layout as the win16 equivalents
4060 UINT WINAPI
waveOutOpen(HWAVEOUT
* lphWaveOut
, UINT uDeviceID
,
4061 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
4062 DWORD dwInstance
, DWORD dwFlags
)
4065 UINT ret
= waveOutOpen16(&hwo16
, uDeviceID
, lpFormat
, dwCallback
, dwInstance
,
4066 CALLBACK32CONV(dwFlags
));
4068 if (lphWaveOut
) *lphWaveOut
=hwo16
;
4072 /**************************************************************************
4073 * waveOutOpen [MMSYSTEM.404]
4075 UINT16 WINAPI
waveOutOpen16(HWAVEOUT16
* lphWaveOut
, UINT16 uDeviceID
,
4076 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
4077 DWORD dwInstance
, DWORD dwFlags
)
4079 HWAVEOUT16 hWaveOut
;
4080 LPWAVEOPENDESC lpDesc
;
4081 DWORD dwRet
= MMSYSERR_NOERROR
;
4082 BOOL bMapperFlg
= FALSE
;
4084 TRACE("(%p, %d, %p, %08lX, %08lX, %08lX);\n",
4085 lphWaveOut
, uDeviceID
, lpFormat
, dwCallback
, dwInstance
, dwFlags
);
4086 if (dwFlags
& WAVE_FORMAT_QUERY
)
4087 TRACE("WAVE_FORMAT_QUERY requested !\n");
4088 if (uDeviceID
== (UINT16
)WAVE_MAPPER
) {
4089 TRACE("WAVE_MAPPER mode requested !\n");
4093 if (lpFormat
== NULL
) return WAVERR_BADFORMAT
;
4095 hWaveOut
= USER_HEAP_ALLOC(sizeof(WAVEOPENDESC
));
4096 if (hWaveOut
== 0) return MMSYSERR_NOMEM
;
4097 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4098 if (lpDesc
== NULL
) return MMSYSERR_NOMEM
;
4099 lpDesc
->hWave
= hWaveOut
;
4100 lpDesc
->lpFormat
= (LPWAVEFORMAT
)lpFormat
; /* should the struct be copied iso pointer? */
4101 lpDesc
->dwCallBack
= dwCallback
;
4102 lpDesc
->dwInstance
= dwInstance
;
4103 if (uDeviceID
>= MAXWAVEDRIVERS
)
4105 while (uDeviceID
< MAXWAVEDRIVERS
) {
4106 dwRet
= wodMessage(uDeviceID
, WODM_OPEN
,
4107 lpDesc
->dwInstance
, (DWORD
)lpDesc
, dwFlags
);
4108 if (dwRet
== MMSYSERR_NOERROR
) break;
4109 if (!bMapperFlg
) break;
4111 TRACE("WAVE_MAPPER mode ! try next driver...\n");
4113 lpDesc
->uDeviceID
= uDeviceID
; /* save physical Device ID */
4114 if (dwFlags
& WAVE_FORMAT_QUERY
) {
4115 TRACE("End of WAVE_FORMAT_QUERY !\n");
4116 USER_HEAP_FREE(hWaveOut
);
4119 else if (dwRet
!= MMSYSERR_NOERROR
)
4121 USER_HEAP_FREE(hWaveOut
);
4124 if (lphWaveOut
!= NULL
) *lphWaveOut
= hWaveOut
;
4125 TRACE("=> %ld\n", dwRet
);
4129 /**************************************************************************
4130 * waveOutClose [WINMM.161]
4132 UINT WINAPI
waveOutClose(HWAVEOUT hWaveOut
)
4134 return waveOutClose16(hWaveOut
);
4137 /**************************************************************************
4138 * waveOutClose [MMSYSTEM.405]
4140 UINT16 WINAPI
waveOutClose16(HWAVEOUT16 hWaveOut
)
4142 LPWAVEOPENDESC lpDesc
;
4145 TRACE("(%04X)\n", hWaveOut
);
4147 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4148 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4149 dwRet
= wodMessage(lpDesc
->uDeviceID
, WODM_CLOSE
, lpDesc
->dwInstance
, 0L, 0L);
4150 USER_HEAP_FREE(hWaveOut
);
4154 /**************************************************************************
4155 * waveOutPrepareHeader [WINMM.175]
4157 UINT WINAPI
waveOutPrepareHeader(HWAVEOUT hWaveOut
,
4158 WAVEHDR
* lpWaveOutHdr
, UINT uSize
)
4160 LPWAVEOPENDESC lpDesc
;
4162 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
4164 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4166 return MMSYSERR_INVALHANDLE
;
4167 lpWaveOutHdr
->reserved
= (DWORD
)lpWaveOutHdr
;
4168 return wodMessage(lpDesc
->uDeviceID
, WODM_PREPARE
, lpDesc
->dwInstance
,
4169 (DWORD
)lpWaveOutHdr
, uSize
);
4172 /**************************************************************************
4173 * waveOutPrepareHeader [MMSYSTEM.406]
4175 UINT16 WINAPI
waveOutPrepareHeader16(HWAVEOUT16 hWaveOut
,
4176 WAVEHDR
* /*SEGPTR*/ _lpWaveOutHdr
, UINT16 uSize
)
4178 LPWAVEOPENDESC lpDesc
;
4179 LPWAVEHDR lpWaveOutHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(_lpWaveOutHdr
);
4182 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
4184 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4186 return MMSYSERR_INVALHANDLE
;
4187 lpWaveOutHdr
->reserved
= (DWORD
)_lpWaveOutHdr
;
4188 ret
= wodMessage(lpDesc
->uDeviceID
, WODM_PREPARE
, lpDesc
->dwInstance
,
4189 (DWORD
)lpWaveOutHdr
, uSize
);
4193 /**************************************************************************
4194 * waveOutUnprepareHeader [WINMM.181]
4196 UINT WINAPI
waveOutUnprepareHeader(HWAVEOUT hWaveOut
,
4197 WAVEHDR
* lpWaveOutHdr
, UINT uSize
)
4199 LPWAVEOPENDESC lpDesc
;
4201 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
4203 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4204 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4205 lpWaveOutHdr
->reserved
= (DWORD
)lpWaveOutHdr
;
4206 return wodMessage(lpDesc
->uDeviceID
, WODM_UNPREPARE
, lpDesc
->dwInstance
,
4207 (DWORD
)lpWaveOutHdr
, uSize
);
4210 /**************************************************************************
4211 * waveOutUnprepareHeader [MMSYSTEM.407]
4213 UINT16 WINAPI
waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut
,
4214 WAVEHDR
* lpWaveOutHdr
, UINT16 uSize
)
4216 LPWAVEOPENDESC lpDesc
;
4219 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
4221 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4223 return MMSYSERR_INVALHANDLE
;
4224 ret
= wodMessage(lpDesc
->uDeviceID
, WODM_UNPREPARE
, lpDesc
->dwInstance
,
4225 (DWORD
)lpWaveOutHdr
, uSize
);
4229 /**************************************************************************
4230 * waveOutWrite [MMSYSTEM.408]
4232 UINT WINAPI
waveOutWrite(HWAVEOUT hWaveOut
, WAVEHDR
* lpWaveOutHdr
,
4235 LPWAVEOPENDESC lpDesc
;
4237 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
4239 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4241 return MMSYSERR_INVALHANDLE
;
4242 return wodMessage(lpDesc
->uDeviceID
, WODM_WRITE
, lpDesc
->dwInstance
,
4243 (DWORD
)lpWaveOutHdr
, uSize
);
4246 /**************************************************************************
4247 * waveOutWrite [MMSYSTEM.408]
4249 UINT16 WINAPI
waveOutWrite16(HWAVEOUT16 hWaveOut
, WAVEHDR
* lpWaveOutHdr
,
4252 LPWAVEOPENDESC lpDesc
;
4255 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
4257 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4259 return MMSYSERR_INVALHANDLE
;
4260 ret
= wodMessage(lpDesc
->uDeviceID
, WODM_WRITE
, lpDesc
->dwInstance
, (DWORD
)lpWaveOutHdr
, uSize
);
4264 /**************************************************************************
4265 * waveOutPause [WINMM.174]
4267 UINT WINAPI
waveOutPause(HWAVEOUT hWaveOut
)
4269 return waveOutPause16(hWaveOut
);
4272 /**************************************************************************
4273 * waveOutPause [MMSYSTEM.409]
4275 UINT16 WINAPI
waveOutPause16(HWAVEOUT16 hWaveOut
)
4277 LPWAVEOPENDESC lpDesc
;
4279 TRACE("(%04X)\n", hWaveOut
);
4281 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4282 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4283 return wodMessage(lpDesc
->uDeviceID
, WODM_PAUSE
, lpDesc
->dwInstance
, 0L, 0L);
4286 /**************************************************************************
4287 * waveOutRestart [WINMM.177]
4289 UINT WINAPI
waveOutRestart(HWAVEOUT hWaveOut
)
4291 return waveOutRestart16(hWaveOut
);
4294 /**************************************************************************
4295 * waveOutRestart [MMSYSTEM.410]
4297 UINT16 WINAPI
waveOutRestart16(HWAVEOUT16 hWaveOut
)
4299 LPWAVEOPENDESC lpDesc
;
4301 TRACE("(%04X)\n", hWaveOut
);
4303 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4304 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4305 return wodMessage(lpDesc
->uDeviceID
, WODM_RESTART
, lpDesc
->dwInstance
, 0L, 0L);
4308 /**************************************************************************
4309 * waveOutReset [WINMM.176]
4311 UINT WINAPI
waveOutReset(HWAVEOUT hWaveOut
)
4313 return waveOutReset16(hWaveOut
);
4316 /**************************************************************************
4317 * waveOutReset [MMSYSTEM.411]
4319 UINT16 WINAPI
waveOutReset16(HWAVEOUT16 hWaveOut
)
4321 LPWAVEOPENDESC lpDesc
;
4323 TRACE("(%04X)\n", hWaveOut
);
4325 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4326 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4327 return wodMessage(lpDesc
->uDeviceID
, WODM_RESET
, lpDesc
->dwInstance
, 0L, 0L);
4330 /**************************************************************************
4331 * waveOutGetPosition [WINMM.170]
4333 UINT WINAPI
waveOutGetPosition(HWAVEOUT hWaveOut
, LPMMTIME lpTime
,
4339 mmt16
.wType
= lpTime
->wType
;
4340 ret
= waveOutGetPosition16(hWaveOut
, &mmt16
, sizeof(mmt16
));
4341 MMSYSTEM_MMTIME16to32(lpTime
, &mmt16
);
4345 /**************************************************************************
4346 * waveOutGetPosition [MMSYSTEM.412]
4348 UINT16 WINAPI
waveOutGetPosition16(HWAVEOUT16 hWaveOut
, LPMMTIME16 lpTime
,
4351 LPWAVEOPENDESC lpDesc
;
4352 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpTime
, uSize
);
4353 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4354 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4355 return wodMessage(lpDesc
->uDeviceID
, WODM_GETPOS
, lpDesc
->dwInstance
,
4356 (DWORD
)lpTime
, (DWORD
)uSize
);
4359 #define WAVEOUT_SHORTCUT_1(xx, XX, atype) \
4360 UINT WINAPI waveOut##xx(HWAVEOUT hWaveOut, atype x) \
4362 return waveOut##xx##16(hWaveOut, x); \
4364 UINT16 WINAPI waveOut##xx##16(HWAVEOUT16 hWaveOut, atype x) \
4366 LPWAVEOPENDESC lpDesc; \
4367 TRACE("(%04X, %08lx);\n", hWaveOut, (DWORD)x); \
4368 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut); \
4369 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; \
4370 return wodMessage(lpDesc->uDeviceID, WODM_##XX, \
4371 lpDesc->dwInstance, (DWORD)x, 0L); \
4374 WAVEOUT_SHORTCUT_1(GetPitch
, GETPITCH
, LPDWORD
)
4375 WAVEOUT_SHORTCUT_1(SetPitch
, SETPITCH
, DWORD
)
4376 WAVEOUT_SHORTCUT_1(GetPlaybackRate
, GETPLAYBACKRATE
, LPDWORD
)
4377 WAVEOUT_SHORTCUT_1(SetPlaybackRate
, SETPLAYBACKRATE
, DWORD
)
4379 #define WAVEOUT_SHORTCUT_2(xx, XX, atype) \
4380 UINT WINAPI waveOut##xx(UINT devid, atype x) \
4382 return waveOut##xx##16(devid, x); \
4384 UINT16 WINAPI waveOut##xx##16(UINT16 devid, atype x) \
4386 TRACE("(%04X, %08lx);\n", devid, (DWORD)x); \
4387 return wodMessage(devid, WODM_##XX, 0, (DWORD)x, 0L); \
4390 WAVEOUT_SHORTCUT_2(GetVolume
, GETVOLUME
, LPDWORD
)
4391 WAVEOUT_SHORTCUT_2(SetVolume
, SETVOLUME
, DWORD
)
4393 /**************************************************************************
4394 * waveOutBreakLoop [MMSYSTEM.419]
4396 UINT WINAPI
waveOutBreakLoop(HWAVEOUT hWaveOut
)
4398 return waveOutBreakLoop16(hWaveOut
);
4401 /**************************************************************************
4402 * waveOutBreakLoop [MMSYSTEM.419]
4404 UINT16 WINAPI
waveOutBreakLoop16(HWAVEOUT16 hWaveOut
)
4406 FIXME("(%04X)\n", hWaveOut
);
4407 return MMSYSERR_INVALHANDLE
;
4410 /**************************************************************************
4411 * waveOutGetID [MMSYSTEM.420]
4413 UINT WINAPI
waveOutGetID(HWAVEOUT hWaveOut
, UINT
* lpuDeviceID
)
4415 LPWAVEOPENDESC lpDesc
;
4417 TRACE("(%04X, %p);\n", hWaveOut
, lpuDeviceID
);
4419 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4420 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4421 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4422 *lpuDeviceID
= lpDesc
->uDeviceID
;
4426 /**************************************************************************
4427 * waveOutGetID [MMSYSTEM.420]
4429 UINT16 WINAPI
waveOutGetID16(HWAVEOUT16 hWaveOut
, UINT16
* lpuDeviceID
)
4431 LPWAVEOPENDESC lpDesc
;
4433 TRACE("(%04X, %p);\n", hWaveOut
, lpuDeviceID
);
4435 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4436 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4437 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4438 *lpuDeviceID
= lpDesc
->uDeviceID
;
4442 /**************************************************************************
4443 * waveOutMessage [MMSYSTEM.421]
4445 DWORD WINAPI
waveOutMessage(HWAVEOUT hWaveOut
, UINT uMessage
,
4446 DWORD dwParam1
, DWORD dwParam2
)
4448 LPWAVEOPENDESC lpDesc
;
4450 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4451 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4453 case WODM_GETNUMDEVS
:
4455 case WODM_GETVOLUME
:
4457 case WODM_GETPLAYBACKRATE
:
4458 case WODM_SETVOLUME
:
4460 case WODM_SETPLAYBACKRATE
:
4464 case WODM_UNPREPARE
:
4467 /* no argument conversion needed */
4470 return waveOutWrite(hWaveOut
, (LPWAVEHDR
)dwParam1
, dwParam2
);
4471 case WODM_GETDEVCAPS
:
4472 /* FIXME: UNICODE/ANSI? */
4473 return waveOutGetDevCapsA(hWaveOut
, (LPWAVEOUTCAPSA
)dwParam1
, dwParam2
);
4475 FIXME("can't handle WODM_OPEN, please report.\n");
4478 ERR("(0x%04x, 0x%04x, %08lx, %08lx): unhandled message\n",
4479 hWaveOut
, uMessage
, dwParam1
, dwParam2
);
4482 return wodMessage(lpDesc
->uDeviceID
, uMessage
, lpDesc
->dwInstance
, dwParam1
, dwParam2
);
4485 /**************************************************************************
4486 * waveOutMessage [MMSYSTEM.421]
4488 DWORD WINAPI
waveOutMessage16(HWAVEOUT16 hWaveOut
, UINT16 uMessage
,
4489 DWORD dwParam1
, DWORD dwParam2
)
4491 LPWAVEOPENDESC lpDesc
;
4493 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveOut
);
4494 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4496 case WODM_GETNUMDEVS
:
4497 case WODM_SETVOLUME
:
4499 case WODM_SETPLAYBACKRATE
:
4504 /* no argument conversion needed */
4507 return waveOutGetPosition16(hWaveOut
, (LPMMTIME16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
4508 case WODM_GETVOLUME
:
4509 return waveOutGetVolume16(hWaveOut
, (LPDWORD
)PTR_SEG_TO_LIN(dwParam1
));
4511 return waveOutGetPitch16(hWaveOut
, (LPDWORD
)PTR_SEG_TO_LIN(dwParam1
));
4512 case WODM_GETPLAYBACKRATE
:
4513 return waveOutGetPlaybackRate16(hWaveOut
, (LPDWORD
)PTR_SEG_TO_LIN(dwParam1
));
4514 case WODM_GETDEVCAPS
:
4515 return waveOutGetDevCaps16(hWaveOut
, (LPWAVEOUTCAPS16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
4517 return waveOutPrepareHeader16(hWaveOut
, (LPWAVEHDR
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
4518 case WODM_UNPREPARE
:
4519 return waveOutUnprepareHeader16(hWaveOut
, (LPWAVEHDR
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
4521 return waveOutWrite16(hWaveOut
, (LPWAVEHDR
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
4523 FIXME("can't handle WODM_OPEN, please report.\n");
4526 ERR("(0x%04x, 0x%04x, %08lx, %08lx): unhandled message\n",
4527 hWaveOut
, uMessage
, dwParam1
, dwParam2
);
4529 return wodMessage(lpDesc
->uDeviceID
, uMessage
, lpDesc
->dwInstance
, dwParam1
, dwParam2
);
4532 /**************************************************************************
4533 * waveInGetNumDevs [WINMM.151]
4535 UINT WINAPI
waveInGetNumDevs()
4537 return waveInGetNumDevs16();
4540 /**************************************************************************
4541 * waveInGetNumDevs [MMSYSTEM.501]
4543 UINT16 WINAPI
waveInGetNumDevs16()
4547 TRACE("waveInGetNumDevs\n");
4548 count
+= widMessage(0, WIDM_GETNUMDEVS
, 0L, 0L, 0L);
4549 TRACE("waveInGetNumDevs return %u \n", count
);
4553 /**************************************************************************
4554 * waveInGetDevCapsA [WINMM.147]
4556 UINT WINAPI
waveInGetDevCapsW(UINT uDeviceID
, LPWAVEINCAPSW lpCaps
, UINT uSize
)
4559 UINT ret
= waveInGetDevCaps16(uDeviceID
, &wic16
, uSize
);
4561 lpCaps
->wMid
= wic16
.wMid
;
4562 lpCaps
->wPid
= wic16
.wPid
;
4563 lpCaps
->vDriverVersion
= wic16
.vDriverVersion
;
4564 lstrcpyAtoW(lpCaps
->szPname
, wic16
.szPname
);
4565 lpCaps
->dwFormats
= wic16
.dwFormats
;
4566 lpCaps
->wChannels
= wic16
.wChannels
;
4571 /**************************************************************************
4572 * waveInGetDevCapsA [WINMM.146]
4574 UINT WINAPI
waveInGetDevCapsA(UINT uDeviceID
, LPWAVEINCAPSA lpCaps
, UINT uSize
)
4577 UINT ret
= waveInGetDevCaps16(uDeviceID
, &wic16
, uSize
);
4579 lpCaps
->wMid
= wic16
.wMid
;
4580 lpCaps
->wPid
= wic16
.wPid
;
4581 lpCaps
->vDriverVersion
= wic16
.vDriverVersion
;
4582 strcpy(lpCaps
->szPname
, wic16
.szPname
);
4583 lpCaps
->dwFormats
= wic16
.dwFormats
;
4584 lpCaps
->wChannels
= wic16
.wChannels
;
4588 /**************************************************************************
4589 * waveInGetDevCaps [MMSYSTEM.502]
4591 UINT16 WINAPI
waveInGetDevCaps16(UINT16 uDeviceID
, LPWAVEINCAPS16 lpCaps
, UINT16 uSize
)
4593 TRACE("waveInGetDevCaps\n");
4595 return widMessage(uDeviceID
, WIDM_GETDEVCAPS
, 0L, (DWORD
)lpCaps
, uSize
);
4598 /**************************************************************************
4599 * waveInGetErrorTextA [WINMM.148]
4601 UINT WINAPI
waveInGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
4603 TRACE("waveInGetErrorText\n");
4604 return waveGetErrorText(uError
, lpText
, uSize
);
4607 /**************************************************************************
4608 * waveInGetErrorTextW [WINMM.149]
4610 UINT WINAPI
waveInGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
4612 LPSTR txt
= HeapAlloc(GetProcessHeap(), 0, uSize
);
4613 UINT ret
= waveGetErrorText(uError
, txt
, uSize
);
4615 lstrcpyAtoW(lpText
, txt
);
4616 HeapFree(GetProcessHeap(), 0, txt
);
4620 /**************************************************************************
4621 * waveInGetErrorText [MMSYSTEM.503]
4623 UINT16 WINAPI
waveInGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
4625 TRACE("waveInGetErrorText\n");
4626 return waveGetErrorText(uError
, lpText
, uSize
);
4629 /**************************************************************************
4630 * waveInOpen [WINMM.154]
4632 UINT WINAPI
waveInOpen(HWAVEIN
* lphWaveIn
, UINT uDeviceID
,
4633 const LPWAVEFORMAT lpFormat
, DWORD dwCallback
,
4634 DWORD dwInstance
, DWORD dwFlags
)
4637 UINT ret
= waveInOpen16(&hwin16
, uDeviceID
, lpFormat
, dwCallback
, dwInstance
,
4638 CALLBACK32CONV(dwFlags
));
4639 if (lphWaveIn
) *lphWaveIn
= hwin16
;
4643 /**************************************************************************
4644 * waveInOpen [MMSYSTEM.504]
4646 UINT16 WINAPI
waveInOpen16(HWAVEIN16
* lphWaveIn
, UINT16 uDeviceID
,
4647 const LPWAVEFORMAT lpFormat
, DWORD dwCallback
,
4648 DWORD dwInstance
, DWORD dwFlags
)
4651 LPWAVEOPENDESC lpDesc
;
4653 BOOL bMapperFlg
= FALSE
;
4655 TRACE("(%p, %d, %p, %08lX, %08lX, %08lX);\n",
4656 lphWaveIn
, uDeviceID
, lpFormat
, dwCallback
, dwInstance
, dwFlags
);
4657 if (dwFlags
& WAVE_FORMAT_QUERY
)
4658 TRACE("WAVE_FORMAT_QUERY requested !\n");
4659 if (uDeviceID
== (UINT16
)WAVE_MAPPER
) {
4660 TRACE("WAVE_MAPPER mode requested !\n");
4664 if (lpFormat
== NULL
) return WAVERR_BADFORMAT
;
4665 hWaveIn
= USER_HEAP_ALLOC(sizeof(WAVEOPENDESC
));
4666 if (lphWaveIn
!= NULL
) *lphWaveIn
= hWaveIn
;
4667 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4668 if (lpDesc
== NULL
) return MMSYSERR_NOMEM
;
4669 lpDesc
->hWave
= hWaveIn
;
4670 lpDesc
->lpFormat
= lpFormat
;
4671 lpDesc
->dwCallBack
= dwCallback
;
4672 lpDesc
->dwInstance
= dwInstance
;
4673 while (uDeviceID
< MAXWAVEDRIVERS
) {
4674 dwRet
= widMessage(uDeviceID
, WIDM_OPEN
,
4675 lpDesc
->dwInstance
, (DWORD
)lpDesc
, 0L);
4676 if (dwRet
== MMSYSERR_NOERROR
) break;
4677 if (!bMapperFlg
) break;
4679 TRACE("WAVE_MAPPER mode ! try next driver...\n");
4681 lpDesc
->uDeviceID
= uDeviceID
;
4682 if (dwFlags
& WAVE_FORMAT_QUERY
) {
4683 TRACE("End of WAVE_FORMAT_QUERY !\n");
4684 dwRet
= waveInClose16(hWaveIn
);
4685 } else if (dwRet
!= MMSYSERR_NOERROR
) {
4686 USER_HEAP_FREE(hWaveIn
);
4687 if (lphWaveIn
) *lphWaveIn
= 0;
4693 /**************************************************************************
4694 * waveInClose [WINMM.145]
4696 UINT WINAPI
waveInClose(HWAVEIN hWaveIn
)
4698 return waveInClose16(hWaveIn
);
4701 /**************************************************************************
4702 * waveInClose [MMSYSTEM.505]
4704 UINT16 WINAPI
waveInClose16(HWAVEIN16 hWaveIn
)
4706 LPWAVEOPENDESC lpDesc
;
4709 TRACE("(%04X)\n", hWaveIn
);
4710 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4711 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4712 dwRet
= widMessage(lpDesc
->uDeviceID
, WIDM_CLOSE
, lpDesc
->dwInstance
, 0L, 0L);
4713 USER_HEAP_FREE(hWaveIn
);
4717 /**************************************************************************
4718 * waveInPrepareHeader [WINMM.155]
4720 UINT WINAPI
waveInPrepareHeader(HWAVEIN hWaveIn
,
4721 WAVEHDR
* lpWaveInHdr
, UINT uSize
)
4723 LPWAVEOPENDESC lpDesc
;
4725 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4726 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4727 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4728 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4729 lpWaveInHdr
->lpNext
= NULL
;
4730 lpWaveInHdr
->dwBytesRecorded
= 0;
4731 lpWaveInHdr
->reserved
= (DWORD
)lpWaveInHdr
;
4733 return widMessage(lpDesc
->uDeviceID
, WIDM_PREPARE
, lpDesc
->dwInstance
,
4734 (DWORD
)lpWaveInHdr
, uSize
);
4737 /**************************************************************************
4738 * waveInPrepareHeader [MMSYSTEM.506]
4740 UINT16 WINAPI
waveInPrepareHeader16(HWAVEIN16 hWaveIn
,
4741 WAVEHDR
* /* SEGPTR */ _lpWaveInHdr
, UINT16 uSize
)
4743 LPWAVEOPENDESC lpDesc
;
4744 LPWAVEHDR lpWaveInHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(_lpWaveInHdr
);
4747 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4749 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4750 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4751 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4753 lpWaveInHdr
->lpNext
= NULL
;
4754 lpWaveInHdr
->dwBytesRecorded
= 0;
4756 lpWaveInHdr
->reserved
= (DWORD
)_lpWaveInHdr
;
4758 ret
= widMessage(lpDesc
->uDeviceID
, WIDM_PREPARE
, lpDesc
->dwInstance
,
4759 (DWORD
)lpWaveInHdr
, uSize
);
4763 /**************************************************************************
4764 * waveInUnprepareHeader [WINMM.159]
4766 UINT WINAPI
waveInUnprepareHeader(HWAVEIN hWaveIn
,
4767 WAVEHDR
* lpWaveInHdr
, UINT uSize
)
4769 LPWAVEOPENDESC lpDesc
;
4771 TRACE("(%04X, %p, %u);\n",
4772 hWaveIn
, lpWaveInHdr
, uSize
);
4773 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4774 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4775 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4777 lpWaveInHdr
->lpNext
= NULL
;
4778 return widMessage(lpDesc
->uDeviceID
, WIDM_UNPREPARE
, lpDesc
->dwInstance
,
4779 (DWORD
)lpWaveInHdr
, uSize
);
4782 /**************************************************************************
4783 * waveInUnprepareHeader [MMSYSTEM.507]
4785 UINT16 WINAPI
waveInUnprepareHeader16(HWAVEIN16 hWaveIn
,
4786 WAVEHDR
* lpWaveInHdr
, UINT16 uSize
)
4788 LPWAVEOPENDESC lpDesc
;
4790 TRACE("(%04X, %p, %u);\n",
4791 hWaveIn
, lpWaveInHdr
, uSize
);
4792 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4793 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4794 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4796 return widMessage(lpDesc
->uDeviceID
, WIDM_UNPREPARE
, lpDesc
->dwInstance
,
4797 (DWORD
)lpWaveInHdr
, uSize
);
4800 /**************************************************************************
4801 * waveInAddBuffer [WINMM.144]
4803 UINT WINAPI
waveInAddBuffer(HWAVEIN hWaveIn
,
4804 WAVEHDR
* lpWaveInHdr
, UINT uSize
)
4806 LPWAVEOPENDESC lpDesc
;
4808 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4810 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4811 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4812 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4814 lpWaveInHdr
->lpNext
= NULL
;
4815 lpWaveInHdr
->dwBytesRecorded
= 0;
4817 return widMessage(lpDesc
->uDeviceID
, WIDM_ADDBUFFER
, lpDesc
->dwInstance
,
4818 (DWORD
)lpWaveInHdr
, uSize
);
4822 /**************************************************************************
4823 * waveInAddBuffer [MMSYSTEM.508]
4825 UINT16 WINAPI
waveInAddBuffer16(HWAVEIN16 hWaveIn
,
4826 WAVEHDR
* lpWaveInHdr
, UINT16 uSize
)
4828 LPWAVEOPENDESC lpDesc
;
4831 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4833 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4834 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4835 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4836 lpWaveInHdr
->lpNext
= NULL
;
4837 lpWaveInHdr
->dwBytesRecorded
= 0;
4839 ret
= widMessage(lpDesc
->uDeviceID
, WIDM_ADDBUFFER
, lpDesc
->dwInstance
,
4840 (DWORD
)lpWaveInHdr
, uSize
);
4844 /**************************************************************************
4845 * waveInStart [WINMM.157]
4847 UINT WINAPI
waveInStart(HWAVEIN hWaveIn
)
4849 return waveInStart16(hWaveIn
);
4852 /**************************************************************************
4853 * waveInStart [MMSYSTEM.509]
4855 UINT16 WINAPI
waveInStart16(HWAVEIN16 hWaveIn
)
4857 LPWAVEOPENDESC lpDesc
;
4859 TRACE("(%04X)\n", hWaveIn
);
4860 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4861 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4862 return widMessage(lpDesc
->uDeviceID
, WIDM_START
, lpDesc
->dwInstance
, 0, 0);
4865 /**************************************************************************
4866 * waveInStop [WINMM.158]
4868 UINT WINAPI
waveInStop(HWAVEIN hWaveIn
)
4870 return waveInStop16(hWaveIn
);
4873 /**************************************************************************
4874 * waveInStop [MMSYSTEM.510]
4876 UINT16 WINAPI
waveInStop16(HWAVEIN16 hWaveIn
)
4878 LPWAVEOPENDESC lpDesc
;
4880 TRACE("(%04X)\n", hWaveIn
);
4881 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4882 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4883 return widMessage(lpDesc
->uDeviceID
, WIDM_STOP
, lpDesc
->dwInstance
, 0L, 0L);
4886 /**************************************************************************
4887 * waveInReset [WINMM.156]
4889 UINT WINAPI
waveInReset(HWAVEIN hWaveIn
)
4891 return waveInReset16(hWaveIn
);
4894 /**************************************************************************
4895 * waveInReset [MMSYSTEM.511]
4897 UINT16 WINAPI
waveInReset16(HWAVEIN16 hWaveIn
)
4899 LPWAVEOPENDESC lpDesc
;
4901 TRACE("(%04X)\n", hWaveIn
);
4902 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4903 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4904 return widMessage(lpDesc
->uDeviceID
, WIDM_RESET
, lpDesc
->dwInstance
, 0, 0);
4907 /**************************************************************************
4908 * waveInGetPosition [WINMM.152]
4910 UINT WINAPI
waveInGetPosition(HWAVEIN hWaveIn
, LPMMTIME lpTime
,
4916 mmt16
.wType
= lpTime
->wType
;
4917 ret
= waveInGetPosition16(hWaveIn
, &mmt16
, uSize
);
4919 MMSYSTEM_MMTIME16to32(lpTime
, &mmt16
);
4923 /**************************************************************************
4924 * waveInGetPosition [MMSYSTEM.512]
4926 UINT16 WINAPI
waveInGetPosition16(HWAVEIN16 hWaveIn
, LPMMTIME16 lpTime
,
4929 LPWAVEOPENDESC lpDesc
;
4931 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpTime
, uSize
);
4932 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4933 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4934 return widMessage(lpDesc
->uDeviceID
, WIDM_GETPOS
, lpDesc
->dwInstance
,
4935 (DWORD
)lpTime
, (DWORD
)uSize
);
4938 /**************************************************************************
4939 * waveInGetID [WINMM.150]
4941 UINT WINAPI
waveInGetID(HWAVEIN hWaveIn
, UINT
* lpuDeviceID
)
4943 LPWAVEOPENDESC lpDesc
;
4945 TRACE("waveInGetID\n");
4946 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4947 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4948 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4949 *lpuDeviceID
= lpDesc
->uDeviceID
;
4953 /**************************************************************************
4954 * waveInGetID [MMSYSTEM.513]
4956 UINT16 WINAPI
waveInGetID16(HWAVEIN16 hWaveIn
, UINT16
* lpuDeviceID
)
4958 LPWAVEOPENDESC lpDesc
;
4960 TRACE("waveInGetID\n");
4961 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4962 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4963 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4964 *lpuDeviceID
= lpDesc
->uDeviceID
;
4968 /**************************************************************************
4969 * waveInMessage [WINMM.153]
4971 DWORD WINAPI
waveInMessage(HWAVEIN hWaveIn
, UINT uMessage
,
4972 DWORD dwParam1
, DWORD dwParam2
)
4974 LPWAVEOPENDESC lpDesc
;
4976 FIXME("(%04X, %04X, %08lX, %08lX)\n",
4977 hWaveIn
, uMessage
, dwParam1
, dwParam2
);
4978 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
4979 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
4982 FIXME("cannot handle WIDM_OPEN, please report.\n");
4984 case WIDM_GETNUMDEVS
:
4991 case WIDM_UNPREPARE
:
4992 case WIDM_ADDBUFFER
:
4994 /* no argument conversion needed */
4996 case WIDM_GETDEVCAPS
:
4997 /*FIXME: ANSI/UNICODE */
4998 return waveInGetDevCapsA(hWaveIn
, (LPWAVEINCAPSA
)dwParam1
, dwParam2
);
5000 ERR("(%04x, %04x, %08lx, %08lx): unhandled message\n",
5001 hWaveIn
, uMessage
, dwParam1
, dwParam2
);
5004 return widMessage(lpDesc
->uDeviceID
, uMessage
, lpDesc
->dwInstance
, dwParam1
, dwParam2
);
5007 /**************************************************************************
5008 * waveInMessage [MMSYSTEM.514]
5010 DWORD WINAPI
waveInMessage16(HWAVEIN16 hWaveIn
, UINT16 uMessage
,
5011 DWORD dwParam1
, DWORD dwParam2
)
5013 LPWAVEOPENDESC lpDesc
;
5015 FIXME("(%04X, %04X, %08lX, %08lX)\n",
5016 hWaveIn
, uMessage
, dwParam1
, dwParam2
);
5017 lpDesc
= (LPWAVEOPENDESC
) USER_HEAP_LIN_ADDR(hWaveIn
);
5018 if (lpDesc
== NULL
) return MMSYSERR_INVALHANDLE
;
5021 FIXME("cannot handle WIDM_OPEN, please report.\n");
5023 case WIDM_GETNUMDEVS
:
5029 /* no argument conversion needed */
5031 case WIDM_GETDEVCAPS
:
5032 return waveInGetDevCaps16(hWaveIn
, (LPWAVEINCAPS16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
5034 return waveInGetPosition16(hWaveIn
, (LPMMTIME16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
5036 return waveInPrepareHeader16(hWaveIn
, (LPWAVEHDR
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
5037 case WIDM_UNPREPARE
:
5038 return waveInUnprepareHeader16(hWaveIn
, (LPWAVEHDR
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
5039 case WIDM_ADDBUFFER
:
5040 return waveInAddBuffer16(hWaveIn
, (LPWAVEHDR
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
5042 ERR("(%04x, %04x, %08lx, %08lx): unhandled message\n",
5043 hWaveIn
, uMessage
, dwParam1
, dwParam2
);
5046 return widMessage(lpDesc
->uDeviceID
, uMessage
, lpDesc
->dwInstance
, dwParam1
, dwParam2
);
5049 /**************************************************************************
5050 * DrvOpen [MMSYSTEM.1100]
5052 HDRVR16 WINAPI
DrvOpen(LPSTR lpDriverName
, LPSTR lpSectionName
, LPARAM lParam
)
5054 TRACE("('%s','%s', %08lX);\n", lpDriverName
, lpSectionName
, lParam
);
5056 return OpenDriver16(lpDriverName
, lpSectionName
, lParam
);
5059 /**************************************************************************
5060 * DrvClose [MMSYSTEM.1101]
5062 LRESULT WINAPI
DrvClose(HDRVR16 hDrv
, LPARAM lParam1
, LPARAM lParam2
)
5064 TRACE("(%04X, %08lX, %08lX);\n", hDrv
, lParam1
, lParam2
);
5066 return CloseDriver16(hDrv
, lParam1
, lParam2
);
5069 /**************************************************************************
5070 * DrvSendMessage [MMSYSTEM.1102]
5072 LRESULT WINAPI
DrvSendMessage(HDRVR16 hDrv
, WORD msg
, LPARAM lParam1
,
5075 return SendDriverMessage(hDrv
, msg
, lParam1
, lParam2
);
5078 /**************************************************************************
5079 * DrvGetModuleHandle [MMSYSTEM.1103]
5081 HANDLE16 WINAPI
DrvGetModuleHandle16(HDRVR16 hDrv
)
5083 return GetDriverModuleHandle16(hDrv
);
5086 /**************************************************************************
5087 * DrvDefDriverProc [MMSYSTEM.1104]
5089 LRESULT WINAPI
DrvDefDriverProc(DWORD dwDriverID
, HDRVR16 hDrv
, WORD wMsg
,
5090 DWORD dwParam1
, DWORD dwParam2
)
5092 /* FIXME : any mapping from 32 to 16 bit structure ? */
5093 return DefDriverProc16(dwDriverID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
5096 /**************************************************************************
5097 * DefDriverProc [WINMM.5]
5099 LRESULT WINAPI
DefDriverProc(DWORD dwDriverIdentifier
, HDRVR hDrv
,
5100 UINT Msg
, LPARAM lParam1
, LPARAM lParam2
)
5116 /*#define USE_MM_TSK_WINE*/
5118 /**************************************************************************
5119 * mmTaskCreate [MMSYSTEM.900]
5121 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
5122 * called upon creation with dwPmt as parameter.
5124 HINSTANCE16 WINAPI
mmTaskCreate16(SEGPTR spProc
, HINSTANCE16
*lphMmTask
, DWORD dwPmt
)
5126 DWORD showCmd
= 0x40002;
5133 TRACE("(%08lx, %p, %08lx);\n", spProc
, lphMmTask
, dwPmt
);
5134 /* This to work requires NE modules to be started with a binary command line
5135 * which is not currently the case. A patch exists but has never been committed.
5136 * A workaround would be to integrate code for mmtask.tsk into Wine, but
5137 * this requires tremendous work (starting with patching tools/build to
5138 * create NE executables (and not only DLLs) for builtins modules.
5141 FIXME("This is currently broken. It will fail\n");
5143 cmdline
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, 0x0d);
5145 *(LPDWORD
)(cmdline
+ 1) = (DWORD
)spProc
;
5146 *(LPDWORD
)(cmdline
+ 5) = dwPmt
;
5147 *(LPDWORD
)(cmdline
+ 9) = 0;
5149 sel1
= SELECTOR_AllocBlock(cmdline
, 0x0d, SEGMENT_DATA
, FALSE
, FALSE
);
5150 sel2
= SELECTOR_AllocBlock(&showCmd
, sizeof(showCmd
),
5151 SEGMENT_DATA
, FALSE
, FALSE
);
5153 lp
= (LOADPARAMS16
*)HeapAlloc(GetProcessHeap(), 0, sizeof(LOADPARAMS16
));
5154 lp
->hEnvironment
= 0;
5155 lp
->cmdLine
= PTR_SEG_OFF_TO_SEGPTR(sel1
, 0);
5156 lp
->showCmd
= PTR_SEG_OFF_TO_SEGPTR(sel2
, 0);
5159 #ifndef USE_MM_TSK_WINE
5160 handle
= LoadModule16("c:\\windows\\system\\mmtask.tsk", lp
);
5162 handle
= LoadModule16("mmtask.tsk", lp
);
5165 ret
= (handle
) ? 1 : 2;
5171 *lphMmTask
= handle
;
5173 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel2
, 0));
5174 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel1
, 0));
5176 HeapFree(GetProcessHeap(), 0, lp
);
5177 HeapFree(GetProcessHeap(), 0, cmdline
);
5179 TRACE("=> 0x%04x/%d\n", handle
, ret
);
5183 #ifdef USE_MM_TSK_WINE
5184 /* C equivalent to mmtask.tsk binary content */
5185 void mmTaskEntryPoint16(LPSTR cmdLine
, WORD di
, WORD si
)
5187 int len
= cmdLine
[0x80];
5190 void (*fpProc
)(DWORD
) = (void (*)(DWORD
))PTR_SEG_TO_LIN(*((DWORD
*)(cmdLine
+ 1)));
5191 DWORD dwPmt
= *((DWORD
*)(cmdLine
+ 5));
5194 InitTask16(); /* fixme: pmts / from context ? */
5197 if (SetMessageQueue16(0x40)) {
5199 if (HIWORD(fpProc
)) {
5201 /* EPP StackEnter16(); */
5213 /**************************************************************************
5214 * mmTaskBlock [MMSYSTEM.902]
5216 void WINAPI
mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst
)
5221 GetMessageA(&msg
, 0, 0, 0);
5223 TranslateMessage(&msg
);
5224 DispatchMessageA(&msg
);
5226 } while (msg
.message
< 0x3A0);
5229 /**************************************************************************
5230 * mmTaskSignal [MMSYSTEM.903]
5232 LRESULT WINAPI
mmTaskSignal16(HTASK16 ht
)
5234 TRACE("(%04x);\n", ht
);
5235 return Callout
.PostAppMessage16(ht
, WM_USER
, 0, 0);
5238 /**************************************************************************
5239 * mmTaskYield16 [MMSYSTEM.905]
5241 void WINAPI
mmTaskYield16(void)
5245 if (PeekMessageA(&msg
, 0, 0, 0, 0)) {
5250 DWORD WINAPI
GetProcessFlags(DWORD
);
5252 /**************************************************************************
5253 * mmThreadCreate [MMSYSTEM.1120]
5256 * Creates a MM thread, calling fpThreadAddr(dwPmt).
5258 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
5259 * bit.1 set means to open a VxD for this thread (unsupported)
5261 LRESULT WINAPI
mmThreadCreate16(FARPROC16 fpThreadAddr
, LPHANDLE lpHndl
, DWORD dwPmt
, DWORD dwFlags
)
5266 TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr
, lpHndl
, dwPmt
, dwFlags
);
5268 hndl
= GlobalAlloc16(sizeof(WINE_MMTHREAD
), GMEM_SHARE
|GMEM_ZEROINIT
);
5273 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5276 /* force mmtask routines even if mmthread is required */
5277 /* this will work only if the patch about binary cmd line and NE tasks
5283 lpMMThd
->dwSignature
= WINE_MMTHREAD_CREATED
;
5284 lpMMThd
->dwCounter
= 0;
5285 lpMMThd
->hThread
= 0;
5286 lpMMThd
->dwThreadID
= 0;
5287 lpMMThd
->fpThread
= fpThreadAddr
;
5288 lpMMThd
->dwThreadPmt
= dwPmt
;
5289 lpMMThd
->dwSignalCount
= 0;
5290 lpMMThd
->hEvent
= 0;
5292 lpMMThd
->dwStatus
= 0;
5293 lpMMThd
->dwFlags
= dwFlags
;
5296 if ((dwFlags
& 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
5297 lpMMThd
->hEvent
= CreateEventA(0, 0, 1, 0);
5299 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd
);
5300 if (lpMMThd
->dwFlags
& 2) {
5301 /* as long as we don't support MM VxD in wine, we don't need
5302 * to care about this flag
5304 /* FIXME("Don't know how to properly open VxD handles\n"); */
5305 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
5308 lpMMThd
->hThread
= CreateThread(0, 0, (LPTHREAD_START_ROUTINE
)WINE_mmThreadEntryPoint
,
5309 (LPVOID
)(DWORD
)hndl
, CREATE_SUSPENDED
, &lpMMThd
->dwThreadID
);
5310 if (lpMMThd
->hThread
== 0) {
5311 WARN("Couldn't create thread\n");
5312 /* clean-up(VxDhandle...); devicedirectio... */
5313 if (lpMMThd
->hEvent
!= 0)
5314 CloseHandle(lpMMThd
->hEvent
);
5317 TRACE("Got a nice thread hndl=0x%04x id=0x%08lx\n", lpMMThd
->hThread
, lpMMThd
->dwThreadID
);
5321 /* get WINE_mmThreadEntryPoint()
5322 * 2047 is its ordinal in mmsystem.spec
5324 FARPROC16 fp
= GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (SEGPTR
)2047);
5326 TRACE("farproc seg=0x%08lx lin=%p\n", (DWORD
)fp
, PTR_SEG_TO_LIN(fp
));
5328 ret
= (fp
== 0) ? 2 : mmTaskCreate16((DWORD
)fp
, 0, hndl
);
5332 if (lpMMThd
->hThread
&& !ResumeThread(lpMMThd
->hThread
))
5333 WARN("Couldn't resume thread\n");
5335 while (lpMMThd
->dwStatus
!= 0x10) { /* test also HIWORD of dwStatus */
5349 TRACE("ok => %ld\n", ret
);
5353 /**************************************************************************
5354 * mmThreadSignal [MMSYSTEM.1121]
5356 void WINAPI
mmThreadSignal16(HANDLE16 hndl
)
5358 TRACE("(%04x)!\n", hndl
);
5361 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5363 lpMMThd
->dwCounter
++;
5364 if (lpMMThd
->hThread
!= 0) {
5365 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
5366 SetEvent(lpMMThd
->hEvent
);
5368 mmTaskSignal16(lpMMThd
->hTask
);
5370 lpMMThd
->dwCounter
--;
5374 /**************************************************************************
5375 * MMSYSTEM_ThreadBlock [internal]
5377 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD
* lpMMThd
)
5382 if (lpMMThd
->dwThreadID
!= GetCurrentThreadId())
5383 ERR("Not called by thread itself\n");
5386 ResetEvent(lpMMThd
->hEvent
);
5387 if (InterlockedDecrement(&lpMMThd
->dwSignalCount
) >= 0)
5389 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
5393 ret
= MsgWaitForMultipleObjects(1, &lpMMThd
->hEvent
, FALSE
, INFINITE
, QS_ALLINPUT
);
5395 case WAIT_OBJECT_0
: /* Event */
5398 case WAIT_OBJECT_0
+ 1: /* Msg */
5400 if (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
5401 Callout
.TranslateMessage(&msg
);
5402 Callout
.DispatchMessageA(&msg
);
5406 WARN("S2.x unsupported ret val 0x%08lx\n", ret
);
5412 /**************************************************************************
5413 * mmThreadBlock [MMSYSTEM.1122]
5415 void WINAPI
mmThreadBlock16(HANDLE16 hndl
)
5417 TRACE("(%04x)!\n", hndl
);
5420 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5422 if (lpMMThd
->hThread
!= 0) {
5423 SYSLEVEL_ReleaseWin16Lock();
5424 MMSYSTEM_ThreadBlock(lpMMThd
);
5425 SYSLEVEL_RestoreWin16Lock();
5427 mmTaskBlock16(lpMMThd
->hTask
);
5433 /**************************************************************************
5434 * mmThreadIsCurrent [MMSYSTEM.1123]
5436 BOOL16 WINAPI
mmThreadIsCurrent16(HANDLE16 hndl
)
5440 TRACE("(%04x)!\n", hndl
);
5442 if (hndl
&& mmThreadIsValid16(hndl
)) {
5443 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5444 ret
= (GetCurrentThreadId() == lpMMThd
->dwThreadID
);
5446 /* FIXME: just a test */
5447 SYSLEVEL_ReleaseWin16Lock();
5448 SYSLEVEL_RestoreWin16Lock();
5451 TRACE("=> %d\n", ret
);
5455 /**************************************************************************
5456 * mmThreadIsValid [MMSYSTEM.1124]
5458 BOOL16 WINAPI
mmThreadIsValid16(HANDLE16 hndl
)
5462 TRACE("(%04x)!\n", hndl
);
5465 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5467 if (!IsBadWritePtr(lpMMThd
, sizeof(WINE_MMTHREAD
)) &&
5468 lpMMThd
->dwSignature
== WINE_MMTHREAD_CREATED
&&
5469 IsTask16(lpMMThd
->hTask
)) {
5470 lpMMThd
->dwCounter
++;
5471 if (lpMMThd
->hThread
!= 0) {
5473 if (GetExitCodeThread(lpMMThd
->hThread
, &dwThreadRet
) &&
5474 dwThreadRet
== STATUS_PENDING
) {
5480 lpMMThd
->dwCounter
--;
5483 TRACE("=> %d\n", ret
);
5487 /**************************************************************************
5488 * mmThreadGetTask [MMSYSTEM.1125]
5490 HANDLE16 WINAPI
mmThreadGetTask16(HANDLE16 hndl
)
5494 TRACE("(%04x)\n", hndl
);
5496 if (mmThreadIsValid16(hndl
)) {
5497 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5498 ret
= lpMMThd
->hTask
;
5503 /**************************************************************************
5504 * mmThreadGetTask [internal]
5506 void CALLBACK
WINE_mmThreadEntryPoint(DWORD _pmt
)
5508 HANDLE16 hndl
= (HANDLE16
)_pmt
;
5509 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5511 TRACE("(%04x %p)\n", hndl
, lpMMThd
);
5513 lpMMThd
->hTask
= LOWORD(GetCurrentTask());
5514 TRACE("[10-%08x] setting hTask to 0x%08x\n", lpMMThd
->hThread
, lpMMThd
->hTask
);
5515 lpMMThd
->dwStatus
= 0x10;
5516 MMSYSTEM_ThreadBlock(lpMMThd
);
5517 TRACE("[20-%08x]\n", lpMMThd
->hThread
);
5518 lpMMThd
->dwStatus
= 0x20;
5519 if (lpMMThd
->fpThread
) {
5520 Callbacks
->CallWOWCallbackProc(lpMMThd
->fpThread
, lpMMThd
->dwThreadPmt
);
5522 lpMMThd
->dwStatus
= 0x30;
5523 TRACE("[30-%08x]\n", lpMMThd
->hThread
);
5524 while (lpMMThd
->dwCounter
) {
5528 TRACE("[XX-%08x]\n", lpMMThd
->hThread
);
5530 lpMMThd
->dwSignature
= WINE_MMTHREAD_DELETED
;
5531 /* close lpMMThread->hVxD directio */
5532 if (lpMMThd
->hEvent
)
5533 CloseHandle(lpMMThd
->hEvent
);
5538 typedef BOOL16 (WINAPI
*MMCPLCALLBACK
)(HWND
, LPCSTR
, LPCSTR
, LPCSTR
);
5540 /**************************************************************************
5541 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
5543 BOOL16 WINAPI
mmShowMMCPLPropertySheet16(HWND hWnd
, LPCSTR lpStrDevice
,
5544 LPCSTR lpStrTab
, LPCSTR lpStrTitle
)
5549 TRACE("(%04x \"%s\" \"%s\" \"%s\")\n", hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
5551 hndl
= LoadLibraryA("MMSYS.CPL");
5553 MMCPLCALLBACK fp
= (MMCPLCALLBACK
)GetProcAddress(hndl
, "ShowMMCPLPropertySheet");
5555 SYSLEVEL_ReleaseWin16Lock();
5556 ret
= (fp
)(hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
5557 SYSLEVEL_RestoreWin16Lock();
5565 /**************************************************************************
5566 * StackEnter & StackLeave [MMSYSTEM.32][MMSYSTEM.33]
5568 void WINAPI
StackEnterLeave16(void)
5571 /* mmsystem.dll from Win 95 does only this: so does Wine */