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 * auxGetDevCapsW [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 * auxGetDevCapsA [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
,
2206 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2208 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2209 return MMSYSERR_INVALHANDLE
;
2211 return MMDRV_Message(wmld
, MODM_PREPARE
, (DWORD
)lpsegMidiOutHdr
, uSize
, FALSE
);
2214 /**************************************************************************
2215 * midiOutUnprepareHeader [WINMM.89]
2217 UINT WINAPI
midiOutUnprepareHeader(HMIDIOUT hMidiOut
,
2218 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2222 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2224 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
2225 return MMSYSERR_NOERROR
;
2228 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2229 return MMSYSERR_INVALHANDLE
;
2231 return MMDRV_Message(wmld
, MODM_UNPREPARE
, (DWORD
)lpMidiOutHdr
, uSize
, TRUE
);
2234 /**************************************************************************
2235 * midiOutUnprepareHeader [MMSYSTEM.207]
2237 UINT16 WINAPI
midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut
,
2238 LPMIDIHDR16
/*SEGPTR*/ lpsegMidiOutHdr
,
2242 LPMIDIHDR16 lpMidiOutHdr
= PTR_SEG_TO_LIN(lpsegMidiOutHdr
);
2244 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2246 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
2247 return MMSYSERR_NOERROR
;
2250 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2251 return MMSYSERR_INVALHANDLE
;
2253 return MMDRV_Message(wmld
, MODM_UNPREPARE
, (DWORD
)lpsegMidiOutHdr
, uSize
, FALSE
);
2256 /**************************************************************************
2257 * midiOutShortMsg [WINMM.88]
2259 UINT WINAPI
midiOutShortMsg(HMIDIOUT hMidiOut
, DWORD dwMsg
)
2263 TRACE("(%04X, %08lX)\n", hMidiOut
, dwMsg
);
2265 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2266 return MMSYSERR_INVALHANDLE
;
2268 return MMDRV_Message(wmld
, MODM_DATA
, dwMsg
, 0L, FALSE
);
2271 /**************************************************************************
2272 * midiOutShortMsg [MMSYSTEM.208]
2274 UINT16 WINAPI
midiOutShortMsg16(HMIDIOUT16 hMidiOut
, DWORD dwMsg
)
2276 return midiOutShortMsg(hMidiOut
, dwMsg
);
2279 /**************************************************************************
2280 * midiOutLongMsg [WINMM.82]
2282 UINT WINAPI
midiOutLongMsg(HMIDIOUT hMidiOut
,
2283 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2287 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2289 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2290 return MMSYSERR_INVALHANDLE
;
2292 return MMDRV_Message(wmld
, MODM_LONGDATA
, (DWORD
)lpMidiOutHdr
, uSize
, TRUE
);
2295 /**************************************************************************
2296 * midiOutLongMsg [MMSYSTEM.209]
2298 UINT16 WINAPI
midiOutLongMsg16(HMIDIOUT16 hMidiOut
,
2299 LPMIDIHDR16
/* SEGPTR */ lpsegMidiOutHdr
,
2304 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2306 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2307 return MMSYSERR_INVALHANDLE
;
2309 return MMDRV_Message(wmld
, MODM_LONGDATA
, (DWORD
)lpsegMidiOutHdr
, uSize
, FALSE
);
2312 /**************************************************************************
2313 * midiOutReset [WINMM.86]
2315 UINT WINAPI
midiOutReset(HMIDIOUT hMidiOut
)
2319 TRACE("(%04X)\n", hMidiOut
);
2321 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2322 return MMSYSERR_INVALHANDLE
;
2324 return MMDRV_Message(wmld
, MODM_RESET
, 0L, 0L, TRUE
);
2327 /**************************************************************************
2328 * midiOutReset [MMSYSTEM.210]
2330 UINT16 WINAPI
midiOutReset16(HMIDIOUT16 hMidiOut
)
2332 return midiOutReset(hMidiOut
);
2335 /**************************************************************************
2336 * midiOutGetVolume [WINM.81]
2338 UINT WINAPI
midiOutGetVolume(UINT uDeviceID
, DWORD
* lpdwVolume
)
2342 TRACE("(%04X, %p);\n", uDeviceID
, lpdwVolume
);
2344 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIOUT
, TRUE
)) == NULL
)
2345 return MMSYSERR_INVALHANDLE
;
2347 return MMDRV_Message(wmld
, MODM_GETVOLUME
, (DWORD
)lpdwVolume
, 0L, TRUE
);
2350 /**************************************************************************
2351 * midiOutGetVolume [MMSYSTEM.211]
2353 UINT16 WINAPI
midiOutGetVolume16(UINT16 uDeviceID
, DWORD
* lpdwVolume
)
2355 return midiOutGetVolume(uDeviceID
, lpdwVolume
);
2358 /**************************************************************************
2359 * midiOutSetVolume [WINMM.87]
2361 UINT WINAPI
midiOutSetVolume(UINT uDeviceID
, DWORD dwVolume
)
2365 TRACE("(%04X, %ld);\n", uDeviceID
, dwVolume
);
2367 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIOUT
, TRUE
)) == NULL
)
2368 return MMSYSERR_INVALHANDLE
;
2370 return MMDRV_Message(wmld
, MODM_SETVOLUME
, dwVolume
, 0L, TRUE
);
2373 /**************************************************************************
2374 * midiOutSetVolume [MMSYSTEM.212]
2376 UINT16 WINAPI
midiOutSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
2378 return midiOutSetVolume(uDeviceID
, dwVolume
);
2381 /**************************************************************************
2382 * midiOutCachePatches [WINMM.73]
2384 UINT WINAPI
midiOutCachePatches(HMIDIOUT hMidiOut
, UINT uBank
,
2385 WORD
* lpwPatchArray
, UINT uFlags
)
2387 /* not really necessary to support this */
2388 FIXME("not supported yet\n");
2389 return MMSYSERR_NOTSUPPORTED
;
2392 /**************************************************************************
2393 * midiOutCachePatches [MMSYSTEM.213]
2395 UINT16 WINAPI
midiOutCachePatches16(HMIDIOUT16 hMidiOut
, UINT16 uBank
,
2396 WORD
* lpwPatchArray
, UINT16 uFlags
)
2398 return midiOutCachePatches(hMidiOut
, uBank
, lpwPatchArray
, uFlags
);
2401 /**************************************************************************
2402 * midiOutCacheDrumPatches [WINMM.72]
2404 UINT WINAPI
midiOutCacheDrumPatches(HMIDIOUT hMidiOut
, UINT uPatch
,
2405 WORD
* lpwKeyArray
, UINT uFlags
)
2407 FIXME("not supported yet\n");
2408 return MMSYSERR_NOTSUPPORTED
;
2411 /**************************************************************************
2412 * midiOutCacheDrumPatches [MMSYSTEM.214]
2414 UINT16 WINAPI
midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut
, UINT16 uPatch
,
2415 WORD
* lpwKeyArray
, UINT16 uFlags
)
2417 return midiOutCacheDrumPatches16(hMidiOut
, uPatch
, lpwKeyArray
, uFlags
);
2420 /**************************************************************************
2421 * midiOutGetID [WINMM.79]
2423 UINT WINAPI
midiOutGetID(HMIDIOUT hMidiOut
, UINT
* lpuDeviceID
)
2427 TRACE("(%04X, %p)\n", hMidiOut
, lpuDeviceID
);
2429 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2430 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2431 return MMSYSERR_INVALHANDLE
;
2433 *lpuDeviceID
= wmld
->uDeviceID
;
2434 return MMSYSERR_NOERROR
;
2437 /**************************************************************************
2438 * midiOutGetID [MMSYSTEM.215]
2440 UINT16 WINAPI
midiOutGetID16(HMIDIOUT16 hMidiOut
, UINT16
* lpuDeviceID
)
2444 TRACE("(%04X, %p)\n", hMidiOut
, lpuDeviceID
);
2446 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2447 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2448 return MMSYSERR_INVALHANDLE
;
2450 *lpuDeviceID
= wmld
->uDeviceID
;
2451 return MMSYSERR_NOERROR
;
2454 /**************************************************************************
2455 * midiOutMessage [WINMM.83]
2457 DWORD WINAPI
midiOutMessage(HMIDIOUT hMidiOut
, UINT uMessage
,
2458 DWORD dwParam1
, DWORD dwParam2
)
2462 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2464 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2465 return MMSYSERR_INVALHANDLE
;
2470 FIXME("can't handle OPEN or CLOSE message!\n");
2471 return MMSYSERR_NOTSUPPORTED
;
2473 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2476 /**************************************************************************
2477 * midiOutMessage [MMSYSTEM.216]
2479 DWORD WINAPI
midiOutMessage16(HMIDIOUT16 hMidiOut
, UINT16 uMessage
,
2480 DWORD dwParam1
, DWORD dwParam2
)
2484 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2486 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2487 return MMSYSERR_INVALHANDLE
;
2492 FIXME("can't handle OPEN or CLOSE message!\n");
2493 return MMSYSERR_NOTSUPPORTED
;
2495 case MODM_GETVOLUME
:
2496 return midiOutGetVolume16(hMidiOut
, (LPDWORD
)PTR_SEG_TO_LIN(dwParam1
));
2498 return midiOutLongMsg16(hMidiOut
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2500 /* lpMidiOutHdr is still a segmented pointer for this function */
2501 return midiOutPrepareHeader16(hMidiOut
, (LPMIDIHDR16
)dwParam1
, dwParam2
);
2502 case MODM_UNPREPARE
:
2503 return midiOutUnprepareHeader16(hMidiOut
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2505 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2508 /**************************************************************************
2509 * midiInGetNumDevs [WINMM.64]
2511 UINT WINAPI
midiInGetNumDevs(void)
2513 return MMDRV_GetNum(MMDRV_MIDIIN
);
2516 /**************************************************************************
2517 * midiInGetNumDevs [MMSYSTEM.301]
2519 UINT16 WINAPI
midiInGetNumDevs16(void)
2521 return MMDRV_GetNum(MMDRV_MIDIIN
);
2524 /**************************************************************************
2525 * midiInGetDevCapsW [WINMM.60]
2527 UINT WINAPI
midiInGetDevCapsW(UINT uDeviceID
, LPMIDIINCAPSW lpCaps
, UINT uSize
)
2530 UINT ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
2532 if (ret
== MMSYSERR_NOERROR
) {
2533 lpCaps
->wMid
= micA
.wMid
;
2534 lpCaps
->wPid
= micA
.wPid
;
2535 lpCaps
->vDriverVersion
= micA
.vDriverVersion
;
2536 lstrcpyAtoW(lpCaps
->szPname
, micA
.szPname
);
2537 lpCaps
->dwSupport
= micA
.dwSupport
;
2542 /**************************************************************************
2543 * midiInGetDevCapsA [WINMM.59]
2545 UINT WINAPI
midiInGetDevCapsA(UINT uDeviceID
, LPMIDIINCAPSA lpCaps
, UINT uSize
)
2549 TRACE("(%d, %p, %d);\n", uDeviceID
, lpCaps
, uSize
);
2551 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2552 return MMSYSERR_INVALHANDLE
;
2554 return MMDRV_Message(wmld
, MIDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
2557 /**************************************************************************
2558 * midiInGetDevCaps [MMSYSTEM.302]
2560 UINT16 WINAPI
midiInGetDevCaps16(UINT16 uDeviceID
, LPMIDIINCAPS16 lpCaps
,
2564 UINT ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
2566 if (ret
== MMSYSERR_NOERROR
) {
2567 lpCaps
->wMid
= micA
.wMid
;
2568 lpCaps
->wPid
= micA
.wPid
;
2569 lpCaps
->vDriverVersion
= micA
.vDriverVersion
;
2570 strcpy(lpCaps
->szPname
, micA
.szPname
);
2571 lpCaps
->dwSupport
= micA
.dwSupport
;
2577 /**************************************************************************
2578 * midiInGetErrorTextW [WINMM.62]
2580 UINT WINAPI
midiInGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
2582 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
2583 UINT ret
= MIDI_GetErrorText(uError
, xstr
, uSize
);
2585 lstrcpyAtoW(lpText
, xstr
);
2586 HeapFree(GetProcessHeap(), 0, xstr
);
2590 /**************************************************************************
2591 * midiInGetErrorTextA [WINMM.61]
2593 UINT WINAPI
midiInGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
2595 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2598 /**************************************************************************
2599 * midiInGetErrorText [MMSYSTEM.303]
2601 UINT16 WINAPI
midiInGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2603 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2606 static UINT
MMSYSTEM_midiInOpen(HMIDIIN
* lphMidiIn
, UINT uDeviceID
, DWORD dwCallback
,
2607 DWORD dwInstance
, DWORD dwFlags
, BOOL bFrom32
)
2613 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2614 lphMidiIn
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
2616 if (lphMidiIn
!= NULL
) *lphMidiIn
= 0;
2618 lpwm
= (LPWINE_MIDI
)MMDRV_Alloc(sizeof(WINE_MIDI
), MMDRV_MIDIIN
, &hMidiIn
,
2619 &dwFlags
, &dwCallback
, &dwInstance
, bFrom32
);
2622 return MMSYSERR_NOMEM
;
2624 lpwm
->mod
.hMidi
= hMidiIn
;
2625 lpwm
->mod
.dwCallback
= dwCallback
;
2626 lpwm
->mod
.dwInstance
= dwInstance
;
2628 lpwm
->mld
.uDeviceID
= uDeviceID
;
2629 dwRet
= MMDRV_Open(&lpwm
->mld
, MIDM_OPEN
, (DWORD
)&lpwm
->mod
, dwFlags
);
2631 if (dwRet
!= MMSYSERR_NOERROR
) {
2632 MMDRV_Free(hMidiIn
, &lpwm
->mld
);
2635 if (lphMidiIn
!= NULL
) *lphMidiIn
= hMidiIn
;
2636 TRACE("=> %ld hMidi=%04x\n", dwRet
, hMidiIn
);
2641 /**************************************************************************
2642 * midiInOpen [WINMM.66]
2644 UINT WINAPI
midiInOpen(HMIDIIN
* lphMidiIn
, UINT uDeviceID
,
2645 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2647 return MMSYSTEM_midiInOpen(lphMidiIn
, uDeviceID
, dwCallback
,
2648 dwInstance
, dwFlags
, TRUE
);
2651 /**************************************************************************
2652 * midiInOpen [MMSYSTEM.304]
2654 UINT16 WINAPI
midiInOpen16(HMIDIIN16
* lphMidiIn
, UINT16 uDeviceID
,
2655 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2660 ret
= MMSYSTEM_midiInOpen(&xhmid
, uDeviceID
, dwCallback
, dwInstance
,
2663 if (lphMidiIn
) *lphMidiIn
= xhmid
;
2667 /**************************************************************************
2668 * midiInClose [WINMM.58]
2670 UINT WINAPI
midiInClose(HMIDIIN hMidiIn
)
2675 TRACE("(%04X)\n", hMidiIn
);
2677 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2678 return MMSYSERR_INVALHANDLE
;
2680 dwRet
= MMDRV_Close(wmld
, MIDM_CLOSE
);
2681 MMDRV_Free(hMidiIn
, wmld
);
2685 /**************************************************************************
2686 * midiInClose [MMSYSTEM.305]
2688 UINT16 WINAPI
midiInClose16(HMIDIIN16 hMidiIn
)
2690 return midiInClose(hMidiIn
);
2693 /**************************************************************************
2694 * midiInPrepareHeader [WINMM.67]
2696 UINT WINAPI
midiInPrepareHeader(HMIDIIN hMidiIn
,
2697 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2701 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2703 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2704 return MMSYSERR_INVALHANDLE
;
2706 return MMDRV_Message(wmld
, MIDM_PREPARE
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2709 /**************************************************************************
2710 * midiInPrepareHeader [MMSYSTEM.306]
2712 UINT16 WINAPI
midiInPrepareHeader16(HMIDIIN16 hMidiIn
,
2713 MIDIHDR16
* /*SEGPTR*/ lpsegMidiInHdr
,
2718 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2720 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2721 return MMSYSERR_INVALHANDLE
;
2723 return MMDRV_Message(wmld
, MIDM_PREPARE
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2726 /**************************************************************************
2727 * midiInUnprepareHeader [WINMM.71]
2729 UINT WINAPI
midiInUnprepareHeader(HMIDIIN hMidiIn
,
2730 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2734 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2736 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
2737 return MMSYSERR_NOERROR
;
2740 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2741 return MMSYSERR_INVALHANDLE
;
2743 return MMDRV_Message(wmld
, MIDM_UNPREPARE
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2746 /**************************************************************************
2747 * midiInUnprepareHeader [MMSYSTEM.307]
2749 UINT16 WINAPI
midiInUnprepareHeader16(HMIDIIN16 hMidiIn
,
2750 MIDIHDR16
* /* SEGPTR */ lpsegMidiInHdr
,
2754 LPMIDIHDR16 lpMidiInHdr
= PTR_SEG_TO_LIN(lpsegMidiInHdr
);
2756 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2758 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
2759 return MMSYSERR_NOERROR
;
2762 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2763 return MMSYSERR_INVALHANDLE
;
2765 return MMDRV_Message(wmld
, MIDM_UNPREPARE
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2768 /**************************************************************************
2769 * midiInAddBuffer [WINMM.57]
2771 UINT WINAPI
midiInAddBuffer(HMIDIIN hMidiIn
,
2772 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2776 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2778 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2779 return MMSYSERR_INVALHANDLE
;
2781 return MMDRV_Message(wmld
, MIDM_ADDBUFFER
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2784 /**************************************************************************
2785 * midiInAddBuffer [MMSYSTEM.308]
2787 UINT16 WINAPI
midiInAddBuffer16(HMIDIIN16 hMidiIn
,
2788 MIDIHDR16
* /* SEGPTR */ lpsegMidiInHdr
,
2793 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2795 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2796 return MMSYSERR_INVALHANDLE
;
2798 return MMDRV_Message(wmld
, MIDM_ADDBUFFER
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2801 /**************************************************************************
2802 * midiInStart [WINMM.69]
2804 UINT WINAPI
midiInStart(HMIDIIN hMidiIn
)
2808 TRACE("(%04X)\n", hMidiIn
);
2810 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2811 return MMSYSERR_INVALHANDLE
;
2813 return MMDRV_Message(wmld
, MIDM_START
, 0L, 0L, TRUE
);
2816 /**************************************************************************
2817 * midiInStart [MMSYSTEM.309]
2819 UINT16 WINAPI
midiInStart16(HMIDIIN16 hMidiIn
)
2821 return midiInStart(hMidiIn
);
2824 /**************************************************************************
2825 * midiInStop [WINMM.70]
2827 UINT WINAPI
midiInStop(HMIDIIN hMidiIn
)
2831 TRACE("(%04X)\n", hMidiIn
);
2833 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2834 return MMSYSERR_INVALHANDLE
;
2836 return MMDRV_Message(wmld
, MIDM_STOP
, 0L, 0L, TRUE
);
2839 /**************************************************************************
2840 * midiInStop [MMSYSTEM.310]
2842 UINT16 WINAPI
midiInStop16(HMIDIIN16 hMidiIn
)
2844 return midiInStop(hMidiIn
);
2847 /**************************************************************************
2848 * midiInReset [WINMM.68]
2850 UINT WINAPI
midiInReset(HMIDIIN hMidiIn
)
2854 TRACE("(%04X)\n", hMidiIn
);
2856 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2857 return MMSYSERR_INVALHANDLE
;
2859 return MMDRV_Message(wmld
, MIDM_RESET
, 0L, 0L, TRUE
);
2862 /**************************************************************************
2863 * midiInReset [MMSYSTEM.311]
2865 UINT16 WINAPI
midiInReset16(HMIDIIN16 hMidiIn
)
2867 return midiInReset(hMidiIn
);
2870 /**************************************************************************
2871 * midiInGetID [WINMM.63]
2873 UINT WINAPI
midiInGetID(HMIDIIN hMidiIn
, UINT
* lpuDeviceID
)
2877 TRACE("(%04X, %p)\n", hMidiIn
, lpuDeviceID
);
2879 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2881 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2882 return MMSYSERR_INVALHANDLE
;
2884 *lpuDeviceID
= wmld
->uDeviceID
;
2886 return MMSYSERR_NOERROR
;
2889 /**************************************************************************
2890 * midiInGetID [MMSYSTEM.312]
2892 UINT16 WINAPI
midiInGetID16(HMIDIIN16 hMidiIn
, UINT16
* lpuDeviceID
)
2896 TRACE("(%04X, %p)\n", hMidiIn
, lpuDeviceID
);
2898 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2900 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2901 return MMSYSERR_INVALHANDLE
;
2903 *lpuDeviceID
= wmld
->uDeviceID
;
2905 return MMSYSERR_NOERROR
;
2908 /**************************************************************************
2909 * midiInMessage [WINMM.65]
2911 DWORD WINAPI
midiInMessage(HMIDIIN hMidiIn
, UINT uMessage
,
2912 DWORD dwParam1
, DWORD dwParam2
)
2916 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
2918 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2919 return MMSYSERR_INVALHANDLE
;
2924 FIXME("can't handle OPEN or CLOSE message!\n");
2925 return MMSYSERR_NOTSUPPORTED
;
2927 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2930 /**************************************************************************
2931 * midiInMessage [MMSYSTEM.313]
2933 DWORD WINAPI
midiInMessage16(HMIDIIN16 hMidiIn
, UINT16 uMessage
,
2934 DWORD dwParam1
, DWORD dwParam2
)
2938 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
2943 FIXME("can't handle OPEN or CLOSE message!\n");
2944 return MMSYSERR_NOTSUPPORTED
;
2946 case MIDM_GETDEVCAPS
:
2947 return midiInGetDevCaps16(hMidiIn
, (LPMIDIINCAPS16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2949 return midiInPrepareHeader16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2950 case MIDM_UNPREPARE
:
2951 return midiInUnprepareHeader16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2952 case MIDM_ADDBUFFER
:
2953 return midiInAddBuffer16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2956 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2957 return MMSYSERR_INVALHANDLE
;
2959 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, FALSE
);
2962 typedef struct WINE_MIDIStream
{
2973 LPMIDIHDR lpMidiHdr
;
2976 #define WINE_MSM_HEADER (WM_USER+0)
2977 #define WINE_MSM_STOP (WM_USER+1)
2979 /**************************************************************************
2980 * MMSYSTEM_GetMidiStream [internal]
2982 static BOOL
MMSYSTEM_GetMidiStream(HMIDISTRM hMidiStrm
, WINE_MIDIStream
** lpMidiStrm
, WINE_MIDI
** lplpwm
)
2984 WINE_MIDI
* lpwm
= (LPWINE_MIDI
)MMDRV_Get(hMidiStrm
, MMDRV_MIDIOUT
, FALSE
);
2993 *lpMidiStrm
= (WINE_MIDIStream
*)lpwm
->mod
.rgIds
.dwStreamID
;
2995 return *lpMidiStrm
!= NULL
;
2998 /**************************************************************************
2999 * MMSYSTEM_MidiStream_Convert [internal]
3001 static DWORD
MMSYSTEM_MidiStream_Convert(WINE_MIDIStream
* lpMidiStrm
, DWORD pulse
)
3005 if (lpMidiStrm
->dwTimeDiv
== 0) {
3006 FIXME("Shouldn't happen. lpMidiStrm->dwTimeDiv = 0\n");
3007 } else if (lpMidiStrm
->dwTimeDiv
> 0x8000) { /* SMPTE, unchecked FIXME? */
3008 int nf
= -(char)HIBYTE(lpMidiStrm
->dwTimeDiv
); /* number of frames */
3009 int nsf
= LOBYTE(lpMidiStrm
->dwTimeDiv
); /* number of sub-frames */
3010 ret
= (pulse
* 1000) / (nf
* nsf
);
3012 ret
= (DWORD
)((double)pulse
* ((double)lpMidiStrm
->dwTempo
/ 1000) /
3013 (double)lpMidiStrm
->dwTimeDiv
);
3019 /**************************************************************************
3020 * MMSYSTEM_MidiStream_MessageHandler [internal]
3022 static BOOL
MMSYSTEM_MidiStream_MessageHandler(WINE_MIDIStream
* lpMidiStrm
, LPWINE_MIDI lpwm
, LPMSG msg
)
3024 LPMIDIHDR lpMidiHdr
;
3028 switch (msg
->message
) {
3030 SetEvent(lpMidiStrm
->hEvent
);
3034 /* this is not quite what MS doc says... */
3035 midiOutReset(lpMidiStrm
->hDevice
);
3036 /* empty list of already submitted buffers */
3037 for (lpMidiHdr
= lpMidiStrm
->lpMidiHdr
; lpMidiHdr
; lpMidiHdr
= (LPMIDIHDR
)lpMidiHdr
->lpNext
) {
3038 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3039 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3041 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3042 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
3044 lpMidiStrm
->lpMidiHdr
= 0;
3045 SetEvent(lpMidiStrm
->hEvent
);
3047 case WINE_MSM_HEADER
:
3048 /* sets initial tick count for first MIDIHDR */
3049 if (!lpMidiStrm
->dwStartTicks
)
3050 lpMidiStrm
->dwStartTicks
= GetTickCount();
3052 /* FIXME(EPP): "I don't understand the content of the first MIDIHDR sent
3053 * by native mcimidi, it doesn't look like a correct one".
3054 * this trick allows to throw it away... but I don't like it.
3055 * It looks like part of the file I'm trying to play and definitively looks
3056 * like raw midi content
3057 * I'd really like to understand why native mcimidi sends it. Perhaps a bad
3058 * synchronization issue where native mcimidi is still processing raw MIDI
3059 * content before generating MIDIEVENTs ?
3061 * 4c 04 89 3b 00 81 7c 99 3b 43 00 99 23 5e 04 89 L..;..|.;C..#^..
3062 * 3b 00 00 89 23 00 7c 99 3b 45 00 99 28 62 04 89 ;...#.|.;E..(b..
3063 * 3b 00 00 89 28 00 81 7c 99 3b 4e 00 99 23 5e 04 ;...(..|.;N..#^.
3064 * 89 3b 00 00 89 23 00 7c 99 3b 45 00 99 23 78 04 .;...#.|.;E..#x.
3065 * 89 3b 00 00 89 23 00 81 7c 99 3b 48 00 99 23 5e .;...#..|.;H..#^
3066 * 04 89 3b 00 00 89 23 00 7c 99 3b 4e 00 99 28 62 ..;...#.|.;N..(b
3067 * 04 89 3b 00 00 89 28 00 81 7c 99 39 4c 00 99 23 ..;...(..|.9L..#
3068 * 5e 04 89 39 00 00 89 23 00 82 7c 99 3b 4c 00 99 ^..9...#..|.;L..
3069 * 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 00 99 #^..;...#.|.;H..
3070 * 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b 3f 04 (b..;...(..|.;?.
3071 * 89 3b 00 1c 99 23 5e 04 89 23 00 5c 99 3b 45 00 .;...#^..#.\.;E.
3072 * 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 3b 46 .#x..;...#..|.;F
3073 * 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 ..#^..;...#.|.;H
3074 * 00 99 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b ..(b..;...(..|.;
3075 * 46 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b F..#^..;...#.|.;
3076 * 48 00 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 H..#x..;...#..|.
3077 * 3b 4c 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 ;L..#^..;...#.|.
3079 lpMidiHdr
= (LPMIDIHDR
)msg
->lParam
;
3080 lpData
= lpMidiHdr
->lpData
;
3081 TRACE("Adding %s lpMidiHdr=%p [lpData=0x%08lx dwBufferLength=%lu/%lu dwFlags=0x%08lx size=%u]\n",
3082 (lpMidiHdr
->dwFlags
& MHDR_ISSTRM
) ? "stream" : "regular", lpMidiHdr
,
3083 (DWORD
)lpMidiHdr
, lpMidiHdr
->dwBufferLength
, lpMidiHdr
->dwBytesRecorded
,
3084 lpMidiHdr
->dwFlags
, msg
->wParam
);
3086 /* dumps content of lpMidiHdr->lpData
3087 * FIXME: there should be a debug routine somewhere that already does this
3088 * I hate spreading this type of shit all around the code
3090 for (dwToGo
= 0; dwToGo
< lpMidiHdr
->dwBufferLength
; dwToGo
+= 16) {
3094 for (i
= 0; i
< min(16, lpMidiHdr
->dwBufferLength
- dwToGo
); i
++)
3095 printf("%02x ", lpData
[dwToGo
+ i
]);
3098 for (i
= 0; i
< min(16, lpMidiHdr
->dwBufferLength
- dwToGo
); i
++) {
3099 ch
= lpData
[dwToGo
+ i
];
3100 printf("%c", (ch
>= 0x20 && ch
<= 0x7F) ? ch
: '.');
3105 if (((LPMIDIEVENT
)lpData
)->dwStreamID
!= 0 &&
3106 ((LPMIDIEVENT
)lpData
)->dwStreamID
!= 0xFFFFFFFF &&
3107 ((LPMIDIEVENT
)lpData
)->dwStreamID
!= (DWORD
)lpMidiStrm
) {
3108 FIXME("Dropping bad %s lpMidiHdr (streamID=%08lx)\n",
3109 (lpMidiHdr
->dwFlags
& MHDR_ISSTRM
) ? "stream" : "regular",
3110 ((LPMIDIEVENT
)lpData
)->dwStreamID
);
3111 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3112 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3114 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3115 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
3119 for (lpmh
= &lpMidiStrm
->lpMidiHdr
; *lpmh
; lpmh
= (LPMIDIHDR
*)&((*lpmh
)->lpNext
));
3121 lpMidiHdr
= (LPMIDIHDR
)msg
->lParam
;
3122 lpMidiHdr
->lpNext
= 0;
3123 lpMidiHdr
->dwFlags
|= MHDR_INQUEUE
;
3124 lpMidiHdr
->dwFlags
&= MHDR_DONE
;
3125 lpMidiHdr
->dwOffset
= 0;
3129 FIXME("Unknown message %d\n", msg
->message
);
3135 /**************************************************************************
3136 * MMSYSTEM_MidiStream_Player [internal]
3138 static DWORD CALLBACK
MMSYSTEM_MidiStream_Player(LPVOID pmt
)
3140 WINE_MIDIStream
* lpMidiStrm
= pmt
;
3145 LPMIDIHDR lpMidiHdr
;
3149 TRACE("(%p)!\n", lpMidiStrm
);
3152 (lpwm
= (LPWINE_MIDI
)MMDRV_Get(lpMidiStrm
->hDevice
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
3155 /* force thread's queue creation */
3156 /* Used to be InitThreadInput16(0, 5); */
3157 /* but following works also with hack in midiStreamOpen */
3158 Callout
.PeekMessageA(&msg
, 0, 0, 0, 0);
3160 /* FIXME: this next line must be called before midiStreamOut or midiStreamRestart are called */
3161 SetEvent(lpMidiStrm
->hEvent
);
3162 TRACE("Ready to go 1\n");
3163 /* thread is started in paused mode */
3164 SuspendThread(lpMidiStrm
->hThread
);
3165 TRACE("Ready to go 2\n");
3167 lpMidiStrm
->dwStartTicks
= 0;
3168 lpMidiStrm
->dwPulses
= 0;
3170 lpMidiStrm
->lpMidiHdr
= 0;
3173 lpMidiHdr
= lpMidiStrm
->lpMidiHdr
;
3175 /* for first message, block until one arrives, then process all that are available */
3176 Callout
.GetMessageA(&msg
, 0, 0, 0);
3178 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm
, lpwm
, &msg
))
3180 } while (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
));
3186 lpData
= lpMidiHdr
->lpData
;
3188 me
= (LPMIDIEVENT
)(lpData
+ lpMidiHdr
->dwOffset
);
3190 /* do we have to wait ? */
3191 if (me
->dwDeltaTime
) {
3192 lpMidiStrm
->dwPositionMS
+= MMSYSTEM_MidiStream_Convert(lpMidiStrm
, me
->dwDeltaTime
);
3193 lpMidiStrm
->dwPulses
+= me
->dwDeltaTime
;
3195 dwToGo
= lpMidiStrm
->dwStartTicks
+ lpMidiStrm
->dwPositionMS
;
3197 TRACE("%ld/%ld/%ld\n", dwToGo
, GetTickCount(), me
->dwDeltaTime
);
3198 while ((dwCurrTC
= GetTickCount()) < dwToGo
) {
3199 if (MsgWaitForMultipleObjects(0, NULL
, FALSE
, dwToGo
- dwCurrTC
, QS_ALLINPUT
) == WAIT_OBJECT_0
) {
3200 /* got a message, handle it */
3201 while (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
3202 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm
, lpwm
, &msg
))
3207 /* timeout, so me->dwDeltaTime is elapsed, can break the while loop */
3212 switch (MEVT_EVENTTYPE(me
->dwEvent
& ~MEVT_F_CALLBACK
)) {
3214 FIXME("NIY: MEVT_COMMENT\n");
3215 /* do nothing, skip bytes */
3218 FIXME("NIY: MEVT_LONGMSG, aka sending Sysex event\n");
3223 midiOutShortMsg(lpMidiStrm
->hDevice
, MEVT_EVENTPARM(me
->dwEvent
));
3226 lpMidiStrm
->dwTempo
= MEVT_EVENTPARM(me
->dwEvent
);
3231 FIXME("Unknown MEVT (0x%02x)\n", MEVT_EVENTTYPE(me
->dwEvent
& ~MEVT_F_CALLBACK
));
3234 if (me
->dwEvent
& MEVT_F_CALLBACK
) {
3235 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3236 MM_MOM_POSITIONCB
, lpwm
->mod
.dwInstance
, (LPARAM
)lpMidiHdr
, 0L);
3238 lpMidiHdr
->dwOffset
+= sizeof(MIDIEVENT
);
3239 if (me
->dwEvent
& MEVT_F_LONG
)
3240 lpMidiHdr
->dwOffset
+= (MEVT_EVENTPARM(me
->dwEvent
) + 3) & ~3;
3241 if (lpMidiHdr
->dwOffset
>= lpMidiHdr
->dwBufferLength
) {
3242 /* done with this header */
3243 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3244 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3246 lpMidiStrm
->lpMidiHdr
= (LPMIDIHDR
)lpMidiHdr
->lpNext
;
3247 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3248 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
3253 TRACE("End of thread\n");
3255 return 0; /* for removing the warning, never executed */
3258 /**************************************************************************
3259 * MMSYSTEM_MidiStream_PostMessage [internal]
3261 static BOOL
MMSYSTEM_MidiStream_PostMessage(WINE_MIDIStream
* lpMidiStrm
, WORD msg
, DWORD pmt1
, DWORD pmt2
)
3263 if (Callout
.PostThreadMessageA(lpMidiStrm
->dwThreadID
, msg
, pmt1
, pmt2
)) {
3267 /* FIXME: should use the new syslevel APIs */
3268 if ((bHasWin16Lock
= _ConfirmWin16Lock()) != 0) {
3269 ReleaseThunkLock(&count
);
3271 WaitForSingleObject(lpMidiStrm
->hEvent
, INFINITE
);
3272 if (bHasWin16Lock
) {
3273 RestoreThunkLock(count
);
3276 WARN("bad PostThreadMessageA\n");
3282 /**************************************************************************
3283 * midiStreamClose [WINMM.90]
3285 MMRESULT WINAPI
midiStreamClose(HMIDISTRM hMidiStrm
)
3287 WINE_MIDIStream
* lpMidiStrm
;
3289 TRACE("(%08x)!\n", hMidiStrm
);
3291 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
))
3292 return MMSYSERR_INVALHANDLE
;
3294 midiStreamStop(hMidiStrm
);
3295 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm
, WM_QUIT
, 0, 0);
3296 HeapFree(GetProcessHeap(), 0, lpMidiStrm
);
3297 CloseHandle(lpMidiStrm
->hEvent
);
3299 return midiOutClose(hMidiStrm
);
3302 /**************************************************************************
3303 * MMSYSTEM_MidiStream_Open [internal]
3305 static MMRESULT WINAPI
MMSYSTEM_MidiStream_Open(HMIDISTRM
* lphMidiStrm
, LPUINT lpuDeviceID
,
3306 DWORD cMidi
, DWORD dwCallback
,
3307 DWORD dwInstance
, DWORD fdwOpen
, BOOL bFrom32
)
3309 WINE_MIDIStream
* lpMidiStrm
;
3311 MIDIOPENSTRMID mosm
;
3315 TRACE("(%p, %p, %ld, 0x%08lx, 0x%08lx, 0x%08lx)!\n",
3316 lphMidiStrm
, lpuDeviceID
, cMidi
, dwCallback
, dwInstance
, fdwOpen
);
3318 if (cMidi
!= 1 || lphMidiStrm
== NULL
|| lpuDeviceID
== NULL
)
3319 return MMSYSERR_INVALPARAM
;
3321 lpMidiStrm
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MIDIStream
));
3323 return MMSYSERR_NOMEM
;
3325 lpMidiStrm
->dwTempo
= 500000;
3326 lpMidiStrm
->dwTimeDiv
= 480; /* 480 is 120 quater notes per minute *//* FIXME ??*/
3327 lpMidiStrm
->dwPositionMS
= 0;
3329 mosm
.dwStreamID
= (DWORD
)lpMidiStrm
;
3330 /* FIXME: the correct value is not allocated yet for MAPPER */
3331 mosm
.wDeviceID
= *lpuDeviceID
;
3332 lpwm
= MIDI_OutAlloc(&hMidiOut
, &dwCallback
, &dwInstance
, &fdwOpen
, 1, &mosm
, bFrom32
);
3333 lpMidiStrm
->hDevice
= hMidiOut
;
3335 *lphMidiStrm
= hMidiOut
;
3337 /* FIXME: is lpuDevice initialized upon entering midiStreamOpen ? */
3338 FIXME("*lpuDeviceID=%u\n", *lpuDeviceID
);
3339 lpwm
->mld
.uDeviceID
= *lpuDeviceID
= 0;
3341 ret
= MMDRV_Open(&lpwm
->mld
, MODM_OPEN
, (DWORD
)&lpwm
->mod
, fdwOpen
);
3342 lpMidiStrm
->hEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
);
3343 lpMidiStrm
->wFlags
= HIWORD(fdwOpen
);
3345 lpMidiStrm
->hThread
= CreateThread(NULL
, 0, MMSYSTEM_MidiStream_Player
,
3346 lpMidiStrm
, 0, &(lpMidiStrm
->dwThreadID
));
3348 if (!lpMidiStrm
->hThread
) {
3349 midiStreamClose((HMIDISTRM
)hMidiOut
);
3350 return MMSYSERR_NOMEM
;
3353 /* wait for thread to have started, and for it's queue to be created */
3358 /* (Release|Restore)ThunkLock() is needed when this method is called from 16 bit code,
3359 * (meaning the Win16Lock is set), so that it's released and the 32 bit thread running
3360 * MMSYSTEM_MidiStreamPlayer can acquire Win16Lock to create its queue.
3362 if ((bHasWin16Lock
= _ConfirmWin16Lock()) != 0) {
3363 ReleaseThunkLock(&count
);
3365 WaitForSingleObject(lpMidiStrm
->hEvent
, INFINITE
);
3366 if (bHasWin16Lock
) {
3367 RestoreThunkLock(count
);
3371 TRACE("=> (%u/%d) hMidi=0x%04x ret=%d lpMidiStrm=%p\n",
3372 *lpuDeviceID
, lpwm
->mld
.uDeviceID
, *lphMidiStrm
, ret
, lpMidiStrm
);
3376 /**************************************************************************
3377 * midiStreamOpen [WINMM.91]
3379 MMRESULT WINAPI
midiStreamOpen(HMIDISTRM
* lphMidiStrm
, LPUINT lpuDeviceID
,
3380 DWORD cMidi
, DWORD dwCallback
,
3381 DWORD dwInstance
, DWORD fdwOpen
)
3383 return MMSYSTEM_MidiStream_Open(lphMidiStrm
, lpuDeviceID
, cMidi
, dwCallback
,
3384 dwInstance
, fdwOpen
, TRUE
);
3387 /**************************************************************************
3388 * midiStreamOut [WINMM.92]
3390 MMRESULT WINAPI
midiStreamOut(HMIDISTRM hMidiStrm
, LPMIDIHDR lpMidiHdr
,
3393 WINE_MIDIStream
* lpMidiStrm
;
3394 DWORD ret
= MMSYSERR_NOERROR
;
3396 TRACE("(%08x, %p, %u)!\n", hMidiStrm
, lpMidiHdr
, cbMidiHdr
);
3398 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3399 ret
= MMSYSERR_INVALHANDLE
;
3401 if (!Callout
.PostThreadMessageA(lpMidiStrm
->dwThreadID
,
3402 WINE_MSM_HEADER
, cbMidiHdr
,
3403 (DWORD
)lpMidiHdr
)) {
3404 WARN("bad PostThreadMessageA\n");
3405 ret
= MMSYSERR_ERROR
;
3411 /**************************************************************************
3412 * midiStreamPause [WINMM.93]
3414 MMRESULT WINAPI
midiStreamPause(HMIDISTRM hMidiStrm
)
3416 WINE_MIDIStream
* lpMidiStrm
;
3417 DWORD ret
= MMSYSERR_NOERROR
;
3419 TRACE("(%08x)!\n", hMidiStrm
);
3421 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3422 ret
= MMSYSERR_INVALHANDLE
;
3424 if (SuspendThread(lpMidiStrm
->hThread
) == 0xFFFFFFFF) {
3425 WARN("bad Suspend (%ld)\n", GetLastError());
3426 ret
= MMSYSERR_ERROR
;
3432 /**************************************************************************
3433 * midiStreamPosition [WINMM.94]
3435 MMRESULT WINAPI
midiStreamPosition(HMIDISTRM hMidiStrm
, LPMMTIME lpMMT
, UINT cbmmt
)
3437 WINE_MIDIStream
* lpMidiStrm
;
3438 DWORD ret
= MMSYSERR_NOERROR
;
3440 TRACE("(%08x, %p, %u)!\n", hMidiStrm
, lpMMT
, cbmmt
);
3442 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3443 ret
= MMSYSERR_INVALHANDLE
;
3444 } else if (lpMMT
== NULL
|| cbmmt
!= sizeof(MMTIME
)) {
3445 ret
= MMSYSERR_INVALPARAM
;
3447 switch (lpMMT
->wType
) {
3449 lpMMT
->u
.ms
= lpMidiStrm
->dwPositionMS
;
3450 TRACE("=> %ld ms\n", lpMMT
->u
.ms
);
3453 lpMMT
->u
.ticks
= lpMidiStrm
->dwPulses
;
3454 TRACE("=> %ld ticks\n", lpMMT
->u
.ticks
);
3457 WARN("Unsupported time type %d\n", lpMMT
->wType
);
3458 lpMMT
->wType
= TIME_MS
;
3459 ret
= MMSYSERR_INVALPARAM
;
3466 /**************************************************************************
3467 * midiStreamProperty [WINMM.95]
3469 MMRESULT WINAPI
midiStreamProperty(HMIDISTRM hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
3471 WINE_MIDIStream
* lpMidiStrm
;
3472 MMRESULT ret
= MMSYSERR_NOERROR
;
3474 TRACE("(%08x, %p, %lx)\n", hMidiStrm
, lpPropData
, dwProperty
);
3476 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3477 ret
= MMSYSERR_INVALHANDLE
;
3478 } else if ((dwProperty
& (MIDIPROP_GET
|MIDIPROP_SET
)) == 0) {
3479 ret
= MMSYSERR_INVALPARAM
;
3480 } else if (dwProperty
& MIDIPROP_TEMPO
) {
3481 MIDIPROPTEMPO
* mpt
= (MIDIPROPTEMPO
*)lpPropData
;
3483 if (sizeof(MIDIPROPTEMPO
) != mpt
->cbStruct
) {
3484 ret
= MMSYSERR_INVALPARAM
;
3485 } else if (dwProperty
& MIDIPROP_SET
) {
3486 lpMidiStrm
->dwTempo
= mpt
->dwTempo
;
3487 TRACE("Setting tempo to %ld\n", mpt
->dwTempo
);
3488 } else if (dwProperty
& MIDIPROP_GET
) {
3489 mpt
->dwTempo
= lpMidiStrm
->dwTempo
;
3490 TRACE("Getting tempo <= %ld\n", mpt
->dwTempo
);
3492 } else if (dwProperty
& MIDIPROP_TIMEDIV
) {
3493 MIDIPROPTIMEDIV
* mptd
= (MIDIPROPTIMEDIV
*)lpPropData
;
3495 if (sizeof(MIDIPROPTIMEDIV
) != mptd
->cbStruct
) {
3496 ret
= MMSYSERR_INVALPARAM
;
3497 } else if (dwProperty
& MIDIPROP_SET
) {
3498 lpMidiStrm
->dwTimeDiv
= mptd
->dwTimeDiv
;
3499 TRACE("Setting time div to %ld\n", mptd
->dwTimeDiv
);
3500 } else if (dwProperty
& MIDIPROP_GET
) {
3501 mptd
->dwTimeDiv
= lpMidiStrm
->dwTimeDiv
;
3502 TRACE("Getting time div <= %ld\n", mptd
->dwTimeDiv
);
3505 ret
= MMSYSERR_INVALPARAM
;
3511 /**************************************************************************
3512 * midiStreamRestart [WINMM.96]
3514 MMRESULT WINAPI
midiStreamRestart(HMIDISTRM hMidiStrm
)
3516 WINE_MIDIStream
* lpMidiStrm
;
3517 MMRESULT ret
= MMSYSERR_NOERROR
;
3519 TRACE("(%08x)!\n", hMidiStrm
);
3521 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3522 ret
= MMSYSERR_INVALHANDLE
;
3526 /* since we increase the thread suspend count on each midiStreamPause
3527 * there may be a need for several midiStreamResume
3530 ret
= ResumeThread(lpMidiStrm
->hThread
);
3531 } while (ret
!= 0xFFFFFFFF && ret
!= 0);
3532 if (ret
== 0xFFFFFFFF) {
3533 WARN("bad Resume (%ld)\n", GetLastError());
3534 ret
= MMSYSERR_ERROR
;
3536 lpMidiStrm
->dwStartTicks
= GetTickCount() - lpMidiStrm
->dwPositionMS
;
3542 /**************************************************************************
3543 * midiStreamStop [WINMM.97]
3545 MMRESULT WINAPI
midiStreamStop(HMIDISTRM hMidiStrm
)
3547 WINE_MIDIStream
* lpMidiStrm
;
3548 MMRESULT ret
= MMSYSERR_NOERROR
;
3550 TRACE("(%08x)!\n", hMidiStrm
);
3552 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3553 ret
= MMSYSERR_INVALHANDLE
;
3555 /* in case stream has been paused... FIXME is the current state correct ? */
3556 midiStreamRestart(hMidiStrm
);
3557 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm
, WINE_MSM_STOP
, 0, 0);
3562 /**************************************************************************
3563 * midiStreamClose [MMSYSTEM.252]
3565 MMRESULT16 WINAPI
midiStreamClose16(HMIDISTRM16 hMidiStrm
)
3567 return midiStreamClose(hMidiStrm
);
3570 /**************************************************************************
3571 * midiStreamOpen [MMSYSTEM.251]
3573 MMRESULT16 WINAPI
midiStreamOpen16(HMIDISTRM16
* phMidiStrm
, LPUINT16 devid
,
3574 DWORD cMidi
, DWORD dwCallback
,
3575 DWORD dwInstance
, DWORD fdwOpen
)
3577 HMIDISTRM hMidiStrm32
;
3581 if (!phMidiStrm
|| !devid
)
3582 return MMSYSERR_INVALPARAM
;
3584 ret
= MMSYSTEM_MidiStream_Open(&hMidiStrm32
, &devid32
, cMidi
, dwCallback
,
3585 dwInstance
, fdwOpen
, FALSE
);
3586 *phMidiStrm
= hMidiStrm32
;
3591 /**************************************************************************
3592 * midiStreamOut [MMSYSTEM.254]
3594 MMRESULT16 WINAPI
midiStreamOut16(HMIDISTRM16 hMidiStrm
, LPMIDIHDR16 lpMidiHdr
, UINT16 cbMidiHdr
)
3596 return midiStreamOut(hMidiStrm
, (LPMIDIHDR
)lpMidiHdr
, cbMidiHdr
);
3599 /**************************************************************************
3600 * midiStreamPause [MMSYSTEM.255]
3602 MMRESULT16 WINAPI
midiStreamPause16(HMIDISTRM16 hMidiStrm
)
3604 return midiStreamPause(hMidiStrm
);
3607 /**************************************************************************
3608 * midiStreamPosition [MMSYSTEM.253]
3610 MMRESULT16 WINAPI
midiStreamPosition16(HMIDISTRM16 hMidiStrm
, LPMMTIME16 lpmmt16
, UINT16 cbmmt
)
3616 return MMSYSERR_INVALPARAM
;
3617 MMSYSTEM_MMTIME16to32(&mmt32
, lpmmt16
);
3618 ret
= midiStreamPosition(hMidiStrm
, &mmt32
, sizeof(MMTIME
));
3619 MMSYSTEM_MMTIME32to16(lpmmt16
, &mmt32
);
3623 /**************************************************************************
3624 * midiStreamProperty [MMSYSTEM.250]
3626 MMRESULT16 WINAPI
midiStreamProperty16(HMIDISTRM16 hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
3628 return midiStreamProperty(hMidiStrm
, lpPropData
, dwProperty
);
3631 /**************************************************************************
3632 * midiStreamRestart [MMSYSTEM.256]
3634 MMRESULT16 WINAPI
midiStreamRestart16(HMIDISTRM16 hMidiStrm
)
3636 return midiStreamRestart(hMidiStrm
);
3639 /**************************************************************************
3640 * midiStreamStop [MMSYSTEM.257]
3642 MMRESULT16 WINAPI
midiStreamStop16(HMIDISTRM16 hMidiStrm
)
3644 return midiStreamStop(hMidiStrm
);
3647 static UINT WINAPI
MMSYSTEM_waveOpen(HANDLE
* lphndl
, UINT uDeviceID
, UINT uType
,
3648 const LPWAVEFORMATEX lpFormat
,
3649 DWORD dwCallback
, DWORD dwInstance
,
3650 DWORD dwFlags
, BOOL bFrom32
)
3654 DWORD dwRet
= MMSYSERR_NOERROR
;
3657 TRACE("(%p, %d, %s, %p, %08lX, %08lX, %08lX, %d);\n",
3658 lphndl
, (int)uDeviceID
, (uType
==MMDRV_WAVEOUT
)?"Out":"In", lpFormat
, dwCallback
,
3659 dwInstance
, dwFlags
, bFrom32
?32:16);
3661 if (dwFlags
& WAVE_FORMAT_QUERY
) TRACE("WAVE_FORMAT_QUERY requested !\n");
3663 if (lpFormat
== NULL
) return WAVERR_BADFORMAT
;
3665 TRACE("wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u\n",
3666 lpFormat
->wFormatTag
, lpFormat
->nChannels
, lpFormat
->nSamplesPerSec
,
3667 lpFormat
->nAvgBytesPerSec
, lpFormat
->nBlockAlign
, lpFormat
->wBitsPerSample
, lpFormat
->cbSize
);
3669 if ((wmld
= MMDRV_Alloc(sizeof(WINE_WAVE
), uType
, &handle
,
3670 &dwFlags
, &dwCallback
, &dwInstance
, bFrom32
)) == NULL
)
3671 return MMSYSERR_NOMEM
;
3674 wod
.lpFormat
= lpFormat
; /* should the struct be copied iso pointer? */
3675 wod
.dwCallback
= dwCallback
;
3676 wod
.dwInstance
= dwInstance
;
3677 wod
.uMappedDeviceID
= 0;
3680 /* when called from 16 bit code, mapper will be 0x0000FFFF instead of 0xFFFFFFFF */
3681 /* this should fix it */
3682 wmld
->uDeviceID
= (uDeviceID
== (UINT16
)-1 && !bFrom32
) ? (UINT
)-1 : uDeviceID
;
3684 dwRet
= MMDRV_Open(wmld
, (uType
==MMDRV_WAVEOUT
)?WODM_OPEN
:WIDM_OPEN
, (DWORD
)&wod
, dwFlags
);
3686 if ((dwFlags
& WAVE_FORMAT_QUERY
) || dwRet
!= MMSYSERR_NOERROR
) {
3687 MMDRV_Free(handle
, wmld
);
3691 if (lphndl
!= NULL
) *lphndl
= handle
;
3692 TRACE("=> %ld hWave=%04x\n", dwRet
, handle
);
3697 /**************************************************************************
3698 * waveOutGetNumDevs [MMSYSTEM.401]
3700 UINT WINAPI
waveOutGetNumDevs(void)
3702 return MMDRV_GetNum(MMDRV_WAVEOUT
);
3705 /**************************************************************************
3706 * waveOutGetNumDevs [WINMM.167]
3708 UINT16 WINAPI
waveOutGetNumDevs16(void)
3710 return MMDRV_GetNum(MMDRV_WAVEOUT
);
3713 /**************************************************************************
3714 * waveOutGetDevCaps [MMSYSTEM.402]
3716 UINT16 WINAPI
waveOutGetDevCaps16(UINT16 uDeviceID
,
3717 LPWAVEOUTCAPS16 lpCaps
, UINT16 uSize
)
3722 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
3723 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3725 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
3727 if (ret
== MMSYSERR_NOERROR
) {
3728 lpCaps
->wMid
= wocA
.wMid
;
3729 lpCaps
->wPid
= wocA
.wPid
;
3730 lpCaps
->vDriverVersion
= wocA
.vDriverVersion
;
3731 strcpy(lpCaps
->szPname
, wocA
.szPname
);
3732 lpCaps
->dwFormats
= wocA
.dwFormats
;
3733 lpCaps
->wChannels
= wocA
.wChannels
;
3734 lpCaps
->dwSupport
= wocA
.dwSupport
;
3739 /**************************************************************************
3740 * waveOutGetDevCapsA [WINMM.162]
3742 UINT WINAPI
waveOutGetDevCapsA(UINT uDeviceID
, LPWAVEOUTCAPSA lpCaps
,
3747 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
3749 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3751 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_WAVEOUT
, TRUE
)) == NULL
)
3752 return MMSYSERR_INVALHANDLE
;
3754 return MMDRV_Message(wmld
, WODM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
3758 /**************************************************************************
3759 * waveOutGetDevCapsW [WINMM.163]
3761 UINT WINAPI
waveOutGetDevCapsW(UINT uDeviceID
, LPWAVEOUTCAPSW lpCaps
,
3767 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3769 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
3771 if (ret
== MMSYSERR_NOERROR
) {
3772 lpCaps
->wMid
= wocA
.wMid
;
3773 lpCaps
->wPid
= wocA
.wPid
;
3774 lpCaps
->vDriverVersion
= wocA
.vDriverVersion
;
3775 lstrcpyAtoW(lpCaps
->szPname
, wocA
.szPname
);
3776 lpCaps
->dwFormats
= wocA
.dwFormats
;
3777 lpCaps
->wChannels
= wocA
.wChannels
;
3778 lpCaps
->dwSupport
= wocA
.dwSupport
;
3783 /**************************************************************************
3784 * WAVE_GetErrorText [internal]
3786 static UINT16
WAVE_GetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
3788 UINT16 ret
= MMSYSERR_BADERRNUM
;
3790 if (lpText
== NULL
) {
3791 ret
= MMSYSERR_INVALPARAM
;
3792 } else if (uSize
== 0) {
3793 ret
= MMSYSERR_NOERROR
;
3795 /* test has been removed 'coz MMSYSERR_BASE is 0, and gcc did emit
3796 * a warning for the test was always true */
3797 (/*uError >= MMSYSERR_BASE && */uError
<= MMSYSERR_LASTERROR
) ||
3798 (uError
>= WAVERR_BASE
&& uError
<= WAVERR_LASTERROR
)) {
3800 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance
,
3801 uError
, lpText
, uSize
) > 0) {
3802 ret
= MMSYSERR_NOERROR
;
3808 /**************************************************************************
3809 * waveOutGetErrorText [MMSYSTEM.403]
3811 UINT16 WINAPI
waveOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
3813 return WAVE_GetErrorText(uError
, lpText
, uSize
);
3816 /**************************************************************************
3817 * waveOutGetErrorTextA [WINMM.164]
3819 UINT WINAPI
waveOutGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
3821 return WAVE_GetErrorText(uError
, lpText
, uSize
);
3824 /**************************************************************************
3825 * waveOutGetErrorTextW [WINMM.165]
3827 UINT WINAPI
waveOutGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
3829 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
3830 UINT ret
= WAVE_GetErrorText(uError
, xstr
, uSize
);
3832 lstrcpyAtoW(lpText
, xstr
);
3833 HeapFree(GetProcessHeap(), 0, xstr
);
3837 /**************************************************************************
3838 * waveOutOpen [WINMM.173]
3839 * All the args/structs have the same layout as the win16 equivalents
3841 UINT WINAPI
waveOutOpen(HWAVEOUT
* lphWaveOut
, UINT uDeviceID
,
3842 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
3843 DWORD dwInstance
, DWORD dwFlags
)
3845 return MMSYSTEM_waveOpen(lphWaveOut
, uDeviceID
, MMDRV_WAVEOUT
, lpFormat
,
3846 dwCallback
, dwInstance
, dwFlags
, TRUE
);
3849 /**************************************************************************
3850 * waveOutOpen [MMSYSTEM.404]
3852 UINT16 WINAPI
waveOutOpen16(HWAVEOUT16
* lphWaveOut
, UINT16 uDeviceID
,
3853 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
3854 DWORD dwInstance
, DWORD dwFlags
)
3859 /* since layout of WAVEOFORMATEX is the same for 16/32 bits, we directly
3860 * call the 32 bit version
3862 ret
= MMSYSTEM_waveOpen(&hWaveOut
, uDeviceID
, MMDRV_WAVEOUT
, lpFormat
,
3863 dwCallback
, dwInstance
, dwFlags
, FALSE
);
3865 if (lphWaveOut
!= NULL
) *lphWaveOut
= hWaveOut
;
3869 /**************************************************************************
3870 * waveOutClose [WINMM.161]
3872 UINT WINAPI
waveOutClose(HWAVEOUT hWaveOut
)
3877 TRACE("(%04X)\n", hWaveOut
);
3879 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3880 return MMSYSERR_INVALHANDLE
;
3882 dwRet
= MMDRV_Close(wmld
, WODM_CLOSE
);
3883 MMDRV_Free(hWaveOut
, wmld
);
3888 /**************************************************************************
3889 * waveOutClose [MMSYSTEM.405]
3891 UINT16 WINAPI
waveOutClose16(HWAVEOUT16 hWaveOut
)
3893 return waveOutClose(hWaveOut
);
3896 /**************************************************************************
3897 * waveOutPrepareHeader [WINMM.175]
3899 UINT WINAPI
waveOutPrepareHeader(HWAVEOUT hWaveOut
,
3900 WAVEHDR
* lpWaveOutHdr
, UINT uSize
)
3904 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3906 if (lpWaveOutHdr
== NULL
) return MMSYSERR_INVALPARAM
;
3908 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3909 return MMSYSERR_INVALHANDLE
;
3911 return MMDRV_Message(wmld
, WODM_PREPARE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3914 /**************************************************************************
3915 * waveOutPrepareHeader [MMSYSTEM.406]
3917 UINT16 WINAPI
waveOutPrepareHeader16(HWAVEOUT16 hWaveOut
,
3918 WAVEHDR
* /*SEGPTR*/ lpsegWaveOutHdr
,
3922 LPWAVEHDR lpWaveOutHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveOutHdr
);
3924 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
3926 if (lpWaveOutHdr
== NULL
) return MMSYSERR_INVALPARAM
;
3928 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3929 return MMSYSERR_INVALHANDLE
;
3931 return MMDRV_Message(wmld
, WODM_PREPARE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
3934 /**************************************************************************
3935 * waveOutUnprepareHeader [WINMM.181]
3937 UINT WINAPI
waveOutUnprepareHeader(HWAVEOUT hWaveOut
,
3938 LPWAVEHDR lpWaveOutHdr
, UINT uSize
)
3942 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3944 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
3945 return MMSYSERR_NOERROR
;
3948 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3949 return MMSYSERR_INVALHANDLE
;
3951 return MMDRV_Message(wmld
, WODM_UNPREPARE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3954 /**************************************************************************
3955 * waveOutUnprepareHeader [MMSYSTEM.407]
3957 UINT16 WINAPI
waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut
,
3958 LPWAVEHDR
/*SEGPTR*/ lpsegWaveOutHdr
,
3962 LPWAVEHDR lpWaveOutHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveOutHdr
);
3964 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
3966 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
3967 return MMSYSERR_NOERROR
;
3970 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3971 return MMSYSERR_INVALHANDLE
;
3973 return MMDRV_Message(wmld
, WODM_UNPREPARE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
3976 /**************************************************************************
3977 * waveOutWrite [MMSYSTEM.408]
3979 UINT WINAPI
waveOutWrite(HWAVEOUT hWaveOut
, LPWAVEHDR lpWaveOutHdr
,
3984 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3986 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3987 return MMSYSERR_INVALHANDLE
;
3989 return MMDRV_Message(wmld
, WODM_WRITE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3992 /**************************************************************************
3993 * waveOutWrite [MMSYSTEM.408]
3995 UINT16 WINAPI
waveOutWrite16(HWAVEOUT16 hWaveOut
,
3996 LPWAVEHDR
/*SEGPTR*/ lpsegWaveOutHdr
,
4001 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
4003 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4004 return MMSYSERR_INVALHANDLE
;
4006 return MMDRV_Message(wmld
, WODM_WRITE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
4009 #define WAVEOUT_SHORTCUT_0(xx, XX) \
4010 UINT WINAPI waveOut##xx(HWAVEOUT hWaveOut) \
4013 TRACE("(%04X);\n", hWaveOut); \
4014 if ((wmld = MMDRV_Get(hWaveOut,MMDRV_WAVEOUT,FALSE))==NULL) \
4015 return MMSYSERR_INVALHANDLE; \
4016 return MMDRV_Message(wmld,WODM_##XX,0L,0L,TRUE); \
4018 UINT16 WINAPI waveOut##xx##16(HWAVEOUT16 hWaveOut16) \
4019 {return waveOut##xx(hWaveOut16);}
4021 WAVEOUT_SHORTCUT_0(BreakLoop
, BREAKLOOP
)
4022 WAVEOUT_SHORTCUT_0(Pause
, PAUSE
)
4023 WAVEOUT_SHORTCUT_0(Reset
, RESET
)
4024 WAVEOUT_SHORTCUT_0(Restart
, RESTART
)
4025 #undef WAVEOUT_SHORTCUT_0
4027 /**************************************************************************
4028 * waveOutGetPosition [WINMM.170]
4030 UINT WINAPI
waveOutGetPosition(HWAVEOUT hWaveOut
, LPMMTIME lpTime
,
4035 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpTime
, uSize
);
4037 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4038 return MMSYSERR_INVALHANDLE
;
4040 return MMDRV_Message(wmld
, WODM_GETPOS
, (DWORD
)lpTime
, uSize
, TRUE
);
4043 /**************************************************************************
4044 * waveOutGetPosition [MMSYSTEM.412]
4046 UINT16 WINAPI
waveOutGetPosition16(HWAVEOUT16 hWaveOut
, LPMMTIME16 lpTime
,
4052 mmt
.wType
= lpTime
->wType
;
4053 ret
= waveOutGetPosition(hWaveOut
, &mmt
, sizeof(mmt
));
4054 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
4058 #define WAVEOUT_SHORTCUT_1(xx, XX, atype) \
4059 UINT WINAPI waveOut##xx(HWAVEOUT hWaveOut, atype x) \
4062 TRACE("(%04X, %08lx);\n", hWaveOut, (DWORD)x); \
4063 if ((wmld = MMDRV_Get(hWaveOut,MMDRV_WAVEOUT,FALSE))==NULL) \
4064 return MMSYSERR_INVALHANDLE; \
4065 return MMDRV_Message(wmld,WODM_##XX,(DWORD)x,0L,TRUE); \
4067 UINT16 WINAPI waveOut##xx##16(HWAVEOUT16 hWaveOut16, atype x) \
4068 {return waveOut##xx(hWaveOut16, x);}
4070 WAVEOUT_SHORTCUT_1(GetPitch
, GETPITCH
, LPDWORD
)
4071 WAVEOUT_SHORTCUT_1(SetPitch
, SETPITCH
, DWORD
)
4072 WAVEOUT_SHORTCUT_1(GetPlaybackRate
, GETPLAYBACKRATE
, LPDWORD
)
4073 WAVEOUT_SHORTCUT_1(SetPlaybackRate
, SETPLAYBACKRATE
, DWORD
)
4074 #undef WAVEOUT_SHORTCUT_1
4076 #define WAVEOUT_SHORTCUT_2(xx, XX, atype) \
4077 UINT WINAPI waveOut##xx(UINT devid, atype x) \
4080 TRACE("(%04X, %08lx);\n", devid, (DWORD)x); \
4081 if ((wmld = MMDRV_Get(devid,MMDRV_WAVEOUT,TRUE))==NULL) \
4082 return MMSYSERR_INVALHANDLE; \
4083 return MMDRV_Message(wmld, WODM_##XX, (DWORD)x, 0L, TRUE); \
4085 UINT16 WINAPI waveOut##xx##16(UINT16 devid, atype x) \
4086 {return waveOut##xx(devid, x);}
4088 WAVEOUT_SHORTCUT_2(GetVolume
, GETVOLUME
, LPDWORD
)
4089 WAVEOUT_SHORTCUT_2(SetVolume
, SETVOLUME
, DWORD
)
4090 #undef WAVEOUT_SHORTCUT_2
4092 /**************************************************************************
4093 * waveOutGetID [MMSYSTEM.420]
4095 UINT WINAPI
waveOutGetID(HWAVEOUT hWaveOut
, UINT
* lpuDeviceID
)
4099 TRACE("(%04X, %p);\n", hWaveOut
, lpuDeviceID
);
4101 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4103 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4104 return MMSYSERR_INVALHANDLE
;
4106 *lpuDeviceID
= wmld
->uDeviceID
;
4110 /**************************************************************************
4111 * waveOutGetID [MMSYSTEM.420]
4113 UINT16 WINAPI
waveOutGetID16(HWAVEOUT16 hWaveOut
, UINT16
* lpuDeviceID
)
4117 TRACE("(%04X, %p);\n", hWaveOut
, lpuDeviceID
);
4119 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4121 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4122 return MMSYSERR_INVALHANDLE
;
4124 *lpuDeviceID
= wmld
->uDeviceID
;
4128 /**************************************************************************
4129 * waveOutMessage [WINMM.172]
4131 DWORD WINAPI
waveOutMessage(HWAVEOUT hWaveOut
, UINT uMessage
,
4132 DWORD dwParam1
, DWORD dwParam2
)
4136 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
4138 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
) {
4139 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, TRUE
)) != NULL
) {
4140 return MMDRV_PhysicalFeatures(wmld
, uMessage
, dwParam1
, dwParam2
);
4142 return MMSYSERR_INVALHANDLE
;
4146 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4147 return MMSYSERR_INVALPARAM
;
4149 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4152 /**************************************************************************
4153 * waveOutMessage [MMSYSTEM.421]
4155 DWORD WINAPI
waveOutMessage16(HWAVEOUT16 hWaveOut
, UINT16 uMessage
,
4156 DWORD dwParam1
, DWORD dwParam2
)
4160 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
4162 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
) {
4163 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, TRUE
)) != NULL
) {
4164 return MMDRV_PhysicalFeatures(wmld
, uMessage
, dwParam1
, dwParam2
);
4166 return MMSYSERR_INVALHANDLE
;
4170 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4171 return MMSYSERR_INVALPARAM
;
4173 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, FALSE
);
4176 /**************************************************************************
4177 * waveInGetNumDevs [WINMM.151]
4179 UINT WINAPI
waveInGetNumDevs(void)
4181 return MMDRV_GetNum(MMDRV_WAVEIN
);
4184 /**************************************************************************
4185 * waveInGetNumDevs [MMSYSTEM.501]
4187 UINT16 WINAPI
waveInGetNumDevs16(void)
4189 return MMDRV_GetNum(MMDRV_WAVEIN
);
4192 /**************************************************************************
4193 * waveInGetDevCapsW [WINMM.147]
4195 UINT WINAPI
waveInGetDevCapsW(UINT uDeviceID
, LPWAVEINCAPSW lpCaps
, UINT uSize
)
4198 UINT ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, uSize
);
4200 if (ret
== MMSYSERR_NOERROR
) {
4201 lpCaps
->wMid
= wicA
.wMid
;
4202 lpCaps
->wPid
= wicA
.wPid
;
4203 lpCaps
->vDriverVersion
= wicA
.vDriverVersion
;
4204 lstrcpyAtoW(lpCaps
->szPname
, wicA
.szPname
);
4205 lpCaps
->dwFormats
= wicA
.dwFormats
;
4206 lpCaps
->wChannels
= wicA
.wChannels
;
4212 /**************************************************************************
4213 * waveInGetDevCapsA [WINMM.146]
4215 UINT WINAPI
waveInGetDevCapsA(UINT uDeviceID
, LPWAVEINCAPSA lpCaps
, UINT uSize
)
4219 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
4221 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_WAVEIN
, TRUE
)) == NULL
)
4222 return MMSYSERR_INVALHANDLE
;
4224 return MMDRV_Message(wmld
, WIDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
4227 /**************************************************************************
4228 * waveInGetDevCaps [MMSYSTEM.502]
4230 UINT16 WINAPI
waveInGetDevCaps16(UINT16 uDeviceID
, LPWAVEINCAPS16 lpCaps
,
4234 UINT ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, sizeof(wicA
));
4236 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
4238 if (ret
== MMSYSERR_NOERROR
) {
4239 lpCaps
->wMid
= wicA
.wMid
;
4240 lpCaps
->wPid
= wicA
.wPid
;
4241 lpCaps
->vDriverVersion
= wicA
.vDriverVersion
;
4242 strcpy(lpCaps
->szPname
, wicA
.szPname
);
4243 lpCaps
->dwFormats
= wicA
.dwFormats
;
4244 lpCaps
->wChannels
= wicA
.wChannels
;
4249 /**************************************************************************
4250 * waveInGetErrorTextA [WINMM.148]
4252 UINT WINAPI
waveInGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
4254 return WAVE_GetErrorText(uError
, lpText
, uSize
);
4257 /**************************************************************************
4258 * waveInGetErrorTextW [WINMM.149]
4260 UINT WINAPI
waveInGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
4262 LPSTR txt
= HeapAlloc(GetProcessHeap(), 0, uSize
);
4263 UINT ret
= WAVE_GetErrorText(uError
, txt
, uSize
);
4265 lstrcpyAtoW(lpText
, txt
);
4266 HeapFree(GetProcessHeap(), 0, txt
);
4270 /**************************************************************************
4271 * waveInGetErrorText [MMSYSTEM.503]
4273 UINT16 WINAPI
waveInGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
4275 return WAVE_GetErrorText(uError
, lpText
, uSize
);
4278 /**************************************************************************
4279 * waveInOpen [WINMM.154]
4281 UINT WINAPI
waveInOpen(HWAVEIN
* lphWaveIn
, UINT uDeviceID
,
4282 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
4283 DWORD dwInstance
, DWORD dwFlags
)
4285 return MMSYSTEM_waveOpen(lphWaveIn
, uDeviceID
, MMDRV_WAVEIN
, lpFormat
,
4286 dwCallback
, dwInstance
, dwFlags
, TRUE
);
4289 /**************************************************************************
4290 * waveInOpen [MMSYSTEM.504]
4292 UINT16 WINAPI
waveInOpen16(HWAVEIN16
* lphWaveIn
, UINT16 uDeviceID
,
4293 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
4294 DWORD dwInstance
, DWORD dwFlags
)
4299 /* since layout of WAVEOFORMATEX is the same for 16/32 bits, we directly
4300 * call the 32 bit version
4302 ret
= MMSYSTEM_waveOpen(&hWaveIn
, uDeviceID
, MMDRV_WAVEIN
, lpFormat
,
4303 dwCallback
, dwInstance
, dwFlags
, FALSE
);
4305 if (lphWaveIn
!= NULL
) *lphWaveIn
= hWaveIn
;
4309 /**************************************************************************
4310 * waveInClose [WINMM.145]
4312 UINT WINAPI
waveInClose(HWAVEIN hWaveIn
)
4317 TRACE("(%04X)\n", hWaveIn
);
4319 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4320 return MMSYSERR_INVALHANDLE
;
4322 dwRet
= MMDRV_Message(wmld
, WIDM_CLOSE
, 0L, 0L, TRUE
);
4323 MMDRV_Free(hWaveIn
, wmld
);
4327 /**************************************************************************
4328 * waveInClose [MMSYSTEM.505]
4330 UINT16 WINAPI
waveInClose16(HWAVEIN16 hWaveIn
)
4332 return waveOutClose(hWaveIn
);
4335 /**************************************************************************
4336 * waveInPrepareHeader [WINMM.155]
4338 UINT WINAPI
waveInPrepareHeader(HWAVEIN hWaveIn
, WAVEHDR
* lpWaveInHdr
,
4343 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4345 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4346 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4347 return MMSYSERR_INVALHANDLE
;
4349 lpWaveInHdr
->dwBytesRecorded
= 0;
4351 return MMDRV_Message(wmld
, WIDM_PREPARE
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4354 /**************************************************************************
4355 * waveInPrepareHeader [MMSYSTEM.506]
4357 UINT16 WINAPI
waveInPrepareHeader16(HWAVEIN16 hWaveIn
,
4358 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4362 LPWAVEHDR lpWaveInHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveInHdr
);
4365 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4367 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4368 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4369 return MMSYSERR_INVALHANDLE
;
4371 lpWaveInHdr
->dwBytesRecorded
= 0;
4373 ret
= MMDRV_Message(wmld
, WIDM_PREPARE
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4377 /**************************************************************************
4378 * waveInUnprepareHeader [WINMM.159]
4380 UINT WINAPI
waveInUnprepareHeader(HWAVEIN hWaveIn
, WAVEHDR
* lpWaveInHdr
,
4385 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4387 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4388 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
4389 return MMSYSERR_NOERROR
;
4392 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4393 return MMSYSERR_INVALHANDLE
;
4395 return MMDRV_Message(wmld
, WIDM_UNPREPARE
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4398 /**************************************************************************
4399 * waveInUnprepareHeader [MMSYSTEM.507]
4401 UINT16 WINAPI
waveInUnprepareHeader16(HWAVEIN16 hWaveIn
,
4402 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4406 LPWAVEHDR lpWaveInHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveInHdr
);
4408 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
4410 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4412 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
4413 return MMSYSERR_NOERROR
;
4416 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4417 return MMSYSERR_INVALHANDLE
;
4419 return MMDRV_Message(wmld
, WIDM_UNPREPARE
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4422 /**************************************************************************
4423 * waveInAddBuffer [WINMM.144]
4425 UINT WINAPI
waveInAddBuffer(HWAVEIN hWaveIn
,
4426 WAVEHDR
* lpWaveInHdr
, UINT uSize
)
4430 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4432 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4433 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4434 return MMSYSERR_INVALHANDLE
;
4436 return MMDRV_Message(wmld
, WIDM_ADDBUFFER
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4439 /**************************************************************************
4440 * waveInAddBuffer [MMSYSTEM.508]
4442 UINT16 WINAPI
waveInAddBuffer16(HWAVEIN16 hWaveIn
,
4443 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4448 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
4450 if (lpsegWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4451 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4452 return MMSYSERR_INVALHANDLE
;
4454 return MMDRV_Message(wmld
, WIDM_ADDBUFFER
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4457 #define WAVEIN_SHORTCUT_0(xx, XX) \
4458 UINT WINAPI waveIn##xx(HWAVEIN hWaveIn) \
4461 TRACE("(%04X);\n", hWaveIn); \
4462 if ((wmld=MMDRV_Get(hWaveIn,MMDRV_WAVEIN,FALSE)) == NULL) \
4463 return MMSYSERR_INVALHANDLE; \
4464 return MMDRV_Message(wmld,WIDM_##XX,0L,0L,TRUE); \
4466 UINT16 WINAPI waveIn##xx##16(HWAVEIN16 hWaveIn16) \
4467 {return waveIn##xx(hWaveIn16);}
4469 WAVEIN_SHORTCUT_0(Reset
, RESET
)
4470 WAVEIN_SHORTCUT_0(Start
, START
)
4471 WAVEIN_SHORTCUT_0(Stop
, STOP
)
4472 #undef WAVEIN_SHORTCUT_0
4474 /**************************************************************************
4475 * waveInGetPosition [WINMM.152]
4477 UINT WINAPI
waveInGetPosition(HWAVEIN hWaveIn
, LPMMTIME lpTime
,
4482 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpTime
, uSize
);
4484 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4485 return MMSYSERR_INVALHANDLE
;
4487 return MMDRV_Message(wmld
, WIDM_GETPOS
, (DWORD
)lpTime
, uSize
, TRUE
);
4490 /**************************************************************************
4491 * waveInGetPosition [MMSYSTEM.512]
4493 UINT16 WINAPI
waveInGetPosition16(HWAVEIN16 hWaveIn
, LPMMTIME16 lpTime
,
4499 mmt
.wType
= lpTime
->wType
;
4500 ret
= waveInGetPosition(hWaveIn
, &mmt
, sizeof(mmt
));
4501 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
4505 /**************************************************************************
4506 * waveInGetID [WINMM.150]
4508 UINT WINAPI
waveInGetID(HWAVEIN hWaveIn
, UINT
* lpuDeviceID
)
4512 TRACE("(%04X, %p);\n", hWaveIn
, lpuDeviceID
);
4514 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4516 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4517 return MMSYSERR_INVALHANDLE
;
4519 *lpuDeviceID
= wmld
->uDeviceID
;
4520 return MMSYSERR_NOERROR
;
4523 /**************************************************************************
4524 * waveInGetID [MMSYSTEM.513]
4526 UINT16 WINAPI
waveInGetID16(HWAVEIN16 hWaveIn
, UINT16
* lpuDeviceID
)
4530 TRACE("(%04X, %p);\n", hWaveIn
, lpuDeviceID
);
4532 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4534 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4535 return MMSYSERR_INVALHANDLE
;
4537 *lpuDeviceID
= wmld
->uDeviceID
;
4538 return MMSYSERR_NOERROR
;
4541 /**************************************************************************
4542 * waveInMessage [WINMM.153]
4544 DWORD WINAPI
waveInMessage(HWAVEIN hWaveIn
, UINT uMessage
,
4545 DWORD dwParam1
, DWORD dwParam2
)
4549 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
4552 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4553 return MMSYSERR_INVALPARAM
;
4555 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4556 return MMSYSERR_INVALHANDLE
;
4558 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4561 /**************************************************************************
4562 * waveInMessage [MMSYSTEM.514]
4564 DWORD WINAPI
waveInMessage16(HWAVEIN16 hWaveIn
, UINT16 uMessage
,
4565 DWORD dwParam1
, DWORD dwParam2
)
4569 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
4572 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4573 return MMSYSERR_INVALPARAM
;
4575 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4576 return MMSYSERR_INVALHANDLE
;
4578 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4581 /**************************************************************************
4582 * DrvOpen [MMSYSTEM.1100]
4584 HDRVR16 WINAPI
DrvOpen(LPSTR lpDriverName
, LPSTR lpSectionName
, LPARAM lParam
)
4586 TRACE("('%s','%s', %08lX);\n", lpDriverName
, lpSectionName
, lParam
);
4588 return OpenDriver16(lpDriverName
, lpSectionName
, lParam
);
4591 /**************************************************************************
4592 * DrvClose [MMSYSTEM.1101]
4594 LRESULT WINAPI
DrvClose(HDRVR16 hDrv
, LPARAM lParam1
, LPARAM lParam2
)
4596 TRACE("(%04X, %08lX, %08lX);\n", hDrv
, lParam1
, lParam2
);
4598 return CloseDriver16(hDrv
, lParam1
, lParam2
);
4601 /**************************************************************************
4602 * DrvSendMessage [MMSYSTEM.1102]
4604 LRESULT WINAPI
DrvSendMessage(HDRVR16 hDrv
, WORD msg
, LPARAM lParam1
,
4607 return SendDriverMessage(hDrv
, msg
, lParam1
, lParam2
);
4610 /**************************************************************************
4611 * DrvGetModuleHandle [MMSYSTEM.1103]
4613 HANDLE16 WINAPI
DrvGetModuleHandle16(HDRVR16 hDrv
)
4615 return GetDriverModuleHandle16(hDrv
);
4618 /**************************************************************************
4619 * DrvDefDriverProc [MMSYSTEM.1104]
4621 LRESULT WINAPI
DrvDefDriverProc(DWORD dwDriverID
, HDRVR16 hDrv
, WORD wMsg
,
4622 DWORD dwParam1
, DWORD dwParam2
)
4624 /* FIXME : any mapping from 32 to 16 bit structure ? */
4625 return DefDriverProc16(dwDriverID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
4628 /**************************************************************************
4629 * DefDriverProc [WINMM.5]
4631 LRESULT WINAPI
DefDriverProc(DWORD dwDriverIdentifier
, HDRVR hDrv
,
4632 UINT Msg
, LPARAM lParam1
, LPARAM lParam2
)
4648 /*#define USE_MM_TSK_WINE*/
4650 /**************************************************************************
4651 * mmTaskCreate [MMSYSTEM.900]
4653 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
4654 * called upon creation with dwPmt as parameter.
4656 HINSTANCE16 WINAPI
mmTaskCreate16(SEGPTR spProc
, HINSTANCE16
*lphMmTask
, DWORD dwPmt
)
4658 DWORD showCmd
= 0x40002;
4665 TRACE("(%08lx, %p, %08lx);\n", spProc
, lphMmTask
, dwPmt
);
4666 /* This to work requires NE modules to be started with a binary command line
4667 * which is not currently the case. A patch exists but has never been committed.
4668 * A workaround would be to integrate code for mmtask.tsk into Wine, but
4669 * this requires tremendous work (starting with patching tools/build to
4670 * create NE executables (and not only DLLs) for builtins modules.
4673 FIXME("This is currently broken. It will fail\n");
4675 cmdline
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, 0x0d);
4677 *(LPDWORD
)(cmdline
+ 1) = (DWORD
)spProc
;
4678 *(LPDWORD
)(cmdline
+ 5) = dwPmt
;
4679 *(LPDWORD
)(cmdline
+ 9) = 0;
4681 sel1
= SELECTOR_AllocBlock(cmdline
, 0x0d, SEGMENT_DATA
, FALSE
, FALSE
);
4682 sel2
= SELECTOR_AllocBlock(&showCmd
, sizeof(showCmd
),
4683 SEGMENT_DATA
, FALSE
, FALSE
);
4685 lp
= (LOADPARAMS16
*)HeapAlloc(GetProcessHeap(), 0, sizeof(LOADPARAMS16
));
4686 lp
->hEnvironment
= 0;
4687 lp
->cmdLine
= PTR_SEG_OFF_TO_SEGPTR(sel1
, 0);
4688 lp
->showCmd
= PTR_SEG_OFF_TO_SEGPTR(sel2
, 0);
4691 #ifndef USE_MM_TSK_WINE
4692 handle
= LoadModule16("c:\\windows\\system\\mmtask.tsk", lp
);
4694 handle
= LoadModule16("mmtask.tsk", lp
);
4697 ret
= (handle
) ? 1 : 2;
4703 *lphMmTask
= handle
;
4705 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel2
, 0));
4706 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel1
, 0));
4708 HeapFree(GetProcessHeap(), 0, lp
);
4709 HeapFree(GetProcessHeap(), 0, cmdline
);
4711 TRACE("=> 0x%04x/%d\n", handle
, ret
);
4715 #ifdef USE_MM_TSK_WINE
4716 /* C equivalent to mmtask.tsk binary content */
4717 void mmTaskEntryPoint16(LPSTR cmdLine
, WORD di
, WORD si
)
4719 int len
= cmdLine
[0x80];
4722 void (*fpProc
)(DWORD
) = (void (*)(DWORD
))PTR_SEG_TO_LIN(*((DWORD
*)(cmdLine
+ 1)));
4723 DWORD dwPmt
= *((DWORD
*)(cmdLine
+ 5));
4726 InitTask16(); /* fixme: pmts / from context ? */
4729 if (SetMessageQueue16(0x40)) {
4731 if (HIWORD(fpProc
)) {
4733 /* EPP StackEnter16(); */
4745 /**************************************************************************
4746 * mmTaskBlock [MMSYSTEM.902]
4748 void WINAPI
mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst
)
4753 GetMessageA(&msg
, 0, 0, 0);
4755 TranslateMessage(&msg
);
4756 DispatchMessageA(&msg
);
4758 } while (msg
.message
< 0x3A0);
4761 /**************************************************************************
4762 * mmTaskSignal [MMSYSTEM.903]
4764 LRESULT WINAPI
mmTaskSignal16(HTASK16 ht
)
4766 TRACE("(%04x);\n", ht
);
4767 return Callout
.PostAppMessage16(ht
, WM_USER
, 0, 0);
4770 /**************************************************************************
4771 * mmTaskYield16 [MMSYSTEM.905]
4773 void WINAPI
mmTaskYield16(void)
4777 if (PeekMessageA(&msg
, 0, 0, 0, 0)) {
4782 DWORD WINAPI
GetProcessFlags(DWORD
);
4784 /**************************************************************************
4785 * mmThreadCreate [MMSYSTEM.1120]
4788 * Creates a MM thread, calling fpThreadAddr(dwPmt).
4790 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
4791 * bit.1 set means to open a VxD for this thread (unsupported)
4793 LRESULT WINAPI
mmThreadCreate16(FARPROC16 fpThreadAddr
, LPHANDLE lpHndl
, DWORD dwPmt
, DWORD dwFlags
)
4798 TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr
, lpHndl
, dwPmt
, dwFlags
);
4800 hndl
= GlobalAlloc16(sizeof(WINE_MMTHREAD
), GMEM_SHARE
|GMEM_ZEROINIT
);
4805 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4808 /* force mmtask routines even if mmthread is required */
4809 /* this will work only if the patch about binary cmd line and NE tasks
4815 lpMMThd
->dwSignature
= WINE_MMTHREAD_CREATED
;
4816 lpMMThd
->dwCounter
= 0;
4817 lpMMThd
->hThread
= 0;
4818 lpMMThd
->dwThreadID
= 0;
4819 lpMMThd
->fpThread
= fpThreadAddr
;
4820 lpMMThd
->dwThreadPmt
= dwPmt
;
4821 lpMMThd
->dwSignalCount
= 0;
4822 lpMMThd
->hEvent
= 0;
4824 lpMMThd
->dwStatus
= 0;
4825 lpMMThd
->dwFlags
= dwFlags
;
4828 if ((dwFlags
& 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
4829 lpMMThd
->hEvent
= CreateEventA(0, 0, 1, 0);
4831 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd
);
4832 if (lpMMThd
->dwFlags
& 2) {
4833 /* as long as we don't support MM VxD in wine, we don't need
4834 * to care about this flag
4836 /* FIXME("Don't know how to properly open VxD handles\n"); */
4837 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
4840 lpMMThd
->hThread
= CreateThread(0, 0, (LPTHREAD_START_ROUTINE
)WINE_mmThreadEntryPoint
,
4841 (LPVOID
)(DWORD
)hndl
, CREATE_SUSPENDED
, &lpMMThd
->dwThreadID
);
4842 if (lpMMThd
->hThread
== 0) {
4843 WARN("Couldn't create thread\n");
4844 /* clean-up(VxDhandle...); devicedirectio... */
4845 if (lpMMThd
->hEvent
!= 0)
4846 CloseHandle(lpMMThd
->hEvent
);
4849 TRACE("Got a nice thread hndl=0x%04x id=0x%08lx\n", lpMMThd
->hThread
, lpMMThd
->dwThreadID
);
4853 /* get WINE_mmThreadEntryPoint()
4854 * 2047 is its ordinal in mmsystem.spec
4856 FARPROC16 fp
= GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (SEGPTR
)2047);
4858 TRACE("farproc seg=0x%08lx lin=%p\n", (DWORD
)fp
, PTR_SEG_TO_LIN(fp
));
4860 ret
= (fp
== 0) ? 2 : mmTaskCreate16((DWORD
)fp
, 0, hndl
);
4864 if (lpMMThd
->hThread
&& !ResumeThread(lpMMThd
->hThread
))
4865 WARN("Couldn't resume thread\n");
4867 while (lpMMThd
->dwStatus
!= 0x10) { /* test also HIWORD of dwStatus */
4881 TRACE("ok => %ld\n", ret
);
4885 /**************************************************************************
4886 * mmThreadSignal [MMSYSTEM.1121]
4888 void WINAPI
mmThreadSignal16(HANDLE16 hndl
)
4890 TRACE("(%04x)!\n", hndl
);
4893 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4895 lpMMThd
->dwCounter
++;
4896 if (lpMMThd
->hThread
!= 0) {
4897 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
4898 SetEvent(lpMMThd
->hEvent
);
4900 mmTaskSignal16(lpMMThd
->hTask
);
4902 lpMMThd
->dwCounter
--;
4906 /**************************************************************************
4907 * MMSYSTEM_ThreadBlock [internal]
4909 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD
* lpMMThd
)
4914 if (lpMMThd
->dwThreadID
!= GetCurrentThreadId())
4915 ERR("Not called by thread itself\n");
4918 ResetEvent(lpMMThd
->hEvent
);
4919 if (InterlockedDecrement(&lpMMThd
->dwSignalCount
) >= 0)
4921 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
4925 ret
= MsgWaitForMultipleObjects(1, &lpMMThd
->hEvent
, FALSE
, INFINITE
, QS_ALLINPUT
);
4927 case WAIT_OBJECT_0
: /* Event */
4930 case WAIT_OBJECT_0
+ 1: /* Msg */
4932 if (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
4933 Callout
.TranslateMessage(&msg
);
4934 Callout
.DispatchMessageA(&msg
);
4938 WARN("S2.x unsupported ret val 0x%08lx\n", ret
);
4944 /**************************************************************************
4945 * mmThreadBlock [MMSYSTEM.1122]
4947 void WINAPI
mmThreadBlock16(HANDLE16 hndl
)
4949 TRACE("(%04x)!\n", hndl
);
4952 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4954 if (lpMMThd
->hThread
!= 0) {
4955 SYSLEVEL_ReleaseWin16Lock();
4956 MMSYSTEM_ThreadBlock(lpMMThd
);
4957 SYSLEVEL_RestoreWin16Lock();
4959 mmTaskBlock16(lpMMThd
->hTask
);
4965 /**************************************************************************
4966 * mmThreadIsCurrent [MMSYSTEM.1123]
4968 BOOL16 WINAPI
mmThreadIsCurrent16(HANDLE16 hndl
)
4972 TRACE("(%04x)!\n", hndl
);
4974 if (hndl
&& mmThreadIsValid16(hndl
)) {
4975 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4976 ret
= (GetCurrentThreadId() == lpMMThd
->dwThreadID
);
4978 TRACE("=> %d\n", ret
);
4982 /**************************************************************************
4983 * mmThreadIsValid [MMSYSTEM.1124]
4985 BOOL16 WINAPI
mmThreadIsValid16(HANDLE16 hndl
)
4989 TRACE("(%04x)!\n", hndl
);
4992 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4994 if (!IsBadWritePtr(lpMMThd
, sizeof(WINE_MMTHREAD
)) &&
4995 lpMMThd
->dwSignature
== WINE_MMTHREAD_CREATED
&&
4996 IsTask16(lpMMThd
->hTask
)) {
4997 lpMMThd
->dwCounter
++;
4998 if (lpMMThd
->hThread
!= 0) {
5000 if (GetExitCodeThread(lpMMThd
->hThread
, &dwThreadRet
) &&
5001 dwThreadRet
== STATUS_PENDING
) {
5007 lpMMThd
->dwCounter
--;
5010 TRACE("=> %d\n", ret
);
5014 /**************************************************************************
5015 * mmThreadGetTask [MMSYSTEM.1125]
5017 HANDLE16 WINAPI
mmThreadGetTask16(HANDLE16 hndl
)
5021 TRACE("(%04x)\n", hndl
);
5023 if (mmThreadIsValid16(hndl
)) {
5024 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5025 ret
= lpMMThd
->hTask
;
5030 /* ### start build ### */
5031 extern LONG CALLBACK
MMSYSTEM_CallTo16_long_l (FARPROC16
,LONG
);
5032 /* ### stop build ### */
5034 /**************************************************************************
5035 * WINE_mmThreadEntryPoint [internal]
5037 void WINAPI
WINE_mmThreadEntryPoint(DWORD _pmt
)
5039 HANDLE16 hndl
= (HANDLE16
)_pmt
;
5040 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
5042 TRACE("(%04x %p)\n", hndl
, lpMMThd
);
5044 lpMMThd
->hTask
= LOWORD(GetCurrentTask());
5045 TRACE("[10-%08x] setting hTask to 0x%08x\n", lpMMThd
->hThread
, lpMMThd
->hTask
);
5046 lpMMThd
->dwStatus
= 0x10;
5047 MMSYSTEM_ThreadBlock(lpMMThd
);
5048 TRACE("[20-%08x]\n", lpMMThd
->hThread
);
5049 lpMMThd
->dwStatus
= 0x20;
5050 if (lpMMThd
->fpThread
) {
5051 MMSYSTEM_CallTo16_long_l(lpMMThd
->fpThread
, lpMMThd
->dwThreadPmt
);
5053 lpMMThd
->dwStatus
= 0x30;
5054 TRACE("[30-%08x]\n", lpMMThd
->hThread
);
5055 while (lpMMThd
->dwCounter
) {
5059 TRACE("[XX-%08x]\n", lpMMThd
->hThread
);
5061 lpMMThd
->dwSignature
= WINE_MMTHREAD_DELETED
;
5062 /* close lpMMThread->hVxD directio */
5063 if (lpMMThd
->hEvent
)
5064 CloseHandle(lpMMThd
->hEvent
);
5069 typedef BOOL16 (WINAPI
*MMCPLCALLBACK
)(HWND
, LPCSTR
, LPCSTR
, LPCSTR
);
5071 /**************************************************************************
5072 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
5074 BOOL16 WINAPI
mmShowMMCPLPropertySheet16(HWND hWnd
, LPCSTR lpStrDevice
,
5075 LPCSTR lpStrTab
, LPCSTR lpStrTitle
)
5080 TRACE("(%04x \"%s\" \"%s\" \"%s\")\n", hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
5082 hndl
= LoadLibraryA("MMSYS.CPL");
5084 MMCPLCALLBACK fp
= (MMCPLCALLBACK
)GetProcAddress(hndl
, "ShowMMCPLPropertySheet");
5086 SYSLEVEL_ReleaseWin16Lock();
5087 ret
= (fp
)(hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
5088 SYSLEVEL_RestoreWin16Lock();
5096 /**************************************************************************
5097 * StackEnter [MMSYSTEM.32]
5099 void WINAPI
StackEnter16(void)
5102 /* mmsystem.dll from Win 95 does only this: so does Wine */
5107 /**************************************************************************
5108 * StackLeave [MMSYSTEM.33]
5110 void WINAPI
StackLeave16(void)
5113 /* mmsystem.dll from Win 95 does only this: so does Wine */
5118 /**************************************************************************
5119 * WMMMidiRunOnce [MMSYSTEM.8]
5121 void WINAPI
WMMMidiRunOnce16(void)
5123 FIXME("(), stub!\n");