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
14 * 99/9 added support for loadable low level drivers
17 /* FIXME: I think there are some segmented vs. linear pointer weirdnesses
18 * and long term pointers to 16 bit space in here
24 #include "wine/winbase16.h"
31 #include "selectors.h"
33 #include "debugtools.h"
35 DEFAULT_DEBUG_CHANNEL(mmsys
)
37 LONG WINAPI
DrvDefDriverProc(DWORD dwDevID
, HDRVR16 hDrv
, WORD wMsg
,
38 DWORD dwParam1
, DWORD dwParam2
);
40 static LPWINE_MM_IDATA lpFirstIData
= NULL
;
42 static LPWINE_MM_IDATA
MULTIMEDIA_GetIDataNoCheck(void)
44 DWORD pid
= GetCurrentProcessId();
45 LPWINE_MM_IDATA iData
;
47 for (iData
= lpFirstIData
; iData
; iData
= iData
->lpNextIData
) {
48 if (iData
->dwThisProcess
== pid
)
54 /**************************************************************************
55 * MULTIMEDIA_GetIData [internal]
57 LPWINE_MM_IDATA
MULTIMEDIA_GetIData(void)
59 LPWINE_MM_IDATA iData
= MULTIMEDIA_GetIDataNoCheck();
62 ERR("IData not found. Suicide !!!\n");
68 /**************************************************************************
69 * MULTIMEDIA_CreateIData [internal]
71 static BOOL
MULTIMEDIA_CreateIData(HINSTANCE hInstDLL
)
73 LPWINE_MM_IDATA iData
;
75 iData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINE_MM_IDATA
));
79 iData
->hWinMM32Instance
= hInstDLL
;
80 iData
->dwThisProcess
= GetCurrentProcessId();
81 iData
->lpNextIData
= lpFirstIData
;
83 InitializeCriticalSection(&iData
->cs
);
87 /**************************************************************************
88 * MULTIMEDIA_DeleteIData [internal]
90 static void MULTIMEDIA_DeleteIData(void)
92 LPWINE_MM_IDATA iData
= MULTIMEDIA_GetIDataNoCheck();
93 LPWINE_MM_IDATA
* ppid
;
96 for (ppid
= &lpFirstIData
; *ppid
; ppid
= &(*ppid
)->lpNextIData
) {
98 *ppid
= iData
->lpNextIData
;
102 /* FIXME: should also free content and resources allocated
104 HeapFree(GetProcessHeap(), 0, iData
);
108 /**************************************************************************
109 * WINMM_LibMain [EntryPoint]
111 * WINMM DLL entry point
114 BOOL WINAPI
WINMM_LibMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
116 static BOOL bInitDone
= FALSE
;
118 TRACE("0x%x 0x%lx %p\n", hInstDLL
, fdwReason
, fImpLoad
);
121 case DLL_PROCESS_ATTACH
:
122 if (!MULTIMEDIA_CreateIData(hInstDLL
))
124 if (!bInitDone
) { /* to be done only once */
125 if (!MULTIMEDIA_MciInit() || !MMDRV_Init()) {
126 MULTIMEDIA_DeleteIData();
132 case DLL_PROCESS_DETACH
:
133 MULTIMEDIA_DeleteIData();
135 case DLL_THREAD_ATTACH
:
136 case DLL_THREAD_DETACH
:
142 /**************************************************************************
143 * MMSYSTEM_LibMain [EntryPoint]
145 * MMSYSTEM DLL entry point
148 BOOL WINAPI
MMSYSTEM_LibMain(DWORD fdwReason
, HINSTANCE hinstDLL
, WORD ds
,
149 WORD wHeapSize
, DWORD dwReserved1
, WORD wReserved2
)
152 LPWINE_MM_IDATA iData
;
154 TRACE("0x%x 0x%lx\n", hinstDLL
, fdwReason
);
157 case DLL_PROCESS_ATTACH
:
158 /* need to load WinMM in order to:
159 * - correctly initiates shared variables (MULTIMEDIA_Init())
160 * - correctly creates the per process WINE_MM_IDATA chunk
162 hndl
= LoadLibraryA("WINMM.DLL");
165 ERR("Could not load sibling WinMM.dll\n");
168 iData
= MULTIMEDIA_GetIData();
169 iData
->hWinMM16Instance
= hinstDLL
;
170 iData
->h16Module32
= hndl
;
172 case DLL_PROCESS_DETACH
:
173 iData
= MULTIMEDIA_GetIData();
174 FreeLibrary(iData
->h16Module32
);
176 case DLL_THREAD_ATTACH
:
177 case DLL_THREAD_DETACH
:
183 /**************************************************************************
184 * MMSYSTEM_WEP [MMSYSTEM.1]
186 int WINAPI
MMSYSTEM_WEP(HINSTANCE16 hInstance
, WORD wDataSeg
,
187 WORD cbHeapSize
, LPSTR lpCmdLine
)
189 FIXME("STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance
);
193 void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16
, const MMTIME
* mmt32
)
195 mmt16
->wType
= mmt32
->wType
;
196 /* layout of rest is the same for 32/16,
197 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
199 memcpy(&(mmt16
->u
), &(mmt32
->u
), sizeof(mmt16
->u
));
202 void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32
, const MMTIME16
* mmt16
)
204 mmt32
->wType
= mmt16
->wType
;
205 /* layout of rest is the same for 32/16,
206 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
208 memcpy(&(mmt32
->u
), &(mmt16
->u
), sizeof(mmt16
->u
));
211 static HANDLE PlaySound_hThread
= 0;
212 static HANDLE PlaySound_hPlayEvent
= 0;
213 static HANDLE PlaySound_hReadyEvent
= 0;
214 static HANDLE PlaySound_hMiddleEvent
= 0;
215 static BOOL PlaySound_Result
= FALSE
;
216 static int PlaySound_Stop
= FALSE
;
217 static int PlaySound_Playing
= FALSE
;
219 static LPCSTR PlaySound_pszSound
= NULL
;
220 static HMODULE PlaySound_hmod
= 0;
221 static DWORD PlaySound_fdwSound
= 0;
222 static int PlaySound_Loop
= FALSE
;
223 static int PlaySound_SearchMode
= 0; /* 1 - sndPlaySound search order
224 2 - PlaySound order */
226 static HMMIO
get_mmioFromFile(LPCSTR lpszName
)
228 return mmioOpenA((LPSTR
)lpszName
, NULL
,
229 MMIO_ALLOCBUF
| MMIO_READ
| MMIO_DENYWRITE
);
232 static HMMIO
get_mmioFromProfile(UINT uFlags
, LPCSTR lpszName
)
238 TRACE("searching in SystemSound List !\n");
239 GetProfileStringA("Sounds", (LPSTR
)lpszName
, "", str
, sizeof(str
));
240 if (strlen(str
) == 0) {
241 if (uFlags
& SND_NODEFAULT
) return 0;
242 GetProfileStringA("Sounds", "Default", "", str
, sizeof(str
));
243 if (strlen(str
) == 0) return 0;
245 if ((ptr
= (LPSTR
)strchr(str
, ',')) != NULL
) *ptr
= '\0';
246 hmmio
= get_mmioFromFile(str
);
248 WARN("can't find SystemSound='%s' !\n", str
);
254 struct playsound_data
{
259 static void CALLBACK
PlaySound_Callback(HWAVEOUT hwo
, UINT uMsg
,
261 DWORD dwParam1
, DWORD dwParam2
)
263 struct playsound_data
* s
= (struct playsound_data
*)dwInstance
;
270 InterlockedIncrement(&s
->dwEventCount
);
271 TRACE("Returning waveHdr=%lx\n", dwParam1
);
275 ERR("Unknown uMsg=%d\n", uMsg
);
279 static void PlaySound_WaitDone(struct playsound_data
* s
)
282 ResetEvent(s
->hEvent
);
283 if (InterlockedDecrement(&s
->dwEventCount
) >= 0) {
286 InterlockedIncrement(&s
->dwEventCount
);
288 WaitForSingleObject(s
->hEvent
, INFINITE
);
292 static BOOL WINAPI
proc_PlaySound(LPCSTR lpszSoundName
, UINT uFlags
)
298 LPWAVEFORMATEX lpWaveFormat
= NULL
;
300 LPWAVEHDR waveHdr
= NULL
;
301 INT count
, bufsize
, left
, index
;
302 struct playsound_data s
;
306 TRACE("SoundName='%s' uFlags=%04X !\n", lpszSoundName
, uFlags
);
307 if (lpszSoundName
== NULL
) {
311 if (uFlags
& SND_MEMORY
) {
313 memset(&mminfo
, 0, sizeof(mminfo
));
314 mminfo
.fccIOProc
= FOURCC_MEM
;
315 mminfo
.pchBuffer
= (LPSTR
)lpszSoundName
;
316 mminfo
.cchBuffer
= -1;
317 TRACE("Memory sound %p\n", lpszSoundName
);
318 hmmio
= mmioOpenA(NULL
, &mminfo
, MMIO_READ
);
321 if (uFlags
& SND_ALIAS
)
322 if ((hmmio
= get_mmioFromProfile(uFlags
, lpszSoundName
)) == 0)
325 if (uFlags
& SND_FILENAME
)
326 if ((hmmio
=get_mmioFromFile(lpszSoundName
)) == 0) return FALSE
;
328 if (PlaySound_SearchMode
== 1) {
329 PlaySound_SearchMode
= 0;
330 if ((hmmio
= get_mmioFromFile(lpszSoundName
)) == 0)
331 hmmio
= get_mmioFromProfile(uFlags
, lpszSoundName
);
334 if (PlaySound_SearchMode
== 2) {
335 PlaySound_SearchMode
= 0;
336 if ((hmmio
= get_mmioFromProfile(uFlags
| SND_NODEFAULT
, lpszSoundName
)) == 0)
337 if ((hmmio
= get_mmioFromFile(lpszSoundName
)) == 0)
338 hmmio
= get_mmioFromProfile(uFlags
, lpszSoundName
);
341 if (hmmio
== 0) return FALSE
;
343 if (mmioDescend(hmmio
, &ckMainRIFF
, NULL
, 0))
346 TRACE("ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX \n",
347 (LPSTR
)&ckMainRIFF
.ckid
, (LPSTR
)&ckMainRIFF
.fccType
, ckMainRIFF
.cksize
);
349 if ((ckMainRIFF
.ckid
!= FOURCC_RIFF
) ||
350 (ckMainRIFF
.fccType
!= mmioFOURCC('W', 'A', 'V', 'E')))
353 mmckInfo
.ckid
= mmioFOURCC('f', 'm', 't', ' ');
354 if (mmioDescend(hmmio
, &mmckInfo
, &ckMainRIFF
, MMIO_FINDCHUNK
))
357 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n",
358 (LPSTR
)&mmckInfo
.ckid
, (LPSTR
)&mmckInfo
.fccType
, mmckInfo
.cksize
);
360 lpWaveFormat
= HeapAlloc(GetProcessHeap(), 0, mmckInfo
.cksize
);
361 if (mmioRead(hmmio
, (HPSTR
)lpWaveFormat
, mmckInfo
.cksize
) < sizeof(WAVEFORMAT
))
364 TRACE("wFormatTag=%04X !\n", lpWaveFormat
->wFormatTag
);
365 TRACE("nChannels=%d \n", lpWaveFormat
->nChannels
);
366 TRACE("nSamplesPerSec=%ld\n", lpWaveFormat
->nSamplesPerSec
);
367 TRACE("nAvgBytesPerSec=%ld\n", lpWaveFormat
->nAvgBytesPerSec
);
368 TRACE("nBlockAlign=%d \n", lpWaveFormat
->nBlockAlign
);
369 TRACE("wBitsPerSample=%u !\n", lpWaveFormat
->wBitsPerSample
);
371 /* move to end of 'fmt ' chunk */
372 mmioAscend(hmmio
, &mmckInfo
, 0);
374 mmckInfo
.ckid
= mmioFOURCC('d', 'a', 't', 'a');
375 if (mmioDescend(hmmio
, &mmckInfo
, &ckMainRIFF
, MMIO_FINDCHUNK
))
378 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n",
379 (LPSTR
)&mmckInfo
.ckid
, (LPSTR
)&mmckInfo
.fccType
, mmckInfo
.cksize
);
381 s
.hEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
);
383 if (waveOutOpen(&hWave
, WAVE_MAPPER
, lpWaveFormat
, (DWORD
)PlaySound_Callback
,
384 (DWORD
)&s
, CALLBACK_FUNCTION
) != MMSYSERR_NOERROR
)
387 /* make it so that 3 buffers per second are needed */
388 bufsize
= (((lpWaveFormat
->nAvgBytesPerSec
/ 3) - 1) / lpWaveFormat
->nBlockAlign
+ 1) *
389 lpWaveFormat
->nBlockAlign
;
390 waveHdr
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR
) + 2 * bufsize
);
391 waveHdr
[0].lpData
= (char*)waveHdr
+ 2 * sizeof(WAVEHDR
);
392 waveHdr
[1].lpData
= (char*)waveHdr
+ 2 * sizeof(WAVEHDR
) + bufsize
;
393 waveHdr
[0].dwUser
= waveHdr
[1].dwUser
= 0L;
394 waveHdr
[0].dwLoops
= waveHdr
[1].dwLoops
= 0L;
395 waveHdr
[0].dwFlags
= waveHdr
[1].dwFlags
= 0L;
396 waveHdr
[0].dwBufferLength
= waveHdr
[1].dwBufferLength
= bufsize
;
397 if (waveOutPrepareHeader(hWave
, &waveHdr
[0], sizeof(WAVEHDR
)) ||
398 waveOutPrepareHeader(hWave
, &waveHdr
[1], sizeof(WAVEHDR
))) {
404 left
= mmckInfo
.cksize
;
405 s
.dwEventCount
= 1L; /* for first buffer */
407 mmioSeek(hmmio
, mmckInfo
.dwDataOffset
, SEEK_SET
);
409 if (PlaySound_Stop
) {
410 PlaySound_Stop
= PlaySound_Loop
= FALSE
;
413 count
= mmioRead(hmmio
, waveHdr
[index
].lpData
, MIN(bufsize
, left
));
414 if (count
< 1) break;
416 waveHdr
[index
].dwBufferLength
= count
;
417 waveHdr
[index
].dwFlags
&= ~WHDR_DONE
;
418 waveOutWrite(hWave
, &waveHdr
[index
], sizeof(WAVEHDR
));
420 PlaySound_WaitDone(&s
);
423 } while (PlaySound_Loop
);
425 PlaySound_WaitDone(&s
);
428 waveOutUnprepareHeader(hWave
, &waveHdr
[0], sizeof(WAVEHDR
));
429 waveOutUnprepareHeader(hWave
, &waveHdr
[1], sizeof(WAVEHDR
));
432 CloseHandle(s
.hEvent
);
433 HeapFree(GetProcessHeap(), 0, waveHdr
);
434 HeapFree(GetProcessHeap(), 0, lpWaveFormat
);
435 if (hWave
) while (waveOutClose(hWave
) == WAVERR_STILLPLAYING
) Sleep(100);
436 if (hmmio
) mmioClose(hmmio
, 0);
441 static DWORD WINAPI
PlaySound_Thread(LPVOID arg
)
446 PlaySound_Playing
= FALSE
;
447 SetEvent(PlaySound_hReadyEvent
);
448 res
= WaitForSingleObject(PlaySound_hPlayEvent
, INFINITE
);
449 ResetEvent(PlaySound_hReadyEvent
);
450 SetEvent(PlaySound_hMiddleEvent
);
451 if (res
== WAIT_FAILED
) ExitThread(2);
452 if (res
!= WAIT_OBJECT_0
) continue;
453 PlaySound_Playing
= TRUE
;
455 if ((PlaySound_fdwSound
& SND_RESOURCE
) == SND_RESOURCE
) {
460 if ((hRES
= FindResourceA(PlaySound_hmod
, PlaySound_pszSound
, "WAVE")) == 0) {
461 PlaySound_Result
= FALSE
;
464 if ((hGLOB
= LoadResource(PlaySound_hmod
, hRES
)) == 0) {
465 PlaySound_Result
= FALSE
;
468 if ((ptr
= LockResource(hGLOB
)) == NULL
) {
470 PlaySound_Result
= FALSE
;
473 PlaySound_Result
= proc_PlaySound(ptr
,
474 ((UINT16
)PlaySound_fdwSound
^ SND_RESOURCE
) | SND_MEMORY
);
478 PlaySound_Result
= proc_PlaySound(PlaySound_pszSound
, (UINT16
)PlaySound_fdwSound
);
482 /**************************************************************************
483 * PlaySoundA [WINMM.1]
485 BOOL WINAPI
PlaySoundA(LPCSTR pszSound
, HMODULE hmod
, DWORD fdwSound
)
487 static LPSTR StrDup
= NULL
;
489 TRACE("pszSound='%p' hmod=%04X fdwSound=%08lX\n",
490 pszSound
, hmod
, fdwSound
);
492 if (PlaySound_hThread
== 0) { /* This is the first time they called us */
494 if ((PlaySound_hReadyEvent
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
)) == 0)
496 if ((PlaySound_hMiddleEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
)) == 0)
498 if ((PlaySound_hPlayEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
)) == 0)
500 if ((PlaySound_hThread
= CreateThread(NULL
, 0, PlaySound_Thread
, 0, 0, &id
)) == 0)
504 /* FIXME? I see no difference between SND_WAIT and SND_NOSTOP ! */
505 if ((fdwSound
& (SND_NOWAIT
| SND_NOSTOP
)) && PlaySound_Playing
)
508 /* Trying to stop if playing */
509 if (PlaySound_Playing
) PlaySound_Stop
= TRUE
;
511 /* Waiting playing thread to get ready. I think 10 secs is ok & if not then leave*/
512 if (WaitForSingleObject(PlaySound_hReadyEvent
, 1000*10) != WAIT_OBJECT_0
)
515 if (!pszSound
|| (fdwSound
& SND_PURGE
))
516 return FALSE
; /* We stoped playing so leaving */
518 if (PlaySound_SearchMode
!= 1) PlaySound_SearchMode
= 2;
519 if (!(fdwSound
& SND_ASYNC
)) {
520 if (fdwSound
& SND_LOOP
)
522 PlaySound_pszSound
= pszSound
;
523 PlaySound_hmod
= hmod
;
524 PlaySound_fdwSound
= fdwSound
;
525 PlaySound_Result
= FALSE
;
526 SetEvent(PlaySound_hPlayEvent
);
527 if (WaitForSingleObject(PlaySound_hMiddleEvent
, INFINITE
) != WAIT_OBJECT_0
)
529 if (WaitForSingleObject(PlaySound_hReadyEvent
, INFINITE
) != WAIT_OBJECT_0
)
531 return PlaySound_Result
;
533 PlaySound_hmod
= hmod
;
534 PlaySound_fdwSound
= fdwSound
;
535 PlaySound_Result
= FALSE
;
537 HeapFree(GetProcessHeap(), 0, StrDup
);
540 if (!((fdwSound
& SND_MEMORY
) || ((fdwSound
& SND_RESOURCE
) &&
541 !((DWORD
)pszSound
>> 16)) || !pszSound
)) {
542 StrDup
= HEAP_strdupA(GetProcessHeap(), 0,pszSound
);
543 PlaySound_pszSound
= StrDup
;
544 } else PlaySound_pszSound
= pszSound
;
545 PlaySound_Loop
= fdwSound
& SND_LOOP
;
546 SetEvent(PlaySound_hPlayEvent
);
547 ResetEvent(PlaySound_hMiddleEvent
);
553 /**************************************************************************
554 * PlaySoundW [WINMM.18]
556 BOOL WINAPI
PlaySoundW(LPCWSTR pszSound
, HMODULE hmod
, DWORD fdwSound
)
561 if (!((fdwSound
& SND_MEMORY
) || ((fdwSound
& SND_RESOURCE
) &&
562 !((DWORD
)pszSound
>> 16)) || !pszSound
)) {
563 pszSoundA
= HEAP_strdupWtoA(GetProcessHeap(), 0,pszSound
);
564 bSound
= PlaySoundA(pszSoundA
, hmod
, fdwSound
);
565 HeapFree(GetProcessHeap(), 0,pszSoundA
);
567 bSound
= PlaySoundA((LPCSTR
)pszSound
, hmod
, fdwSound
);
572 /**************************************************************************
573 * PlaySound16 [MMSYSTEM.3]
575 BOOL16 WINAPI
PlaySound16(LPCSTR pszSound
, HMODULE16 hmod
, DWORD fdwSound
)
579 SYSLEVEL_ReleaseWin16Lock();
580 retv
= PlaySoundA( pszSound
, hmod
, fdwSound
);
581 SYSLEVEL_RestoreWin16Lock();
586 /**************************************************************************
587 * sndPlaySoundA [WINMM135]
589 BOOL WINAPI
sndPlaySoundA(LPCSTR lpszSoundName
, UINT uFlags
)
591 PlaySound_SearchMode
= 1;
592 return PlaySoundA(lpszSoundName
, 0, uFlags
);
595 /**************************************************************************
596 * sndPlaySoundW [WINMM.136]
598 BOOL WINAPI
sndPlaySoundW(LPCWSTR lpszSoundName
, UINT uFlags
)
600 PlaySound_SearchMode
= 1;
601 return PlaySoundW(lpszSoundName
, 0, uFlags
);
604 /**************************************************************************
605 * sndPlaySound16 [MMSYSTEM.2]
607 BOOL16 WINAPI
sndPlaySound16(LPCSTR lpszSoundName
, UINT16 uFlags
)
611 SYSLEVEL_ReleaseWin16Lock();
612 retv
= sndPlaySoundA( lpszSoundName
, uFlags
);
613 SYSLEVEL_RestoreWin16Lock();
619 /**************************************************************************
620 * mmsystemGetVersion [WINMM.134]
622 UINT WINAPI
mmsystemGetVersion(void)
624 return mmsystemGetVersion16();
627 /**************************************************************************
628 * mmsystemGetVersion [MMSYSTEM.5]
629 * return value borrowed from Win95 winmm.dll ;)
631 UINT16 WINAPI
mmsystemGetVersion16(void)
633 TRACE("3.10 (Win95?)\n");
637 /**************************************************************************
638 * DriverProc [MMSYSTEM.6]
640 LRESULT WINAPI
DriverProc16(DWORD dwDevID
, HDRVR16 hDrv
, WORD wMsg
,
641 DWORD dwParam1
, DWORD dwParam2
)
643 TRACE("dwDevID=%08lx hDrv=%04x wMsg=%04x dwParam1=%08lx dwParam2=%08lx\n",
644 dwDevID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
646 return DrvDefDriverProc(dwDevID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
649 /**************************************************************************
650 * DriverCallback [MMSYSTEM.31]
652 BOOL WINAPI
DriverCallback(DWORD dwCallBack
, UINT uFlags
, HDRVR hDev
,
653 UINT wMsg
, DWORD dwUser
, DWORD dwParam1
,
656 TRACE("(%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n",
657 dwCallBack
, uFlags
, hDev
, wMsg
, dwUser
, dwParam1
, dwParam2
);
659 switch (uFlags
& DCB_TYPEMASK
) {
663 WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags
, dwCallBack
);
666 TRACE("Window(%04lX) handle=%04X!\n", dwCallBack
, hDev
);
667 if (!IsWindow(dwCallBack
))
669 Callout
.PostMessageA((HWND16
)dwCallBack
, wMsg
, hDev
, dwParam1
);
671 case DCB_TASK
: /* aka DCB_THREAD */
672 TRACE("Task(%04lx) !\n", dwCallBack
);
673 Callout
.PostThreadMessageA(dwCallBack
, wMsg
, hDev
, dwParam1
);
676 TRACE("Function (32 bit) !\n");
677 ((LPDRVCALLBACK
)dwCallBack
)(hDev
, wMsg
, dwUser
, dwParam1
, dwParam2
);
680 TRACE("Event(%08lx) !\n", dwCallBack
);
681 SetEvent((HANDLE
)dwCallBack
);
683 case 6: /* I would dub it DCB_MMTHREADSIGNAL */
684 /* this is an undocumented DCB_ value used for mmThreads
685 * loword of dwCallBack contains the handle of the lpMMThd block
686 * which dwSignalCount has to be incremented
689 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(LOWORD(dwCallBack
), 0);
691 TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack
), lpMMThd
);
692 /* same as mmThreadSignal16 */
693 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
694 SetEvent(lpMMThd
->hEvent
);
695 /* some other stuff on lpMMThd->hVxD */
700 /* this is an undocumented DCB_ value for... I don't know */
704 WARN("Unknown callback type %d\n", uFlags
& DCB_TYPEMASK
);
711 /**************************************************************************
712 * DriverCallback [MMSYSTEM.31]
714 BOOL16 WINAPI
DriverCallback16(DWORD dwCallBack
, UINT16 uFlags
, HDRVR16 hDev
,
715 WORD wMsg
, DWORD dwUser
, DWORD dwParam1
,
718 return DriverCallback(dwCallBack
, uFlags
, hDev
, wMsg
, dwUser
, dwParam1
, dwParam2
);
721 /**************************************************************************
722 * Mixer devices. New to Win95
725 /**************************************************************************
726 * find out the real mixer ID depending on hmix (depends on dwFlags)
728 static LPWINE_MIXER
MIXER_GetDev(HMIXEROBJ hmix
, DWORD dwFlags
)
730 LPWINE_MIXER lpwm
= NULL
;
732 switch (dwFlags
& 0xF0000000ul
) {
733 case MIXER_OBJECTF_MIXER
:
734 lpwm
= (LPWINE_MIXER
)MMDRV_Get(hmix
, MMDRV_MIXER
, TRUE
);
736 case MIXER_OBJECTF_HMIXER
:
737 lpwm
= (LPWINE_MIXER
)MMDRV_Get(hmix
, MMDRV_MIXER
, FALSE
);
739 case MIXER_OBJECTF_WAVEOUT
:
740 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_WAVEOUT
, TRUE
, MMDRV_MIXER
);
742 case MIXER_OBJECTF_HWAVEOUT
:
743 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_WAVEOUT
, FALSE
, MMDRV_MIXER
);
745 case MIXER_OBJECTF_WAVEIN
:
746 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_WAVEIN
, TRUE
, MMDRV_MIXER
);
748 case MIXER_OBJECTF_HWAVEIN
:
749 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_WAVEIN
, FALSE
, MMDRV_MIXER
);
751 case MIXER_OBJECTF_MIDIOUT
:
752 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_MIDIOUT
, TRUE
, MMDRV_MIXER
);
754 case MIXER_OBJECTF_HMIDIOUT
:
755 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_MIDIOUT
, FALSE
, MMDRV_MIXER
);
757 case MIXER_OBJECTF_MIDIIN
:
758 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_MIDIIN
, TRUE
, MMDRV_MIXER
);
760 case MIXER_OBJECTF_HMIDIIN
:
761 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_MIDIIN
, FALSE
, MMDRV_MIXER
);
763 case MIXER_OBJECTF_AUX
:
764 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_AUX
, TRUE
, MMDRV_MIXER
);
767 FIXME("Unsupported flag (%08lx)\n", dwFlags
& 0xF0000000ul
);
773 /**************************************************************************
774 * mixerGetNumDevs [WINMM.108]
776 UINT WINAPI
mixerGetNumDevs(void)
778 return MMDRV_GetNum(MMDRV_MIXER
);
781 /**************************************************************************
782 * mixerGetNumDevs [MMSYSTEM.800]
784 UINT16 WINAPI
mixerGetNumDevs16(void)
786 return MMDRV_GetNum(MMDRV_MIXER
);
789 /**************************************************************************
790 * mixerGetDevCapsA [WINMM.101]
792 UINT WINAPI
mixerGetDevCapsA(UINT devid
, LPMIXERCAPSA mixcaps
, UINT size
)
796 if ((wmld
= MMDRV_Get(devid
, MMDRV_MIXER
, TRUE
)) == NULL
)
797 return MMSYSERR_BADDEVICEID
;
799 return MMDRV_Message(wmld
, MXDM_GETDEVCAPS
, (DWORD
)mixcaps
, size
, TRUE
);
802 /**************************************************************************
803 * mixerGetDevCapsW [WINMM.102]
805 UINT WINAPI
mixerGetDevCapsW(UINT devid
, LPMIXERCAPSW mixcaps
, UINT size
)
808 UINT ret
= mixerGetDevCapsA(devid
, &micA
, sizeof(micA
));
810 if (ret
== MMSYSERR_NOERROR
) {
811 mixcaps
->wMid
= micA
.wMid
;
812 mixcaps
->wPid
= micA
.wPid
;
813 mixcaps
->vDriverVersion
= micA
.vDriverVersion
;
814 lstrcpyAtoW(mixcaps
->szPname
, micA
.szPname
);
815 mixcaps
->fdwSupport
= micA
.fdwSupport
;
816 mixcaps
->cDestinations
= micA
.cDestinations
;
821 /**************************************************************************
822 * mixerGetDevCaps [MMSYSTEM.801]
824 UINT16 WINAPI
mixerGetDevCaps16(UINT16 devid
, LPMIXERCAPS16 mixcaps
,
828 UINT ret
= mixerGetDevCapsA(devid
, &micA
, sizeof(micA
));
830 if (ret
== MMSYSERR_NOERROR
) {
831 mixcaps
->wMid
= micA
.wMid
;
832 mixcaps
->wPid
= micA
.wPid
;
833 mixcaps
->vDriverVersion
= micA
.vDriverVersion
;
834 strcpy(mixcaps
->szPname
, micA
.szPname
);
835 mixcaps
->fdwSupport
= micA
.fdwSupport
;
836 mixcaps
->cDestinations
= micA
.cDestinations
;
841 static UINT
MMSYSTEM_mixerOpen(LPHMIXER lphMix
, UINT uDeviceID
, DWORD dwCallback
,
842 DWORD dwInstance
, DWORD fdwOpen
, BOOL bFrom32
)
849 TRACE("(%p, %d, %08lx, %08lx, %08lx)\n",
850 lphMix
, uDeviceID
, dwCallback
, dwInstance
, fdwOpen
);
852 wmld
= MMDRV_Alloc(sizeof(WINE_MIXER
), MMDRV_MIXER
, &hMix
, &fdwOpen
,
853 &dwCallback
, &dwInstance
, bFrom32
);
855 wmld
->uDeviceID
= uDeviceID
;
857 mod
.dwCallback
= dwCallback
;
858 mod
.dwInstance
= dwInstance
;
860 dwRet
= MMDRV_Open(wmld
, MXDM_OPEN
, (DWORD
)&mod
, fdwOpen
);
862 if (dwRet
!= MMSYSERR_NOERROR
) {
863 MMDRV_Free(hMix
, wmld
);
866 if (lphMix
) *lphMix
= hMix
;
867 TRACE("=> %ld hMixer=%04x\n", dwRet
, hMix
);
872 /**************************************************************************
873 * mixerOpen [WINMM.110]
875 UINT WINAPI
mixerOpen(LPHMIXER lphMix
, UINT uDeviceID
, DWORD dwCallback
,
876 DWORD dwInstance
, DWORD fdwOpen
)
878 return MMSYSTEM_mixerOpen(lphMix
, uDeviceID
,
879 dwCallback
, dwInstance
, fdwOpen
, TRUE
);
882 /**************************************************************************
883 * mixerOpen [MMSYSTEM.803]
885 UINT16 WINAPI
mixerOpen16(LPHMIXER16 lphmix
, UINT16 uDeviceID
, DWORD dwCallback
,
886 DWORD dwInstance
, DWORD fdwOpen
)
891 ret
= MMSYSTEM_mixerOpen(&hmix
, uDeviceID
,
892 dwCallback
, dwInstance
, fdwOpen
, FALSE
);
893 if (lphmix
) *lphmix
= hmix
;
897 /**************************************************************************
898 * mixerClose [WINMM.98]
900 UINT WINAPI
mixerClose(HMIXER hMix
)
905 TRACE("(%04x)\n", hMix
);
907 if ((wmld
= MMDRV_Get(hMix
, MMDRV_MIXER
, FALSE
)) == NULL
) return MMSYSERR_INVALHANDLE
;
909 dwRet
= MMDRV_Close(wmld
, MXDM_CLOSE
);
910 MMDRV_Free(hMix
, wmld
);
915 /**************************************************************************
916 * mixerClose [MMSYSTEM.803]
918 UINT16 WINAPI
mixerClose16(HMIXER16 hMix
)
920 return mixerClose(hMix
);
923 /**************************************************************************
924 * mixerGetID [WINMM.103]
926 UINT WINAPI
mixerGetID(HMIXEROBJ hmix
, LPUINT lpid
, DWORD fdwID
)
930 TRACE("(%04x %p %08lx)\n", hmix
, lpid
, fdwID
);
932 if ((lpwm
= MIXER_GetDev(hmix
, fdwID
)) == NULL
) {
933 return MMSYSERR_INVALHANDLE
;
937 *lpid
= lpwm
->mld
.uDeviceID
;
939 return MMSYSERR_NOERROR
;
942 /**************************************************************************
945 UINT16 WINAPI
mixerGetID16(HMIXEROBJ16 hmix
, LPUINT16 lpid
, DWORD fdwID
)
948 UINT ret
= mixerGetID(hmix
, &xid
, fdwID
);
955 /**************************************************************************
956 * mixerGetControlDetailsA [WINMM.99]
958 UINT WINAPI
mixerGetControlDetailsA(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcdA
,
963 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcdA
, fdwDetails
);
965 if ((lpwm
= MIXER_GetDev(hmix
, fdwDetails
)) == NULL
)
966 return MMSYSERR_INVALHANDLE
;
968 if (lpmcdA
== NULL
|| lpmcdA
->cbStruct
!= sizeof(*lpmcdA
))
969 return MMSYSERR_INVALPARAM
;
971 return MMDRV_Message(&lpwm
->mld
, MXDM_GETCONTROLDETAILS
, (DWORD
)lpmcdA
,
975 /**************************************************************************
976 * mixerGetControlDetailsW [WINMM.100]
978 UINT WINAPI
mixerGetControlDetailsW(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcd
, DWORD fdwDetails
)
980 DWORD ret
= MMSYSERR_NOTENABLED
;
982 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
984 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
985 return MMSYSERR_INVALPARAM
;
987 switch (fdwDetails
& MIXER_GETCONTROLDETAILSF_QUERYMASK
) {
988 case MIXER_GETCONTROLDETAILSF_VALUE
:
989 /* can savely use W structure as it is, no string inside */
990 ret
= mixerGetControlDetailsA(hmix
, lpmcd
, fdwDetails
);
992 case MIXER_GETCONTROLDETAILSF_LISTTEXT
:
994 LPVOID paDetailsW
= lpmcd
->paDetails
;
995 int size
= MAX(1, lpmcd
->cChannels
) * sizeof(MIXERCONTROLDETAILS_LISTTEXTA
);
997 if (lpmcd
->u
.cMultipleItems
!= 0 && lpmcd
->u
.cMultipleItems
!= lpmcd
->u
.hwndOwner
) {
998 size
*= lpmcd
->u
.cMultipleItems
;
1000 lpmcd
->paDetails
= HeapAlloc(GetProcessHeap(), 0, size
);
1001 /* set up lpmcd->paDetails */
1002 ret
= mixerGetControlDetailsA(hmix
, lpmcd
, fdwDetails
);
1003 /* copy from lpmcd->paDetails back to paDetailsW; */
1004 HeapFree(GetProcessHeap(), 0, lpmcd
->paDetails
);
1005 lpmcd
->paDetails
= paDetailsW
;
1009 ERR("Unsupported fdwDetails=0x%08lx\n", fdwDetails
);
1015 /**************************************************************************
1016 * mixerGetControlDetails [MMSYSTEM.808]
1018 UINT16 WINAPI
mixerGetControlDetails16(HMIXEROBJ16 hmix
,
1019 LPMIXERCONTROLDETAILS16 lpmcd
,
1022 DWORD ret
= MMSYSERR_NOTENABLED
;
1025 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
1027 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
1028 return MMSYSERR_INVALPARAM
;
1030 sppaDetails
= (SEGPTR
)lpmcd
->paDetails
;
1031 lpmcd
->paDetails
= PTR_SEG_TO_LIN(sppaDetails
);
1032 ret
= mixerGetControlDetailsA(hmix
, (LPMIXERCONTROLDETAILS
)lpmcd
, fdwDetails
);
1033 lpmcd
->paDetails
= (LPVOID
)sppaDetails
;
1038 /**************************************************************************
1039 * mixerGetLineControlsA [WINMM.104]
1041 UINT WINAPI
mixerGetLineControlsA(HMIXEROBJ hmix
, LPMIXERLINECONTROLSA lpmlcA
,
1046 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlcA
, fdwControls
);
1048 if ((lpwm
= MIXER_GetDev(hmix
, fdwControls
)) == NULL
)
1049 return MMSYSERR_INVALHANDLE
;
1051 if (lpmlcA
== NULL
|| lpmlcA
->cbStruct
!= sizeof(*lpmlcA
))
1052 return MMSYSERR_INVALPARAM
;
1054 return MMDRV_Message(&lpwm
->mld
, MXDM_GETLINECONTROLS
, (DWORD
)lpmlcA
,
1058 /**************************************************************************
1059 * mixerGetLineControlsW [WINMM.105]
1061 UINT WINAPI
mixerGetLineControlsW(HMIXEROBJ hmix
, LPMIXERLINECONTROLSW lpmlcW
,
1064 MIXERLINECONTROLSA mlcA
;
1068 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlcW
, fdwControls
);
1070 if (lpmlcW
== NULL
|| lpmlcW
->cbStruct
!= sizeof(*lpmlcW
) ||
1071 lpmlcW
->cbmxctrl
!= sizeof(MIXERCONTROLW
))
1072 return MMSYSERR_INVALPARAM
;
1074 mlcA
.cbStruct
= sizeof(mlcA
);
1075 mlcA
.dwLineID
= lpmlcW
->dwLineID
;
1076 mlcA
.u
.dwControlID
= lpmlcW
->u
.dwControlID
;
1077 mlcA
.u
.dwControlType
= lpmlcW
->u
.dwControlType
;
1078 mlcA
.cControls
= lpmlcW
->cControls
;
1079 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
1080 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0,
1081 mlcA
.cControls
* mlcA
.cbmxctrl
);
1083 ret
= mixerGetLineControlsA(hmix
, &mlcA
, fdwControls
);
1085 if (ret
== MMSYSERR_NOERROR
) {
1086 lpmlcW
->dwLineID
= mlcA
.dwLineID
;
1087 lpmlcW
->u
.dwControlID
= mlcA
.u
.dwControlID
;
1088 lpmlcW
->u
.dwControlType
= mlcA
.u
.dwControlType
;
1089 lpmlcW
->cControls
= mlcA
.cControls
;
1091 for (i
= 0; i
< mlcA
.cControls
; i
++) {
1092 lpmlcW
->pamxctrl
[i
].cbStruct
= sizeof(MIXERCONTROLW
);
1093 lpmlcW
->pamxctrl
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
1094 lpmlcW
->pamxctrl
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
1095 lpmlcW
->pamxctrl
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
1096 lpmlcW
->pamxctrl
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
1097 lstrcpyAtoW(lpmlcW
->pamxctrl
[i
].szShortName
,
1098 mlcA
.pamxctrl
[i
].szShortName
);
1099 lstrcpyAtoW(lpmlcW
->pamxctrl
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
1100 /* sizeof(lpmlcW->pamxctrl[i].Bounds) ==
1101 * sizeof(mlcA.pamxctrl[i].Bounds) */
1102 memcpy(&lpmlcW
->pamxctrl
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
,
1103 sizeof(mlcA
.pamxctrl
[i
].Bounds
));
1104 /* sizeof(lpmlcW->pamxctrl[i].Metrics) ==
1105 * sizeof(mlcA.pamxctrl[i].Metrics) */
1106 memcpy(&lpmlcW
->pamxctrl
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
,
1107 sizeof(mlcA
.pamxctrl
[i
].Metrics
));
1111 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
1116 /**************************************************************************
1117 * mixerGetLineControls [MMSYSTEM.807]
1119 UINT16 WINAPI
mixerGetLineControls16(HMIXEROBJ16 hmix
,
1120 LPMIXERLINECONTROLS16 lpmlc16
,
1123 MIXERLINECONTROLSA mlcA
;
1126 LPMIXERCONTROL16 lpmc16
;
1128 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlc16
, fdwControls
);
1130 if (lpmlc16
== NULL
|| lpmlc16
->cbStruct
!= sizeof(*lpmlc16
) ||
1131 lpmlc16
->cbmxctrl
!= sizeof(MIXERCONTROL16
))
1132 return MMSYSERR_INVALPARAM
;
1134 mlcA
.cbStruct
= sizeof(mlcA
);
1135 mlcA
.dwLineID
= lpmlc16
->dwLineID
;
1136 mlcA
.u
.dwControlID
= lpmlc16
->u
.dwControlID
;
1137 mlcA
.u
.dwControlType
= lpmlc16
->u
.dwControlType
;
1138 mlcA
.cControls
= lpmlc16
->cControls
;
1139 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
1140 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0,
1141 mlcA
.cControls
* mlcA
.cbmxctrl
);
1143 ret
= mixerGetLineControlsA(hmix
, &mlcA
, fdwControls
);
1145 if (ret
== MMSYSERR_NOERROR
) {
1146 lpmlc16
->dwLineID
= mlcA
.dwLineID
;
1147 lpmlc16
->u
.dwControlID
= mlcA
.u
.dwControlID
;
1148 lpmlc16
->u
.dwControlType
= mlcA
.u
.dwControlType
;
1149 lpmlc16
->cControls
= mlcA
.cControls
;
1151 lpmc16
= PTR_SEG_TO_LIN(lpmlc16
->pamxctrl
);
1153 for (i
= 0; i
< mlcA
.cControls
; i
++) {
1154 lpmc16
[i
].cbStruct
= sizeof(MIXERCONTROL16
);
1155 lpmc16
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
1156 lpmc16
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
1157 lpmc16
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
1158 lpmc16
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
1159 strcpy(lpmc16
[i
].szShortName
, mlcA
.pamxctrl
[i
].szShortName
);
1160 strcpy(lpmc16
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
1161 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
1162 memcpy(&lpmc16
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
,
1163 sizeof(mlcA
.pamxctrl
[i
].Bounds
));
1164 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
1165 memcpy(&lpmc16
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
,
1166 sizeof(mlcA
.pamxctrl
[i
].Metrics
));
1170 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
1175 /**************************************************************************
1176 * mixerGetLineInfoA [WINMM.106]
1178 UINT WINAPI
mixerGetLineInfoA(HMIXEROBJ hmix
, LPMIXERLINEA lpmliW
, DWORD fdwInfo
)
1182 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmliW
, fdwInfo
);
1184 if ((lpwm
= MIXER_GetDev(hmix
, fdwInfo
)) == NULL
)
1185 return MMSYSERR_INVALHANDLE
;
1187 return MMDRV_Message(&lpwm
->mld
, MXDM_GETLINEINFO
, (DWORD
)lpmliW
,
1191 /**************************************************************************
1192 * mixerGetLineInfoW [WINMM.107]
1194 UINT WINAPI
mixerGetLineInfoW(HMIXEROBJ hmix
, LPMIXERLINEW lpmliW
,
1200 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmliW
, fdwInfo
);
1202 if (lpmliW
== NULL
|| lpmliW
->cbStruct
!= sizeof(*lpmliW
))
1203 return MMSYSERR_INVALPARAM
;
1205 mliA
.cbStruct
= sizeof(mliA
);
1206 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
1207 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
1208 mliA
.dwComponentType
= lpmliW
->dwComponentType
;
1210 case MIXER_GETLINEINFOF_DESTINATION
:
1211 mliA
.dwDestination
= lpmliW
->dwDestination
;
1213 case MIXER_GETLINEINFOF_LINEID
:
1214 mliA
.dwLineID
= lpmliW
->dwLineID
;
1216 case MIXER_GETLINEINFOF_SOURCE
:
1217 mliA
.dwDestination
= lpmliW
->dwDestination
;
1218 mliA
.dwSource
= lpmliW
->dwSource
;
1220 case MIXER_GETLINEINFOF_TARGETTYPE
:
1221 mliA
.Target
.dwType
= lpmliW
->Target
.dwType
;
1222 mliA
.Target
.wMid
= lpmliW
->Target
.wMid
;
1223 mliA
.Target
.wPid
= lpmliW
->Target
.wPid
;
1224 mliA
.Target
.vDriverVersion
= lpmliW
->Target
.vDriverVersion
;
1225 lstrcpyWtoA(mliA
.Target
.szPname
, lpmliW
->Target
.szPname
);
1228 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo
);
1231 ret
= mixerGetLineInfoA(hmix
, &mliA
, fdwInfo
);
1233 lpmliW
->dwDestination
= mliA
.dwDestination
;
1234 lpmliW
->dwSource
= mliA
.dwSource
;
1235 lpmliW
->dwLineID
= mliA
.dwLineID
;
1236 lpmliW
->fdwLine
= mliA
.fdwLine
;
1237 lpmliW
->dwUser
= mliA
.dwUser
;
1238 lpmliW
->dwComponentType
= mliA
.dwComponentType
;
1239 lpmliW
->cChannels
= mliA
.cChannels
;
1240 lpmliW
->cConnections
= mliA
.cConnections
;
1241 lpmliW
->cControls
= mliA
.cControls
;
1242 lstrcpyAtoW(lpmliW
->szShortName
, mliA
.szShortName
);
1243 lstrcpyAtoW(lpmliW
->szName
, mliA
.szName
);
1244 lpmliW
->Target
.dwType
= mliA
.Target
.dwType
;
1245 lpmliW
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
1246 lpmliW
->Target
.wMid
= mliA
.Target
.wMid
;
1247 lpmliW
->Target
.wPid
= mliA
.Target
.wPid
;
1248 lpmliW
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
1249 lstrcpyAtoW(lpmliW
->Target
.szPname
, mliA
.Target
.szPname
);
1254 /**************************************************************************
1255 * mixerGetLineInfo [MMSYSTEM.805]
1257 UINT16 WINAPI
mixerGetLineInfo16(HMIXEROBJ16 hmix
, LPMIXERLINE16 lpmli16
,
1263 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmli16
, fdwInfo
);
1265 if (lpmli16
== NULL
|| lpmli16
->cbStruct
!= sizeof(*lpmli16
))
1266 return MMSYSERR_INVALPARAM
;
1268 mliA
.cbStruct
= sizeof(mliA
);
1269 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
1270 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
1271 mliA
.dwComponentType
= lpmli16
->dwComponentType
;
1273 case MIXER_GETLINEINFOF_DESTINATION
:
1274 mliA
.dwDestination
= lpmli16
->dwDestination
;
1276 case MIXER_GETLINEINFOF_LINEID
:
1277 mliA
.dwLineID
= lpmli16
->dwLineID
;
1279 case MIXER_GETLINEINFOF_SOURCE
:
1280 mliA
.dwDestination
= lpmli16
->dwDestination
;
1281 mliA
.dwSource
= lpmli16
->dwSource
;
1283 case MIXER_GETLINEINFOF_TARGETTYPE
:
1284 mliA
.Target
.dwType
= lpmli16
->Target
.dwType
;
1285 mliA
.Target
.wMid
= lpmli16
->Target
.wMid
;
1286 mliA
.Target
.wPid
= lpmli16
->Target
.wPid
;
1287 mliA
.Target
.vDriverVersion
= lpmli16
->Target
.vDriverVersion
;
1288 strcpy(mliA
.Target
.szPname
, lpmli16
->Target
.szPname
);
1291 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo
);
1294 ret
= mixerGetLineInfoA(hmix
, &mliA
, fdwInfo
);
1296 lpmli16
->dwDestination
= mliA
.dwDestination
;
1297 lpmli16
->dwSource
= mliA
.dwSource
;
1298 lpmli16
->dwLineID
= mliA
.dwLineID
;
1299 lpmli16
->fdwLine
= mliA
.fdwLine
;
1300 lpmli16
->dwUser
= mliA
.dwUser
;
1301 lpmli16
->dwComponentType
= mliA
.dwComponentType
;
1302 lpmli16
->cChannels
= mliA
.cChannels
;
1303 lpmli16
->cConnections
= mliA
.cConnections
;
1304 lpmli16
->cControls
= mliA
.cControls
;
1305 strcpy(lpmli16
->szShortName
, mliA
.szShortName
);
1306 strcpy(lpmli16
->szName
, mliA
.szName
);
1307 lpmli16
->Target
.dwType
= mliA
.Target
.dwType
;
1308 lpmli16
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
1309 lpmli16
->Target
.wMid
= mliA
.Target
.wMid
;
1310 lpmli16
->Target
.wPid
= mliA
.Target
.wPid
;
1311 lpmli16
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
1312 strcpy(lpmli16
->Target
.szPname
, mliA
.Target
.szPname
);
1317 /**************************************************************************
1318 * mixerSetControlDetails [WINMM.111]
1320 UINT WINAPI
mixerSetControlDetails(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcdA
,
1325 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcdA
, fdwDetails
);
1327 if ((lpwm
= MIXER_GetDev(hmix
, fdwDetails
)) == NULL
)
1328 return MMSYSERR_INVALHANDLE
;
1330 return MMDRV_Message(&lpwm
->mld
, MXDM_SETCONTROLDETAILS
, (DWORD
)lpmcdA
,
1334 /**************************************************************************
1335 * mixerSetControlDetails [MMSYSTEM.809]
1337 UINT16 WINAPI
mixerSetControlDetails16(HMIXEROBJ16 hmix
,
1338 LPMIXERCONTROLDETAILS16 lpmcd
,
1341 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
1342 return MMSYSERR_NOTENABLED
;
1345 /**************************************************************************
1346 * mixerMessage [WINMM.109]
1348 UINT WINAPI
mixerMessage(HMIXER hmix
, UINT uMsg
, DWORD dwParam1
, DWORD dwParam2
)
1352 TRACE("(%04lx, %d, %08lx, %08lx): semi-stub?\n",
1353 (DWORD
)hmix
, uMsg
, dwParam1
, dwParam2
);
1355 if ((wmld
= MMDRV_Get(hmix
, MMDRV_MIXER
, FALSE
)) == NULL
)
1356 return MMSYSERR_INVALHANDLE
;
1358 return MMDRV_Message(wmld
, uMsg
, dwParam1
, dwParam2
, TRUE
);
1361 /**************************************************************************
1362 * mixerMessage [MMSYSTEM.804]
1364 UINT16 WINAPI
mixerMessage16(HMIXER16 hmix
, UINT16 uMsg
, DWORD dwParam1
,
1367 return mixerMessage(hmix
, uMsg
, dwParam1
, dwParam2
);
1370 /**************************************************************************
1371 * auxGetNumDevs [WINMM.22]
1373 UINT WINAPI
auxGetNumDevs(void)
1375 return MMDRV_GetNum(MMDRV_AUX
);
1378 /**************************************************************************
1379 * auxGetNumDevs [MMSYSTEM.350]
1381 UINT16 WINAPI
auxGetNumDevs16(void)
1383 return MMDRV_GetNum(MMDRV_AUX
);
1386 /**************************************************************************
1387 * auxGetDevCaps [WINMM.20]
1389 UINT WINAPI
auxGetDevCapsW(UINT uDeviceID
, LPAUXCAPSW lpCaps
, UINT uSize
)
1392 UINT ret
= auxGetDevCapsA(uDeviceID
, &acA
, sizeof(acA
));
1394 lpCaps
->wMid
= acA
.wMid
;
1395 lpCaps
->wPid
= acA
.wPid
;
1396 lpCaps
->vDriverVersion
= acA
.vDriverVersion
;
1397 lstrcpyAtoW(lpCaps
->szPname
, acA
.szPname
);
1398 lpCaps
->wTechnology
= acA
.wTechnology
;
1399 lpCaps
->dwSupport
= acA
.dwSupport
;
1403 /**************************************************************************
1404 * auxGetDevCaps [WINMM.21]
1406 UINT WINAPI
auxGetDevCapsA(UINT uDeviceID
, LPAUXCAPSA lpCaps
, UINT uSize
)
1410 TRACE("(%04X, %p, %d) !\n", uDeviceID
, lpCaps
, uSize
);
1412 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1413 return MMSYSERR_INVALHANDLE
;
1414 return MMDRV_Message(wmld
, AUXDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
1417 /**************************************************************************
1418 * auxGetDevCaps [MMSYSTEM.351]
1420 UINT16 WINAPI
auxGetDevCaps16(UINT16 uDeviceID
, LPAUXCAPS16 lpCaps
, UINT16 uSize
)
1424 TRACE("(%04X, %p, %d) !\n", uDeviceID
, lpCaps
, uSize
);
1426 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1427 return MMSYSERR_INVALHANDLE
;
1428 return MMDRV_Message(wmld
, AUXDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
1431 /**************************************************************************
1432 * auxGetVolume [WINM.23]
1434 UINT WINAPI
auxGetVolume(UINT uDeviceID
, DWORD
* lpdwVolume
)
1438 TRACE("(%04X, %p) !\n", uDeviceID
, lpdwVolume
);
1440 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1441 return MMSYSERR_INVALHANDLE
;
1442 return MMDRV_Message(wmld
, AUXDM_GETVOLUME
, (DWORD
)lpdwVolume
, 0L, TRUE
);
1445 /**************************************************************************
1446 * auxGetVolume [MMSYSTEM.352]
1448 UINT16 WINAPI
auxGetVolume16(UINT16 uDeviceID
, LPDWORD lpdwVolume
)
1452 TRACE("(%04X, %p) !\n", uDeviceID
, lpdwVolume
);
1454 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1455 return MMSYSERR_INVALHANDLE
;
1456 return MMDRV_Message(wmld
, AUXDM_GETVOLUME
, (DWORD
)lpdwVolume
, 0L, TRUE
);
1459 /**************************************************************************
1460 * auxSetVolume [WINMM.25]
1462 UINT WINAPI
auxSetVolume(UINT uDeviceID
, DWORD dwVolume
)
1466 TRACE("(%04X, %lu) !\n", uDeviceID
, dwVolume
);
1468 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1469 return MMSYSERR_INVALHANDLE
;
1470 return MMDRV_Message(wmld
, AUXDM_SETVOLUME
, dwVolume
, 0L, TRUE
);
1473 /**************************************************************************
1474 * auxSetVolume [MMSYSTEM.353]
1476 UINT16 WINAPI
auxSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
1480 TRACE("(%04X, %lu) !\n", uDeviceID
, dwVolume
);
1482 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1483 return MMSYSERR_INVALHANDLE
;
1484 return MMDRV_Message(wmld
, AUXDM_SETVOLUME
, dwVolume
, 0L, TRUE
);
1487 /**************************************************************************
1488 * auxOutMessage [MMSYSTEM.354]
1490 DWORD WINAPI
auxOutMessage(UINT uDeviceID
, UINT uMessage
, DWORD dw1
, DWORD dw2
)
1494 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1495 return MMSYSERR_INVALHANDLE
;
1497 return MMDRV_Message(wmld
, uMessage
, dw1
, dw2
, TRUE
);
1500 /**************************************************************************
1501 * auxOutMessage [MMSYSTEM.354]
1503 DWORD WINAPI
auxOutMessage16(UINT16 uDeviceID
, UINT16 uMessage
, DWORD dw1
, DWORD dw2
)
1507 TRACE("(%04X, %04X, %08lX, %08lX)\n", uDeviceID
, uMessage
, dw1
, dw2
);
1510 case AUXDM_GETNUMDEVS
:
1511 case AUXDM_SETVOLUME
:
1512 /* no argument conversion needed */
1514 case AUXDM_GETVOLUME
:
1515 return auxGetVolume16(uDeviceID
, (LPDWORD
)PTR_SEG_TO_LIN(dw1
));
1516 case AUXDM_GETDEVCAPS
:
1517 return auxGetDevCaps16(uDeviceID
, (LPAUXCAPS16
)PTR_SEG_TO_LIN(dw1
), dw2
);
1519 TRACE("(%04x, %04x, %08lx, %08lx): unhandled message\n",
1520 uDeviceID
, uMessage
, dw1
, dw2
);
1523 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1524 return MMSYSERR_INVALHANDLE
;
1526 return MMDRV_Message(wmld
, uMessage
, dw1
, dw2
, TRUE
);
1529 /**************************************************************************
1530 * mciGetErrorStringW [WINMM.46]
1532 BOOL WINAPI
mciGetErrorStringW(DWORD wError
, LPWSTR lpstrBuffer
, UINT uLength
)
1534 LPSTR bufstr
= HeapAlloc(GetProcessHeap(), 0, uLength
);
1535 BOOL ret
= mciGetErrorStringA(wError
, bufstr
, uLength
);
1537 lstrcpyAtoW(lpstrBuffer
, bufstr
);
1538 HeapFree(GetProcessHeap(), 0, bufstr
);
1542 /**************************************************************************
1543 * mciGetErrorStringA [WINMM.45]
1545 BOOL WINAPI
mciGetErrorStringA(DWORD wError
, LPSTR lpstrBuffer
, UINT uLength
)
1547 return mciGetErrorString16(wError
, lpstrBuffer
, uLength
);
1550 /**************************************************************************
1551 * mciGetErrorString [MMSYSTEM.706]
1553 BOOL16 WINAPI
mciGetErrorString16(DWORD dwError
, LPSTR lpstrBuffer
, UINT16 uLength
)
1557 if (lpstrBuffer
!= NULL
&& uLength
> 0 &&
1558 dwError
>= MCIERR_BASE
&& dwError
<= MCIERR_CUSTOM_DRIVER_BASE
) {
1560 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance
,
1561 dwError
, lpstrBuffer
, uLength
) > 0) {
1568 /**************************************************************************
1569 * mciDriverNotify [MMSYSTEM.711]
1571 BOOL16 WINAPI
mciDriverNotify16(HWND16 hWndCallBack
, UINT16 wDevID
, UINT16 wStatus
)
1573 TRACE("(%04X, %04x, %04X)\n", hWndCallBack
, wDevID
, wStatus
);
1575 if (!IsWindow(hWndCallBack
)) {
1576 WARN("bad hWnd for call back (0x%04x)\n", hWndCallBack
);
1579 TRACE("before PostMessage\n");
1580 Callout
.PostMessageA(hWndCallBack
, MM_MCINOTIFY
, wStatus
, wDevID
);
1584 /**************************************************************************
1585 * mciDriverNotify [WINMM.36]
1587 BOOL WINAPI
mciDriverNotify(HWND hWndCallBack
, UINT wDevID
, UINT wStatus
)
1590 TRACE("(%08X, %04x, %04X)\n", hWndCallBack
, wDevID
, wStatus
);
1592 if (!IsWindow(hWndCallBack
)) {
1593 WARN("bad hWnd for call back (0x%04x)\n", hWndCallBack
);
1596 TRACE("before PostMessage\n");
1597 Callout
.PostMessageA(hWndCallBack
, MM_MCINOTIFY
, wStatus
, wDevID
);
1601 /**************************************************************************
1602 * mciGetDriverData [MMSYSTEM.708]
1604 DWORD WINAPI
mciGetDriverData16(UINT16 uDeviceID
)
1606 return mciGetDriverData(uDeviceID
);
1609 /**************************************************************************
1610 * mciGetDriverData [WINMM.44]
1612 DWORD WINAPI
mciGetDriverData(UINT uDeviceID
)
1614 LPWINE_MCIDRIVER wmd
;
1616 TRACE("(%04x)\n", uDeviceID
);
1618 wmd
= MCI_GetDriver(uDeviceID
);
1621 WARN("Bad uDeviceID\n");
1625 return wmd
->dwPrivate
;
1628 /**************************************************************************
1629 * mciSetDriverData [MMSYSTEM.707]
1631 BOOL16 WINAPI
mciSetDriverData16(UINT16 uDeviceID
, DWORD data
)
1633 return mciSetDriverData(uDeviceID
, data
);
1636 /**************************************************************************
1637 * mciSetDriverData [WINMM.53]
1639 BOOL WINAPI
mciSetDriverData(UINT uDeviceID
, DWORD data
)
1641 LPWINE_MCIDRIVER wmd
;
1643 TRACE("(%04x, %08lx)\n", uDeviceID
, data
);
1645 wmd
= MCI_GetDriver(uDeviceID
);
1648 WARN("Bad uDeviceID\n");
1652 wmd
->dwPrivate
= data
;
1656 /**************************************************************************
1657 * mciSendCommandA [WINMM.49]
1659 DWORD WINAPI
mciSendCommandA(UINT wDevID
, UINT wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1663 TRACE("(%08x, %s, %08lx, %08lx)\n",
1664 wDevID
, MCI_MessageToString(wMsg
), dwParam1
, dwParam2
);
1666 dwRet
= MCI_SendCommand(wDevID
, wMsg
, dwParam1
, dwParam2
, TRUE
);
1667 dwRet
= MCI_CleanUp(dwRet
, wMsg
, dwParam2
, TRUE
);
1668 TRACE("=> %08lx\n", dwRet
);
1672 /**************************************************************************
1673 * mciSendCommandW [WINMM.50]
1675 DWORD WINAPI
mciSendCommandW(UINT wDevID
, UINT wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1677 FIXME("(%08x, %s, %08lx, %08lx): stub\n",
1678 wDevID
, MCI_MessageToString(wMsg
), dwParam1
, dwParam2
);
1679 return MCIERR_UNSUPPORTED_FUNCTION
;
1682 /**************************************************************************
1683 * mciSendCommand [MMSYSTEM.701]
1685 DWORD WINAPI
mciSendCommand16(UINT16 wDevID
, UINT16 wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1689 TRACE("(%04X, %s, %08lX, %08lX)\n",
1690 wDevID
, MCI_MessageToString(wMsg
), dwParam1
, dwParam2
);
1692 dwRet
= MCI_SendCommand(wDevID
, wMsg
, dwParam1
, dwParam2
, FALSE
);
1693 dwRet
= MCI_CleanUp(dwRet
, wMsg
, dwParam2
, FALSE
);
1694 TRACE("=> %ld\n", dwRet
);
1698 /**************************************************************************
1699 * mciGetDeviceID [MMSYSTEM.703]
1701 UINT16 WINAPI
mciGetDeviceID16(LPCSTR lpstrName
)
1703 TRACE("(\"%s\")\n", lpstrName
);
1705 return MCI_GetDriverFromString(lpstrName
);
1708 /**************************************************************************
1709 * mciGetDeviceIDA [WINMM.41]
1711 UINT WINAPI
mciGetDeviceIDA(LPCSTR lpstrName
)
1713 return MCI_GetDriverFromString(lpstrName
);
1716 /**************************************************************************
1717 * mciGetDeviceIDW [WINMM.43]
1719 UINT WINAPI
mciGetDeviceIDW(LPCWSTR lpwstrName
)
1724 lpstrName
= HEAP_strdupWtoA(GetProcessHeap(), 0, lpwstrName
);
1725 ret
= MCI_GetDriverFromString(lpstrName
);
1726 HeapFree(GetProcessHeap(), 0, lpstrName
);
1730 /**************************************************************************
1731 * MCI_DefYieldProc [internal]
1733 UINT16 WINAPI
MCI_DefYieldProc(UINT16 wDevID
, DWORD data
)
1737 TRACE("(0x%04x, 0x%08lx)\n", wDevID
, data
);
1739 if ((HIWORD(data
) != 0 && GetActiveWindow16() != HIWORD(data
)) ||
1740 (GetAsyncKeyState(LOWORD(data
)) & 1) == 0) {
1746 msg
.hwnd
= HIWORD(data
);
1747 while (!PeekMessageA(&msg
, HIWORD(data
), WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
));
1753 /**************************************************************************
1754 * mciSetYieldProc [MMSYSTEM.714]
1756 BOOL16 WINAPI
mciSetYieldProc16(UINT16 uDeviceID
, YIELDPROC fpYieldProc
, DWORD dwYieldData
)
1758 LPWINE_MCIDRIVER wmd
;
1760 TRACE("(%u, %p, %08lx)\n", uDeviceID
, fpYieldProc
, dwYieldData
);
1762 if (!(wmd
= MCI_GetDriver(uDeviceID
))) {
1763 WARN("Bad uDeviceID\n");
1767 wmd
->lpfnYieldProc
= fpYieldProc
;
1768 wmd
->dwYieldData
= dwYieldData
;
1774 /**************************************************************************
1775 * mciSetYieldProc [WINMM.54]
1777 BOOL WINAPI
mciSetYieldProc(UINT uDeviceID
, YIELDPROC fpYieldProc
, DWORD dwYieldData
)
1779 LPWINE_MCIDRIVER wmd
;
1781 TRACE("(%u, %p, %08lx)\n", uDeviceID
, fpYieldProc
, dwYieldData
);
1783 if (!(wmd
= MCI_GetDriver(uDeviceID
))) {
1784 WARN("Bad uDeviceID\n");
1788 wmd
->lpfnYieldProc
= fpYieldProc
;
1789 wmd
->dwYieldData
= dwYieldData
;
1795 /**************************************************************************
1796 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
1798 UINT16 WINAPI
mciGetDeviceIDFromElementID16(DWORD dwElementID
, LPCSTR lpstrType
)
1800 FIXME("(%lu, %s) stub\n", dwElementID
, lpstrType
);
1804 /**************************************************************************
1805 * mciGetDeviceIDFromElementIDW [WINMM.42]
1807 UINT WINAPI
mciGetDeviceIDFromElementIDW(DWORD dwElementID
, LPCWSTR lpstrType
)
1809 /* FIXME: that's rather strange, there is no
1810 * mciGetDeviceIDFromElementID32A in winmm.spec
1812 FIXME("(%lu, %p) stub\n", dwElementID
, lpstrType
);
1816 /**************************************************************************
1817 * mciGetYieldProc [MMSYSTEM.716]
1819 YIELDPROC WINAPI
mciGetYieldProc16(UINT16 uDeviceID
, DWORD
* lpdwYieldData
)
1821 LPWINE_MCIDRIVER wmd
;
1823 TRACE("(%u, %p)\n", uDeviceID
, lpdwYieldData
);
1825 if (!(wmd
= MCI_GetDriver(uDeviceID
))) {
1826 WARN("Bad uDeviceID\n");
1829 if (!wmd
->lpfnYieldProc
) {
1830 WARN("No proc set\n");
1834 WARN("Proc is 32 bit\n");
1837 return wmd
->lpfnYieldProc
;
1840 /**************************************************************************
1841 * mciGetYieldProc [WINMM.47]
1843 YIELDPROC WINAPI
mciGetYieldProc(UINT uDeviceID
, DWORD
* lpdwYieldData
)
1845 LPWINE_MCIDRIVER wmd
;
1847 TRACE("(%u, %p)\n", uDeviceID
, lpdwYieldData
);
1849 if (!(wmd
= MCI_GetDriver(uDeviceID
))) {
1850 WARN("Bad uDeviceID\n");
1853 if (!wmd
->lpfnYieldProc
) {
1854 WARN("No proc set\n");
1858 WARN("Proc is 32 bit\n");
1861 return wmd
->lpfnYieldProc
;
1864 /**************************************************************************
1865 * mciGetCreatorTask [MMSYSTEM.717]
1867 HTASK16 WINAPI
mciGetCreatorTask16(UINT16 uDeviceID
)
1869 return mciGetCreatorTask(uDeviceID
);
1872 /**************************************************************************
1873 * mciGetCreatorTask [WINMM.40]
1875 HTASK WINAPI
mciGetCreatorTask(UINT uDeviceID
)
1877 LPWINE_MCIDRIVER wmd
;
1880 TRACE("(%u)\n", uDeviceID
);
1882 ret
= (!(wmd
= MCI_GetDriver(uDeviceID
))) ? 0 : wmd
->hCreatorTask
;
1884 TRACE("=> %04x\n", ret
);
1888 /**************************************************************************
1889 * mciDriverYield [MMSYSTEM.710]
1891 UINT16 WINAPI
mciDriverYield16(UINT16 uDeviceID
)
1893 LPWINE_MCIDRIVER wmd
;
1896 /* TRACE("(%04x)\n", uDeviceID); */
1898 if (!(wmd
= MCI_GetDriver(uDeviceID
)) || !wmd
->lpfnYieldProc
|| wmd
->bIs32
) {
1901 ret
= wmd
->lpfnYieldProc(uDeviceID
, wmd
->dwYieldData
);
1907 /**************************************************************************
1908 * mciDriverYield [WINMM.37]
1910 UINT WINAPI
mciDriverYield(UINT uDeviceID
)
1912 LPWINE_MCIDRIVER wmd
;
1915 TRACE("(%04x)\n", uDeviceID
);
1917 if (!(wmd
= MCI_GetDriver(uDeviceID
)) || !wmd
->lpfnYieldProc
|| !wmd
->bIs32
) {
1920 ret
= wmd
->lpfnYieldProc(uDeviceID
, wmd
->dwYieldData
);
1926 /**************************************************************************
1927 * midiOutGetNumDevs [WINMM.80]
1929 UINT WINAPI
midiOutGetNumDevs(void)
1931 return MMDRV_GetNum(MMDRV_MIDIOUT
);
1934 /**************************************************************************
1935 * midiOutGetNumDevs [MMSYSTEM.201]
1937 UINT16 WINAPI
midiOutGetNumDevs16(void)
1939 return MMDRV_GetNum(MMDRV_MIDIOUT
);
1942 /**************************************************************************
1943 * midiOutGetDevCapsW [WINMM.76]
1945 UINT WINAPI
midiOutGetDevCapsW(UINT uDeviceID
, LPMIDIOUTCAPSW lpCaps
,
1951 ret
= midiOutGetDevCapsA(uDeviceID
, &mocA
, sizeof(mocA
));
1952 lpCaps
->wMid
= mocA
.wMid
;
1953 lpCaps
->wPid
= mocA
.wPid
;
1954 lpCaps
->vDriverVersion
= mocA
.vDriverVersion
;
1955 lstrcpyAtoW(lpCaps
->szPname
, mocA
.szPname
);
1956 lpCaps
->wTechnology
= mocA
.wTechnology
;
1957 lpCaps
->wVoices
= mocA
.wVoices
;
1958 lpCaps
->wNotes
= mocA
.wNotes
;
1959 lpCaps
->wChannelMask
= mocA
.wChannelMask
;
1960 lpCaps
->dwSupport
= mocA
.dwSupport
;
1964 /**************************************************************************
1965 * midiOutGetDevCapsA [WINMM.75]
1967 UINT WINAPI
midiOutGetDevCapsA(UINT uDeviceID
, LPMIDIOUTCAPSA lpCaps
,
1972 TRACE("(%u, %p, %u);\n", uDeviceID
, lpCaps
, uSize
);
1974 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1976 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIOUT
, TRUE
)) == NULL
)
1977 return MMSYSERR_INVALHANDLE
;
1979 return MMDRV_Message(wmld
, MODM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
1982 /**************************************************************************
1983 * midiOutGetDevCaps [MMSYSTEM.202]
1985 UINT16 WINAPI
midiOutGetDevCaps16(UINT16 uDeviceID
, LPMIDIOUTCAPS16 lpCaps
,
1991 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1993 dwRet
= midiOutGetDevCapsA(uDeviceID
, &capsA
, sizeof(capsA
));
1994 if (dwRet
== MMSYSERR_NOERROR
) {
1995 lpCaps
->wMid
= capsA
.wMid
;
1996 lpCaps
->wPid
= capsA
.wPid
;
1997 lpCaps
->vDriverVersion
= capsA
.vDriverVersion
;
1998 strcpy(lpCaps
->szPname
, capsA
.szPname
);
1999 lpCaps
->wTechnology
= capsA
.wTechnology
;
2000 lpCaps
->wVoices
= capsA
.wVoices
;
2001 lpCaps
->wNotes
= capsA
.wNotes
;
2002 lpCaps
->wChannelMask
= capsA
.wChannelMask
;
2003 lpCaps
->dwSupport
= capsA
.dwSupport
;
2008 /**************************************************************************
2009 * MIDI_GetErrorText [internal]
2011 static UINT16
MIDI_GetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2013 UINT16 ret
= MMSYSERR_BADERRNUM
;
2015 if (lpText
== NULL
) {
2016 ret
= MMSYSERR_INVALPARAM
;
2017 } else if (uSize
== 0) {
2018 ret
= MMSYSERR_NOERROR
;
2020 /* test has been removed 'coz MMSYSERR_BASE is 0, and gcc did emit
2021 * a warning for the test was always true */
2022 (/*uError >= MMSYSERR_BASE && */ uError
<= MMSYSERR_LASTERROR
) ||
2023 (uError
>= MIDIERR_BASE
&& uError
<= MIDIERR_LASTERROR
)) {
2025 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance
,
2026 uError
, lpText
, uSize
) > 0) {
2027 ret
= MMSYSERR_NOERROR
;
2033 /**************************************************************************
2034 * midiOutGetErrorTextA [WINMM.77]
2036 UINT WINAPI
midiOutGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
2038 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2041 /**************************************************************************
2042 * midiOutGetErrorTextW [WINMM.78]
2044 UINT WINAPI
midiOutGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
2046 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
2049 ret
= MIDI_GetErrorText(uError
, xstr
, uSize
);
2050 lstrcpyAtoW(lpText
, xstr
);
2051 HeapFree(GetProcessHeap(), 0, xstr
);
2055 /**************************************************************************
2056 * midiOutGetErrorText [MMSYSTEM.203]
2058 UINT16 WINAPI
midiOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2060 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2063 /**************************************************************************
2064 * MIDI_OutAlloc [internal]
2066 static LPWINE_MIDI
MIDI_OutAlloc(HMIDIOUT
* lphMidiOut
, LPDWORD lpdwCallback
,
2067 LPDWORD lpdwInstance
, LPDWORD lpdwFlags
,
2068 DWORD cIDs
, MIDIOPENSTRMID
* lpIDs
, BOOL bFrom32
)
2074 size
= sizeof(WINE_MIDI
) + (cIDs
? (cIDs
-1) : 0) * sizeof(MIDIOPENSTRMID
);
2076 lpwm
= (LPWINE_MIDI
)MMDRV_Alloc(size
, MMDRV_MIDIOUT
, &hMidiOut
, lpdwFlags
,
2077 lpdwCallback
, lpdwInstance
, bFrom32
);
2079 if (lphMidiOut
!= NULL
)
2080 *lphMidiOut
= hMidiOut
;
2083 lpwm
->mod
.hMidi
= hMidiOut
;
2084 lpwm
->mod
.dwCallback
= *lpdwCallback
;
2085 lpwm
->mod
.dwInstance
= *lpdwInstance
;
2086 lpwm
->mod
.dnDevNode
= 0;
2087 lpwm
->mod
.cIds
= cIDs
;
2089 memcpy(&(lpwm
->mod
.rgIds
), lpIDs
, cIDs
* sizeof(MIDIOPENSTRMID
));
2094 UINT
MMSYSTEM_midiOutOpen(HMIDIOUT
* lphMidiOut
, UINT uDeviceID
, DWORD dwCallback
,
2095 DWORD dwInstance
, DWORD dwFlags
, BOOL bFrom32
)
2101 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2102 lphMidiOut
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
2104 if (lphMidiOut
!= NULL
) *lphMidiOut
= 0;
2106 lpwm
= MIDI_OutAlloc(&hMidiOut
, &dwCallback
, &dwInstance
, &dwFlags
,
2110 return MMSYSERR_NOMEM
;
2112 lpwm
->mld
.uDeviceID
= uDeviceID
;
2114 dwRet
= MMDRV_Open((LPWINE_MLD
)lpwm
, MODM_OPEN
, (DWORD
)&lpwm
->mod
,
2117 if (dwRet
!= MMSYSERR_NOERROR
) {
2118 MMDRV_Free(hMidiOut
, (LPWINE_MLD
)lpwm
);
2122 if (lphMidiOut
) *lphMidiOut
= hMidiOut
;
2123 TRACE("=> %d hMidi=%04x\n", dwRet
, hMidiOut
);
2128 /**************************************************************************
2129 * midiOutOpen [WINM.84]
2131 UINT WINAPI
midiOutOpen(HMIDIOUT
* lphMidiOut
, UINT uDeviceID
,
2132 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2134 return MMSYSTEM_midiOutOpen(lphMidiOut
, uDeviceID
, dwCallback
,
2135 dwInstance
, dwFlags
, TRUE
);
2138 /**************************************************************************
2139 * midiOutOpen [MMSYSTEM.204]
2141 UINT16 WINAPI
midiOutOpen16(HMIDIOUT16
* lphMidiOut
, UINT16 uDeviceID
,
2142 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2147 ret
= MMSYSTEM_midiOutOpen(&hmo
, uDeviceID
, dwCallback
, dwInstance
,
2150 if (lphMidiOut
!= NULL
) *lphMidiOut
= hmo
;
2154 /**************************************************************************
2155 * midiOutClose [WINMM.74]
2157 UINT WINAPI
midiOutClose(HMIDIOUT hMidiOut
)
2162 TRACE("(%04X)\n", hMidiOut
);
2164 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2165 return MMSYSERR_INVALHANDLE
;
2167 dwRet
= MMDRV_Close(wmld
, MODM_CLOSE
);
2168 MMDRV_Free(hMidiOut
, wmld
);
2173 /**************************************************************************
2174 * midiOutClose [MMSYSTEM.205]
2176 UINT16 WINAPI
midiOutClose16(HMIDIOUT16 hMidiOut
)
2178 return midiOutClose(hMidiOut
);
2181 /**************************************************************************
2182 * midiOutPrepareHeader [WINMM.85]
2184 UINT WINAPI
midiOutPrepareHeader(HMIDIOUT hMidiOut
,
2185 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2189 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2191 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2192 return MMSYSERR_INVALHANDLE
;
2194 return MMDRV_Message(wmld
, MODM_PREPARE
, (DWORD
)lpMidiOutHdr
, uSize
, TRUE
);
2197 /**************************************************************************
2198 * midiOutPrepareHeader [MMSYSTEM.206]
2200 UINT16 WINAPI
midiOutPrepareHeader16(HMIDIOUT16 hMidiOut
,
2201 LPMIDIHDR16
/*SEGPTR*/ lpsegMidiOutHdr
,
2205 LPMIDIHDR16 lpMidiOutHdr
= PTR_SEG_TO_LIN(lpsegMidiOutHdr
);
2207 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2209 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2210 return MMSYSERR_INVALHANDLE
;
2212 return MMDRV_Message(wmld
, MODM_PREPARE
, (DWORD
)lpMidiOutHdr
, uSize
, FALSE
);
2215 /**************************************************************************
2216 * midiOutUnprepareHeader [WINMM.89]
2218 UINT WINAPI
midiOutUnprepareHeader(HMIDIOUT hMidiOut
,
2219 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2223 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2225 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
2226 return MMSYSERR_NOERROR
;
2229 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2230 return MMSYSERR_INVALHANDLE
;
2232 return MMDRV_Message(wmld
, MODM_UNPREPARE
, (DWORD
)lpMidiOutHdr
, uSize
, TRUE
);
2235 /**************************************************************************
2236 * midiOutUnprepareHeader [MMSYSTEM.207]
2238 UINT16 WINAPI
midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut
,
2239 LPMIDIHDR16
/*SEGPTR*/ lpsegMidiOutHdr
,
2243 LPMIDIHDR16 lpMidiOutHdr
= PTR_SEG_TO_LIN(lpsegMidiOutHdr
);
2245 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2247 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
2248 return MMSYSERR_NOERROR
;
2251 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2252 return MMSYSERR_INVALHANDLE
;
2254 return MMDRV_Message(wmld
, MODM_UNPREPARE
, (DWORD
)lpsegMidiOutHdr
, uSize
, FALSE
);
2257 /**************************************************************************
2258 * midiOutShortMsg [WINMM.88]
2260 UINT WINAPI
midiOutShortMsg(HMIDIOUT hMidiOut
, DWORD dwMsg
)
2264 TRACE("(%04X, %08lX)\n", hMidiOut
, dwMsg
);
2266 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2267 return MMSYSERR_INVALHANDLE
;
2269 return MMDRV_Message(wmld
, MODM_DATA
, dwMsg
, 0L, FALSE
);
2272 /**************************************************************************
2273 * midiOutShortMsg [MMSYSTEM.208]
2275 UINT16 WINAPI
midiOutShortMsg16(HMIDIOUT16 hMidiOut
, DWORD dwMsg
)
2277 return midiOutShortMsg(hMidiOut
, dwMsg
);
2280 /**************************************************************************
2281 * midiOutLongMsg [WINMM.82]
2283 UINT WINAPI
midiOutLongMsg(HMIDIOUT hMidiOut
,
2284 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2288 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2290 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2291 return MMSYSERR_INVALHANDLE
;
2293 return MMDRV_Message(wmld
, MODM_LONGDATA
, (DWORD
)lpMidiOutHdr
, uSize
, TRUE
);
2296 /**************************************************************************
2297 * midiOutLongMsg [MMSYSTEM.209]
2299 UINT16 WINAPI
midiOutLongMsg16(HMIDIOUT16 hMidiOut
,
2300 LPMIDIHDR16
/* SEGPTR */ lpsegMidiOutHdr
,
2305 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2307 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2308 return MMSYSERR_INVALHANDLE
;
2310 return MMDRV_Message(wmld
, MODM_LONGDATA
, (DWORD
)lpsegMidiOutHdr
, uSize
, FALSE
);
2313 /**************************************************************************
2314 * midiOutReset [WINMM.86]
2316 UINT WINAPI
midiOutReset(HMIDIOUT hMidiOut
)
2320 TRACE("(%04X)\n", hMidiOut
);
2322 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2323 return MMSYSERR_INVALHANDLE
;
2325 return MMDRV_Message(wmld
, MODM_RESET
, 0L, 0L, TRUE
);
2328 /**************************************************************************
2329 * midiOutReset [MMSYSTEM.210]
2331 UINT16 WINAPI
midiOutReset16(HMIDIOUT16 hMidiOut
)
2333 return midiOutReset(hMidiOut
);
2336 /**************************************************************************
2337 * midiOutGetVolume [WINM.81]
2339 UINT WINAPI
midiOutGetVolume(UINT uDeviceID
, DWORD
* lpdwVolume
)
2343 TRACE("(%04X, %p);\n", uDeviceID
, lpdwVolume
);
2345 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIOUT
, TRUE
)) == NULL
)
2346 return MMSYSERR_INVALHANDLE
;
2348 return MMDRV_Message(wmld
, MODM_GETVOLUME
, (DWORD
)lpdwVolume
, 0L, TRUE
);
2351 /**************************************************************************
2352 * midiOutGetVolume [MMSYSTEM.211]
2354 UINT16 WINAPI
midiOutGetVolume16(UINT16 uDeviceID
, DWORD
* lpdwVolume
)
2356 return midiOutGetVolume(uDeviceID
, lpdwVolume
);
2359 /**************************************************************************
2360 * midiOutSetVolume [WINMM.87]
2362 UINT WINAPI
midiOutSetVolume(UINT uDeviceID
, DWORD dwVolume
)
2366 TRACE("(%04X, %ld);\n", uDeviceID
, dwVolume
);
2368 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIOUT
, TRUE
)) == NULL
)
2369 return MMSYSERR_INVALHANDLE
;
2371 return MMDRV_Message(wmld
, MODM_SETVOLUME
, dwVolume
, 0L, TRUE
);
2374 /**************************************************************************
2375 * midiOutSetVolume [MMSYSTEM.212]
2377 UINT16 WINAPI
midiOutSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
2379 return midiOutSetVolume(uDeviceID
, dwVolume
);
2382 /**************************************************************************
2383 * midiOutCachePatches [WINMM.73]
2385 UINT WINAPI
midiOutCachePatches(HMIDIOUT hMidiOut
, UINT uBank
,
2386 WORD
* lpwPatchArray
, UINT uFlags
)
2388 /* not really necessary to support this */
2389 FIXME("not supported yet\n");
2390 return MMSYSERR_NOTSUPPORTED
;
2393 /**************************************************************************
2394 * midiOutCachePatches [MMSYSTEM.213]
2396 UINT16 WINAPI
midiOutCachePatches16(HMIDIOUT16 hMidiOut
, UINT16 uBank
,
2397 WORD
* lpwPatchArray
, UINT16 uFlags
)
2399 return midiOutCachePatches(hMidiOut
, uBank
, lpwPatchArray
, uFlags
);
2402 /**************************************************************************
2403 * midiOutCacheDrumPatches [WINMM.72]
2405 UINT WINAPI
midiOutCacheDrumPatches(HMIDIOUT hMidiOut
, UINT uPatch
,
2406 WORD
* lpwKeyArray
, UINT uFlags
)
2408 FIXME("not supported yet\n");
2409 return MMSYSERR_NOTSUPPORTED
;
2412 /**************************************************************************
2413 * midiOutCacheDrumPatches [MMSYSTEM.214]
2415 UINT16 WINAPI
midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut
, UINT16 uPatch
,
2416 WORD
* lpwKeyArray
, UINT16 uFlags
)
2418 return midiOutCacheDrumPatches16(hMidiOut
, uPatch
, lpwKeyArray
, uFlags
);
2421 /**************************************************************************
2422 * midiOutGetID [WINMM.79]
2424 UINT WINAPI
midiOutGetID(HMIDIOUT hMidiOut
, UINT
* lpuDeviceID
)
2428 TRACE("(%04X, %p)\n", hMidiOut
, lpuDeviceID
);
2430 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2431 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2432 return MMSYSERR_INVALHANDLE
;
2434 *lpuDeviceID
= wmld
->uDeviceID
;
2435 return MMSYSERR_NOERROR
;
2438 /**************************************************************************
2439 * midiOutGetID [MMSYSTEM.215]
2441 UINT16 WINAPI
midiOutGetID16(HMIDIOUT16 hMidiOut
, UINT16
* lpuDeviceID
)
2445 TRACE("(%04X, %p)\n", hMidiOut
, lpuDeviceID
);
2447 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2448 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2449 return MMSYSERR_INVALHANDLE
;
2451 *lpuDeviceID
= wmld
->uDeviceID
;
2452 return MMSYSERR_NOERROR
;
2455 /**************************************************************************
2456 * midiOutMessage [WINMM.83]
2458 DWORD WINAPI
midiOutMessage(HMIDIOUT hMidiOut
, UINT uMessage
,
2459 DWORD dwParam1
, DWORD dwParam2
)
2463 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2465 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2466 return MMSYSERR_INVALHANDLE
;
2471 FIXME("can't handle OPEN or CLOSE message!\n");
2472 return MMSYSERR_NOTSUPPORTED
;
2474 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2477 /**************************************************************************
2478 * midiOutMessage [MMSYSTEM.216]
2480 DWORD WINAPI
midiOutMessage16(HMIDIOUT16 hMidiOut
, UINT16 uMessage
,
2481 DWORD dwParam1
, DWORD dwParam2
)
2485 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2487 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2488 return MMSYSERR_INVALHANDLE
;
2493 FIXME("can't handle OPEN or CLOSE message!\n");
2494 return MMSYSERR_NOTSUPPORTED
;
2496 case MODM_GETVOLUME
:
2497 return midiOutGetVolume16(hMidiOut
, (LPDWORD
)PTR_SEG_TO_LIN(dwParam1
));
2499 return midiOutLongMsg16(hMidiOut
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2501 /* lpMidiOutHdr is still a segmented pointer for this function */
2502 return midiOutPrepareHeader16(hMidiOut
, (LPMIDIHDR16
)dwParam1
, dwParam2
);
2503 case MODM_UNPREPARE
:
2504 return midiOutUnprepareHeader16(hMidiOut
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2506 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2509 /**************************************************************************
2510 * midiInGetNumDevs [WINMM.64]
2512 UINT WINAPI
midiInGetNumDevs(void)
2514 return MMDRV_GetNum(MMDRV_MIDIIN
);
2517 /**************************************************************************
2518 * midiInGetNumDevs [MMSYSTEM.301]
2520 UINT16 WINAPI
midiInGetNumDevs16(void)
2522 return MMDRV_GetNum(MMDRV_MIDIIN
);
2525 /**************************************************************************
2526 * midiInGetDevCaps [WINMM.60]
2528 UINT WINAPI
midiInGetDevCapsW(UINT uDeviceID
, LPMIDIINCAPSW lpCaps
, UINT uSize
)
2531 UINT ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
2533 if (ret
== MMSYSERR_NOERROR
) {
2534 lpCaps
->wMid
= micA
.wMid
;
2535 lpCaps
->wPid
= micA
.wPid
;
2536 lpCaps
->vDriverVersion
= micA
.vDriverVersion
;
2537 lstrcpyAtoW(lpCaps
->szPname
, micA
.szPname
);
2538 lpCaps
->dwSupport
= micA
.dwSupport
;
2543 /**************************************************************************
2544 * midiInGetDevCaps [WINMM.59]
2546 UINT WINAPI
midiInGetDevCapsA(UINT uDeviceID
, LPMIDIINCAPSA lpCaps
, UINT uSize
)
2550 TRACE("(%d, %p, %d);\n", uDeviceID
, lpCaps
, uSize
);
2552 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2553 return MMSYSERR_INVALHANDLE
;
2555 return MMDRV_Message(wmld
, MIDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
2558 /**************************************************************************
2559 * midiInGetDevCaps [MMSYSTEM.302]
2561 UINT16 WINAPI
midiInGetDevCaps16(UINT16 uDeviceID
, LPMIDIINCAPS16 lpCaps
,
2565 UINT ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
2567 if (ret
== MMSYSERR_NOERROR
) {
2568 lpCaps
->wMid
= micA
.wMid
;
2569 lpCaps
->wPid
= micA
.wPid
;
2570 lpCaps
->vDriverVersion
= micA
.vDriverVersion
;
2571 strcpy(lpCaps
->szPname
, micA
.szPname
);
2572 lpCaps
->dwSupport
= micA
.dwSupport
;
2578 /**************************************************************************
2579 * midiInGetErrorText [WINMM.62]
2581 UINT WINAPI
midiInGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
2583 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
2584 UINT ret
= MIDI_GetErrorText(uError
, xstr
, uSize
);
2586 lstrcpyAtoW(lpText
, xstr
);
2587 HeapFree(GetProcessHeap(), 0, xstr
);
2591 /**************************************************************************
2592 * midiInGetErrorText [WINMM.61]
2594 UINT WINAPI
midiInGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
2596 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2599 /**************************************************************************
2600 * midiInGetErrorText [MMSYSTEM.303]
2602 UINT16 WINAPI
midiInGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2604 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2607 static UINT
MMSYSTEM_midiInOpen(HMIDIIN
* lphMidiIn
, UINT uDeviceID
, DWORD dwCallback
,
2608 DWORD dwInstance
, DWORD dwFlags
, BOOL bFrom32
)
2614 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2615 lphMidiIn
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
2617 if (lphMidiIn
!= NULL
) *lphMidiIn
= 0;
2619 lpwm
= (LPWINE_MIDI
)MMDRV_Alloc(sizeof(WINE_MIDI
), MMDRV_MIDIIN
, &hMidiIn
,
2620 &dwFlags
, &dwCallback
, &dwInstance
, bFrom32
);
2623 return MMSYSERR_NOMEM
;
2625 lpwm
->mod
.hMidi
= hMidiIn
;
2626 lpwm
->mod
.dwCallback
= dwCallback
;
2627 lpwm
->mod
.dwInstance
= dwInstance
;
2629 lpwm
->mld
.uDeviceID
= uDeviceID
;
2630 dwRet
= MMDRV_Open(&lpwm
->mld
, MIDM_OPEN
, (DWORD
)&lpwm
->mod
, dwFlags
);
2632 if (dwRet
!= MMSYSERR_NOERROR
) {
2633 MMDRV_Free(hMidiIn
, &lpwm
->mld
);
2636 if (lphMidiIn
!= NULL
) *lphMidiIn
= hMidiIn
;
2637 TRACE("=> %ld hMidi=%04x\n", dwRet
, hMidiIn
);
2642 /**************************************************************************
2643 * midiInOpen [WINMM.66]
2645 UINT WINAPI
midiInOpen(HMIDIIN
* lphMidiIn
, UINT uDeviceID
,
2646 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2648 return MMSYSTEM_midiInOpen(lphMidiIn
, uDeviceID
, dwCallback
,
2649 dwInstance
, dwFlags
, TRUE
);
2652 /**************************************************************************
2653 * midiInOpen [MMSYSTEM.304]
2655 UINT16 WINAPI
midiInOpen16(HMIDIIN16
* lphMidiIn
, UINT16 uDeviceID
,
2656 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2661 ret
= MMSYSTEM_midiInOpen(&xhmid
, uDeviceID
, dwCallback
, dwInstance
,
2664 if (lphMidiIn
) *lphMidiIn
= xhmid
;
2668 /**************************************************************************
2669 * midiInClose [WINMM.58]
2671 UINT WINAPI
midiInClose(HMIDIIN hMidiIn
)
2676 TRACE("(%04X)\n", hMidiIn
);
2678 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2679 return MMSYSERR_INVALHANDLE
;
2681 dwRet
= MMDRV_Close(wmld
, MIDM_CLOSE
);
2682 MMDRV_Free(hMidiIn
, wmld
);
2686 /**************************************************************************
2687 * midiInClose [MMSYSTEM.305]
2689 UINT16 WINAPI
midiInClose16(HMIDIIN16 hMidiIn
)
2691 return midiInClose(hMidiIn
);
2694 /**************************************************************************
2695 * midiInPrepareHeader [WINMM.67]
2697 UINT WINAPI
midiInPrepareHeader(HMIDIIN hMidiIn
,
2698 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2702 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2704 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2705 return MMSYSERR_INVALHANDLE
;
2707 return MMDRV_Message(wmld
, MIDM_PREPARE
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2710 /**************************************************************************
2711 * midiInPrepareHeader [MMSYSTEM.306]
2713 UINT16 WINAPI
midiInPrepareHeader16(HMIDIIN16 hMidiIn
,
2714 MIDIHDR16
* /*SEGPTR*/ lpsegMidiInHdr
,
2719 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2721 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2722 return MMSYSERR_INVALHANDLE
;
2724 return MMDRV_Message(wmld
, MIDM_PREPARE
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2727 /**************************************************************************
2728 * midiInUnprepareHeader [WINMM.71]
2730 UINT WINAPI
midiInUnprepareHeader(HMIDIIN hMidiIn
,
2731 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2735 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2737 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
2738 return MMSYSERR_NOERROR
;
2741 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2742 return MMSYSERR_INVALHANDLE
;
2744 return MMDRV_Message(wmld
, MIDM_UNPREPARE
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2747 /**************************************************************************
2748 * midiInUnprepareHeader [MMSYSTEM.307]
2750 UINT16 WINAPI
midiInUnprepareHeader16(HMIDIIN16 hMidiIn
,
2751 MIDIHDR16
* /* SEGPTR */ lpsegMidiInHdr
,
2755 LPMIDIHDR16 lpMidiInHdr
= PTR_SEG_TO_LIN(lpsegMidiInHdr
);
2757 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2759 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
2760 return MMSYSERR_NOERROR
;
2763 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2764 return MMSYSERR_INVALHANDLE
;
2766 return MMDRV_Message(wmld
, MIDM_UNPREPARE
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2769 /**************************************************************************
2770 * midiInAddBuffer [WINMM.57]
2772 UINT WINAPI
midiInAddBuffer(HMIDIIN hMidiIn
,
2773 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2777 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2779 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2780 return MMSYSERR_INVALHANDLE
;
2782 return MMDRV_Message(wmld
, MIDM_ADDBUFFER
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2785 /**************************************************************************
2786 * midiInAddBuffer [MMSYSTEM.308]
2788 UINT16 WINAPI
midiInAddBuffer16(HMIDIIN16 hMidiIn
,
2789 MIDIHDR16
* /* SEGPTR */ lpsegMidiInHdr
,
2794 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2796 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2797 return MMSYSERR_INVALHANDLE
;
2799 return MMDRV_Message(wmld
, MIDM_ADDBUFFER
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2802 /**************************************************************************
2803 * midiInStart [WINMM.69]
2805 UINT WINAPI
midiInStart(HMIDIIN hMidiIn
)
2809 TRACE("(%04X)\n", hMidiIn
);
2811 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2812 return MMSYSERR_INVALHANDLE
;
2814 return MMDRV_Message(wmld
, MIDM_START
, 0L, 0L, TRUE
);
2817 /**************************************************************************
2818 * midiInStart [MMSYSTEM.309]
2820 UINT16 WINAPI
midiInStart16(HMIDIIN16 hMidiIn
)
2822 return midiInStart(hMidiIn
);
2825 /**************************************************************************
2826 * midiInStop [WINMM.70]
2828 UINT WINAPI
midiInStop(HMIDIIN hMidiIn
)
2832 TRACE("(%04X)\n", hMidiIn
);
2834 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2835 return MMSYSERR_INVALHANDLE
;
2837 return MMDRV_Message(wmld
, MIDM_STOP
, 0L, 0L, TRUE
);
2840 /**************************************************************************
2841 * midiInStop [MMSYSTEM.310]
2843 UINT16 WINAPI
midiInStop16(HMIDIIN16 hMidiIn
)
2845 return midiInStop(hMidiIn
);
2848 /**************************************************************************
2849 * midiInReset [WINMM.68]
2851 UINT WINAPI
midiInReset(HMIDIIN hMidiIn
)
2855 TRACE("(%04X)\n", hMidiIn
);
2857 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2858 return MMSYSERR_INVALHANDLE
;
2860 return MMDRV_Message(wmld
, MIDM_RESET
, 0L, 0L, TRUE
);
2863 /**************************************************************************
2864 * midiInReset [MMSYSTEM.311]
2866 UINT16 WINAPI
midiInReset16(HMIDIIN16 hMidiIn
)
2868 return midiInReset(hMidiIn
);
2871 /**************************************************************************
2872 * midiInGetID [WINMM.63]
2874 UINT WINAPI
midiInGetID(HMIDIIN hMidiIn
, UINT
* lpuDeviceID
)
2878 TRACE("(%04X, %p)\n", hMidiIn
, lpuDeviceID
);
2880 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2882 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2883 return MMSYSERR_INVALHANDLE
;
2885 *lpuDeviceID
= wmld
->uDeviceID
;
2887 return MMSYSERR_NOERROR
;
2890 /**************************************************************************
2891 * midiInGetID [MMSYSTEM.312]
2893 UINT16 WINAPI
midiInGetID16(HMIDIIN16 hMidiIn
, UINT16
* lpuDeviceID
)
2897 TRACE("(%04X, %p)\n", hMidiIn
, lpuDeviceID
);
2899 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2901 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2902 return MMSYSERR_INVALHANDLE
;
2904 *lpuDeviceID
= wmld
->uDeviceID
;
2906 return MMSYSERR_NOERROR
;
2909 /**************************************************************************
2910 * midiInMessage [WINMM.65]
2912 DWORD WINAPI
midiInMessage(HMIDIIN hMidiIn
, UINT uMessage
,
2913 DWORD dwParam1
, DWORD dwParam2
)
2917 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
2919 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2920 return MMSYSERR_INVALHANDLE
;
2925 FIXME("can't handle OPEN or CLOSE message!\n");
2926 return MMSYSERR_NOTSUPPORTED
;
2928 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2931 /**************************************************************************
2932 * midiInMessage [MMSYSTEM.313]
2934 DWORD WINAPI
midiInMessage16(HMIDIIN16 hMidiIn
, UINT16 uMessage
,
2935 DWORD dwParam1
, DWORD dwParam2
)
2939 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
2944 FIXME("can't handle OPEN or CLOSE message!\n");
2945 return MMSYSERR_NOTSUPPORTED
;
2947 case MIDM_GETDEVCAPS
:
2948 return midiInGetDevCaps16(hMidiIn
, (LPMIDIINCAPS16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2950 return midiInPrepareHeader16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2951 case MIDM_UNPREPARE
:
2952 return midiInUnprepareHeader16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2953 case MIDM_ADDBUFFER
:
2954 return midiInAddBuffer16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2957 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2958 return MMSYSERR_INVALHANDLE
;
2960 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, FALSE
);
2963 typedef struct WINE_MIDIStream
{
2974 LPMIDIHDR lpMidiHdr
;
2977 #define WINE_MSM_HEADER (WM_USER+0)
2978 #define WINE_MSM_STOP (WM_USER+1)
2980 /**************************************************************************
2981 * MMSYSTEM_GetMidiStream [internal]
2983 static BOOL
MMSYSTEM_GetMidiStream(HMIDISTRM hMidiStrm
, WINE_MIDIStream
** lpMidiStrm
, WINE_MIDI
** lplpwm
)
2985 WINE_MIDI
* lpwm
= (LPWINE_MIDI
)MMDRV_Get(hMidiStrm
, MMDRV_MIDIOUT
, FALSE
);
2994 *lpMidiStrm
= (WINE_MIDIStream
*)lpwm
->mod
.rgIds
.dwStreamID
;
2996 return *lpMidiStrm
!= NULL
;
2999 /**************************************************************************
3000 * MMSYSTEM_MidiStream_Convert [internal]
3002 static DWORD
MMSYSTEM_MidiStream_Convert(WINE_MIDIStream
* lpMidiStrm
, DWORD pulse
)
3006 if (lpMidiStrm
->dwTimeDiv
== 0) {
3007 FIXME("Shouldn't happen. lpMidiStrm->dwTimeDiv = 0\n");
3008 } else if (lpMidiStrm
->dwTimeDiv
> 0x8000) { /* SMPTE, unchecked FIXME? */
3009 int nf
= -(char)HIBYTE(lpMidiStrm
->dwTimeDiv
); /* number of frames */
3010 int nsf
= LOBYTE(lpMidiStrm
->dwTimeDiv
); /* number of sub-frames */
3011 ret
= (pulse
* 1000) / (nf
* nsf
);
3013 ret
= (DWORD
)((double)pulse
* ((double)lpMidiStrm
->dwTempo
/ 1000) /
3014 (double)lpMidiStrm
->dwTimeDiv
);
3020 /**************************************************************************
3021 * MMSYSTEM_MidiStream_MessageHandler [internal]
3023 static BOOL
MMSYSTEM_MidiStream_MessageHandler(WINE_MIDIStream
* lpMidiStrm
, LPWINE_MIDI lpwm
, LPMSG msg
)
3025 LPMIDIHDR lpMidiHdr
;
3029 switch (msg
->message
) {
3031 SetEvent(lpMidiStrm
->hEvent
);
3035 /* this is not quite what MS doc says... */
3036 midiOutReset(lpMidiStrm
->hDevice
);
3037 /* empty list of already submitted buffers */
3038 for (lpMidiHdr
= lpMidiStrm
->lpMidiHdr
; lpMidiHdr
; lpMidiHdr
= (LPMIDIHDR
)lpMidiHdr
->lpNext
) {
3039 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3040 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3042 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3043 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
3045 lpMidiStrm
->lpMidiHdr
= 0;
3046 SetEvent(lpMidiStrm
->hEvent
);
3048 case WINE_MSM_HEADER
:
3049 /* sets initial tick count for first MIDIHDR */
3050 if (!lpMidiStrm
->dwStartTicks
)
3051 lpMidiStrm
->dwStartTicks
= GetTickCount();
3053 /* FIXME(EPP): "I don't understand the content of the first MIDIHDR sent
3054 * by native mcimidi, it doesn't look like a correct one".
3055 * this trick allows to throw it away... but I don't like it.
3056 * It looks like part of the file I'm trying to play and definitively looks
3057 * like raw midi content
3058 * I'd really like to understand why native mcimidi sends it. Perhaps a bad
3059 * synchronization issue where native mcimidi is still processing raw MIDI
3060 * content before generating MIDIEVENTs ?
3062 * 4c 04 89 3b 00 81 7c 99 3b 43 00 99 23 5e 04 89 L..;..|.;C..#^..
3063 * 3b 00 00 89 23 00 7c 99 3b 45 00 99 28 62 04 89 ;...#.|.;E..(b..
3064 * 3b 00 00 89 28 00 81 7c 99 3b 4e 00 99 23 5e 04 ;...(..|.;N..#^.
3065 * 89 3b 00 00 89 23 00 7c 99 3b 45 00 99 23 78 04 .;...#.|.;E..#x.
3066 * 89 3b 00 00 89 23 00 81 7c 99 3b 48 00 99 23 5e .;...#..|.;H..#^
3067 * 04 89 3b 00 00 89 23 00 7c 99 3b 4e 00 99 28 62 ..;...#.|.;N..(b
3068 * 04 89 3b 00 00 89 28 00 81 7c 99 39 4c 00 99 23 ..;...(..|.9L..#
3069 * 5e 04 89 39 00 00 89 23 00 82 7c 99 3b 4c 00 99 ^..9...#..|.;L..
3070 * 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 00 99 #^..;...#.|.;H..
3071 * 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b 3f 04 (b..;...(..|.;?.
3072 * 89 3b 00 1c 99 23 5e 04 89 23 00 5c 99 3b 45 00 .;...#^..#.\.;E.
3073 * 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 3b 46 .#x..;...#..|.;F
3074 * 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 ..#^..;...#.|.;H
3075 * 00 99 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b ..(b..;...(..|.;
3076 * 46 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b F..#^..;...#.|.;
3077 * 48 00 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 H..#x..;...#..|.
3078 * 3b 4c 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 ;L..#^..;...#.|.
3080 lpMidiHdr
= (LPMIDIHDR
)msg
->lParam
;
3081 lpData
= lpMidiHdr
->lpData
;
3082 TRACE("Adding %s lpMidiHdr=%p [lpData=0x%08lx dwBufferLength=%lu/%lu dwFlags=0x%08lx size=%u]\n",
3083 (lpMidiHdr
->dwFlags
& MHDR_ISSTRM
) ? "stream" : "regular", lpMidiHdr
,
3084 (DWORD
)lpMidiHdr
, lpMidiHdr
->dwBufferLength
, lpMidiHdr
->dwBytesRecorded
,
3085 lpMidiHdr
->dwFlags
, msg
->wParam
);
3087 /* dumps content of lpMidiHdr->lpData
3088 * FIXME: there should be a debug routine somewhere that already does this
3089 * I hate spreading this type of shit all around the code
3091 for (dwToGo
= 0; dwToGo
< lpMidiHdr
->dwBufferLength
; dwToGo
+= 16) {
3095 for (i
= 0; i
< MIN(16, lpMidiHdr
->dwBufferLength
- dwToGo
); i
++)
3096 printf("%02x ", lpData
[dwToGo
+ i
]);
3099 for (i
= 0; i
< MIN(16, lpMidiHdr
->dwBufferLength
- dwToGo
); i
++) {
3100 ch
= lpData
[dwToGo
+ i
];
3101 printf("%c", (ch
>= 0x20 && ch
<= 0x7F) ? ch
: '.');
3106 if (((LPMIDIEVENT
)lpData
)->dwStreamID
!= 0 &&
3107 ((LPMIDIEVENT
)lpData
)->dwStreamID
!= 0xFFFFFFFF &&
3108 ((LPMIDIEVENT
)lpData
)->dwStreamID
!= (DWORD
)lpMidiStrm
) {
3109 FIXME("Dropping bad %s lpMidiHdr (streamID=%08lx)\n",
3110 (lpMidiHdr
->dwFlags
& MHDR_ISSTRM
) ? "stream" : "regular",
3111 ((LPMIDIEVENT
)lpData
)->dwStreamID
);
3112 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3113 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3115 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3116 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
3120 for (lpmh
= &lpMidiStrm
->lpMidiHdr
; *lpmh
; lpmh
= (LPMIDIHDR
*)&((*lpmh
)->lpNext
));
3122 lpMidiHdr
= (LPMIDIHDR
)msg
->lParam
;
3123 lpMidiHdr
->lpNext
= 0;
3124 lpMidiHdr
->dwFlags
|= MHDR_INQUEUE
;
3125 lpMidiHdr
->dwFlags
&= MHDR_DONE
;
3126 lpMidiHdr
->dwOffset
= 0;
3130 FIXME("Unknown message %d\n", msg
->message
);
3136 /**************************************************************************
3137 * MMSYSTEM_MidiStream_Player [internal]
3139 static DWORD CALLBACK
MMSYSTEM_MidiStream_Player(LPVOID pmt
)
3141 WINE_MIDIStream
* lpMidiStrm
= pmt
;
3146 LPMIDIHDR lpMidiHdr
;
3150 TRACE("(%p)!\n", lpMidiStrm
);
3153 (lpwm
= (LPWINE_MIDI
)MMDRV_Get(lpMidiStrm
->hDevice
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
3156 /* force thread's queue creation */
3157 /* Used to be InitThreadInput16(0, 5); */
3158 /* but following works also with hack in midiStreamOpen */
3159 Callout
.PeekMessageA(&msg
, 0, 0, 0, 0);
3161 /* FIXME: this next line must be called before midiStreamOut or midiStreamRestart are called */
3162 SetEvent(lpMidiStrm
->hEvent
);
3163 TRACE("Ready to go 1\n");
3164 /* thread is started in paused mode */
3165 SuspendThread(lpMidiStrm
->hThread
);
3166 TRACE("Ready to go 2\n");
3168 lpMidiStrm
->dwStartTicks
= 0;
3169 lpMidiStrm
->dwPulses
= 0;
3171 lpMidiStrm
->lpMidiHdr
= 0;
3174 lpMidiHdr
= lpMidiStrm
->lpMidiHdr
;
3176 /* for first message, block until one arrives, then process all that are available */
3177 Callout
.GetMessageA(&msg
, 0, 0, 0);
3179 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm
, lpwm
, &msg
))
3181 } while (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
));
3187 lpData
= lpMidiHdr
->lpData
;
3189 me
= (LPMIDIEVENT
)(lpData
+ lpMidiHdr
->dwOffset
);
3191 /* do we have to wait ? */
3192 if (me
->dwDeltaTime
) {
3193 lpMidiStrm
->dwPositionMS
+= MMSYSTEM_MidiStream_Convert(lpMidiStrm
, me
->dwDeltaTime
);
3194 lpMidiStrm
->dwPulses
+= me
->dwDeltaTime
;
3196 dwToGo
= lpMidiStrm
->dwStartTicks
+ lpMidiStrm
->dwPositionMS
;
3198 TRACE("%ld/%ld/%ld\n", dwToGo
, GetTickCount(), me
->dwDeltaTime
);
3199 while ((dwCurrTC
= GetTickCount()) < dwToGo
) {
3200 if (MsgWaitForMultipleObjects(0, NULL
, FALSE
, dwToGo
- dwCurrTC
, QS_ALLINPUT
) == WAIT_OBJECT_0
) {
3201 /* got a message, handle it */
3202 while (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
3203 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm
, lpwm
, &msg
))
3208 /* timeout, so me->dwDeltaTime is elapsed, can break the while loop */
3213 switch (MEVT_EVENTTYPE(me
->dwEvent
& ~MEVT_F_CALLBACK
)) {
3215 FIXME("NIY: MEVT_COMMENT\n");
3216 /* do nothing, skip bytes */
3219 FIXME("NIY: MEVT_LONGMSG, aka sending Sysex event\n");
3224 midiOutShortMsg(lpMidiStrm
->hDevice
, MEVT_EVENTPARM(me
->dwEvent
));
3227 lpMidiStrm
->dwTempo
= MEVT_EVENTPARM(me
->dwEvent
);
3232 FIXME("Unknown MEVT (0x%02x)\n", MEVT_EVENTTYPE(me
->dwEvent
& ~MEVT_F_CALLBACK
));
3235 if (me
->dwEvent
& MEVT_F_CALLBACK
) {
3236 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3237 MM_MOM_POSITIONCB
, lpwm
->mod
.dwInstance
, (LPARAM
)lpMidiHdr
, 0L);
3239 lpMidiHdr
->dwOffset
+= sizeof(MIDIEVENT
);
3240 if (me
->dwEvent
& MEVT_F_LONG
)
3241 lpMidiHdr
->dwOffset
+= (MEVT_EVENTPARM(me
->dwEvent
) + 3) & ~3;
3242 if (lpMidiHdr
->dwOffset
>= lpMidiHdr
->dwBufferLength
) {
3243 /* done with this header */
3244 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3245 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3247 lpMidiStrm
->lpMidiHdr
= (LPMIDIHDR
)lpMidiHdr
->lpNext
;
3248 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3249 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
3254 TRACE("End of thread\n");
3256 return 0; /* for removing the warning, never executed */
3259 /**************************************************************************
3260 * MMSYSTEM_MidiStream_PostMessage [internal]
3262 static BOOL
MMSYSTEM_MidiStream_PostMessage(WINE_MIDIStream
* lpMidiStrm
, WORD msg
, DWORD pmt1
, DWORD pmt2
)
3264 if (Callout
.PostThreadMessageA(lpMidiStrm
->dwThreadID
, msg
, pmt1
, pmt2
)) {
3268 /* FIXME: should use the new syslevel APIs */
3269 if ((bHasWin16Lock
= _ConfirmWin16Lock()) != 0) {
3270 ReleaseThunkLock(&count
);
3272 WaitForSingleObject(lpMidiStrm
->hEvent
, INFINITE
);
3273 if (bHasWin16Lock
) {
3274 RestoreThunkLock(count
);
3277 WARN("bad PostThreadMessageA\n");
3283 /**************************************************************************
3284 * midiStreamClose [WINMM.90]
3286 MMRESULT WINAPI
midiStreamClose(HMIDISTRM hMidiStrm
)
3288 WINE_MIDIStream
* lpMidiStrm
;
3290 TRACE("(%08x)!\n", hMidiStrm
);
3292 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
))
3293 return MMSYSERR_INVALHANDLE
;
3295 midiStreamStop(hMidiStrm
);
3296 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm
, WM_QUIT
, 0, 0);
3297 HeapFree(GetProcessHeap(), 0, lpMidiStrm
);
3298 CloseHandle(lpMidiStrm
->hEvent
);
3300 return midiOutClose(hMidiStrm
);
3303 /**************************************************************************
3304 * MMSYSTEM_MidiStream_Open [internal]
3306 static MMRESULT WINAPI
MMSYSTEM_MidiStream_Open(HMIDISTRM
* lphMidiStrm
, LPUINT lpuDeviceID
,
3307 DWORD cMidi
, DWORD dwCallback
,
3308 DWORD dwInstance
, DWORD fdwOpen
, BOOL bFrom32
)
3310 WINE_MIDIStream
* lpMidiStrm
;
3312 MIDIOPENSTRMID mosm
;
3316 TRACE("(%p, %p, %ld, 0x%08lx, 0x%08lx, 0x%08lx)!\n",
3317 lphMidiStrm
, lpuDeviceID
, cMidi
, dwCallback
, dwInstance
, fdwOpen
);
3319 if (cMidi
!= 1 || lphMidiStrm
== NULL
|| lpuDeviceID
== NULL
)
3320 return MMSYSERR_INVALPARAM
;
3322 lpMidiStrm
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MIDIStream
));
3324 return MMSYSERR_NOMEM
;
3326 lpMidiStrm
->dwTempo
= 500000;
3327 lpMidiStrm
->dwTimeDiv
= 480; /* 480 is 120 quater notes per minute *//* FIXME ??*/
3328 lpMidiStrm
->dwPositionMS
= 0;
3330 mosm
.dwStreamID
= (DWORD
)lpMidiStrm
;
3331 /* FIXME: the correct value is not allocated yet for MAPPER */
3332 mosm
.wDeviceID
= *lpuDeviceID
;
3333 lpwm
= MIDI_OutAlloc(&hMidiOut
, &dwCallback
, &dwInstance
, &fdwOpen
, 1, &mosm
, bFrom32
);
3334 lpMidiStrm
->hDevice
= hMidiOut
;
3336 *lphMidiStrm
= hMidiOut
;
3338 /* FIXME: is lpuDevice initialized upon entering midiStreamOpen ? */
3339 FIXME("*lpuDeviceID=%u\n", *lpuDeviceID
);
3340 lpwm
->mld
.uDeviceID
= *lpuDeviceID
= 0;
3342 ret
= MMDRV_Open(&lpwm
->mld
, MODM_OPEN
, (DWORD
)&lpwm
->mod
, fdwOpen
);
3343 lpMidiStrm
->hEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
);
3344 lpMidiStrm
->wFlags
= HIWORD(fdwOpen
);
3346 lpMidiStrm
->hThread
= CreateThread(NULL
, 0, MMSYSTEM_MidiStream_Player
,
3347 lpMidiStrm
, 0, &(lpMidiStrm
->dwThreadID
));
3349 if (!lpMidiStrm
->hThread
) {
3350 midiStreamClose((HMIDISTRM
)hMidiOut
);
3351 return MMSYSERR_NOMEM
;
3354 /* wait for thread to have started, and for it's queue to be created */
3359 /* (Release|Restore)ThunkLock() is needed when this method is called from 16 bit code,
3360 * (meaning the Win16Lock is set), so that it's released and the 32 bit thread running
3361 * MMSYSTEM_MidiStreamPlayer can acquire Win16Lock to create its queue.
3363 if ((bHasWin16Lock
= _ConfirmWin16Lock()) != 0) {
3364 ReleaseThunkLock(&count
);
3366 WaitForSingleObject(lpMidiStrm
->hEvent
, INFINITE
);
3367 if (bHasWin16Lock
) {
3368 RestoreThunkLock(count
);
3372 TRACE("=> (%u/%d) hMidi=0x%04x ret=%d lpMidiStrm=%p\n",
3373 *lpuDeviceID
, lpwm
->mld
.uDeviceID
, *lphMidiStrm
, ret
, lpMidiStrm
);
3377 /**************************************************************************
3378 * midiStreamOpen [WINMM.91]
3380 MMRESULT WINAPI
midiStreamOpen(HMIDISTRM
* lphMidiStrm
, LPUINT lpuDeviceID
,
3381 DWORD cMidi
, DWORD dwCallback
,
3382 DWORD dwInstance
, DWORD fdwOpen
)
3384 return MMSYSTEM_MidiStream_Open(lphMidiStrm
, lpuDeviceID
, cMidi
, dwCallback
,
3385 dwInstance
, fdwOpen
, TRUE
);
3388 /**************************************************************************
3389 * midiStreamOut [WINMM.92]
3391 MMRESULT WINAPI
midiStreamOut(HMIDISTRM hMidiStrm
, LPMIDIHDR lpMidiHdr
,
3394 WINE_MIDIStream
* lpMidiStrm
;
3395 DWORD ret
= MMSYSERR_NOERROR
;
3397 TRACE("(%08x, %p, %u)!\n", hMidiStrm
, lpMidiHdr
, cbMidiHdr
);
3399 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3400 ret
= MMSYSERR_INVALHANDLE
;
3402 if (!Callout
.PostThreadMessageA(lpMidiStrm
->dwThreadID
,
3403 WINE_MSM_HEADER
, cbMidiHdr
,
3404 (DWORD
)lpMidiHdr
)) {
3405 WARN("bad PostThreadMessageA\n");
3406 ret
= MMSYSERR_ERROR
;
3412 /**************************************************************************
3413 * midiStreamPause [WINMM.93]
3415 MMRESULT WINAPI
midiStreamPause(HMIDISTRM hMidiStrm
)
3417 WINE_MIDIStream
* lpMidiStrm
;
3418 DWORD ret
= MMSYSERR_NOERROR
;
3420 TRACE("(%08x)!\n", hMidiStrm
);
3422 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3423 ret
= MMSYSERR_INVALHANDLE
;
3425 if (SuspendThread(lpMidiStrm
->hThread
) == 0xFFFFFFFF) {
3426 WARN("bad Suspend (%ld)\n", GetLastError());
3427 ret
= MMSYSERR_ERROR
;
3433 /**************************************************************************
3434 * midiStreamPosition [WINMM.94]
3436 MMRESULT WINAPI
midiStreamPosition(HMIDISTRM hMidiStrm
, LPMMTIME lpMMT
, UINT cbmmt
)
3438 WINE_MIDIStream
* lpMidiStrm
;
3439 DWORD ret
= MMSYSERR_NOERROR
;
3441 TRACE("(%08x, %p, %u)!\n", hMidiStrm
, lpMMT
, cbmmt
);
3443 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3444 ret
= MMSYSERR_INVALHANDLE
;
3445 } else if (lpMMT
== NULL
|| cbmmt
!= sizeof(MMTIME
)) {
3446 ret
= MMSYSERR_INVALPARAM
;
3448 switch (lpMMT
->wType
) {
3450 lpMMT
->u
.ms
= lpMidiStrm
->dwPositionMS
;
3451 TRACE("=> %ld ms\n", lpMMT
->u
.ms
);
3454 lpMMT
->u
.ticks
= lpMidiStrm
->dwPulses
;
3455 TRACE("=> %ld ticks\n", lpMMT
->u
.ticks
);
3458 WARN("Unsupported time type %d\n", lpMMT
->wType
);
3459 lpMMT
->wType
= TIME_MS
;
3460 ret
= MMSYSERR_INVALPARAM
;
3467 /**************************************************************************
3468 * midiStreamProperty [WINMM.95]
3470 MMRESULT WINAPI
midiStreamProperty(HMIDISTRM hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
3472 WINE_MIDIStream
* lpMidiStrm
;
3473 MMRESULT ret
= MMSYSERR_NOERROR
;
3475 TRACE("(%08x, %p, %lx)\n", hMidiStrm
, lpPropData
, dwProperty
);
3477 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3478 ret
= MMSYSERR_INVALHANDLE
;
3479 } else if ((dwProperty
& (MIDIPROP_GET
|MIDIPROP_SET
)) == 0) {
3480 ret
= MMSYSERR_INVALPARAM
;
3481 } else if (dwProperty
& MIDIPROP_TEMPO
) {
3482 MIDIPROPTEMPO
* mpt
= (MIDIPROPTEMPO
*)lpPropData
;
3484 if (sizeof(MIDIPROPTEMPO
) != mpt
->cbStruct
) {
3485 ret
= MMSYSERR_INVALPARAM
;
3486 } else if (dwProperty
& MIDIPROP_SET
) {
3487 lpMidiStrm
->dwTempo
= mpt
->dwTempo
;
3488 TRACE("Setting tempo to %ld\n", mpt
->dwTempo
);
3489 } else if (dwProperty
& MIDIPROP_GET
) {
3490 mpt
->dwTempo
= lpMidiStrm
->dwTempo
;
3491 TRACE("Getting tempo <= %ld\n", mpt
->dwTempo
);
3493 } else if (dwProperty
& MIDIPROP_TIMEDIV
) {
3494 MIDIPROPTIMEDIV
* mptd
= (MIDIPROPTIMEDIV
*)lpPropData
;
3496 if (sizeof(MIDIPROPTIMEDIV
) != mptd
->cbStruct
) {
3497 ret
= MMSYSERR_INVALPARAM
;
3498 } else if (dwProperty
& MIDIPROP_SET
) {
3499 lpMidiStrm
->dwTimeDiv
= mptd
->dwTimeDiv
;
3500 TRACE("Setting time div to %ld\n", mptd
->dwTimeDiv
);
3501 } else if (dwProperty
& MIDIPROP_GET
) {
3502 mptd
->dwTimeDiv
= lpMidiStrm
->dwTimeDiv
;
3503 TRACE("Getting time div <= %ld\n", mptd
->dwTimeDiv
);
3506 ret
= MMSYSERR_INVALPARAM
;
3512 /**************************************************************************
3513 * midiStreamRestart [WINMM.96]
3515 MMRESULT WINAPI
midiStreamRestart(HMIDISTRM hMidiStrm
)
3517 WINE_MIDIStream
* lpMidiStrm
;
3518 MMRESULT ret
= MMSYSERR_NOERROR
;
3520 TRACE("(%08x)!\n", hMidiStrm
);
3522 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3523 ret
= MMSYSERR_INVALHANDLE
;
3527 /* since we increase the thread suspend count on each midiStreamPause
3528 * there may be a need for several midiStreamResume
3531 ret
= ResumeThread(lpMidiStrm
->hThread
);
3532 } while (ret
!= 0xFFFFFFFF && ret
!= 0);
3533 if (ret
== 0xFFFFFFFF) {
3534 WARN("bad Resume (%ld)\n", GetLastError());
3535 ret
= MMSYSERR_ERROR
;
3537 lpMidiStrm
->dwStartTicks
= GetTickCount() - lpMidiStrm
->dwPositionMS
;
3543 /**************************************************************************
3544 * midiStreamStop [WINMM.97]
3546 MMRESULT WINAPI
midiStreamStop(HMIDISTRM hMidiStrm
)
3548 WINE_MIDIStream
* lpMidiStrm
;
3549 MMRESULT ret
= MMSYSERR_NOERROR
;
3551 TRACE("(%08x)!\n", hMidiStrm
);
3553 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3554 ret
= MMSYSERR_INVALHANDLE
;
3556 /* in case stream has been paused... FIXME is the current state correct ? */
3557 midiStreamRestart(hMidiStrm
);
3558 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm
, WINE_MSM_STOP
, 0, 0);
3563 /**************************************************************************
3564 * midiStreamClose [MMSYSTEM.252]
3566 MMRESULT16 WINAPI
midiStreamClose16(HMIDISTRM16 hMidiStrm
)
3568 return midiStreamClose(hMidiStrm
);
3571 /**************************************************************************
3572 * midiStreamOpen [MMSYSTEM.251]
3574 MMRESULT16 WINAPI
midiStreamOpen16(HMIDISTRM16
* phMidiStrm
, LPUINT16 devid
,
3575 DWORD cMidi
, DWORD dwCallback
,
3576 DWORD dwInstance
, DWORD fdwOpen
)
3578 HMIDISTRM hMidiStrm32
;
3582 if (!phMidiStrm
|| !devid
)
3583 return MMSYSERR_INVALPARAM
;
3585 ret
= MMSYSTEM_MidiStream_Open(&hMidiStrm32
, &devid32
, cMidi
, dwCallback
,
3586 dwInstance
, fdwOpen
, FALSE
);
3587 *phMidiStrm
= hMidiStrm32
;
3592 /**************************************************************************
3593 * midiStreamOut [MMSYSTEM.254]
3595 MMRESULT16 WINAPI
midiStreamOut16(HMIDISTRM16 hMidiStrm
, LPMIDIHDR16 lpMidiHdr
, UINT16 cbMidiHdr
)
3597 return midiStreamOut(hMidiStrm
, (LPMIDIHDR
)lpMidiHdr
, cbMidiHdr
);
3600 /**************************************************************************
3601 * midiStreamPause [MMSYSTEM.255]
3603 MMRESULT16 WINAPI
midiStreamPause16(HMIDISTRM16 hMidiStrm
)
3605 return midiStreamPause(hMidiStrm
);
3608 /**************************************************************************
3609 * midiStreamPosition [MMSYSTEM.253]
3611 MMRESULT16 WINAPI
midiStreamPosition16(HMIDISTRM16 hMidiStrm
, LPMMTIME16 lpmmt16
, UINT16 cbmmt
)
3617 return MMSYSERR_INVALPARAM
;
3618 MMSYSTEM_MMTIME16to32(&mmt32
, lpmmt16
);
3619 ret
= midiStreamPosition(hMidiStrm
, &mmt32
, sizeof(MMTIME
));
3620 MMSYSTEM_MMTIME32to16(lpmmt16
, &mmt32
);
3624 /**************************************************************************
3625 * midiStreamProperty [MMSYSTEM.250]
3627 MMRESULT16 WINAPI
midiStreamProperty16(HMIDISTRM16 hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
3629 return midiStreamProperty(hMidiStrm
, lpPropData
, dwProperty
);
3632 /**************************************************************************
3633 * midiStreamRestart [MMSYSTEM.256]
3635 MMRESULT16 WINAPI
midiStreamRestart16(HMIDISTRM16 hMidiStrm
)
3637 return midiStreamRestart(hMidiStrm
);
3640 /**************************************************************************
3641 * midiStreamStop [MMSYSTEM.257]
3643 MMRESULT16 WINAPI
midiStreamStop16(HMIDISTRM16 hMidiStrm
)
3645 return midiStreamStop(hMidiStrm
);
3648 static UINT WINAPI
MMSYSTEM_waveOpen(HANDLE
* lphndl
, UINT uDeviceID
, UINT uType
,
3649 const LPWAVEFORMATEX lpFormat
,
3650 DWORD dwCallback
, DWORD dwInstance
,
3651 DWORD dwFlags
, BOOL bFrom32
)
3655 DWORD dwRet
= MMSYSERR_NOERROR
;
3658 TRACE("(%p, %d, %s, %p, %08lX, %08lX, %08lX, %d);\n",
3659 lphndl
, (int)uDeviceID
, (uType
==MMDRV_WAVEOUT
)?"Out":"In", lpFormat
, dwCallback
,
3660 dwInstance
, dwFlags
, bFrom32
?32:16);
3662 if (dwFlags
& WAVE_FORMAT_QUERY
) TRACE("WAVE_FORMAT_QUERY requested !\n");
3664 if (lpFormat
== NULL
) return WAVERR_BADFORMAT
;
3666 TRACE("wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u\n",
3667 lpFormat
->wFormatTag
, lpFormat
->nChannels
, lpFormat
->nSamplesPerSec
,
3668 lpFormat
->nAvgBytesPerSec
, lpFormat
->nBlockAlign
, lpFormat
->wBitsPerSample
, lpFormat
->cbSize
);
3670 if ((wmld
= MMDRV_Alloc(sizeof(WINE_WAVE
), uType
, &handle
,
3671 &dwFlags
, &dwCallback
, &dwInstance
, bFrom32
)) == NULL
)
3672 return MMSYSERR_NOMEM
;
3675 wod
.lpFormat
= lpFormat
; /* should the struct be copied iso pointer? */
3676 wod
.dwCallback
= dwCallback
;
3677 wod
.dwInstance
= dwInstance
;
3678 wod
.uMappedDeviceID
= 0;
3681 /* when called from 16 bit code, mapper will be 0x0000FFFF instead of 0xFFFFFFFF */
3682 /* this should fix it */
3683 wmld
->uDeviceID
= (uDeviceID
== (UINT16
)-1 && !bFrom32
) ? (UINT
)-1 : uDeviceID
;
3685 dwRet
= MMDRV_Open(wmld
, (uType
==MMDRV_WAVEOUT
)?WODM_OPEN
:WIDM_OPEN
, (DWORD
)&wod
, dwFlags
);
3687 if ((dwFlags
& WAVE_FORMAT_QUERY
) || dwRet
!= MMSYSERR_NOERROR
) {
3688 MMDRV_Free(handle
, wmld
);
3692 if (lphndl
!= NULL
) *lphndl
= handle
;
3693 TRACE("=> %ld hWave=%04x\n", dwRet
, handle
);
3698 /**************************************************************************
3699 * waveOutGetNumDevs [MMSYSTEM.401]
3701 UINT WINAPI
waveOutGetNumDevs(void)
3703 return MMDRV_GetNum(MMDRV_WAVEOUT
);
3706 /**************************************************************************
3707 * waveOutGetNumDevs [WINMM.167]
3709 UINT16 WINAPI
waveOutGetNumDevs16(void)
3711 return MMDRV_GetNum(MMDRV_WAVEOUT
);
3714 /**************************************************************************
3715 * waveOutGetDevCaps [MMSYSTEM.402]
3717 UINT16 WINAPI
waveOutGetDevCaps16(UINT16 uDeviceID
,
3718 LPWAVEOUTCAPS16 lpCaps
, UINT16 uSize
)
3723 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
3724 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3726 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
3728 if (ret
== MMSYSERR_NOERROR
) {
3729 lpCaps
->wMid
= wocA
.wMid
;
3730 lpCaps
->wPid
= wocA
.wPid
;
3731 lpCaps
->vDriverVersion
= wocA
.vDriverVersion
;
3732 strcpy(lpCaps
->szPname
, wocA
.szPname
);
3733 lpCaps
->dwFormats
= wocA
.dwFormats
;
3734 lpCaps
->wChannels
= wocA
.wChannels
;
3735 lpCaps
->dwSupport
= wocA
.dwSupport
;
3740 /**************************************************************************
3741 * waveOutGetDevCapsA [WINMM.162]
3743 UINT WINAPI
waveOutGetDevCapsA(UINT uDeviceID
, LPWAVEOUTCAPSA lpCaps
,
3748 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
3750 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3752 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_WAVEOUT
, TRUE
)) == NULL
)
3753 return MMSYSERR_INVALHANDLE
;
3755 return MMDRV_Message(wmld
, WODM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
3759 /**************************************************************************
3760 * waveOutGetDevCapsW [WINMM.163]
3762 UINT WINAPI
waveOutGetDevCapsW(UINT uDeviceID
, LPWAVEOUTCAPSW lpCaps
,
3768 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3770 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
3772 if (ret
== MMSYSERR_NOERROR
) {
3773 lpCaps
->wMid
= wocA
.wMid
;
3774 lpCaps
->wPid
= wocA
.wPid
;
3775 lpCaps
->vDriverVersion
= wocA
.vDriverVersion
;
3776 lstrcpyAtoW(lpCaps
->szPname
, wocA
.szPname
);
3777 lpCaps
->dwFormats
= wocA
.dwFormats
;
3778 lpCaps
->wChannels
= wocA
.wChannels
;
3779 lpCaps
->dwSupport
= wocA
.dwSupport
;
3784 /**************************************************************************
3785 * WAVE_GetErrorText [internal]
3787 static UINT16
WAVE_GetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
3789 UINT16 ret
= MMSYSERR_BADERRNUM
;
3791 if (lpText
== NULL
) {
3792 ret
= MMSYSERR_INVALPARAM
;
3793 } else if (uSize
== 0) {
3794 ret
= MMSYSERR_NOERROR
;
3796 /* test has been removed 'coz MMSYSERR_BASE is 0, and gcc did emit
3797 * a warning for the test was always true */
3798 (/*uError >= MMSYSERR_BASE && */uError
<= MMSYSERR_LASTERROR
) ||
3799 (uError
>= WAVERR_BASE
&& uError
<= WAVERR_LASTERROR
)) {
3801 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance
,
3802 uError
, lpText
, uSize
) > 0) {
3803 ret
= MMSYSERR_NOERROR
;
3809 /**************************************************************************
3810 * waveOutGetErrorText [MMSYSTEM.403]
3812 UINT16 WINAPI
waveOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
3814 return WAVE_GetErrorText(uError
, lpText
, uSize
);
3817 /**************************************************************************
3818 * waveOutGetErrorTextA [WINMM.164]
3820 UINT WINAPI
waveOutGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
3822 return WAVE_GetErrorText(uError
, lpText
, uSize
);
3825 /**************************************************************************
3826 * waveOutGetErrorTextW [WINMM.165]
3828 UINT WINAPI
waveOutGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
3830 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
3831 UINT ret
= WAVE_GetErrorText(uError
, xstr
, uSize
);
3833 lstrcpyAtoW(lpText
, xstr
);
3834 HeapFree(GetProcessHeap(), 0, xstr
);
3838 /**************************************************************************
3839 * waveOutOpen [WINMM.173]
3840 * All the args/structs have the same layout as the win16 equivalents
3842 UINT WINAPI
waveOutOpen(HWAVEOUT
* lphWaveOut
, UINT uDeviceID
,
3843 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
3844 DWORD dwInstance
, DWORD dwFlags
)
3846 return MMSYSTEM_waveOpen(lphWaveOut
, uDeviceID
, MMDRV_WAVEOUT
, lpFormat
,
3847 dwCallback
, dwInstance
, dwFlags
, TRUE
);
3850 /**************************************************************************
3851 * waveOutOpen [MMSYSTEM.404]
3853 UINT16 WINAPI
waveOutOpen16(HWAVEOUT16
* lphWaveOut
, UINT16 uDeviceID
,
3854 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
3855 DWORD dwInstance
, DWORD dwFlags
)
3860 /* since layout of WAVEOFORMATEX is the same for 16/32 bits, we directly
3861 * call the 32 bit version
3863 ret
= MMSYSTEM_waveOpen(&hWaveOut
, uDeviceID
, MMDRV_WAVEOUT
, lpFormat
,
3864 dwCallback
, dwInstance
, dwFlags
, FALSE
);
3866 if (lphWaveOut
!= NULL
) *lphWaveOut
= hWaveOut
;
3870 /**************************************************************************
3871 * waveOutClose [WINMM.161]
3873 UINT WINAPI
waveOutClose(HWAVEOUT hWaveOut
)
3878 TRACE("(%04X)\n", hWaveOut
);
3880 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3881 return MMSYSERR_INVALHANDLE
;
3883 dwRet
= MMDRV_Close(wmld
, WODM_CLOSE
);
3884 MMDRV_Free(hWaveOut
, wmld
);
3889 /**************************************************************************
3890 * waveOutClose [MMSYSTEM.405]
3892 UINT16 WINAPI
waveOutClose16(HWAVEOUT16 hWaveOut
)
3894 return waveOutClose(hWaveOut
);
3897 /**************************************************************************
3898 * waveOutPrepareHeader [WINMM.175]
3900 UINT WINAPI
waveOutPrepareHeader(HWAVEOUT hWaveOut
,
3901 WAVEHDR
* lpWaveOutHdr
, UINT uSize
)
3905 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3907 if (lpWaveOutHdr
== NULL
) return MMSYSERR_INVALPARAM
;
3909 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3910 return MMSYSERR_INVALHANDLE
;
3912 return MMDRV_Message(wmld
, WODM_PREPARE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3915 /**************************************************************************
3916 * waveOutPrepareHeader [MMSYSTEM.406]
3918 UINT16 WINAPI
waveOutPrepareHeader16(HWAVEOUT16 hWaveOut
,
3919 WAVEHDR
* /*SEGPTR*/ lpsegWaveOutHdr
,
3923 LPWAVEHDR lpWaveOutHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveOutHdr
);
3925 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
3927 if (lpWaveOutHdr
== NULL
) return MMSYSERR_INVALPARAM
;
3929 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3930 return MMSYSERR_INVALHANDLE
;
3932 return MMDRV_Message(wmld
, WODM_PREPARE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
3935 /**************************************************************************
3936 * waveOutUnprepareHeader [WINMM.181]
3938 UINT WINAPI
waveOutUnprepareHeader(HWAVEOUT hWaveOut
,
3939 LPWAVEHDR lpWaveOutHdr
, UINT uSize
)
3943 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3945 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
3946 return MMSYSERR_NOERROR
;
3949 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3950 return MMSYSERR_INVALHANDLE
;
3952 return MMDRV_Message(wmld
, WODM_UNPREPARE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3955 /**************************************************************************
3956 * waveOutUnprepareHeader [MMSYSTEM.407]
3958 UINT16 WINAPI
waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut
,
3959 LPWAVEHDR
/*SEGPTR*/ lpsegWaveOutHdr
,
3963 LPWAVEHDR lpWaveOutHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveOutHdr
);
3965 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
3967 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
3968 return MMSYSERR_NOERROR
;
3971 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3972 return MMSYSERR_INVALHANDLE
;
3974 return MMDRV_Message(wmld
, WODM_UNPREPARE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
3977 /**************************************************************************
3978 * waveOutWrite [MMSYSTEM.408]
3980 UINT WINAPI
waveOutWrite(HWAVEOUT hWaveOut
, LPWAVEHDR lpWaveOutHdr
,
3985 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3987 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3988 return MMSYSERR_INVALHANDLE
;
3990 return MMDRV_Message(wmld
, WODM_WRITE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3993 /**************************************************************************
3994 * waveOutWrite [MMSYSTEM.408]
3996 UINT16 WINAPI
waveOutWrite16(HWAVEOUT16 hWaveOut
,
3997 LPWAVEHDR
/*SEGPTR*/ lpsegWaveOutHdr
,
4002 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
4004 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4005 return MMSYSERR_INVALHANDLE
;
4007 return MMDRV_Message(wmld
, WODM_WRITE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
4010 #define WAVEOUT_SHORTCUT_0(xx, XX) \
4011 UINT WINAPI waveOut##xx(HWAVEOUT hWaveOut) \
4014 TRACE("(%04X);\n", hWaveOut); \
4015 if ((wmld = MMDRV_Get(hWaveOut,MMDRV_WAVEOUT,FALSE))==NULL) \
4016 return MMSYSERR_INVALHANDLE; \
4017 return MMDRV_Message(wmld,WODM_##XX,0L,0L,TRUE); \
4019 UINT16 WINAPI waveOut##xx##16(HWAVEOUT16 hWaveOut16) \
4020 {return waveOut##xx(hWaveOut16);}
4022 WAVEOUT_SHORTCUT_0(BreakLoop
, BREAKLOOP
)
4023 WAVEOUT_SHORTCUT_0(Pause
, PAUSE
)
4024 WAVEOUT_SHORTCUT_0(Reset
, RESET
)
4025 WAVEOUT_SHORTCUT_0(Restart
, RESTART
)
4026 #undef WAVEOUT_SHORTCUT_0
4028 /**************************************************************************
4029 * waveOutGetPosition [WINMM.170]
4031 UINT WINAPI
waveOutGetPosition(HWAVEOUT hWaveOut
, LPMMTIME lpTime
,
4036 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpTime
, uSize
);
4038 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4039 return MMSYSERR_INVALHANDLE
;
4041 return MMDRV_Message(wmld
, WODM_GETPOS
, (DWORD
)lpTime
, uSize
, TRUE
);
4044 /**************************************************************************
4045 * waveOutGetPosition [MMSYSTEM.412]
4047 UINT16 WINAPI
waveOutGetPosition16(HWAVEOUT16 hWaveOut
, LPMMTIME16 lpTime
,
4053 mmt
.wType
= lpTime
->wType
;
4054 ret
= waveOutGetPosition(hWaveOut
, &mmt
, sizeof(mmt
));
4055 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
4059 #define WAVEOUT_SHORTCUT_1(xx, XX, atype) \
4060 UINT WINAPI waveOut##xx(HWAVEOUT hWaveOut, atype x) \
4063 TRACE("(%04X, %08lx);\n", hWaveOut, (DWORD)x); \
4064 if ((wmld = MMDRV_Get(hWaveOut,MMDRV_WAVEOUT,FALSE))==NULL) \
4065 return MMSYSERR_INVALHANDLE; \
4066 return MMDRV_Message(wmld,WODM_##XX,(DWORD)x,0L,TRUE); \
4068 UINT16 WINAPI waveOut##xx##16(HWAVEOUT16 hWaveOut16, atype x) \
4069 {return waveOut##xx(hWaveOut16, x);}
4071 WAVEOUT_SHORTCUT_1(GetPitch
, GETPITCH
, LPDWORD
)
4072 WAVEOUT_SHORTCUT_1(SetPitch
, SETPITCH
, DWORD
)
4073 WAVEOUT_SHORTCUT_1(GetPlaybackRate
, GETPLAYBACKRATE
, LPDWORD
)
4074 WAVEOUT_SHORTCUT_1(SetPlaybackRate
, SETPLAYBACKRATE
, DWORD
)
4075 #undef WAVEOUT_SHORTCUT_1
4077 #define WAVEOUT_SHORTCUT_2(xx, XX, atype) \
4078 UINT WINAPI waveOut##xx(UINT devid, atype x) \
4081 TRACE("(%04X, %08lx);\n", devid, (DWORD)x); \
4082 if ((wmld = MMDRV_Get(devid,MMDRV_WAVEOUT,TRUE))==NULL) \
4083 return MMSYSERR_INVALHANDLE; \
4084 return MMDRV_Message(wmld, WODM_##XX, (DWORD)x, 0L, TRUE); \
4086 UINT16 WINAPI waveOut##xx##16(UINT16 devid, atype x) \
4087 {return waveOut##xx(devid, x);}
4089 WAVEOUT_SHORTCUT_2(GetVolume
, GETVOLUME
, LPDWORD
)
4090 WAVEOUT_SHORTCUT_2(SetVolume
, SETVOLUME
, DWORD
)
4091 #undef WAVEOUT_SHORTCUT_2
4093 /**************************************************************************
4094 * waveOutGetID [MMSYSTEM.420]
4096 UINT WINAPI
waveOutGetID(HWAVEOUT hWaveOut
, UINT
* lpuDeviceID
)
4100 TRACE("(%04X, %p);\n", hWaveOut
, lpuDeviceID
);
4102 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4104 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4105 return MMSYSERR_INVALHANDLE
;
4107 *lpuDeviceID
= wmld
->uDeviceID
;
4111 /**************************************************************************
4112 * waveOutGetID [MMSYSTEM.420]
4114 UINT16 WINAPI
waveOutGetID16(HWAVEOUT16 hWaveOut
, UINT16
* lpuDeviceID
)
4118 TRACE("(%04X, %p);\n", hWaveOut
, lpuDeviceID
);
4120 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4122 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4123 return MMSYSERR_INVALHANDLE
;
4125 *lpuDeviceID
= wmld
->uDeviceID
;
4129 /**************************************************************************
4130 * waveOutMessage [WINMM.172]
4132 DWORD WINAPI
waveOutMessage(HWAVEOUT hWaveOut
, UINT uMessage
,
4133 DWORD dwParam1
, DWORD dwParam2
)
4137 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
4140 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4141 return MMSYSERR_INVALPARAM
;
4143 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4144 return MMSYSERR_INVALHANDLE
;
4146 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4149 /**************************************************************************
4150 * waveOutMessage [MMSYSTEM.421]
4152 DWORD WINAPI
waveOutMessage16(HWAVEOUT16 hWaveOut
, UINT16 uMessage
,
4153 DWORD dwParam1
, DWORD dwParam2
)
4157 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
4159 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
) {
4160 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, TRUE
)) != NULL
) {
4161 return MMDRV_PhysicalFeatures(wmld
, uMessage
, dwParam1
, dwParam2
);
4163 return MMSYSERR_INVALHANDLE
;
4167 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4168 return MMSYSERR_INVALPARAM
;
4170 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, FALSE
);
4173 /**************************************************************************
4174 * waveInGetNumDevs [WINMM.151]
4176 UINT WINAPI
waveInGetNumDevs(void)
4178 return MMDRV_GetNum(MMDRV_WAVEIN
);
4181 /**************************************************************************
4182 * waveInGetNumDevs [MMSYSTEM.501]
4184 UINT16 WINAPI
waveInGetNumDevs16(void)
4186 return MMDRV_GetNum(MMDRV_WAVEIN
);
4189 /**************************************************************************
4190 * waveInGetDevCapsA [WINMM.147]
4192 UINT WINAPI
waveInGetDevCapsW(UINT uDeviceID
, LPWAVEINCAPSW lpCaps
, UINT uSize
)
4195 UINT ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, uSize
);
4197 if (ret
== MMSYSERR_NOERROR
) {
4198 lpCaps
->wMid
= wicA
.wMid
;
4199 lpCaps
->wPid
= wicA
.wPid
;
4200 lpCaps
->vDriverVersion
= wicA
.vDriverVersion
;
4201 lstrcpyAtoW(lpCaps
->szPname
, wicA
.szPname
);
4202 lpCaps
->dwFormats
= wicA
.dwFormats
;
4203 lpCaps
->wChannels
= wicA
.wChannels
;
4209 /**************************************************************************
4210 * waveInGetDevCapsA [WINMM.146]
4212 UINT WINAPI
waveInGetDevCapsA(UINT uDeviceID
, LPWAVEINCAPSA lpCaps
, UINT uSize
)
4216 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
4218 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_WAVEIN
, TRUE
)) == NULL
)
4219 return MMSYSERR_INVALHANDLE
;
4221 return MMDRV_Message(wmld
, WIDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
4224 /**************************************************************************
4225 * waveInGetDevCaps [MMSYSTEM.502]
4227 UINT16 WINAPI
waveInGetDevCaps16(UINT16 uDeviceID
, LPWAVEINCAPS16 lpCaps
,
4231 UINT ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, sizeof(wicA
));
4233 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
4235 if (ret
== MMSYSERR_NOERROR
) {
4236 lpCaps
->wMid
= wicA
.wMid
;
4237 lpCaps
->wPid
= wicA
.wPid
;
4238 lpCaps
->vDriverVersion
= wicA
.vDriverVersion
;
4239 strcpy(lpCaps
->szPname
, wicA
.szPname
);
4240 lpCaps
->dwFormats
= wicA
.dwFormats
;
4241 lpCaps
->wChannels
= wicA
.wChannels
;
4246 /**************************************************************************
4247 * waveInGetErrorTextA [WINMM.148]
4249 UINT WINAPI
waveInGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
4251 return WAVE_GetErrorText(uError
, lpText
, uSize
);
4254 /**************************************************************************
4255 * waveInGetErrorTextW [WINMM.149]
4257 UINT WINAPI
waveInGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
4259 LPSTR txt
= HeapAlloc(GetProcessHeap(), 0, uSize
);
4260 UINT ret
= WAVE_GetErrorText(uError
, txt
, uSize
);
4262 lstrcpyAtoW(lpText
, txt
);
4263 HeapFree(GetProcessHeap(), 0, txt
);
4267 /**************************************************************************
4268 * waveInGetErrorText [MMSYSTEM.503]
4270 UINT16 WINAPI
waveInGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
4272 return WAVE_GetErrorText(uError
, lpText
, uSize
);
4275 /**************************************************************************
4276 * waveInOpen [WINMM.154]
4278 UINT WINAPI
waveInOpen(HWAVEIN
* lphWaveIn
, UINT uDeviceID
,
4279 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
4280 DWORD dwInstance
, DWORD dwFlags
)
4282 return MMSYSTEM_waveOpen(lphWaveIn
, uDeviceID
, MMDRV_WAVEIN
, lpFormat
,
4283 dwCallback
, dwInstance
, dwFlags
, TRUE
);
4286 /**************************************************************************
4287 * waveInOpen [MMSYSTEM.504]
4289 UINT16 WINAPI
waveInOpen16(HWAVEIN16
* lphWaveIn
, UINT16 uDeviceID
,
4290 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
4291 DWORD dwInstance
, DWORD dwFlags
)
4296 /* since layout of WAVEOFORMATEX is the same for 16/32 bits, we directly
4297 * call the 32 bit version
4299 ret
= MMSYSTEM_waveOpen(&hWaveIn
, uDeviceID
, MMDRV_WAVEIN
, lpFormat
,
4300 dwCallback
, dwInstance
, dwFlags
, FALSE
);
4302 if (lphWaveIn
!= NULL
) *lphWaveIn
= hWaveIn
;
4306 /**************************************************************************
4307 * waveInClose [WINMM.145]
4309 UINT WINAPI
waveInClose(HWAVEIN hWaveIn
)
4314 TRACE("(%04X)\n", hWaveIn
);
4316 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4317 return MMSYSERR_INVALHANDLE
;
4319 dwRet
= MMDRV_Message(wmld
, WIDM_CLOSE
, 0L, 0L, TRUE
);
4320 MMDRV_Free(hWaveIn
, wmld
);
4324 /**************************************************************************
4325 * waveInClose [MMSYSTEM.505]
4327 UINT16 WINAPI
waveInClose16(HWAVEIN16 hWaveIn
)
4329 return waveOutClose(hWaveIn
);
4332 /**************************************************************************
4333 * waveInPrepareHeader [WINMM.155]
4335 UINT WINAPI
waveInPrepareHeader(HWAVEIN hWaveIn
, WAVEHDR
* lpWaveInHdr
,
4340 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4342 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4343 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4344 return MMSYSERR_INVALHANDLE
;
4346 lpWaveInHdr
->dwBytesRecorded
= 0;
4348 return MMDRV_Message(wmld
, WIDM_PREPARE
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4351 /**************************************************************************
4352 * waveInPrepareHeader [MMSYSTEM.506]
4354 UINT16 WINAPI
waveInPrepareHeader16(HWAVEIN16 hWaveIn
,
4355 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4359 LPWAVEHDR lpWaveInHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveInHdr
);
4362 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4364 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4365 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4366 return MMSYSERR_INVALHANDLE
;
4368 lpWaveInHdr
->dwBytesRecorded
= 0;
4370 ret
= MMDRV_Message(wmld
, WIDM_PREPARE
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4374 /**************************************************************************
4375 * waveInUnprepareHeader [WINMM.159]
4377 UINT WINAPI
waveInUnprepareHeader(HWAVEIN hWaveIn
, WAVEHDR
* lpWaveInHdr
,
4382 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4384 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4385 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
4386 return MMSYSERR_NOERROR
;
4389 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4390 return MMSYSERR_INVALHANDLE
;
4392 return MMDRV_Message(wmld
, WIDM_UNPREPARE
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4395 /**************************************************************************
4396 * waveInUnprepareHeader [MMSYSTEM.507]
4398 UINT16 WINAPI
waveInUnprepareHeader16(HWAVEIN16 hWaveIn
,
4399 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4403 LPWAVEHDR lpWaveInHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveInHdr
);
4405 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
4407 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4409 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
4410 return MMSYSERR_NOERROR
;
4413 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4414 return MMSYSERR_INVALHANDLE
;
4416 return MMDRV_Message(wmld
, WIDM_UNPREPARE
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4419 /**************************************************************************
4420 * waveInAddBuffer [WINMM.144]
4422 UINT WINAPI
waveInAddBuffer(HWAVEIN hWaveIn
,
4423 WAVEHDR
* lpWaveInHdr
, UINT uSize
)
4427 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4429 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4430 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4431 return MMSYSERR_INVALHANDLE
;
4433 return MMDRV_Message(wmld
, WIDM_ADDBUFFER
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4436 /**************************************************************************
4437 * waveInAddBuffer [MMSYSTEM.508]
4439 UINT16 WINAPI
waveInAddBuffer16(HWAVEIN16 hWaveIn
,
4440 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4445 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
4447 if (lpsegWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4448 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4449 return MMSYSERR_INVALHANDLE
;
4451 return MMDRV_Message(wmld
, WIDM_ADDBUFFER
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4454 #define WAVEIN_SHORTCUT_0(xx, XX) \
4455 UINT WINAPI waveIn##xx(HWAVEIN hWaveIn) \
4458 TRACE("(%04X);\n", hWaveIn); \
4459 if ((wmld=MMDRV_Get(hWaveIn,MMDRV_WAVEIN,FALSE)) == NULL) \
4460 return MMSYSERR_INVALHANDLE; \
4461 return MMDRV_Message(wmld,WIDM_##XX,0L,0L,TRUE); \
4463 UINT16 WINAPI waveIn##xx##16(HWAVEIN16 hWaveIn16) \
4464 {return waveIn##xx(hWaveIn16);}
4466 WAVEIN_SHORTCUT_0(Reset
, RESET
)
4467 WAVEIN_SHORTCUT_0(Start
, START
)
4468 WAVEIN_SHORTCUT_0(Stop
, STOP
)
4469 #undef WAVEIN_SHORTCUT_0
4471 /**************************************************************************
4472 * waveInGetPosition [WINMM.152]
4474 UINT WINAPI
waveInGetPosition(HWAVEIN hWaveIn
, LPMMTIME lpTime
,
4479 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpTime
, uSize
);
4481 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4482 return MMSYSERR_INVALHANDLE
;
4484 return MMDRV_Message(wmld
, WIDM_GETPOS
, (DWORD
)lpTime
, uSize
, TRUE
);
4487 /**************************************************************************
4488 * waveInGetPosition [MMSYSTEM.512]
4490 UINT16 WINAPI
waveInGetPosition16(HWAVEIN16 hWaveIn
, LPMMTIME16 lpTime
,
4496 mmt
.wType
= lpTime
->wType
;
4497 ret
= waveInGetPosition(hWaveIn
, &mmt
, sizeof(mmt
));
4498 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
4502 /**************************************************************************
4503 * waveInGetID [WINMM.150]
4505 UINT WINAPI
waveInGetID(HWAVEIN hWaveIn
, UINT
* lpuDeviceID
)
4509 TRACE("(%04X, %p);\n", hWaveIn
, lpuDeviceID
);
4511 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4513 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4514 return MMSYSERR_INVALHANDLE
;
4516 *lpuDeviceID
= wmld
->uDeviceID
;
4517 return MMSYSERR_NOERROR
;
4520 /**************************************************************************
4521 * waveInGetID [MMSYSTEM.513]
4523 UINT16 WINAPI
waveInGetID16(HWAVEIN16 hWaveIn
, UINT16
* lpuDeviceID
)
4527 TRACE("(%04X, %p);\n", hWaveIn
, lpuDeviceID
);
4529 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4531 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4532 return MMSYSERR_INVALHANDLE
;
4534 *lpuDeviceID
= wmld
->uDeviceID
;
4535 return MMSYSERR_NOERROR
;
4538 /**************************************************************************
4539 * waveInMessage [WINMM.153]
4541 DWORD WINAPI
waveInMessage(HWAVEIN hWaveIn
, UINT uMessage
,
4542 DWORD dwParam1
, DWORD dwParam2
)
4546 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
4549 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4550 return MMSYSERR_INVALPARAM
;
4552 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4553 return MMSYSERR_INVALHANDLE
;
4555 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4558 /**************************************************************************
4559 * waveInMessage [MMSYSTEM.514]
4561 DWORD WINAPI
waveInMessage16(HWAVEIN16 hWaveIn
, UINT16 uMessage
,
4562 DWORD dwParam1
, DWORD dwParam2
)
4566 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
4569 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4570 return MMSYSERR_INVALPARAM
;
4572 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4573 return MMSYSERR_INVALHANDLE
;
4575 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4578 /**************************************************************************
4579 * DrvOpen [MMSYSTEM.1100]
4581 HDRVR16 WINAPI
DrvOpen(LPSTR lpDriverName
, LPSTR lpSectionName
, LPARAM lParam
)
4583 TRACE("('%s','%s', %08lX);\n", lpDriverName
, lpSectionName
, lParam
);
4585 return OpenDriver16(lpDriverName
, lpSectionName
, lParam
);
4588 /**************************************************************************
4589 * DrvClose [MMSYSTEM.1101]
4591 LRESULT WINAPI
DrvClose(HDRVR16 hDrv
, LPARAM lParam1
, LPARAM lParam2
)
4593 TRACE("(%04X, %08lX, %08lX);\n", hDrv
, lParam1
, lParam2
);
4595 return CloseDriver16(hDrv
, lParam1
, lParam2
);
4598 /**************************************************************************
4599 * DrvSendMessage [MMSYSTEM.1102]
4601 LRESULT WINAPI
DrvSendMessage(HDRVR16 hDrv
, WORD msg
, LPARAM lParam1
,
4604 return SendDriverMessage(hDrv
, msg
, lParam1
, lParam2
);
4607 /**************************************************************************
4608 * DrvGetModuleHandle [MMSYSTEM.1103]
4610 HANDLE16 WINAPI
DrvGetModuleHandle16(HDRVR16 hDrv
)
4612 return GetDriverModuleHandle16(hDrv
);
4615 /**************************************************************************
4616 * DrvDefDriverProc [MMSYSTEM.1104]
4618 LRESULT WINAPI
DrvDefDriverProc(DWORD dwDriverID
, HDRVR16 hDrv
, WORD wMsg
,
4619 DWORD dwParam1
, DWORD dwParam2
)
4621 /* FIXME : any mapping from 32 to 16 bit structure ? */
4622 return DefDriverProc16(dwDriverID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
4625 /**************************************************************************
4626 * DefDriverProc [WINMM.5]
4628 LRESULT WINAPI
DefDriverProc(DWORD dwDriverIdentifier
, HDRVR hDrv
,
4629 UINT Msg
, LPARAM lParam1
, LPARAM lParam2
)
4645 /*#define USE_MM_TSK_WINE*/
4647 /**************************************************************************
4648 * mmTaskCreate [MMSYSTEM.900]
4650 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
4651 * called upon creation with dwPmt as parameter.
4653 HINSTANCE16 WINAPI
mmTaskCreate16(SEGPTR spProc
, HINSTANCE16
*lphMmTask
, DWORD dwPmt
)
4655 DWORD showCmd
= 0x40002;
4662 TRACE("(%08lx, %p, %08lx);\n", spProc
, lphMmTask
, dwPmt
);
4663 /* This to work requires NE modules to be started with a binary command line
4664 * which is not currently the case. A patch exists but has never been committed.
4665 * A workaround would be to integrate code for mmtask.tsk into Wine, but
4666 * this requires tremendous work (starting with patching tools/build to
4667 * create NE executables (and not only DLLs) for builtins modules.
4670 FIXME("This is currently broken. It will fail\n");
4672 cmdline
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, 0x0d);
4674 *(LPDWORD
)(cmdline
+ 1) = (DWORD
)spProc
;
4675 *(LPDWORD
)(cmdline
+ 5) = dwPmt
;
4676 *(LPDWORD
)(cmdline
+ 9) = 0;
4678 sel1
= SELECTOR_AllocBlock(cmdline
, 0x0d, SEGMENT_DATA
, FALSE
, FALSE
);
4679 sel2
= SELECTOR_AllocBlock(&showCmd
, sizeof(showCmd
),
4680 SEGMENT_DATA
, FALSE
, FALSE
);
4682 lp
= (LOADPARAMS16
*)HeapAlloc(GetProcessHeap(), 0, sizeof(LOADPARAMS16
));
4683 lp
->hEnvironment
= 0;
4684 lp
->cmdLine
= PTR_SEG_OFF_TO_SEGPTR(sel1
, 0);
4685 lp
->showCmd
= PTR_SEG_OFF_TO_SEGPTR(sel2
, 0);
4688 #ifndef USE_MM_TSK_WINE
4689 handle
= LoadModule16("c:\\windows\\system\\mmtask.tsk", lp
);
4691 handle
= LoadModule16("mmtask.tsk", lp
);
4694 ret
= (handle
) ? 1 : 2;
4700 *lphMmTask
= handle
;
4702 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel2
, 0));
4703 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel1
, 0));
4705 HeapFree(GetProcessHeap(), 0, lp
);
4706 HeapFree(GetProcessHeap(), 0, cmdline
);
4708 TRACE("=> 0x%04x/%d\n", handle
, ret
);
4712 #ifdef USE_MM_TSK_WINE
4713 /* C equivalent to mmtask.tsk binary content */
4714 void mmTaskEntryPoint16(LPSTR cmdLine
, WORD di
, WORD si
)
4716 int len
= cmdLine
[0x80];
4719 void (*fpProc
)(DWORD
) = (void (*)(DWORD
))PTR_SEG_TO_LIN(*((DWORD
*)(cmdLine
+ 1)));
4720 DWORD dwPmt
= *((DWORD
*)(cmdLine
+ 5));
4723 InitTask16(); /* fixme: pmts / from context ? */
4726 if (SetMessageQueue16(0x40)) {
4728 if (HIWORD(fpProc
)) {
4730 /* EPP StackEnter16(); */
4742 /**************************************************************************
4743 * mmTaskBlock [MMSYSTEM.902]
4745 void WINAPI
mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst
)
4750 GetMessageA(&msg
, 0, 0, 0);
4752 TranslateMessage(&msg
);
4753 DispatchMessageA(&msg
);
4755 } while (msg
.message
< 0x3A0);
4758 /**************************************************************************
4759 * mmTaskSignal [MMSYSTEM.903]
4761 LRESULT WINAPI
mmTaskSignal16(HTASK16 ht
)
4763 TRACE("(%04x);\n", ht
);
4764 return Callout
.PostAppMessage16(ht
, WM_USER
, 0, 0);
4767 /**************************************************************************
4768 * mmTaskYield16 [MMSYSTEM.905]
4770 void WINAPI
mmTaskYield16(void)
4774 if (PeekMessageA(&msg
, 0, 0, 0, 0)) {
4779 DWORD WINAPI
GetProcessFlags(DWORD
);
4781 /**************************************************************************
4782 * mmThreadCreate [MMSYSTEM.1120]
4785 * Creates a MM thread, calling fpThreadAddr(dwPmt).
4787 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
4788 * bit.1 set means to open a VxD for this thread (unsupported)
4790 LRESULT WINAPI
mmThreadCreate16(FARPROC16 fpThreadAddr
, LPHANDLE lpHndl
, DWORD dwPmt
, DWORD dwFlags
)
4795 TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr
, lpHndl
, dwPmt
, dwFlags
);
4797 hndl
= GlobalAlloc16(sizeof(WINE_MMTHREAD
), GMEM_SHARE
|GMEM_ZEROINIT
);
4802 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4805 /* force mmtask routines even if mmthread is required */
4806 /* this will work only if the patch about binary cmd line and NE tasks
4812 lpMMThd
->dwSignature
= WINE_MMTHREAD_CREATED
;
4813 lpMMThd
->dwCounter
= 0;
4814 lpMMThd
->hThread
= 0;
4815 lpMMThd
->dwThreadID
= 0;
4816 lpMMThd
->fpThread
= fpThreadAddr
;
4817 lpMMThd
->dwThreadPmt
= dwPmt
;
4818 lpMMThd
->dwSignalCount
= 0;
4819 lpMMThd
->hEvent
= 0;
4821 lpMMThd
->dwStatus
= 0;
4822 lpMMThd
->dwFlags
= dwFlags
;
4825 if ((dwFlags
& 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
4826 lpMMThd
->hEvent
= CreateEventA(0, 0, 1, 0);
4828 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd
);
4829 if (lpMMThd
->dwFlags
& 2) {
4830 /* as long as we don't support MM VxD in wine, we don't need
4831 * to care about this flag
4833 /* FIXME("Don't know how to properly open VxD handles\n"); */
4834 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
4837 lpMMThd
->hThread
= CreateThread(0, 0, (LPTHREAD_START_ROUTINE
)WINE_mmThreadEntryPoint
,
4838 (LPVOID
)(DWORD
)hndl
, CREATE_SUSPENDED
, &lpMMThd
->dwThreadID
);
4839 if (lpMMThd
->hThread
== 0) {
4840 WARN("Couldn't create thread\n");
4841 /* clean-up(VxDhandle...); devicedirectio... */
4842 if (lpMMThd
->hEvent
!= 0)
4843 CloseHandle(lpMMThd
->hEvent
);
4846 TRACE("Got a nice thread hndl=0x%04x id=0x%08lx\n", lpMMThd
->hThread
, lpMMThd
->dwThreadID
);
4850 /* get WINE_mmThreadEntryPoint()
4851 * 2047 is its ordinal in mmsystem.spec
4853 FARPROC16 fp
= GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (SEGPTR
)2047);
4855 TRACE("farproc seg=0x%08lx lin=%p\n", (DWORD
)fp
, PTR_SEG_TO_LIN(fp
));
4857 ret
= (fp
== 0) ? 2 : mmTaskCreate16((DWORD
)fp
, 0, hndl
);
4861 if (lpMMThd
->hThread
&& !ResumeThread(lpMMThd
->hThread
))
4862 WARN("Couldn't resume thread\n");
4864 while (lpMMThd
->dwStatus
!= 0x10) { /* test also HIWORD of dwStatus */
4878 TRACE("ok => %ld\n", ret
);
4882 /**************************************************************************
4883 * mmThreadSignal [MMSYSTEM.1121]
4885 void WINAPI
mmThreadSignal16(HANDLE16 hndl
)
4887 TRACE("(%04x)!\n", hndl
);
4890 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4892 lpMMThd
->dwCounter
++;
4893 if (lpMMThd
->hThread
!= 0) {
4894 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
4895 SetEvent(lpMMThd
->hEvent
);
4897 mmTaskSignal16(lpMMThd
->hTask
);
4899 lpMMThd
->dwCounter
--;
4903 /**************************************************************************
4904 * MMSYSTEM_ThreadBlock [internal]
4906 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD
* lpMMThd
)
4911 if (lpMMThd
->dwThreadID
!= GetCurrentThreadId())
4912 ERR("Not called by thread itself\n");
4915 ResetEvent(lpMMThd
->hEvent
);
4916 if (InterlockedDecrement(&lpMMThd
->dwSignalCount
) >= 0)
4918 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
4922 ret
= MsgWaitForMultipleObjects(1, &lpMMThd
->hEvent
, FALSE
, INFINITE
, QS_ALLINPUT
);
4924 case WAIT_OBJECT_0
: /* Event */
4927 case WAIT_OBJECT_0
+ 1: /* Msg */
4929 if (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
4930 Callout
.TranslateMessage(&msg
);
4931 Callout
.DispatchMessageA(&msg
);
4935 WARN("S2.x unsupported ret val 0x%08lx\n", ret
);
4941 /**************************************************************************
4942 * mmThreadBlock [MMSYSTEM.1122]
4944 void WINAPI
mmThreadBlock16(HANDLE16 hndl
)
4946 TRACE("(%04x)!\n", hndl
);
4949 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4951 if (lpMMThd
->hThread
!= 0) {
4952 SYSLEVEL_ReleaseWin16Lock();
4953 MMSYSTEM_ThreadBlock(lpMMThd
);
4954 SYSLEVEL_RestoreWin16Lock();
4956 mmTaskBlock16(lpMMThd
->hTask
);
4962 /**************************************************************************
4963 * mmThreadIsCurrent [MMSYSTEM.1123]
4965 BOOL16 WINAPI
mmThreadIsCurrent16(HANDLE16 hndl
)
4969 TRACE("(%04x)!\n", hndl
);
4971 if (hndl
&& mmThreadIsValid16(hndl
)) {
4972 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4973 ret
= (GetCurrentThreadId() == lpMMThd
->dwThreadID
);
4975 TRACE("=> %d\n", ret
);
4979 /**************************************************************************
4980 * mmThreadIsValid [MMSYSTEM.1124]
4982 BOOL16 WINAPI
mmThreadIsValid16(HANDLE16 hndl
)
4986 TRACE("(%04x)!\n", hndl
);
4989 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4991 if (!IsBadWritePtr(lpMMThd
, sizeof(WINE_MMTHREAD
)) &&
4992 lpMMThd
->dwSignature
== WINE_MMTHREAD_CREATED
&&
4993 IsTask16(lpMMThd
->hTask
)) {
4994 lpMMThd
->dwCounter
++;
4995 if (lpMMThd
->hThread
!= 0) {
4997 if (GetExitCodeThread(lpMMThd
->hThread
, &dwThreadRet
) &&
4998 dwThreadRet
== STATUS_PENDING
) {
5004 lpMMThd
->dwCounter
--;
5007 TRACE("=> %d\n", ret
);
5011 /**************************************************************************
5012 * mmThreadGetTask [MMSYSTEM.1125]
5014 HANDLE16 WINAPI
mmThreadGetTask16(HANDLE16 hndl
)
5018 TRACE("(%04x)\n", hndl
);
5020 if (mmThreadIsValid16(hndl
)) {
5021 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5022 ret
= lpMMThd
->hTask
;
5027 /* ### start build ### */
5028 extern LONG CALLBACK
MMSYSTEM_CallTo16_long_l (FARPROC16
,LONG
);
5029 /* ### stop build ### */
5031 /**************************************************************************
5032 * mmThreadGetTask [internal]
5034 void WINAPI
WINE_mmThreadEntryPoint(DWORD _pmt
)
5036 HANDLE16 hndl
= (HANDLE16
)_pmt
;
5037 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5039 TRACE("(%04x %p)\n", hndl
, lpMMThd
);
5041 lpMMThd
->hTask
= LOWORD(GetCurrentTask());
5042 TRACE("[10-%08x] setting hTask to 0x%08x\n", lpMMThd
->hThread
, lpMMThd
->hTask
);
5043 lpMMThd
->dwStatus
= 0x10;
5044 MMSYSTEM_ThreadBlock(lpMMThd
);
5045 TRACE("[20-%08x]\n", lpMMThd
->hThread
);
5046 lpMMThd
->dwStatus
= 0x20;
5047 if (lpMMThd
->fpThread
) {
5048 MMSYSTEM_CallTo16_long_l(lpMMThd
->fpThread
, lpMMThd
->dwThreadPmt
);
5050 lpMMThd
->dwStatus
= 0x30;
5051 TRACE("[30-%08x]\n", lpMMThd
->hThread
);
5052 while (lpMMThd
->dwCounter
) {
5056 TRACE("[XX-%08x]\n", lpMMThd
->hThread
);
5058 lpMMThd
->dwSignature
= WINE_MMTHREAD_DELETED
;
5059 /* close lpMMThread->hVxD directio */
5060 if (lpMMThd
->hEvent
)
5061 CloseHandle(lpMMThd
->hEvent
);
5066 typedef BOOL16 (WINAPI
*MMCPLCALLBACK
)(HWND
, LPCSTR
, LPCSTR
, LPCSTR
);
5068 /**************************************************************************
5069 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
5071 BOOL16 WINAPI
mmShowMMCPLPropertySheet16(HWND hWnd
, LPCSTR lpStrDevice
,
5072 LPCSTR lpStrTab
, LPCSTR lpStrTitle
)
5077 TRACE("(%04x \"%s\" \"%s\" \"%s\")\n", hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
5079 hndl
= LoadLibraryA("MMSYS.CPL");
5081 MMCPLCALLBACK fp
= (MMCPLCALLBACK
)GetProcAddress(hndl
, "ShowMMCPLPropertySheet");
5083 SYSLEVEL_ReleaseWin16Lock();
5084 ret
= (fp
)(hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
5085 SYSLEVEL_RestoreWin16Lock();
5093 /**************************************************************************
5094 * StackEnter & StackLeave [MMSYSTEM.32][MMSYSTEM.33]
5096 void WINAPI
StackEnterLeave16(void)
5099 /* mmsystem.dll from Win 95 does only this: so does Wine */
5104 /**************************************************************************
5105 * WMMMIDIRUNONCE [MMSYSTEM.8]
5107 void WINAPI
WMMMidiRunOnce16(void)
5109 FIXME("(), stub!\n");