1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1993 Martin Ayotte
11 * 98/9 added Win32 MCI support
12 * 99/4 added mmTask and mmThread functions support
13 * added midiStream support
16 /* FIXME: I think there are some segmented vs. linear pointer weirdnesses
17 * and long term pointers to 16 bit space in here
23 #include "wine/winbase16.h"
30 #include "selectors.h"
32 #include "debugtools.h"
34 DEFAULT_DEBUG_CHANNEL(mmsys
)
36 LONG WINAPI
DrvDefDriverProc(DWORD dwDevID
, HDRVR16 hDrv
, WORD wMsg
,
37 DWORD dwParam1
, DWORD dwParam2
);
39 static LPWINE_MM_IDATA lpFirstIData
= NULL
;
41 static LPWINE_MM_IDATA
MULTIMEDIA_GetIDataNoCheck(void)
43 DWORD pid
= GetCurrentProcessId();
44 LPWINE_MM_IDATA iData
;
46 for (iData
= lpFirstIData
; iData
; iData
= iData
->lpNextIData
) {
47 if (iData
->dwThisProcess
== pid
)
53 /**************************************************************************
54 * MULTIMEDIA_GetIData [internal]
56 LPWINE_MM_IDATA
MULTIMEDIA_GetIData(void)
58 LPWINE_MM_IDATA iData
= MULTIMEDIA_GetIDataNoCheck();
61 ERR("IData not found. Suicide !!!\n");
67 /**************************************************************************
68 * MULTIMEDIA_CreateIData [internal]
70 static BOOL
MULTIMEDIA_CreateIData(HINSTANCE hInstDLL
)
72 LPWINE_MM_IDATA iData
;
74 iData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINE_MM_IDATA
));
78 iData
->hWinMM32Instance
= hInstDLL
;
79 iData
->dwThisProcess
= GetCurrentProcessId();
80 iData
->lpNextIData
= lpFirstIData
;
82 InitializeCriticalSection(&iData
->cs
);
86 /**************************************************************************
87 * MULTIMEDIA_DeleteIData [internal]
89 static void MULTIMEDIA_DeleteIData(void)
91 LPWINE_MM_IDATA iData
= MULTIMEDIA_GetIDataNoCheck();
92 LPWINE_MM_IDATA
* ppid
;
95 for (ppid
= &lpFirstIData
; *ppid
; ppid
= &(*ppid
)->lpNextIData
) {
97 *ppid
= iData
->lpNextIData
;
101 /* FIXME: should also free content and resources allocated
103 HeapFree(GetProcessHeap(), 0, iData
);
107 /**************************************************************************
108 * WINMM_LibMain [EntryPoint]
110 * WINMM DLL entry point
113 BOOL WINAPI
WINMM_LibMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
115 static BOOL bInitDone
= FALSE
;
117 TRACE("0x%x 0x%lx %p\n", hInstDLL
, fdwReason
, fImpLoad
);
120 case DLL_PROCESS_ATTACH
:
121 if (!MULTIMEDIA_CreateIData(hInstDLL
))
123 if (!bInitDone
) { /* to be done only once */
124 if (!MULTIMEDIA_MciInit() || !MMDRV_Init()) {
125 MULTIMEDIA_DeleteIData();
131 case DLL_PROCESS_DETACH
:
132 MULTIMEDIA_DeleteIData();
134 case DLL_THREAD_ATTACH
:
135 case DLL_THREAD_DETACH
:
141 /**************************************************************************
142 * MMSYSTEM_LibMain [EntryPoint]
144 * MMSYSTEM DLL entry point
147 BOOL WINAPI
MMSYSTEM_LibMain(DWORD fdwReason
, HINSTANCE hinstDLL
, WORD ds
,
148 WORD wHeapSize
, DWORD dwReserved1
, WORD wReserved2
)
151 LPWINE_MM_IDATA iData
;
153 TRACE("0x%x 0x%lx\n", hinstDLL
, fdwReason
);
156 case DLL_PROCESS_ATTACH
:
157 /* need to load WinMM in order to:
158 * - correctly initiates shared variables (MULTIMEDIA_Init())
159 * - correctly creates the per process WINE_MM_IDATA chunk
161 hndl
= LoadLibraryA("WINMM.DLL");
164 ERR("Could not load sibling WinMM.dll\n");
167 iData
= MULTIMEDIA_GetIData();
168 iData
->hWinMM16Instance
= hinstDLL
;
169 iData
->h16Module32
= hndl
;
171 case DLL_PROCESS_DETACH
:
172 iData
= MULTIMEDIA_GetIData();
173 FreeLibrary(iData
->h16Module32
);
175 case DLL_THREAD_ATTACH
:
176 case DLL_THREAD_DETACH
:
182 /**************************************************************************
183 * MMSYSTEM_WEP [MMSYSTEM.1]
185 int WINAPI
MMSYSTEM_WEP(HINSTANCE16 hInstance
, WORD wDataSeg
,
186 WORD cbHeapSize
, LPSTR lpCmdLine
)
188 FIXME("STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance
);
192 void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16
, const MMTIME
* mmt32
)
194 mmt16
->wType
= mmt32
->wType
;
195 /* layout of rest is the same for 32/16,
196 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
198 memcpy(&(mmt16
->u
), &(mmt32
->u
), sizeof(mmt16
->u
));
201 void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32
, const MMTIME16
* mmt16
)
203 mmt32
->wType
= mmt16
->wType
;
204 /* layout of rest is the same for 32/16,
205 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
207 memcpy(&(mmt32
->u
), &(mmt16
->u
), sizeof(mmt16
->u
));
210 static HANDLE PlaySound_hThread
= 0;
211 static HANDLE PlaySound_hPlayEvent
= 0;
212 static HANDLE PlaySound_hReadyEvent
= 0;
213 static HANDLE PlaySound_hMiddleEvent
= 0;
214 static BOOL PlaySound_Result
= FALSE
;
215 static int PlaySound_Stop
= FALSE
;
216 static int PlaySound_Playing
= FALSE
;
218 static LPCSTR PlaySound_pszSound
= NULL
;
219 static HMODULE PlaySound_hmod
= 0;
220 static DWORD PlaySound_fdwSound
= 0;
221 static int PlaySound_Loop
= FALSE
;
222 static int PlaySound_SearchMode
= 0; /* 1 - sndPlaySound search order
223 2 - PlaySound order */
225 static HMMIO
get_mmioFromFile(LPCSTR lpszName
)
227 return mmioOpenA((LPSTR
)lpszName
, NULL
,
228 MMIO_ALLOCBUF
| MMIO_READ
| MMIO_DENYWRITE
);
231 static HMMIO
get_mmioFromProfile(UINT uFlags
, LPCSTR lpszName
)
237 TRACE("searching in SystemSound List !\n");
238 GetProfileStringA("Sounds", (LPSTR
)lpszName
, "", str
, sizeof(str
));
239 if (strlen(str
) == 0) {
240 if (uFlags
& SND_NODEFAULT
) return 0;
241 GetProfileStringA("Sounds", "Default", "", str
, sizeof(str
));
242 if (strlen(str
) == 0) return 0;
244 if ((ptr
= (LPSTR
)strchr(str
, ',')) != NULL
) *ptr
= '\0';
245 hmmio
= get_mmioFromFile(str
);
247 WARN("can't find SystemSound='%s' !\n", str
);
253 static BOOL WINAPI
proc_PlaySound(LPCSTR lpszSoundName
, UINT uFlags
)
259 TRACE("SoundName='%s' uFlags=%04X !\n", lpszSoundName
, uFlags
);
260 if (lpszSoundName
== NULL
) {
264 if (uFlags
& SND_MEMORY
) {
266 memset(&mminfo
, 0, sizeof(mminfo
));
267 mminfo
.fccIOProc
= FOURCC_MEM
;
268 mminfo
.pchBuffer
= (LPSTR
)lpszSoundName
;
269 mminfo
.cchBuffer
= -1;
270 TRACE("Memory sound %p\n", lpszSoundName
);
271 hmmio
= mmioOpenA(NULL
, &mminfo
, MMIO_READ
);
274 if (uFlags
& SND_ALIAS
)
275 if ((hmmio
=get_mmioFromProfile(uFlags
, lpszSoundName
)) == 0)
278 if (uFlags
& SND_FILENAME
)
279 if ((hmmio
=get_mmioFromFile(lpszSoundName
)) == 0) return FALSE
;
281 if (PlaySound_SearchMode
== 1) {
282 PlaySound_SearchMode
= 0;
283 if ((hmmio
=get_mmioFromFile(lpszSoundName
)) == 0)
284 if ((hmmio
=get_mmioFromProfile(uFlags
, lpszSoundName
)) == 0)
288 if (PlaySound_SearchMode
== 2) {
289 PlaySound_SearchMode
= 0;
290 if ((hmmio
=get_mmioFromProfile(uFlags
| SND_NODEFAULT
, lpszSoundName
)) == 0)
291 if ((hmmio
=get_mmioFromFile(lpszSoundName
)) == 0)
292 if ((hmmio
=get_mmioFromProfile(uFlags
, lpszSoundName
)) == 0) return FALSE
;
296 if (mmioDescend(hmmio
, &ckMainRIFF
, NULL
, 0) == 0) {
297 DWORD dwPos
= mmioSeek(hmmio
, 0, SEEK_CUR
);
299 TRACE("ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX \n",
300 (LPSTR
)&ckMainRIFF
.ckid
, (LPSTR
)&ckMainRIFF
.fccType
,
303 mmioSeek(hmmio
, dwPos
, SEEK_SET
);
305 if ((ckMainRIFF
.ckid
== FOURCC_RIFF
) &&
306 (ckMainRIFF
.fccType
== mmioFOURCC('W', 'A', 'V', 'E'))) {
309 mmckInfo
.ckid
= mmioFOURCC('f', 'm', 't', ' ');
311 if (mmioDescend(hmmio
, &mmckInfo
, &ckMainRIFF
, MMIO_FINDCHUNK
) == 0) {
312 PCMWAVEFORMAT pcmWaveFormat
;
314 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n",
315 (LPSTR
)&mmckInfo
.ckid
, (LPSTR
)&mmckInfo
.fccType
, mmckInfo
.cksize
);
317 if (mmioRead(hmmio
, (HPSTR
)&pcmWaveFormat
,
318 (long) sizeof(PCMWAVEFORMAT
)) == (long) sizeof(PCMWAVEFORMAT
)) {
319 TRACE("wFormatTag=%04X !\n", pcmWaveFormat
.wf
.wFormatTag
);
320 TRACE("nChannels=%d \n", pcmWaveFormat
.wf
.nChannels
);
321 TRACE("nSamplesPerSec=%ld\n", pcmWaveFormat
.wf
.nSamplesPerSec
);
322 TRACE("nAvgBytesPerSec=%ld\n", pcmWaveFormat
.wf
.nAvgBytesPerSec
);
323 TRACE("nBlockAlign=%d \n", pcmWaveFormat
.wf
.nBlockAlign
);
324 TRACE("wBitsPerSample=%u !\n", pcmWaveFormat
.wBitsPerSample
);
326 mmckInfo
.ckid
= mmioFOURCC('d', 'a', 't', 'a');
327 /* move to end of 'fmt ' chunk */
328 mmioSeek(hmmio
, mmckInfo
.dwDataOffset
+ ((mmckInfo
.cksize
+ 1) & ~1), SEEK_SET
);
330 if (mmioDescend(hmmio
, &mmckInfo
, &ckMainRIFF
, MMIO_FINDCHUNK
) == 0) {
334 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n",
335 (LPSTR
)&mmckInfo
.ckid
, (LPSTR
)&mmckInfo
.fccType
, mmckInfo
.cksize
);
337 pcmWaveFormat
.wf
.nAvgBytesPerSec
= pcmWaveFormat
.wf
.nSamplesPerSec
*
338 pcmWaveFormat
.wf
.nBlockAlign
;
340 dwRet
= waveOutOpen(&hWave
, WAVE_MAPPER
, (LPWAVEFORMATEX
)&pcmWaveFormat
, 0L, 0L, CALLBACK_NULL
);
341 if (dwRet
== MMSYSERR_NOERROR
) {
344 INT count
, bufsize
, left
= mmckInfo
.cksize
;
347 hData
= GlobalAlloc16(GMEM_MOVEABLE
, bufsize
);
348 waveHdr
.lpData
= (LPSTR
)GlobalLock16(hData
);
349 waveHdr
.dwBufferLength
= bufsize
;
351 waveHdr
.dwFlags
= 0L;
352 waveHdr
.dwLoops
= 0L;
354 dwRet
= waveOutPrepareHeader(hWave
, &waveHdr
, sizeof(WAVEHDR
));
355 if (dwRet
== MMSYSERR_NOERROR
) {
357 if (PlaySound_Stop
) {
358 PlaySound_Stop
= FALSE
;
359 PlaySound_Loop
= FALSE
;
362 if (bufsize
> left
) bufsize
= left
;
363 count
= mmioRead(hmmio
, waveHdr
.lpData
, bufsize
);
364 if (count
< 1) break;
366 waveHdr
.dwBufferLength
= count
;
367 /* waveHdr.dwBytesRecorded = count; */
368 /* FIXME: doesn't expect async ops */
369 waveOutWrite(hWave
, &waveHdr
, sizeof(WAVEHDR
));
370 while (!(waveHdr
.dwFlags
& WHDR_DONE
))
373 waveOutUnprepareHeader(hWave
, &waveHdr
, sizeof(WAVEHDR
));
374 while (waveOutClose(hWave
) == WAVERR_STILLPLAYING
)
379 WARN("can't prepare WaveOut device !\n");
381 GlobalUnlock16(hData
);
388 } while (PlaySound_Loop
);
391 if (hmmio
!= 0) mmioClose(hmmio
, 0);
395 static DWORD WINAPI
PlaySound_Thread(LPVOID arg
)
400 PlaySound_Playing
= FALSE
;
401 SetEvent(PlaySound_hReadyEvent
);
402 res
= WaitForSingleObject(PlaySound_hPlayEvent
, INFINITE
);
403 ResetEvent(PlaySound_hReadyEvent
);
404 SetEvent(PlaySound_hMiddleEvent
);
405 if (res
== WAIT_FAILED
) ExitThread(2);
406 if (res
!= WAIT_OBJECT_0
) continue;
407 PlaySound_Playing
= TRUE
;
409 if ((PlaySound_fdwSound
& SND_RESOURCE
) == SND_RESOURCE
) {
414 if ((hRES
= FindResourceA(PlaySound_hmod
, PlaySound_pszSound
, "WAVE")) == 0) {
415 PlaySound_Result
= FALSE
;
418 if ((hGLOB
= LoadResource(PlaySound_hmod
, hRES
)) == 0) {
419 PlaySound_Result
= FALSE
;
422 if ((ptr
= LockResource(hGLOB
)) == NULL
) {
424 PlaySound_Result
= FALSE
;
427 PlaySound_Result
= proc_PlaySound(ptr
,
428 ((UINT16
)PlaySound_fdwSound
^ SND_RESOURCE
) | SND_MEMORY
);
432 PlaySound_Result
= proc_PlaySound(PlaySound_pszSound
, (UINT16
)PlaySound_fdwSound
);
436 /**************************************************************************
437 * PlaySoundA [WINMM.1]
439 BOOL WINAPI
PlaySoundA(LPCSTR pszSound
, HMODULE hmod
, DWORD fdwSound
)
441 static LPSTR StrDup
= NULL
;
443 TRACE("pszSound='%p' hmod=%04X fdwSound=%08lX\n",
444 pszSound
, hmod
, fdwSound
);
446 if (PlaySound_hThread
== 0) { /* This is the first time they called us */
448 if ((PlaySound_hReadyEvent
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
)) == 0)
450 if ((PlaySound_hMiddleEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
)) == 0)
452 if ((PlaySound_hPlayEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
)) == 0)
454 if ((PlaySound_hThread
= CreateThread(NULL
, 0, PlaySound_Thread
, 0, 0, &id
)) == 0)
458 /* FIXME? I see no difference between SND_WAIT and SND_NOSTOP ! */
459 if ((fdwSound
& (SND_NOWAIT
| SND_NOSTOP
)) && PlaySound_Playing
)
462 /* Trying to stop if playing */
463 if (PlaySound_Playing
) PlaySound_Stop
= TRUE
;
465 /* Waiting playing thread to get ready. I think 10 secs is ok & if not then leave*/
466 if (WaitForSingleObject(PlaySound_hReadyEvent
, 1000*10) != WAIT_OBJECT_0
)
469 if (!pszSound
|| (fdwSound
& SND_PURGE
))
470 return FALSE
; /* We stoped playing so leaving */
472 if (PlaySound_SearchMode
!= 1) PlaySound_SearchMode
= 2;
473 if (!(fdwSound
& SND_ASYNC
)) {
474 if (fdwSound
& SND_LOOP
)
476 PlaySound_pszSound
= pszSound
;
477 PlaySound_hmod
= hmod
;
478 PlaySound_fdwSound
= fdwSound
;
479 PlaySound_Result
= FALSE
;
480 SetEvent(PlaySound_hPlayEvent
);
481 if (WaitForSingleObject(PlaySound_hMiddleEvent
, INFINITE
) != WAIT_OBJECT_0
)
483 if (WaitForSingleObject(PlaySound_hReadyEvent
, INFINITE
) != WAIT_OBJECT_0
)
485 return PlaySound_Result
;
487 PlaySound_hmod
= hmod
;
488 PlaySound_fdwSound
= fdwSound
;
489 PlaySound_Result
= FALSE
;
491 HeapFree(GetProcessHeap(), 0, StrDup
);
494 if (!((fdwSound
& SND_MEMORY
) || ((fdwSound
& SND_RESOURCE
) &&
495 !((DWORD
)pszSound
>> 16)) || !pszSound
)) {
496 StrDup
= HEAP_strdupA(GetProcessHeap(), 0,pszSound
);
497 PlaySound_pszSound
= StrDup
;
498 } else PlaySound_pszSound
= pszSound
;
499 PlaySound_Loop
= fdwSound
& SND_LOOP
;
500 SetEvent(PlaySound_hPlayEvent
);
501 ResetEvent(PlaySound_hMiddleEvent
);
507 /**************************************************************************
508 * PlaySoundW [WINMM.18]
510 BOOL WINAPI
PlaySoundW(LPCWSTR pszSound
, HMODULE hmod
, DWORD fdwSound
)
515 if (!((fdwSound
& SND_MEMORY
) || ((fdwSound
& SND_RESOURCE
) &&
516 !((DWORD
)pszSound
>> 16)) || !pszSound
)) {
517 pszSoundA
= HEAP_strdupWtoA(GetProcessHeap(), 0,pszSound
);
518 bSound
= PlaySoundA(pszSoundA
, hmod
, fdwSound
);
519 HeapFree(GetProcessHeap(), 0,pszSoundA
);
521 bSound
= PlaySoundA((LPCSTR
)pszSound
, hmod
, fdwSound
);
526 /**************************************************************************
527 * PlaySound16 [MMSYSTEM.3]
529 BOOL16 WINAPI
PlaySound16(LPCSTR pszSound
, HMODULE16 hmod
, DWORD fdwSound
)
533 SYSLEVEL_ReleaseWin16Lock();
534 retv
= PlaySoundA( pszSound
, hmod
, fdwSound
);
535 SYSLEVEL_RestoreWin16Lock();
540 /**************************************************************************
541 * sndPlaySoundA [WINMM135]
543 BOOL WINAPI
sndPlaySoundA(LPCSTR lpszSoundName
, UINT uFlags
)
545 PlaySound_SearchMode
= 1;
546 return PlaySoundA(lpszSoundName
, 0, uFlags
);
549 /**************************************************************************
550 * sndPlaySoundW [WINMM.136]
552 BOOL WINAPI
sndPlaySoundW(LPCWSTR lpszSoundName
, UINT uFlags
)
554 PlaySound_SearchMode
= 1;
555 return PlaySoundW(lpszSoundName
, 0, uFlags
);
558 /**************************************************************************
559 * sndPlaySound16 [MMSYSTEM.2]
561 BOOL16 WINAPI
sndPlaySound16(LPCSTR lpszSoundName
, UINT16 uFlags
)
565 SYSLEVEL_ReleaseWin16Lock();
566 retv
= sndPlaySoundA( lpszSoundName
, uFlags
);
567 SYSLEVEL_RestoreWin16Lock();
573 /**************************************************************************
574 * mmsystemGetVersion [WINMM.134]
576 UINT WINAPI
mmsystemGetVersion(void)
578 return mmsystemGetVersion16();
581 /**************************************************************************
582 * mmsystemGetVersion [MMSYSTEM.5]
583 * return value borrowed from Win95 winmm.dll ;)
585 UINT16 WINAPI
mmsystemGetVersion16(void)
587 TRACE("3.10 (Win95?)\n");
591 /**************************************************************************
592 * DriverProc [MMSYSTEM.6]
594 LRESULT WINAPI
DriverProc16(DWORD dwDevID
, HDRVR16 hDrv
, WORD wMsg
,
595 DWORD dwParam1
, DWORD dwParam2
)
597 TRACE("dwDevID=%08lx hDrv=%04x wMsg=%04x dwParam1=%08lx dwParam2=%08lx\n",
598 dwDevID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
600 return DrvDefDriverProc(dwDevID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
603 /**************************************************************************
604 * DriverCallback [MMSYSTEM.31]
606 BOOL WINAPI
DriverCallback(DWORD dwCallBack
, UINT uFlags
, HDRVR hDev
,
607 UINT wMsg
, DWORD dwUser
, DWORD dwParam1
,
610 TRACE("(%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n",
611 dwCallBack
, uFlags
, hDev
, wMsg
, dwUser
, dwParam1
, dwParam2
);
613 switch (uFlags
& DCB_TYPEMASK
) {
618 TRACE("Window(%04lX) handle=%04X!\n", dwCallBack
, hDev
);
619 if (!IsWindow(dwCallBack
))
621 Callout
.PostMessageA((HWND16
)dwCallBack
, wMsg
, hDev
, dwParam1
);
623 case DCB_TASK
: /* aka DCB_THREAD */
624 TRACE("Task(%04lx) !\n", dwCallBack
);
625 Callout
.PostThreadMessageA(dwCallBack
, wMsg
, hDev
, dwParam1
);
628 TRACE("Function (32 bit) !\n");
629 ((LPDRVCALLBACK
)dwCallBack
)(hDev
, wMsg
, dwUser
, dwParam1
, dwParam2
);
632 TRACE("Event(%08lx) !\n", dwCallBack
);
633 SetEvent((HANDLE
)dwCallBack
);
635 case 6: /* I would dub it DCB_MMTHREADSIGNAL */
636 /* this is an undocumented DCB_ value used for mmThreads
637 * loword of dwCallBack contains the handle of the lpMMThd block
638 * which dwSignalCount has to be incremented
641 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(LOWORD(dwCallBack
), 0);
643 TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack
), lpMMThd
);
644 /* same as mmThreadSignal16 */
645 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
646 SetEvent(lpMMThd
->hEvent
);
647 /* some other stuff on lpMMThd->hVxD */
652 /* this is an undocumented DCB_ value for... I don't know */
656 WARN("Unknown callback type %d\n", uFlags
& DCB_TYPEMASK
);
663 /**************************************************************************
664 * DriverCallback [MMSYSTEM.31]
666 BOOL16 WINAPI
DriverCallback16(DWORD dwCallBack
, UINT16 uFlags
, HDRVR16 hDev
,
667 WORD wMsg
, DWORD dwUser
, DWORD dwParam1
,
670 return DriverCallback(dwCallBack
, uFlags
, hDev
, wMsg
, dwUser
, dwParam1
, dwParam2
);
673 /**************************************************************************
674 * Mixer devices. New to Win95
677 /**************************************************************************
678 * find out the real mixer ID depending on hmix (depends on dwFlags)
680 static LPWINE_MIXER
MIXER_GetDev(HMIXEROBJ hmix
, DWORD dwFlags
)
682 LPWINE_MIXER lpwm
= NULL
;
684 switch (dwFlags
& 0xF0000000ul
) {
685 case MIXER_OBJECTF_MIXER
:
686 lpwm
= (LPWINE_MIXER
)MMDRV_Get(hmix
, MMDRV_MIXER
, TRUE
);
688 case MIXER_OBJECTF_HMIXER
:
689 lpwm
= (LPWINE_MIXER
)MMDRV_Get(hmix
, MMDRV_MIXER
, FALSE
);
691 case MIXER_OBJECTF_WAVEOUT
:
692 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_WAVEOUT
, TRUE
, MMDRV_MIXER
);
694 case MIXER_OBJECTF_HWAVEOUT
:
695 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_WAVEOUT
, FALSE
, MMDRV_MIXER
);
697 case MIXER_OBJECTF_WAVEIN
:
698 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_WAVEIN
, TRUE
, MMDRV_MIXER
);
700 case MIXER_OBJECTF_HWAVEIN
:
701 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_WAVEIN
, FALSE
, MMDRV_MIXER
);
703 case MIXER_OBJECTF_MIDIOUT
:
704 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_MIDIOUT
, TRUE
, MMDRV_MIXER
);
706 case MIXER_OBJECTF_HMIDIOUT
:
707 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_MIDIOUT
, FALSE
, MMDRV_MIXER
);
709 case MIXER_OBJECTF_MIDIIN
:
710 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_MIDIIN
, TRUE
, MMDRV_MIXER
);
712 case MIXER_OBJECTF_HMIDIIN
:
713 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_MIDIIN
, FALSE
, MMDRV_MIXER
);
715 case MIXER_OBJECTF_AUX
:
716 lpwm
= (LPWINE_MIXER
)MMDRV_GetRelated(hmix
, MMDRV_AUX
, TRUE
, MMDRV_MIXER
);
719 FIXME("Unsupported flag (%08lx)\n", dwFlags
& 0xF0000000ul
);
725 /**************************************************************************
726 * mixerGetNumDevs [WINMM.108]
728 UINT WINAPI
mixerGetNumDevs(void)
730 return MMDRV_GetNum(MMDRV_MIXER
);
733 /**************************************************************************
734 * mixerGetNumDevs [MMSYSTEM.800]
736 UINT16 WINAPI
mixerGetNumDevs16(void)
738 return MMDRV_GetNum(MMDRV_MIXER
);
741 /**************************************************************************
742 * mixerGetDevCapsA [WINMM.101]
744 UINT WINAPI
mixerGetDevCapsA(UINT devid
, LPMIXERCAPSA mixcaps
, UINT size
)
748 if ((wmld
= MMDRV_Get(devid
, MMDRV_MIXER
, TRUE
)) == NULL
)
749 return MMSYSERR_BADDEVICEID
;
751 return MMDRV_Message(wmld
, MXDM_GETDEVCAPS
, (DWORD
)mixcaps
, size
, TRUE
);
754 /**************************************************************************
755 * mixerGetDevCapsW [WINMM.102]
757 UINT WINAPI
mixerGetDevCapsW(UINT devid
, LPMIXERCAPSW mixcaps
, UINT size
)
760 UINT ret
= mixerGetDevCapsA(devid
, &micA
, sizeof(micA
));
762 if (ret
== MMSYSERR_NOERROR
) {
763 mixcaps
->wMid
= micA
.wMid
;
764 mixcaps
->wPid
= micA
.wPid
;
765 mixcaps
->vDriverVersion
= micA
.vDriverVersion
;
766 lstrcpyAtoW(mixcaps
->szPname
, micA
.szPname
);
767 mixcaps
->fdwSupport
= micA
.fdwSupport
;
768 mixcaps
->cDestinations
= micA
.cDestinations
;
773 /**************************************************************************
774 * mixerGetDevCaps [MMSYSTEM.801]
776 UINT16 WINAPI
mixerGetDevCaps16(UINT16 devid
, LPMIXERCAPS16 mixcaps
,
780 UINT ret
= mixerGetDevCapsA(devid
, &micA
, sizeof(micA
));
782 if (ret
== MMSYSERR_NOERROR
) {
783 mixcaps
->wMid
= micA
.wMid
;
784 mixcaps
->wPid
= micA
.wPid
;
785 mixcaps
->vDriverVersion
= micA
.vDriverVersion
;
786 strcpy(mixcaps
->szPname
, micA
.szPname
);
787 mixcaps
->fdwSupport
= micA
.fdwSupport
;
788 mixcaps
->cDestinations
= micA
.cDestinations
;
793 static UINT
MMSYSTEM_mixerOpen(LPHMIXER lphMix
, UINT uDeviceID
, DWORD dwCallback
,
794 DWORD dwInstance
, DWORD fdwOpen
, BOOL bFrom32
)
801 TRACE("(%p, %d, %08lx, %08lx, %08lx)\n",
802 lphMix
, uDeviceID
, dwCallback
, dwInstance
, fdwOpen
);
804 wmld
= MMDRV_Alloc(sizeof(WINE_MIXER
), MMDRV_MIXER
, &hMix
, &fdwOpen
,
805 &dwCallback
, &dwInstance
, bFrom32
);
807 wmld
->uDeviceID
= uDeviceID
;
809 mod
.dwCallback
= dwCallback
;
810 mod
.dwInstance
= dwInstance
;
812 dwRet
= MMDRV_Open(wmld
, MXDM_OPEN
, (DWORD
)&mod
, fdwOpen
);
814 if (dwRet
!= MMSYSERR_NOERROR
) {
815 MMDRV_Free(hMix
, wmld
);
818 if (lphMix
) *lphMix
= hMix
;
819 TRACE("=> %ld hMixer=%04x\n", dwRet
, hMix
);
824 /**************************************************************************
825 * mixerOpen [WINMM.110]
827 UINT WINAPI
mixerOpen(LPHMIXER lphMix
, UINT uDeviceID
, DWORD dwCallback
,
828 DWORD dwInstance
, DWORD fdwOpen
)
830 return MMSYSTEM_mixerOpen(lphMix
, uDeviceID
,
831 dwCallback
, dwInstance
, fdwOpen
, TRUE
);
834 /**************************************************************************
835 * mixerOpen [MMSYSTEM.803]
837 UINT16 WINAPI
mixerOpen16(LPHMIXER16 lphmix
, UINT16 uDeviceID
, DWORD dwCallback
,
838 DWORD dwInstance
, DWORD fdwOpen
)
843 ret
= MMSYSTEM_mixerOpen(&hmix
, uDeviceID
,
844 dwCallback
, dwInstance
, fdwOpen
, FALSE
);
845 if (lphmix
) *lphmix
= hmix
;
849 /**************************************************************************
850 * mixerClose [WINMM.98]
852 UINT WINAPI
mixerClose(HMIXER hMix
)
857 TRACE("(%04x)\n", hMix
);
859 if ((wmld
= MMDRV_Get(hMix
, MMDRV_MIXER
, FALSE
)) == NULL
) return MMSYSERR_INVALHANDLE
;
861 dwRet
= MMDRV_Close(wmld
, MXDM_CLOSE
);
862 MMDRV_Free(hMix
, wmld
);
867 /**************************************************************************
868 * mixerClose [MMSYSTEM.803]
870 UINT16 WINAPI
mixerClose16(HMIXER16 hMix
)
872 return mixerClose(hMix
);
875 /**************************************************************************
876 * mixerGetID [WINMM.103]
878 UINT WINAPI
mixerGetID(HMIXEROBJ hmix
, LPUINT lpid
, DWORD fdwID
)
882 TRACE("(%04x %p %08lx)\n", hmix
, lpid
, fdwID
);
884 if ((lpwm
= MIXER_GetDev(hmix
, fdwID
)) == NULL
) {
885 return MMSYSERR_INVALHANDLE
;
889 *lpid
= lpwm
->mld
.uDeviceID
;
891 return MMSYSERR_NOERROR
;
894 /**************************************************************************
897 UINT16 WINAPI
mixerGetID16(HMIXEROBJ16 hmix
, LPUINT16 lpid
, DWORD fdwID
)
900 UINT ret
= mixerGetID(hmix
, &xid
, fdwID
);
907 /**************************************************************************
908 * mixerGetControlDetailsA [WINMM.99]
910 UINT WINAPI
mixerGetControlDetailsA(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcdA
,
915 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcdA
, fdwDetails
);
917 if ((lpwm
= MIXER_GetDev(hmix
, fdwDetails
)) == NULL
)
918 return MMSYSERR_INVALHANDLE
;
920 if (lpmcdA
== NULL
|| lpmcdA
->cbStruct
!= sizeof(*lpmcdA
))
921 return MMSYSERR_INVALPARAM
;
923 return MMDRV_Message(&lpwm
->mld
, MXDM_GETCONTROLDETAILS
, (DWORD
)lpmcdA
,
927 /**************************************************************************
928 * mixerGetControlDetailsW [WINMM.100]
930 UINT WINAPI
mixerGetControlDetailsW(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcd
, DWORD fdwDetails
)
932 DWORD ret
= MMSYSERR_NOTENABLED
;
934 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
936 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
937 return MMSYSERR_INVALPARAM
;
939 switch (fdwDetails
& MIXER_GETCONTROLDETAILSF_QUERYMASK
) {
940 case MIXER_GETCONTROLDETAILSF_VALUE
:
941 /* can savely use W structure as it is, no string inside */
942 ret
= mixerGetControlDetailsA(hmix
, lpmcd
, fdwDetails
);
944 case MIXER_GETCONTROLDETAILSF_LISTTEXT
:
946 LPVOID paDetailsW
= lpmcd
->paDetails
;
947 int size
= MAX(1, lpmcd
->cChannels
) * sizeof(MIXERCONTROLDETAILS_LISTTEXTA
);
949 if (lpmcd
->u
.cMultipleItems
!= 0 && lpmcd
->u
.cMultipleItems
!= lpmcd
->u
.hwndOwner
) {
950 size
*= lpmcd
->u
.cMultipleItems
;
952 lpmcd
->paDetails
= HeapAlloc(GetProcessHeap(), 0, size
);
953 /* set up lpmcd->paDetails */
954 ret
= mixerGetControlDetailsA(hmix
, lpmcd
, fdwDetails
);
955 /* copy from lpmcd->paDetails back to paDetailsW; */
956 HeapFree(GetProcessHeap(), 0, lpmcd
->paDetails
);
957 lpmcd
->paDetails
= paDetailsW
;
961 ERR("Unsupported fdwDetails=0x%08lx\n", fdwDetails
);
967 /**************************************************************************
968 * mixerGetControlDetails [MMSYSTEM.808]
970 UINT16 WINAPI
mixerGetControlDetails16(HMIXEROBJ16 hmix
,
971 LPMIXERCONTROLDETAILS16 lpmcd
,
974 DWORD ret
= MMSYSERR_NOTENABLED
;
977 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
979 if (lpmcd
== NULL
|| lpmcd
->cbStruct
!= sizeof(*lpmcd
))
980 return MMSYSERR_INVALPARAM
;
982 sppaDetails
= (SEGPTR
)lpmcd
->paDetails
;
983 lpmcd
->paDetails
= PTR_SEG_TO_LIN(sppaDetails
);
984 ret
= mixerGetControlDetailsA(hmix
, (LPMIXERCONTROLDETAILS
)lpmcd
, fdwDetails
);
985 lpmcd
->paDetails
= (LPVOID
)sppaDetails
;
990 /**************************************************************************
991 * mixerGetLineControlsA [WINMM.104]
993 UINT WINAPI
mixerGetLineControlsA(HMIXEROBJ hmix
, LPMIXERLINECONTROLSA lpmlcA
,
998 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlcA
, fdwControls
);
1000 if ((lpwm
= MIXER_GetDev(hmix
, fdwControls
)) == NULL
)
1001 return MMSYSERR_INVALHANDLE
;
1003 if (lpmlcA
== NULL
|| lpmlcA
->cbStruct
!= sizeof(*lpmlcA
))
1004 return MMSYSERR_INVALPARAM
;
1006 return MMDRV_Message(&lpwm
->mld
, MXDM_GETLINECONTROLS
, (DWORD
)lpmlcA
,
1010 /**************************************************************************
1011 * mixerGetLineControlsW [WINMM.105]
1013 UINT WINAPI
mixerGetLineControlsW(HMIXEROBJ hmix
, LPMIXERLINECONTROLSW lpmlcW
,
1016 MIXERLINECONTROLSA mlcA
;
1020 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlcW
, fdwControls
);
1022 if (lpmlcW
== NULL
|| lpmlcW
->cbStruct
!= sizeof(*lpmlcW
) ||
1023 lpmlcW
->cbmxctrl
!= sizeof(MIXERCONTROLW
))
1024 return MMSYSERR_INVALPARAM
;
1026 mlcA
.cbStruct
= sizeof(mlcA
);
1027 mlcA
.dwLineID
= lpmlcW
->dwLineID
;
1028 mlcA
.u
.dwControlID
= lpmlcW
->u
.dwControlID
;
1029 mlcA
.u
.dwControlType
= lpmlcW
->u
.dwControlType
;
1030 mlcA
.cControls
= lpmlcW
->cControls
;
1031 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
1032 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0,
1033 mlcA
.cControls
* mlcA
.cbmxctrl
);
1035 ret
= mixerGetLineControlsA(hmix
, &mlcA
, fdwControls
);
1037 if (ret
== MMSYSERR_NOERROR
) {
1038 lpmlcW
->dwLineID
= mlcA
.dwLineID
;
1039 lpmlcW
->u
.dwControlID
= mlcA
.u
.dwControlID
;
1040 lpmlcW
->u
.dwControlType
= mlcA
.u
.dwControlType
;
1041 lpmlcW
->cControls
= mlcA
.cControls
;
1043 for (i
= 0; i
< mlcA
.cControls
; i
++) {
1044 lpmlcW
->pamxctrl
[i
].cbStruct
= sizeof(MIXERCONTROLW
);
1045 lpmlcW
->pamxctrl
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
1046 lpmlcW
->pamxctrl
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
1047 lpmlcW
->pamxctrl
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
1048 lpmlcW
->pamxctrl
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
1049 lstrcpyAtoW(lpmlcW
->pamxctrl
[i
].szShortName
,
1050 mlcA
.pamxctrl
[i
].szShortName
);
1051 lstrcpyAtoW(lpmlcW
->pamxctrl
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
1052 /* sizeof(lpmlcW->pamxctrl[i].Bounds) ==
1053 * sizeof(mlcA.pamxctrl[i].Bounds) */
1054 memcpy(&lpmlcW
->pamxctrl
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
,
1055 sizeof(mlcA
.pamxctrl
[i
].Bounds
));
1056 /* sizeof(lpmlcW->pamxctrl[i].Metrics) ==
1057 * sizeof(mlcA.pamxctrl[i].Metrics) */
1058 memcpy(&lpmlcW
->pamxctrl
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
,
1059 sizeof(mlcA
.pamxctrl
[i
].Metrics
));
1063 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
1068 /**************************************************************************
1069 * mixerGetLineControls [MMSYSTEM.807]
1071 UINT16 WINAPI
mixerGetLineControls16(HMIXEROBJ16 hmix
,
1072 LPMIXERLINECONTROLS16 lpmlc16
,
1075 MIXERLINECONTROLSA mlcA
;
1078 LPMIXERCONTROL16 lpmc16
;
1080 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmlc16
, fdwControls
);
1082 if (lpmlc16
== NULL
|| lpmlc16
->cbStruct
!= sizeof(*lpmlc16
) ||
1083 lpmlc16
->cbmxctrl
!= sizeof(MIXERCONTROL16
))
1084 return MMSYSERR_INVALPARAM
;
1086 mlcA
.cbStruct
= sizeof(mlcA
);
1087 mlcA
.dwLineID
= lpmlc16
->dwLineID
;
1088 mlcA
.u
.dwControlID
= lpmlc16
->u
.dwControlID
;
1089 mlcA
.u
.dwControlType
= lpmlc16
->u
.dwControlType
;
1090 mlcA
.cControls
= lpmlc16
->cControls
;
1091 mlcA
.cbmxctrl
= sizeof(MIXERCONTROLA
);
1092 mlcA
.pamxctrl
= HeapAlloc(GetProcessHeap(), 0,
1093 mlcA
.cControls
* mlcA
.cbmxctrl
);
1095 ret
= mixerGetLineControlsA(hmix
, &mlcA
, fdwControls
);
1097 if (ret
== MMSYSERR_NOERROR
) {
1098 lpmlc16
->dwLineID
= mlcA
.dwLineID
;
1099 lpmlc16
->u
.dwControlID
= mlcA
.u
.dwControlID
;
1100 lpmlc16
->u
.dwControlType
= mlcA
.u
.dwControlType
;
1101 lpmlc16
->cControls
= mlcA
.cControls
;
1103 lpmc16
= PTR_SEG_TO_LIN(lpmlc16
->pamxctrl
);
1105 for (i
= 0; i
< mlcA
.cControls
; i
++) {
1106 lpmc16
[i
].cbStruct
= sizeof(MIXERCONTROL16
);
1107 lpmc16
[i
].dwControlID
= mlcA
.pamxctrl
[i
].dwControlID
;
1108 lpmc16
[i
].dwControlType
= mlcA
.pamxctrl
[i
].dwControlType
;
1109 lpmc16
[i
].fdwControl
= mlcA
.pamxctrl
[i
].fdwControl
;
1110 lpmc16
[i
].cMultipleItems
= mlcA
.pamxctrl
[i
].cMultipleItems
;
1111 strcpy(lpmc16
[i
].szShortName
, mlcA
.pamxctrl
[i
].szShortName
);
1112 strcpy(lpmc16
[i
].szName
, mlcA
.pamxctrl
[i
].szName
);
1113 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
1114 memcpy(&lpmc16
[i
].Bounds
, &mlcA
.pamxctrl
[i
].Bounds
,
1115 sizeof(mlcA
.pamxctrl
[i
].Bounds
));
1116 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
1117 memcpy(&lpmc16
[i
].Metrics
, &mlcA
.pamxctrl
[i
].Metrics
,
1118 sizeof(mlcA
.pamxctrl
[i
].Metrics
));
1122 HeapFree(GetProcessHeap(), 0, mlcA
.pamxctrl
);
1127 /**************************************************************************
1128 * mixerGetLineInfoA [WINMM.106]
1130 UINT WINAPI
mixerGetLineInfoA(HMIXEROBJ hmix
, LPMIXERLINEA lpmliW
, DWORD fdwInfo
)
1134 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmliW
, fdwInfo
);
1136 if ((lpwm
= MIXER_GetDev(hmix
, fdwInfo
)) == NULL
)
1137 return MMSYSERR_INVALHANDLE
;
1139 return MMDRV_Message(&lpwm
->mld
, MXDM_GETLINEINFO
, (DWORD
)lpmliW
,
1143 /**************************************************************************
1144 * mixerGetLineInfoW [WINMM.107]
1146 UINT WINAPI
mixerGetLineInfoW(HMIXEROBJ hmix
, LPMIXERLINEW lpmliW
,
1152 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmliW
, fdwInfo
);
1154 if (lpmliW
== NULL
|| lpmliW
->cbStruct
!= sizeof(*lpmliW
))
1155 return MMSYSERR_INVALPARAM
;
1157 mliA
.cbStruct
= sizeof(mliA
);
1158 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
1159 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
1160 mliA
.dwComponentType
= lpmliW
->dwComponentType
;
1162 case MIXER_GETLINEINFOF_DESTINATION
:
1163 mliA
.dwDestination
= lpmliW
->dwDestination
;
1165 case MIXER_GETLINEINFOF_LINEID
:
1166 mliA
.dwLineID
= lpmliW
->dwLineID
;
1168 case MIXER_GETLINEINFOF_SOURCE
:
1169 mliA
.dwDestination
= lpmliW
->dwDestination
;
1170 mliA
.dwSource
= lpmliW
->dwSource
;
1172 case MIXER_GETLINEINFOF_TARGETTYPE
:
1173 mliA
.Target
.dwType
= lpmliW
->Target
.dwType
;
1174 mliA
.Target
.wMid
= lpmliW
->Target
.wMid
;
1175 mliA
.Target
.wPid
= lpmliW
->Target
.wPid
;
1176 mliA
.Target
.vDriverVersion
= lpmliW
->Target
.vDriverVersion
;
1177 lstrcpyWtoA(mliA
.Target
.szPname
, lpmliW
->Target
.szPname
);
1180 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo
);
1183 ret
= mixerGetLineInfoA(hmix
, &mliA
, fdwInfo
);
1185 lpmliW
->dwDestination
= mliA
.dwDestination
;
1186 lpmliW
->dwSource
= mliA
.dwSource
;
1187 lpmliW
->dwLineID
= mliA
.dwLineID
;
1188 lpmliW
->fdwLine
= mliA
.fdwLine
;
1189 lpmliW
->dwUser
= mliA
.dwUser
;
1190 lpmliW
->dwComponentType
= mliA
.dwComponentType
;
1191 lpmliW
->cChannels
= mliA
.cChannels
;
1192 lpmliW
->cConnections
= mliA
.cConnections
;
1193 lpmliW
->cControls
= mliA
.cControls
;
1194 lstrcpyAtoW(lpmliW
->szShortName
, mliA
.szShortName
);
1195 lstrcpyAtoW(lpmliW
->szName
, mliA
.szName
);
1196 lpmliW
->Target
.dwType
= mliA
.Target
.dwType
;
1197 lpmliW
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
1198 lpmliW
->Target
.wMid
= mliA
.Target
.wMid
;
1199 lpmliW
->Target
.wPid
= mliA
.Target
.wPid
;
1200 lpmliW
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
1201 lstrcpyAtoW(lpmliW
->Target
.szPname
, mliA
.Target
.szPname
);
1206 /**************************************************************************
1207 * mixerGetLineInfo [MMSYSTEM.805]
1209 UINT16 WINAPI
mixerGetLineInfo16(HMIXEROBJ16 hmix
, LPMIXERLINE16 lpmli16
,
1215 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmli16
, fdwInfo
);
1217 if (lpmli16
== NULL
|| lpmli16
->cbStruct
!= sizeof(*lpmli16
))
1218 return MMSYSERR_INVALPARAM
;
1220 mliA
.cbStruct
= sizeof(mliA
);
1221 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
1222 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
1223 mliA
.dwComponentType
= lpmli16
->dwComponentType
;
1225 case MIXER_GETLINEINFOF_DESTINATION
:
1226 mliA
.dwDestination
= lpmli16
->dwDestination
;
1228 case MIXER_GETLINEINFOF_LINEID
:
1229 mliA
.dwLineID
= lpmli16
->dwLineID
;
1231 case MIXER_GETLINEINFOF_SOURCE
:
1232 mliA
.dwDestination
= lpmli16
->dwDestination
;
1233 mliA
.dwSource
= lpmli16
->dwSource
;
1235 case MIXER_GETLINEINFOF_TARGETTYPE
:
1236 mliA
.Target
.dwType
= lpmli16
->Target
.dwType
;
1237 mliA
.Target
.wMid
= lpmli16
->Target
.wMid
;
1238 mliA
.Target
.wPid
= lpmli16
->Target
.wPid
;
1239 mliA
.Target
.vDriverVersion
= lpmli16
->Target
.vDriverVersion
;
1240 strcpy(mliA
.Target
.szPname
, lpmli16
->Target
.szPname
);
1243 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo
);
1246 ret
= mixerGetLineInfoA(hmix
, &mliA
, fdwInfo
);
1248 lpmli16
->dwDestination
= mliA
.dwDestination
;
1249 lpmli16
->dwSource
= mliA
.dwSource
;
1250 lpmli16
->dwLineID
= mliA
.dwLineID
;
1251 lpmli16
->fdwLine
= mliA
.fdwLine
;
1252 lpmli16
->dwUser
= mliA
.dwUser
;
1253 lpmli16
->dwComponentType
= mliA
.dwComponentType
;
1254 lpmli16
->cChannels
= mliA
.cChannels
;
1255 lpmli16
->cConnections
= mliA
.cConnections
;
1256 lpmli16
->cControls
= mliA
.cControls
;
1257 strcpy(lpmli16
->szShortName
, mliA
.szShortName
);
1258 strcpy(lpmli16
->szName
, mliA
.szName
);
1259 lpmli16
->Target
.dwType
= mliA
.Target
.dwType
;
1260 lpmli16
->Target
.dwDeviceID
= mliA
.Target
.dwDeviceID
;
1261 lpmli16
->Target
.wMid
= mliA
.Target
.wMid
;
1262 lpmli16
->Target
.wPid
= mliA
.Target
.wPid
;
1263 lpmli16
->Target
.vDriverVersion
= mliA
.Target
.vDriverVersion
;
1264 strcpy(lpmli16
->Target
.szPname
, mliA
.Target
.szPname
);
1269 /**************************************************************************
1270 * mixerSetControlDetails [WINMM.111]
1272 UINT WINAPI
mixerSetControlDetails(HMIXEROBJ hmix
, LPMIXERCONTROLDETAILS lpmcdA
,
1277 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcdA
, fdwDetails
);
1279 if ((lpwm
= MIXER_GetDev(hmix
, fdwDetails
)) == NULL
)
1280 return MMSYSERR_INVALHANDLE
;
1282 return MMDRV_Message(&lpwm
->mld
, MXDM_SETCONTROLDETAILS
, (DWORD
)lpmcdA
,
1286 /**************************************************************************
1287 * mixerSetControlDetails [MMSYSTEM.809]
1289 UINT16 WINAPI
mixerSetControlDetails16(HMIXEROBJ16 hmix
,
1290 LPMIXERCONTROLDETAILS16 lpmcd
,
1293 TRACE("(%04x, %p, %08lx)\n", hmix
, lpmcd
, fdwDetails
);
1294 return MMSYSERR_NOTENABLED
;
1297 /**************************************************************************
1298 * mixerMessage [WINMM.109]
1300 UINT WINAPI
mixerMessage(HMIXER hmix
, UINT uMsg
, DWORD dwParam1
, DWORD dwParam2
)
1304 TRACE("(%04lx, %d, %08lx, %08lx): semi-stub?\n",
1305 (DWORD
)hmix
, uMsg
, dwParam1
, dwParam2
);
1307 if ((wmld
= MMDRV_Get(hmix
, MMDRV_MIXER
, FALSE
)) == NULL
)
1308 return MMSYSERR_INVALHANDLE
;
1310 return MMDRV_Message(wmld
, uMsg
, dwParam1
, dwParam2
, TRUE
);
1313 /**************************************************************************
1314 * mixerMessage [MMSYSTEM.804]
1316 UINT16 WINAPI
mixerMessage16(HMIXER16 hmix
, UINT16 uMsg
, DWORD dwParam1
,
1319 return mixerMessage(hmix
, uMsg
, dwParam1
, dwParam2
);
1322 /**************************************************************************
1323 * auxGetNumDevs [WINMM.22]
1325 UINT WINAPI
auxGetNumDevs(void)
1327 return MMDRV_GetNum(MMDRV_AUX
);
1330 /**************************************************************************
1331 * auxGetNumDevs [MMSYSTEM.350]
1333 UINT16 WINAPI
auxGetNumDevs16(void)
1335 return MMDRV_GetNum(MMDRV_AUX
);
1338 /**************************************************************************
1339 * auxGetDevCaps [WINMM.20]
1341 UINT WINAPI
auxGetDevCapsW(UINT uDeviceID
, LPAUXCAPSW lpCaps
, UINT uSize
)
1344 UINT ret
= auxGetDevCapsA(uDeviceID
, &acA
, sizeof(acA
));
1346 lpCaps
->wMid
= acA
.wMid
;
1347 lpCaps
->wPid
= acA
.wPid
;
1348 lpCaps
->vDriverVersion
= acA
.vDriverVersion
;
1349 lstrcpyAtoW(lpCaps
->szPname
, acA
.szPname
);
1350 lpCaps
->wTechnology
= acA
.wTechnology
;
1351 lpCaps
->dwSupport
= acA
.dwSupport
;
1355 /**************************************************************************
1356 * auxGetDevCaps [WINMM.21]
1358 UINT WINAPI
auxGetDevCapsA(UINT uDeviceID
, LPAUXCAPSA lpCaps
, UINT uSize
)
1362 TRACE("(%04X, %p, %d) !\n", uDeviceID
, lpCaps
, uSize
);
1364 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1365 return MMSYSERR_INVALHANDLE
;
1366 return MMDRV_Message(wmld
, AUXDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
1369 /**************************************************************************
1370 * auxGetDevCaps [MMSYSTEM.351]
1372 UINT16 WINAPI
auxGetDevCaps16(UINT16 uDeviceID
, LPAUXCAPS16 lpCaps
, UINT16 uSize
)
1376 TRACE("(%04X, %p, %d) !\n", uDeviceID
, lpCaps
, uSize
);
1378 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1379 return MMSYSERR_INVALHANDLE
;
1380 return MMDRV_Message(wmld
, AUXDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
1383 /**************************************************************************
1384 * auxGetVolume [WINM.23]
1386 UINT WINAPI
auxGetVolume(UINT uDeviceID
, DWORD
* lpdwVolume
)
1390 TRACE("(%04X, %p) !\n", uDeviceID
, lpdwVolume
);
1392 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1393 return MMSYSERR_INVALHANDLE
;
1394 return MMDRV_Message(wmld
, AUXDM_GETVOLUME
, (DWORD
)lpdwVolume
, 0L, TRUE
);
1397 /**************************************************************************
1398 * auxGetVolume [MMSYSTEM.352]
1400 UINT16 WINAPI
auxGetVolume16(UINT16 uDeviceID
, LPDWORD lpdwVolume
)
1404 TRACE("(%04X, %p) !\n", uDeviceID
, lpdwVolume
);
1406 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1407 return MMSYSERR_INVALHANDLE
;
1408 return MMDRV_Message(wmld
, AUXDM_GETVOLUME
, (DWORD
)lpdwVolume
, 0L, TRUE
);
1411 /**************************************************************************
1412 * auxSetVolume [WINMM.25]
1414 UINT WINAPI
auxSetVolume(UINT uDeviceID
, DWORD dwVolume
)
1418 TRACE("(%04X, %lu) !\n", uDeviceID
, dwVolume
);
1420 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1421 return MMSYSERR_INVALHANDLE
;
1422 return MMDRV_Message(wmld
, AUXDM_SETVOLUME
, dwVolume
, 0L, TRUE
);
1425 /**************************************************************************
1426 * auxSetVolume [MMSYSTEM.353]
1428 UINT16 WINAPI
auxSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
1432 TRACE("(%04X, %lu) !\n", uDeviceID
, dwVolume
);
1434 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1435 return MMSYSERR_INVALHANDLE
;
1436 return MMDRV_Message(wmld
, AUXDM_SETVOLUME
, dwVolume
, 0L, TRUE
);
1439 /**************************************************************************
1440 * auxOutMessage [MMSYSTEM.354]
1442 DWORD WINAPI
auxOutMessage(UINT uDeviceID
, UINT uMessage
, DWORD dw1
, DWORD dw2
)
1446 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1447 return MMSYSERR_INVALHANDLE
;
1449 return MMDRV_Message(wmld
, uMessage
, dw1
, dw2
, TRUE
);
1452 /**************************************************************************
1453 * auxOutMessage [MMSYSTEM.354]
1455 DWORD WINAPI
auxOutMessage16(UINT16 uDeviceID
, UINT16 uMessage
, DWORD dw1
, DWORD dw2
)
1459 TRACE("(%04X, %04X, %08lX, %08lX)\n", uDeviceID
, uMessage
, dw1
, dw2
);
1462 case AUXDM_GETNUMDEVS
:
1463 case AUXDM_SETVOLUME
:
1464 /* no argument conversion needed */
1466 case AUXDM_GETVOLUME
:
1467 return auxGetVolume16(uDeviceID
, (LPDWORD
)PTR_SEG_TO_LIN(dw1
));
1468 case AUXDM_GETDEVCAPS
:
1469 return auxGetDevCaps16(uDeviceID
, (LPAUXCAPS16
)PTR_SEG_TO_LIN(dw1
), dw2
);
1471 TRACE("(%04x, %04x, %08lx, %08lx): unhandled message\n",
1472 uDeviceID
, uMessage
, dw1
, dw2
);
1475 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_AUX
, TRUE
)) == NULL
)
1476 return MMSYSERR_INVALHANDLE
;
1478 return MMDRV_Message(wmld
, uMessage
, dw1
, dw2
, TRUE
);
1481 /**************************************************************************
1482 * mciGetErrorStringW [WINMM.46]
1484 BOOL WINAPI
mciGetErrorStringW(DWORD wError
, LPWSTR lpstrBuffer
, UINT uLength
)
1486 LPSTR bufstr
= HeapAlloc(GetProcessHeap(), 0, uLength
);
1487 BOOL ret
= mciGetErrorStringA(wError
, bufstr
, uLength
);
1489 lstrcpyAtoW(lpstrBuffer
, bufstr
);
1490 HeapFree(GetProcessHeap(), 0, bufstr
);
1494 /**************************************************************************
1495 * mciGetErrorStringA [WINMM.45]
1497 BOOL WINAPI
mciGetErrorStringA(DWORD wError
, LPSTR lpstrBuffer
, UINT uLength
)
1499 return mciGetErrorString16(wError
, lpstrBuffer
, uLength
);
1502 /**************************************************************************
1503 * mciGetErrorString [MMSYSTEM.706]
1505 BOOL16 WINAPI
mciGetErrorString16(DWORD dwError
, LPSTR lpstrBuffer
, UINT16 uLength
)
1509 if (lpstrBuffer
!= NULL
&& uLength
> 0 &&
1510 dwError
>= MCIERR_BASE
&& dwError
<= MCIERR_CUSTOM_DRIVER_BASE
) {
1512 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance
,
1513 dwError
, lpstrBuffer
, uLength
) > 0) {
1520 /**************************************************************************
1521 * mciDriverNotify [MMSYSTEM.711]
1523 BOOL16 WINAPI
mciDriverNotify16(HWND16 hWndCallBack
, UINT16 wDevID
, UINT16 wStatus
)
1525 TRACE("(%04X, %04x, %04X)\n", hWndCallBack
, wDevID
, wStatus
);
1527 if (!IsWindow(hWndCallBack
)) {
1528 WARN("bad hWnd for call back (0x%04x)\n", hWndCallBack
);
1531 TRACE("before PostMessage\n");
1532 Callout
.PostMessageA(hWndCallBack
, MM_MCINOTIFY
, wStatus
, wDevID
);
1536 /**************************************************************************
1537 * mciDriverNotify [WINMM.36]
1539 BOOL WINAPI
mciDriverNotify(HWND hWndCallBack
, UINT wDevID
, UINT wStatus
)
1542 TRACE("(%08X, %04x, %04X)\n", hWndCallBack
, wDevID
, wStatus
);
1544 if (!IsWindow(hWndCallBack
)) {
1545 WARN("bad hWnd for call back (0x%04x)\n", hWndCallBack
);
1548 TRACE("before PostMessage\n");
1549 Callout
.PostMessageA(hWndCallBack
, MM_MCINOTIFY
, wStatus
, wDevID
);
1553 /**************************************************************************
1554 * mciGetDriverData [MMSYSTEM.708]
1556 DWORD WINAPI
mciGetDriverData16(UINT16 uDeviceID
)
1558 return mciGetDriverData(uDeviceID
);
1561 /**************************************************************************
1562 * mciGetDriverData [WINMM.44]
1564 DWORD WINAPI
mciGetDriverData(UINT uDeviceID
)
1566 LPWINE_MCIDRIVER wmd
;
1568 TRACE("(%04x)\n", uDeviceID
);
1570 wmd
= MCI_GetDriver(uDeviceID
);
1573 WARN("Bad uDeviceID\n");
1577 return wmd
->dwPrivate
;
1580 /**************************************************************************
1581 * mciSetDriverData [MMSYSTEM.707]
1583 BOOL16 WINAPI
mciSetDriverData16(UINT16 uDeviceID
, DWORD data
)
1585 return mciSetDriverData(uDeviceID
, data
);
1588 /**************************************************************************
1589 * mciSetDriverData [WINMM.53]
1591 BOOL WINAPI
mciSetDriverData(UINT uDeviceID
, DWORD data
)
1593 LPWINE_MCIDRIVER wmd
;
1595 TRACE("(%04x, %08lx)\n", uDeviceID
, data
);
1597 wmd
= MCI_GetDriver(uDeviceID
);
1600 WARN("Bad uDeviceID\n");
1604 wmd
->dwPrivate
= data
;
1608 /**************************************************************************
1609 * mciSendCommandA [WINMM.49]
1611 DWORD WINAPI
mciSendCommandA(UINT wDevID
, UINT wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1615 TRACE("(%08x, %s, %08lx, %08lx)\n",
1616 wDevID
, MCI_MessageToString(wMsg
), dwParam1
, dwParam2
);
1618 dwRet
= MCI_SendCommand(wDevID
, wMsg
, dwParam1
, dwParam2
, TRUE
);
1619 dwRet
= MCI_CleanUp(dwRet
, wMsg
, dwParam2
, TRUE
);
1620 TRACE("=> %08lx\n", dwRet
);
1624 /**************************************************************************
1625 * mciSendCommandW [WINMM.50]
1627 DWORD WINAPI
mciSendCommandW(UINT wDevID
, UINT wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1629 FIXME("(%08x, %s, %08lx, %08lx): stub\n",
1630 wDevID
, MCI_MessageToString(wMsg
), dwParam1
, dwParam2
);
1631 return MCIERR_UNSUPPORTED_FUNCTION
;
1634 /**************************************************************************
1635 * mciSendCommand [MMSYSTEM.701]
1637 DWORD WINAPI
mciSendCommand16(UINT16 wDevID
, UINT16 wMsg
, DWORD dwParam1
, DWORD dwParam2
)
1641 TRACE("(%04X, %s, %08lX, %08lX)\n",
1642 wDevID
, MCI_MessageToString(wMsg
), dwParam1
, dwParam2
);
1644 dwRet
= MCI_SendCommand(wDevID
, wMsg
, dwParam1
, dwParam2
, FALSE
);
1645 dwRet
= MCI_CleanUp(dwRet
, wMsg
, dwParam2
, FALSE
);
1646 TRACE("=> %ld\n", dwRet
);
1650 /**************************************************************************
1651 * mciGetDeviceID [MMSYSTEM.703]
1653 UINT16 WINAPI
mciGetDeviceID16(LPCSTR lpstrName
)
1655 TRACE("(\"%s\")\n", lpstrName
);
1657 return MCI_GetDriverFromString(lpstrName
);
1660 /**************************************************************************
1661 * mciGetDeviceIDA [WINMM.41]
1663 UINT WINAPI
mciGetDeviceIDA(LPCSTR lpstrName
)
1665 return MCI_GetDriverFromString(lpstrName
);
1668 /**************************************************************************
1669 * mciGetDeviceIDW [WINMM.43]
1671 UINT WINAPI
mciGetDeviceIDW(LPCWSTR lpwstrName
)
1676 lpstrName
= HEAP_strdupWtoA(GetProcessHeap(), 0, lpwstrName
);
1677 ret
= MCI_GetDriverFromString(lpstrName
);
1678 HeapFree(GetProcessHeap(), 0, lpstrName
);
1682 /**************************************************************************
1683 * MCI_DefYieldProc [internal]
1685 UINT16 WINAPI
MCI_DefYieldProc(UINT16 wDevID
, DWORD data
)
1689 TRACE("(0x%04x, 0x%08lx)\n", wDevID
, data
);
1691 if ((HIWORD(data
) != 0 && GetActiveWindow16() != HIWORD(data
)) ||
1692 (GetAsyncKeyState(LOWORD(data
)) & 1) == 0) {
1698 msg
.hwnd
= HIWORD(data
);
1699 while (!PeekMessageA(&msg
, HIWORD(data
), WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
));
1705 /**************************************************************************
1706 * mciSetYieldProc [MMSYSTEM.714]
1708 BOOL16 WINAPI
mciSetYieldProc16(UINT16 uDeviceID
, YIELDPROC fpYieldProc
, DWORD dwYieldData
)
1710 LPWINE_MCIDRIVER wmd
;
1712 TRACE("(%u, %p, %08lx)\n", uDeviceID
, fpYieldProc
, dwYieldData
);
1714 if (!(wmd
= MCI_GetDriver(uDeviceID
))) {
1715 WARN("Bad uDeviceID\n");
1719 wmd
->lpfnYieldProc
= fpYieldProc
;
1720 wmd
->dwYieldData
= dwYieldData
;
1726 /**************************************************************************
1727 * mciSetYieldProc [WINMM.54]
1729 BOOL WINAPI
mciSetYieldProc(UINT uDeviceID
, YIELDPROC fpYieldProc
, DWORD dwYieldData
)
1731 LPWINE_MCIDRIVER wmd
;
1733 TRACE("(%u, %p, %08lx)\n", uDeviceID
, fpYieldProc
, dwYieldData
);
1735 if (!(wmd
= MCI_GetDriver(uDeviceID
))) {
1736 WARN("Bad uDeviceID\n");
1740 wmd
->lpfnYieldProc
= fpYieldProc
;
1741 wmd
->dwYieldData
= dwYieldData
;
1747 /**************************************************************************
1748 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
1750 UINT16 WINAPI
mciGetDeviceIDFromElementID16(DWORD dwElementID
, LPCSTR lpstrType
)
1752 FIXME("(%lu, %s) stub\n", dwElementID
, lpstrType
);
1756 /**************************************************************************
1757 * mciGetDeviceIDFromElementIDW [WINMM.42]
1759 UINT WINAPI
mciGetDeviceIDFromElementIDW(DWORD dwElementID
, LPCWSTR lpstrType
)
1761 /* FIXME: that's rather strange, there is no
1762 * mciGetDeviceIDFromElementID32A in winmm.spec
1764 FIXME("(%lu, %p) stub\n", dwElementID
, lpstrType
);
1768 /**************************************************************************
1769 * mciGetYieldProc [MMSYSTEM.716]
1771 YIELDPROC WINAPI
mciGetYieldProc16(UINT16 uDeviceID
, DWORD
* lpdwYieldData
)
1773 LPWINE_MCIDRIVER wmd
;
1775 TRACE("(%u, %p)\n", uDeviceID
, lpdwYieldData
);
1777 if (!(wmd
= MCI_GetDriver(uDeviceID
))) {
1778 WARN("Bad uDeviceID\n");
1781 if (!wmd
->lpfnYieldProc
) {
1782 WARN("No proc set\n");
1786 WARN("Proc is 32 bit\n");
1789 return wmd
->lpfnYieldProc
;
1792 /**************************************************************************
1793 * mciGetYieldProc [WINMM.47]
1795 YIELDPROC WINAPI
mciGetYieldProc(UINT uDeviceID
, DWORD
* lpdwYieldData
)
1797 LPWINE_MCIDRIVER wmd
;
1799 TRACE("(%u, %p)\n", uDeviceID
, lpdwYieldData
);
1801 if (!(wmd
= MCI_GetDriver(uDeviceID
))) {
1802 WARN("Bad uDeviceID\n");
1805 if (!wmd
->lpfnYieldProc
) {
1806 WARN("No proc set\n");
1810 WARN("Proc is 32 bit\n");
1813 return wmd
->lpfnYieldProc
;
1816 /**************************************************************************
1817 * mciGetCreatorTask [MMSYSTEM.717]
1819 HTASK16 WINAPI
mciGetCreatorTask16(UINT16 uDeviceID
)
1821 return mciGetCreatorTask(uDeviceID
);
1824 /**************************************************************************
1825 * mciGetCreatorTask [WINMM.40]
1827 HTASK WINAPI
mciGetCreatorTask(UINT uDeviceID
)
1829 LPWINE_MCIDRIVER wmd
;
1832 TRACE("(%u)\n", uDeviceID
);
1834 ret
= (!(wmd
= MCI_GetDriver(uDeviceID
))) ? 0 : wmd
->hCreatorTask
;
1836 TRACE("=> %04x\n", ret
);
1840 /**************************************************************************
1841 * mciDriverYield [MMSYSTEM.710]
1843 UINT16 WINAPI
mciDriverYield16(UINT16 uDeviceID
)
1845 LPWINE_MCIDRIVER wmd
;
1848 /* TRACE("(%04x)\n", uDeviceID); */
1850 if (!(wmd
= MCI_GetDriver(uDeviceID
)) || !wmd
->lpfnYieldProc
|| wmd
->bIs32
) {
1853 ret
= wmd
->lpfnYieldProc(uDeviceID
, wmd
->dwYieldData
);
1859 /**************************************************************************
1860 * mciDriverYield [WINMM.37]
1862 UINT WINAPI
mciDriverYield(UINT uDeviceID
)
1864 LPWINE_MCIDRIVER wmd
;
1867 TRACE("(%04x)\n", uDeviceID
);
1869 if (!(wmd
= MCI_GetDriver(uDeviceID
)) || !wmd
->lpfnYieldProc
|| !wmd
->bIs32
) {
1872 ret
= wmd
->lpfnYieldProc(uDeviceID
, wmd
->dwYieldData
);
1878 /**************************************************************************
1879 * midiOutGetNumDevs [WINMM.80]
1881 UINT WINAPI
midiOutGetNumDevs(void)
1883 return MMDRV_GetNum(MMDRV_MIDIOUT
);
1886 /**************************************************************************
1887 * midiOutGetNumDevs [MMSYSTEM.201]
1889 UINT16 WINAPI
midiOutGetNumDevs16(void)
1891 return MMDRV_GetNum(MMDRV_MIDIOUT
);
1894 /**************************************************************************
1895 * midiOutGetDevCapsW [WINMM.76]
1897 UINT WINAPI
midiOutGetDevCapsW(UINT uDeviceID
, LPMIDIOUTCAPSW lpCaps
,
1903 ret
= midiOutGetDevCapsA(uDeviceID
, &mocA
, sizeof(mocA
));
1904 lpCaps
->wMid
= mocA
.wMid
;
1905 lpCaps
->wPid
= mocA
.wPid
;
1906 lpCaps
->vDriverVersion
= mocA
.vDriverVersion
;
1907 lstrcpyAtoW(lpCaps
->szPname
, mocA
.szPname
);
1908 lpCaps
->wTechnology
= mocA
.wTechnology
;
1909 lpCaps
->wVoices
= mocA
.wVoices
;
1910 lpCaps
->wNotes
= mocA
.wNotes
;
1911 lpCaps
->wChannelMask
= mocA
.wChannelMask
;
1912 lpCaps
->dwSupport
= mocA
.dwSupport
;
1916 /**************************************************************************
1917 * midiOutGetDevCapsA [WINMM.75]
1919 UINT WINAPI
midiOutGetDevCapsA(UINT uDeviceID
, LPMIDIOUTCAPSA lpCaps
,
1924 TRACE("(%u, %p, %u);\n", uDeviceID
, lpCaps
, uSize
);
1926 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1928 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIOUT
, TRUE
)) == NULL
)
1929 return MMSYSERR_INVALHANDLE
;
1931 return MMDRV_Message(wmld
, MODM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
1934 /**************************************************************************
1935 * midiOutGetDevCaps [MMSYSTEM.202]
1937 UINT16 WINAPI
midiOutGetDevCaps16(UINT16 uDeviceID
, LPMIDIOUTCAPS16 lpCaps
,
1943 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
1945 dwRet
= midiOutGetDevCapsA(uDeviceID
, &capsA
, sizeof(capsA
));
1946 if (dwRet
== MMSYSERR_NOERROR
) {
1947 lpCaps
->wMid
= capsA
.wMid
;
1948 lpCaps
->wPid
= capsA
.wPid
;
1949 lpCaps
->vDriverVersion
= capsA
.vDriverVersion
;
1950 strcpy(lpCaps
->szPname
, capsA
.szPname
);
1951 lpCaps
->wTechnology
= capsA
.wTechnology
;
1952 lpCaps
->wVoices
= capsA
.wVoices
;
1953 lpCaps
->wNotes
= capsA
.wNotes
;
1954 lpCaps
->wChannelMask
= capsA
.wChannelMask
;
1955 lpCaps
->dwSupport
= capsA
.dwSupport
;
1960 /**************************************************************************
1961 * MIDI_GetErrorText [internal]
1963 static UINT16
MIDI_GetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
1965 UINT16 ret
= MMSYSERR_BADERRNUM
;
1967 if (lpText
== NULL
) {
1968 ret
= MMSYSERR_INVALPARAM
;
1969 } else if (uSize
== 0) {
1970 ret
= MMSYSERR_NOERROR
;
1972 /* test has been removed 'coz MMSYSERR_BASE is 0, and gcc did emit
1973 * a warning for the test was always true */
1974 (/*uError >= MMSYSERR_BASE && */ uError
<= MMSYSERR_LASTERROR
) ||
1975 (uError
>= MIDIERR_BASE
&& uError
<= MIDIERR_LASTERROR
)) {
1977 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance
,
1978 uError
, lpText
, uSize
) > 0) {
1979 ret
= MMSYSERR_NOERROR
;
1985 /**************************************************************************
1986 * midiOutGetErrorTextA [WINMM.77]
1988 UINT WINAPI
midiOutGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
1990 return MIDI_GetErrorText(uError
, lpText
, uSize
);
1993 /**************************************************************************
1994 * midiOutGetErrorTextW [WINMM.78]
1996 UINT WINAPI
midiOutGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
1998 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
2001 ret
= MIDI_GetErrorText(uError
, xstr
, uSize
);
2002 lstrcpyAtoW(lpText
, xstr
);
2003 HeapFree(GetProcessHeap(), 0, xstr
);
2007 /**************************************************************************
2008 * midiOutGetErrorText [MMSYSTEM.203]
2010 UINT16 WINAPI
midiOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2012 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2015 /**************************************************************************
2016 * MIDI_OutAlloc [internal]
2018 static LPWINE_MIDI
MIDI_OutAlloc(HMIDIOUT
* lphMidiOut
, LPDWORD lpdwCallback
,
2019 LPDWORD lpdwInstance
, LPDWORD lpdwFlags
,
2020 DWORD cIDs
, MIDIOPENSTRMID
* lpIDs
, BOOL bFrom32
)
2026 size
= sizeof(WINE_MIDI
) + (cIDs
? (cIDs
-1) : 0) * sizeof(MIDIOPENSTRMID
);
2028 lpwm
= (LPWINE_MIDI
)MMDRV_Alloc(size
, MMDRV_MIDIOUT
, &hMidiOut
, lpdwFlags
,
2029 lpdwCallback
, lpdwInstance
, bFrom32
);
2031 if (lphMidiOut
!= NULL
)
2032 *lphMidiOut
= hMidiOut
;
2035 lpwm
->mod
.hMidi
= hMidiOut
;
2036 lpwm
->mod
.dwCallback
= *lpdwCallback
;
2037 lpwm
->mod
.dwInstance
= *lpdwInstance
;
2038 lpwm
->mod
.dnDevNode
= 0;
2039 lpwm
->mod
.cIds
= cIDs
;
2041 memcpy(&(lpwm
->mod
.rgIds
), lpIDs
, cIDs
* sizeof(MIDIOPENSTRMID
));
2046 UINT
MMSYSTEM_midiOutOpen(HMIDIOUT
* lphMidiOut
, UINT uDeviceID
, DWORD dwCallback
,
2047 DWORD dwInstance
, DWORD dwFlags
, BOOL bFrom32
)
2053 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2054 lphMidiOut
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
2056 if (lphMidiOut
!= NULL
) *lphMidiOut
= 0;
2058 lpwm
= MIDI_OutAlloc(&hMidiOut
, &dwCallback
, &dwInstance
, &dwFlags
,
2062 return MMSYSERR_NOMEM
;
2064 lpwm
->mld
.uDeviceID
= uDeviceID
;
2066 dwRet
= MMDRV_Open((LPWINE_MLD
)lpwm
, MODM_OPEN
, (DWORD
)&lpwm
->mod
,
2069 if (dwRet
!= MMSYSERR_NOERROR
) {
2070 MMDRV_Free(hMidiOut
, (LPWINE_MLD
)lpwm
);
2074 if (lphMidiOut
) *lphMidiOut
= hMidiOut
;
2075 TRACE("=> %d hMidi=%04x\n", dwRet
, hMidiOut
);
2080 /**************************************************************************
2081 * midiOutOpen [WINM.84]
2083 UINT WINAPI
midiOutOpen(HMIDIOUT
* lphMidiOut
, UINT uDeviceID
,
2084 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2086 return MMSYSTEM_midiOutOpen(lphMidiOut
, uDeviceID
, dwCallback
,
2087 dwInstance
, dwFlags
, TRUE
);
2090 /**************************************************************************
2091 * midiOutOpen [MMSYSTEM.204]
2093 UINT16 WINAPI
midiOutOpen16(HMIDIOUT16
* lphMidiOut
, UINT16 uDeviceID
,
2094 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2099 ret
= MMSYSTEM_midiOutOpen(&hmo
, uDeviceID
, dwCallback
, dwInstance
,
2102 if (lphMidiOut
!= NULL
) *lphMidiOut
= hmo
;
2106 /**************************************************************************
2107 * midiOutClose [WINMM.74]
2109 UINT WINAPI
midiOutClose(HMIDIOUT hMidiOut
)
2114 TRACE("(%04X)\n", hMidiOut
);
2116 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2117 return MMSYSERR_INVALHANDLE
;
2119 dwRet
= MMDRV_Close(wmld
, MODM_CLOSE
);
2120 MMDRV_Free(hMidiOut
, wmld
);
2125 /**************************************************************************
2126 * midiOutClose [MMSYSTEM.205]
2128 UINT16 WINAPI
midiOutClose16(HMIDIOUT16 hMidiOut
)
2130 return midiOutClose(hMidiOut
);
2133 /**************************************************************************
2134 * midiOutPrepareHeader [WINMM.85]
2136 UINT WINAPI
midiOutPrepareHeader(HMIDIOUT hMidiOut
,
2137 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2141 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2143 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2144 return MMSYSERR_INVALHANDLE
;
2146 return MMDRV_Message(wmld
, MODM_PREPARE
, (DWORD
)lpMidiOutHdr
, uSize
, TRUE
);
2149 /**************************************************************************
2150 * midiOutPrepareHeader [MMSYSTEM.206]
2152 UINT16 WINAPI
midiOutPrepareHeader16(HMIDIOUT16 hMidiOut
,
2153 LPMIDIHDR16
/*SEGPTR*/ lpsegMidiOutHdr
,
2157 LPMIDIHDR16 lpMidiOutHdr
= PTR_SEG_TO_LIN(lpsegMidiOutHdr
);
2159 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2161 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2162 return MMSYSERR_INVALHANDLE
;
2164 return MMDRV_Message(wmld
, MODM_PREPARE
, (DWORD
)lpMidiOutHdr
, uSize
, FALSE
);
2167 /**************************************************************************
2168 * midiOutUnprepareHeader [WINMM.89]
2170 UINT WINAPI
midiOutUnprepareHeader(HMIDIOUT hMidiOut
,
2171 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2175 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2177 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
2178 return MMSYSERR_NOERROR
;
2181 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2182 return MMSYSERR_INVALHANDLE
;
2184 return MMDRV_Message(wmld
, MODM_UNPREPARE
, (DWORD
)lpMidiOutHdr
, uSize
, TRUE
);
2187 /**************************************************************************
2188 * midiOutUnprepareHeader [MMSYSTEM.207]
2190 UINT16 WINAPI
midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut
,
2191 LPMIDIHDR16
/*SEGPTR*/ lpsegMidiOutHdr
,
2195 LPMIDIHDR16 lpMidiOutHdr
= PTR_SEG_TO_LIN(lpsegMidiOutHdr
);
2197 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2199 if (!(lpMidiOutHdr
->dwFlags
& MHDR_PREPARED
)) {
2200 return MMSYSERR_NOERROR
;
2203 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2204 return MMSYSERR_INVALHANDLE
;
2206 return MMDRV_Message(wmld
, MODM_UNPREPARE
, (DWORD
)lpsegMidiOutHdr
, uSize
, FALSE
);
2209 /**************************************************************************
2210 * midiOutShortMsg [WINMM.88]
2212 UINT WINAPI
midiOutShortMsg(HMIDIOUT hMidiOut
, DWORD dwMsg
)
2216 TRACE("(%04X, %08lX)\n", hMidiOut
, dwMsg
);
2218 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2219 return MMSYSERR_INVALHANDLE
;
2221 return MMDRV_Message(wmld
, MODM_DATA
, dwMsg
, 0L, FALSE
);
2224 /**************************************************************************
2225 * midiOutShortMsg [MMSYSTEM.208]
2227 UINT16 WINAPI
midiOutShortMsg16(HMIDIOUT16 hMidiOut
, DWORD dwMsg
)
2229 return midiOutShortMsg(hMidiOut
, dwMsg
);
2232 /**************************************************************************
2233 * midiOutLongMsg [WINMM.82]
2235 UINT WINAPI
midiOutLongMsg(HMIDIOUT hMidiOut
,
2236 MIDIHDR
* lpMidiOutHdr
, UINT uSize
)
2240 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpMidiOutHdr
, uSize
);
2242 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2243 return MMSYSERR_INVALHANDLE
;
2245 return MMDRV_Message(wmld
, MODM_LONGDATA
, (DWORD
)lpMidiOutHdr
, uSize
, TRUE
);
2248 /**************************************************************************
2249 * midiOutLongMsg [MMSYSTEM.209]
2251 UINT16 WINAPI
midiOutLongMsg16(HMIDIOUT16 hMidiOut
,
2252 LPMIDIHDR16
/* SEGPTR */ lpsegMidiOutHdr
,
2257 TRACE("(%04X, %p, %d)\n", hMidiOut
, lpsegMidiOutHdr
, uSize
);
2259 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2260 return MMSYSERR_INVALHANDLE
;
2262 return MMDRV_Message(wmld
, MODM_LONGDATA
, (DWORD
)lpsegMidiOutHdr
, uSize
, FALSE
);
2265 /**************************************************************************
2266 * midiOutReset [WINMM.86]
2268 UINT WINAPI
midiOutReset(HMIDIOUT hMidiOut
)
2272 TRACE("(%04X)\n", hMidiOut
);
2274 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2275 return MMSYSERR_INVALHANDLE
;
2277 return MMDRV_Message(wmld
, MODM_RESET
, 0L, 0L, TRUE
);
2280 /**************************************************************************
2281 * midiOutReset [MMSYSTEM.210]
2283 UINT16 WINAPI
midiOutReset16(HMIDIOUT16 hMidiOut
)
2285 return midiOutReset(hMidiOut
);
2288 /**************************************************************************
2289 * midiOutGetVolume [WINM.81]
2291 UINT WINAPI
midiOutGetVolume(UINT uDeviceID
, DWORD
* lpdwVolume
)
2295 TRACE("(%04X, %p);\n", uDeviceID
, lpdwVolume
);
2297 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIOUT
, TRUE
)) == NULL
)
2298 return MMSYSERR_INVALHANDLE
;
2300 return MMDRV_Message(wmld
, MODM_GETVOLUME
, (DWORD
)lpdwVolume
, 0L, TRUE
);
2303 /**************************************************************************
2304 * midiOutGetVolume [MMSYSTEM.211]
2306 UINT16 WINAPI
midiOutGetVolume16(UINT16 uDeviceID
, DWORD
* lpdwVolume
)
2308 return midiOutGetVolume(uDeviceID
, lpdwVolume
);
2311 /**************************************************************************
2312 * midiOutSetVolume [WINMM.87]
2314 UINT WINAPI
midiOutSetVolume(UINT uDeviceID
, DWORD dwVolume
)
2318 TRACE("(%04X, %ld);\n", uDeviceID
, dwVolume
);
2320 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIOUT
, TRUE
)) == NULL
)
2321 return MMSYSERR_INVALHANDLE
;
2323 return MMDRV_Message(wmld
, MODM_SETVOLUME
, dwVolume
, 0L, TRUE
);
2326 /**************************************************************************
2327 * midiOutSetVolume [MMSYSTEM.212]
2329 UINT16 WINAPI
midiOutSetVolume16(UINT16 uDeviceID
, DWORD dwVolume
)
2331 return midiOutSetVolume(uDeviceID
, dwVolume
);
2334 /**************************************************************************
2335 * midiOutCachePatches [WINMM.73]
2337 UINT WINAPI
midiOutCachePatches(HMIDIOUT hMidiOut
, UINT uBank
,
2338 WORD
* lpwPatchArray
, UINT uFlags
)
2340 /* not really necessary to support this */
2341 FIXME("not supported yet\n");
2342 return MMSYSERR_NOTSUPPORTED
;
2345 /**************************************************************************
2346 * midiOutCachePatches [MMSYSTEM.213]
2348 UINT16 WINAPI
midiOutCachePatches16(HMIDIOUT16 hMidiOut
, UINT16 uBank
,
2349 WORD
* lpwPatchArray
, UINT16 uFlags
)
2351 return midiOutCachePatches(hMidiOut
, uBank
, lpwPatchArray
, uFlags
);
2354 /**************************************************************************
2355 * midiOutCacheDrumPatches [WINMM.72]
2357 UINT WINAPI
midiOutCacheDrumPatches(HMIDIOUT hMidiOut
, UINT uPatch
,
2358 WORD
* lpwKeyArray
, UINT uFlags
)
2360 FIXME("not supported yet\n");
2361 return MMSYSERR_NOTSUPPORTED
;
2364 /**************************************************************************
2365 * midiOutCacheDrumPatches [MMSYSTEM.214]
2367 UINT16 WINAPI
midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut
, UINT16 uPatch
,
2368 WORD
* lpwKeyArray
, UINT16 uFlags
)
2370 return midiOutCacheDrumPatches16(hMidiOut
, uPatch
, lpwKeyArray
, uFlags
);
2373 /**************************************************************************
2374 * midiOutGetID [WINMM.79]
2376 UINT WINAPI
midiOutGetID(HMIDIOUT hMidiOut
, UINT
* lpuDeviceID
)
2380 TRACE("(%04X, %p)\n", hMidiOut
, lpuDeviceID
);
2382 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2383 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2384 return MMSYSERR_INVALHANDLE
;
2386 *lpuDeviceID
= wmld
->uDeviceID
;
2387 return MMSYSERR_NOERROR
;
2390 /**************************************************************************
2391 * midiOutGetID [MMSYSTEM.215]
2393 UINT16 WINAPI
midiOutGetID16(HMIDIOUT16 hMidiOut
, UINT16
* lpuDeviceID
)
2397 TRACE("(%04X, %p)\n", hMidiOut
, lpuDeviceID
);
2399 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2400 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2401 return MMSYSERR_INVALHANDLE
;
2403 *lpuDeviceID
= wmld
->uDeviceID
;
2404 return MMSYSERR_NOERROR
;
2407 /**************************************************************************
2408 * midiOutMessage [WINMM.83]
2410 DWORD WINAPI
midiOutMessage(HMIDIOUT hMidiOut
, UINT uMessage
,
2411 DWORD dwParam1
, DWORD dwParam2
)
2415 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2417 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2418 return MMSYSERR_INVALHANDLE
;
2423 FIXME("can't handle OPEN or CLOSE message!\n");
2424 return MMSYSERR_NOTSUPPORTED
;
2426 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2429 /**************************************************************************
2430 * midiOutMessage [MMSYSTEM.216]
2432 DWORD WINAPI
midiOutMessage16(HMIDIOUT16 hMidiOut
, UINT16 uMessage
,
2433 DWORD dwParam1
, DWORD dwParam2
)
2437 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut
, uMessage
, dwParam1
, dwParam2
);
2439 if ((wmld
= MMDRV_Get(hMidiOut
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
2440 return MMSYSERR_INVALHANDLE
;
2445 FIXME("can't handle OPEN or CLOSE message!\n");
2446 return MMSYSERR_NOTSUPPORTED
;
2448 case MODM_GETVOLUME
:
2449 return midiOutGetVolume16(hMidiOut
, (LPDWORD
)PTR_SEG_TO_LIN(dwParam1
));
2451 return midiOutLongMsg16(hMidiOut
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2453 /* lpMidiOutHdr is still a segmented pointer for this function */
2454 return midiOutPrepareHeader16(hMidiOut
, (LPMIDIHDR16
)dwParam1
, dwParam2
);
2455 case MODM_UNPREPARE
:
2456 return midiOutUnprepareHeader16(hMidiOut
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2458 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2461 /**************************************************************************
2462 * midiInGetNumDevs [WINMM.64]
2464 UINT WINAPI
midiInGetNumDevs(void)
2466 return MMDRV_GetNum(MMDRV_MIDIIN
);
2469 /**************************************************************************
2470 * midiInGetNumDevs [MMSYSTEM.301]
2472 UINT16 WINAPI
midiInGetNumDevs16(void)
2474 return MMDRV_GetNum(MMDRV_MIDIIN
);
2477 /**************************************************************************
2478 * midiInGetDevCaps [WINMM.60]
2480 UINT WINAPI
midiInGetDevCapsW(UINT uDeviceID
, LPMIDIINCAPSW lpCaps
, UINT uSize
)
2483 UINT ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
2485 if (ret
== MMSYSERR_NOERROR
) {
2486 lpCaps
->wMid
= micA
.wMid
;
2487 lpCaps
->wPid
= micA
.wPid
;
2488 lpCaps
->vDriverVersion
= micA
.vDriverVersion
;
2489 lstrcpyAtoW(lpCaps
->szPname
, micA
.szPname
);
2490 lpCaps
->dwSupport
= micA
.dwSupport
;
2495 /**************************************************************************
2496 * midiInGetDevCaps [WINMM.59]
2498 UINT WINAPI
midiInGetDevCapsA(UINT uDeviceID
, LPMIDIINCAPSA lpCaps
, UINT uSize
)
2502 TRACE("(%d, %p, %d);\n", uDeviceID
, lpCaps
, uSize
);
2504 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2505 return MMSYSERR_INVALHANDLE
;
2507 return MMDRV_Message(wmld
, MIDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
2510 /**************************************************************************
2511 * midiInGetDevCaps [MMSYSTEM.302]
2513 UINT16 WINAPI
midiInGetDevCaps16(UINT16 uDeviceID
, LPMIDIINCAPS16 lpCaps
,
2517 UINT ret
= midiInGetDevCapsA(uDeviceID
, &micA
, uSize
);
2519 if (ret
== MMSYSERR_NOERROR
) {
2520 lpCaps
->wMid
= micA
.wMid
;
2521 lpCaps
->wPid
= micA
.wPid
;
2522 lpCaps
->vDriverVersion
= micA
.vDriverVersion
;
2523 strcpy(lpCaps
->szPname
, micA
.szPname
);
2524 lpCaps
->dwSupport
= micA
.dwSupport
;
2530 /**************************************************************************
2531 * midiInGetErrorText [WINMM.62]
2533 UINT WINAPI
midiInGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
2535 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
2536 UINT ret
= MIDI_GetErrorText(uError
, xstr
, uSize
);
2538 lstrcpyAtoW(lpText
, xstr
);
2539 HeapFree(GetProcessHeap(), 0, xstr
);
2543 /**************************************************************************
2544 * midiInGetErrorText [WINMM.61]
2546 UINT WINAPI
midiInGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
2548 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2551 /**************************************************************************
2552 * midiInGetErrorText [MMSYSTEM.303]
2554 UINT16 WINAPI
midiInGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
2556 return MIDI_GetErrorText(uError
, lpText
, uSize
);
2559 static UINT
MMSYSTEM_midiInOpen(HMIDIIN
* lphMidiIn
, UINT uDeviceID
, DWORD dwCallback
,
2560 DWORD dwInstance
, DWORD dwFlags
, BOOL bFrom32
)
2566 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2567 lphMidiIn
, uDeviceID
, dwCallback
, dwInstance
, dwFlags
);
2569 if (lphMidiIn
!= NULL
) *lphMidiIn
= 0;
2571 lpwm
= (LPWINE_MIDI
)MMDRV_Alloc(sizeof(WINE_MIDI
), MMDRV_MIDIIN
, &hMidiIn
,
2572 &dwFlags
, &dwCallback
, &dwInstance
, bFrom32
);
2575 return MMSYSERR_NOMEM
;
2577 lpwm
->mod
.hMidi
= hMidiIn
;
2578 lpwm
->mod
.dwCallback
= dwCallback
;
2579 lpwm
->mod
.dwInstance
= dwInstance
;
2581 lpwm
->mld
.uDeviceID
= uDeviceID
;
2582 dwRet
= MMDRV_Open(&lpwm
->mld
, MIDM_OPEN
, (DWORD
)&lpwm
->mod
, dwFlags
);
2584 if (dwRet
!= MMSYSERR_NOERROR
) {
2585 MMDRV_Free(hMidiIn
, &lpwm
->mld
);
2588 if (lphMidiIn
!= NULL
) *lphMidiIn
= hMidiIn
;
2589 TRACE("=> %ld hMidi=%04x\n", dwRet
, hMidiIn
);
2594 /**************************************************************************
2595 * midiInOpen [WINMM.66]
2597 UINT WINAPI
midiInOpen(HMIDIIN
* lphMidiIn
, UINT uDeviceID
,
2598 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2600 return MMSYSTEM_midiInOpen(lphMidiIn
, uDeviceID
, dwCallback
,
2601 dwInstance
, dwFlags
, TRUE
);
2604 /**************************************************************************
2605 * midiInOpen [MMSYSTEM.304]
2607 UINT16 WINAPI
midiInOpen16(HMIDIIN16
* lphMidiIn
, UINT16 uDeviceID
,
2608 DWORD dwCallback
, DWORD dwInstance
, DWORD dwFlags
)
2613 ret
= MMSYSTEM_midiInOpen(&xhmid
, uDeviceID
, dwCallback
, dwInstance
,
2616 if (lphMidiIn
) *lphMidiIn
= xhmid
;
2620 /**************************************************************************
2621 * midiInClose [WINMM.58]
2623 UINT WINAPI
midiInClose(HMIDIIN hMidiIn
)
2628 TRACE("(%04X)\n", hMidiIn
);
2630 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2631 return MMSYSERR_INVALHANDLE
;
2633 dwRet
= MMDRV_Close(wmld
, MIDM_CLOSE
);
2634 MMDRV_Free(hMidiIn
, wmld
);
2638 /**************************************************************************
2639 * midiInClose [MMSYSTEM.305]
2641 UINT16 WINAPI
midiInClose16(HMIDIIN16 hMidiIn
)
2643 return midiInClose(hMidiIn
);
2646 /**************************************************************************
2647 * midiInPrepareHeader [WINMM.67]
2649 UINT WINAPI
midiInPrepareHeader(HMIDIIN hMidiIn
,
2650 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2654 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2656 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2657 return MMSYSERR_INVALHANDLE
;
2659 return MMDRV_Message(wmld
, MIDM_PREPARE
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2662 /**************************************************************************
2663 * midiInPrepareHeader [MMSYSTEM.306]
2665 UINT16 WINAPI
midiInPrepareHeader16(HMIDIIN16 hMidiIn
,
2666 MIDIHDR16
* /*SEGPTR*/ lpsegMidiInHdr
,
2671 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2673 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2674 return MMSYSERR_INVALHANDLE
;
2676 return MMDRV_Message(wmld
, MIDM_PREPARE
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2679 /**************************************************************************
2680 * midiInUnprepareHeader [WINMM.71]
2682 UINT WINAPI
midiInUnprepareHeader(HMIDIIN hMidiIn
,
2683 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2687 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2689 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
2690 return MMSYSERR_NOERROR
;
2693 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2694 return MMSYSERR_INVALHANDLE
;
2696 return MMDRV_Message(wmld
, MIDM_UNPREPARE
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2699 /**************************************************************************
2700 * midiInUnprepareHeader [MMSYSTEM.307]
2702 UINT16 WINAPI
midiInUnprepareHeader16(HMIDIIN16 hMidiIn
,
2703 MIDIHDR16
* /* SEGPTR */ lpsegMidiInHdr
,
2707 LPMIDIHDR16 lpMidiInHdr
= PTR_SEG_TO_LIN(lpsegMidiInHdr
);
2709 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2711 if (!(lpMidiInHdr
->dwFlags
& MHDR_PREPARED
)) {
2712 return MMSYSERR_NOERROR
;
2715 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2716 return MMSYSERR_INVALHANDLE
;
2718 return MMDRV_Message(wmld
, MIDM_UNPREPARE
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2721 /**************************************************************************
2722 * midiInAddBuffer [WINMM.57]
2724 UINT WINAPI
midiInAddBuffer(HMIDIIN hMidiIn
,
2725 MIDIHDR
* lpMidiInHdr
, UINT uSize
)
2729 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpMidiInHdr
, uSize
);
2731 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2732 return MMSYSERR_INVALHANDLE
;
2734 return MMDRV_Message(wmld
, MIDM_ADDBUFFER
, (DWORD
)lpMidiInHdr
, uSize
, TRUE
);
2737 /**************************************************************************
2738 * midiInAddBuffer [MMSYSTEM.308]
2740 UINT16 WINAPI
midiInAddBuffer16(HMIDIIN16 hMidiIn
,
2741 MIDIHDR16
* /* SEGPTR */ lpsegMidiInHdr
,
2746 TRACE("(%04X, %p, %d)\n", hMidiIn
, lpsegMidiInHdr
, uSize
);
2748 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2749 return MMSYSERR_INVALHANDLE
;
2751 return MMDRV_Message(wmld
, MIDM_ADDBUFFER
, (DWORD
)lpsegMidiInHdr
, uSize
, FALSE
);
2754 /**************************************************************************
2755 * midiInStart [WINMM.69]
2757 UINT WINAPI
midiInStart(HMIDIIN hMidiIn
)
2761 TRACE("(%04X\n", hMidiIn
);
2763 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2764 return MMSYSERR_INVALHANDLE
;
2766 return MMDRV_Message(wmld
, MIDM_START
, 0L, 0L, TRUE
);
2769 /**************************************************************************
2770 * midiInStart [MMSYSTEM.309]
2772 UINT16 WINAPI
midiInStart16(HMIDIIN16 hMidiIn
)
2774 return midiInStart(hMidiIn
);
2777 /**************************************************************************
2778 * midiInStop [WINMM.70]
2780 UINT WINAPI
midiInStop(HMIDIIN hMidiIn
)
2784 TRACE("(%04X\n", hMidiIn
);
2786 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2787 return MMSYSERR_INVALHANDLE
;
2789 return MMDRV_Message(wmld
, MIDM_STOP
, 0L, 0L, TRUE
);
2792 /**************************************************************************
2793 * midiInStop [MMSYSTEM.310]
2795 UINT16 WINAPI
midiInStop16(HMIDIIN16 hMidiIn
)
2797 return midiInStop(hMidiIn
);
2800 /**************************************************************************
2801 * midiInReset [WINMM.68]
2803 UINT WINAPI
midiInReset(HMIDIIN hMidiIn
)
2807 TRACE("(%04X\n", hMidiIn
);
2809 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2810 return MMSYSERR_INVALHANDLE
;
2812 return MMDRV_Message(wmld
, MIDM_RESET
, 0L, 0L, TRUE
);
2815 /**************************************************************************
2816 * midiInReset [MMSYSTEM.311]
2818 UINT16 WINAPI
midiInReset16(HMIDIIN16 hMidiIn
)
2820 return midiInReset(hMidiIn
);
2823 /**************************************************************************
2824 * midiInGetID [WINMM.63]
2826 UINT WINAPI
midiInGetID(HMIDIIN hMidiIn
, UINT
* lpuDeviceID
)
2830 TRACE("(%04X, %p)\n", hMidiIn
, lpuDeviceID
);
2832 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2834 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2835 return MMSYSERR_INVALHANDLE
;
2837 *lpuDeviceID
= wmld
->uDeviceID
;
2839 return MMSYSERR_NOERROR
;
2842 /**************************************************************************
2843 * midiInGetID [MMSYSTEM.312]
2845 UINT16 WINAPI
midiInGetID16(HMIDIIN16 hMidiIn
, UINT16
* lpuDeviceID
)
2849 TRACE("(%04X, %p)\n", hMidiIn
, lpuDeviceID
);
2851 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALPARAM
;
2853 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, TRUE
)) == NULL
)
2854 return MMSYSERR_INVALHANDLE
;
2856 *lpuDeviceID
= wmld
->uDeviceID
;
2858 return MMSYSERR_NOERROR
;
2861 /**************************************************************************
2862 * midiInMessage [WINMM.65]
2864 DWORD WINAPI
midiInMessage(HMIDIIN hMidiIn
, UINT uMessage
,
2865 DWORD dwParam1
, DWORD dwParam2
)
2869 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
2871 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2872 return MMSYSERR_INVALHANDLE
;
2877 FIXME("can't handle OPEN or CLOSE message!\n");
2878 return MMSYSERR_NOTSUPPORTED
;
2880 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
2883 /**************************************************************************
2884 * midiInMessage [MMSYSTEM.313]
2886 DWORD WINAPI
midiInMessage16(HMIDIIN16 hMidiIn
, UINT16 uMessage
,
2887 DWORD dwParam1
, DWORD dwParam2
)
2891 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn
, uMessage
, dwParam1
, dwParam2
);
2896 FIXME("can't handle OPEN or CLOSE message!\n");
2897 return MMSYSERR_NOTSUPPORTED
;
2899 case MIDM_GETDEVCAPS
:
2900 return midiInGetDevCaps16(hMidiIn
, (LPMIDIINCAPS16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2902 return midiInPrepareHeader16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2903 case MIDM_UNPREPARE
:
2904 return midiInUnprepareHeader16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2905 case MIDM_ADDBUFFER
:
2906 return midiInAddBuffer16(hMidiIn
, (LPMIDIHDR16
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
2909 if ((wmld
= MMDRV_Get(hMidiIn
, MMDRV_MIDIIN
, FALSE
)) == NULL
)
2910 return MMSYSERR_INVALHANDLE
;
2912 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, FALSE
);
2915 typedef struct WINE_MIDIStream
{
2926 LPMIDIHDR lpMidiHdr
;
2929 #define WINE_MSM_HEADER (WM_USER+0)
2930 #define WINE_MSM_STOP (WM_USER+1)
2932 /**************************************************************************
2933 * MMSYSTEM_GetMidiStream [internal]
2935 static BOOL
MMSYSTEM_GetMidiStream(HMIDISTRM hMidiStrm
, WINE_MIDIStream
** lpMidiStrm
, WINE_MIDI
** lplpwm
)
2937 WINE_MIDI
* lpwm
= (LPWINE_MIDI
)MMDRV_Get(hMidiStrm
, MMDRV_MIDIOUT
, FALSE
);
2946 *lpMidiStrm
= (WINE_MIDIStream
*)lpwm
->mod
.rgIds
.dwStreamID
;
2948 return *lpMidiStrm
!= NULL
;
2951 /**************************************************************************
2952 * MMSYSTEM_MidiStream_Convert [internal]
2954 static DWORD
MMSYSTEM_MidiStream_Convert(WINE_MIDIStream
* lpMidiStrm
, DWORD pulse
)
2958 if (lpMidiStrm
->dwTimeDiv
== 0) {
2959 FIXME("Shouldn't happen. lpMidiStrm->dwTimeDiv = 0\n");
2960 } else if (lpMidiStrm
->dwTimeDiv
> 0x8000) { /* SMPTE, unchecked FIXME? */
2961 int nf
= -(char)HIBYTE(lpMidiStrm
->dwTimeDiv
); /* number of frames */
2962 int nsf
= LOBYTE(lpMidiStrm
->dwTimeDiv
); /* number of sub-frames */
2963 ret
= (pulse
* 1000) / (nf
* nsf
);
2965 ret
= (DWORD
)((double)pulse
* ((double)lpMidiStrm
->dwTempo
/ 1000) /
2966 (double)lpMidiStrm
->dwTimeDiv
);
2972 /**************************************************************************
2973 * MMSYSTEM_MidiStream_MessageHandler [internal]
2975 static BOOL
MMSYSTEM_MidiStream_MessageHandler(WINE_MIDIStream
* lpMidiStrm
, LPWINE_MIDI lpwm
, LPMSG msg
)
2977 LPMIDIHDR lpMidiHdr
;
2981 switch (msg
->message
) {
2983 SetEvent(lpMidiStrm
->hEvent
);
2987 /* this is not quite what MS doc says... */
2988 midiOutReset(lpMidiStrm
->hDevice
);
2989 /* empty list of already submitted buffers */
2990 for (lpMidiHdr
= lpMidiStrm
->lpMidiHdr
; lpMidiHdr
; lpMidiHdr
= (LPMIDIHDR
)lpMidiHdr
->lpNext
) {
2991 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
2992 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
2994 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
2995 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
2997 lpMidiStrm
->lpMidiHdr
= 0;
2998 SetEvent(lpMidiStrm
->hEvent
);
3000 case WINE_MSM_HEADER
:
3001 /* sets initial tick count for first MIDIHDR */
3002 if (!lpMidiStrm
->dwStartTicks
)
3003 lpMidiStrm
->dwStartTicks
= GetTickCount();
3005 /* FIXME(EPP): "I don't understand the content of the first MIDIHDR sent
3006 * by native mcimidi, it doesn't look like a correct one".
3007 * this trick allows to throw it away... but I don't like it.
3008 * It looks like part of the file I'm trying to play and definitively looks
3009 * like raw midi content
3010 * I'd really like to understand why native mcimidi sends it. Perhaps a bad
3011 * synchronization issue where native mcimidi is still processing raw MIDI
3012 * content before generating MIDIEVENTs ?
3014 * 4c 04 89 3b 00 81 7c 99 3b 43 00 99 23 5e 04 89 L..;..|.;C..#^..
3015 * 3b 00 00 89 23 00 7c 99 3b 45 00 99 28 62 04 89 ;...#.|.;E..(b..
3016 * 3b 00 00 89 28 00 81 7c 99 3b 4e 00 99 23 5e 04 ;...(..|.;N..#^.
3017 * 89 3b 00 00 89 23 00 7c 99 3b 45 00 99 23 78 04 .;...#.|.;E..#x.
3018 * 89 3b 00 00 89 23 00 81 7c 99 3b 48 00 99 23 5e .;...#..|.;H..#^
3019 * 04 89 3b 00 00 89 23 00 7c 99 3b 4e 00 99 28 62 ..;...#.|.;N..(b
3020 * 04 89 3b 00 00 89 28 00 81 7c 99 39 4c 00 99 23 ..;...(..|.9L..#
3021 * 5e 04 89 39 00 00 89 23 00 82 7c 99 3b 4c 00 99 ^..9...#..|.;L..
3022 * 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 00 99 #^..;...#.|.;H..
3023 * 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b 3f 04 (b..;...(..|.;?.
3024 * 89 3b 00 1c 99 23 5e 04 89 23 00 5c 99 3b 45 00 .;...#^..#.\.;E.
3025 * 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 3b 46 .#x..;...#..|.;F
3026 * 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 ..#^..;...#.|.;H
3027 * 00 99 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b ..(b..;...(..|.;
3028 * 46 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b F..#^..;...#.|.;
3029 * 48 00 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 H..#x..;...#..|.
3030 * 3b 4c 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 ;L..#^..;...#.|.
3032 lpMidiHdr
= (LPMIDIHDR
)msg
->lParam
;
3033 lpData
= lpMidiHdr
->lpData
;
3034 TRACE("Adding %s lpMidiHdr=%p [lpData=0x%08lx dwBufferLength=%lu/%lu dwFlags=0x%08lx size=%u]\n",
3035 (lpMidiHdr
->dwFlags
& MHDR_ISSTRM
) ? "stream" : "regular", lpMidiHdr
,
3036 (DWORD
)lpMidiHdr
, lpMidiHdr
->dwBufferLength
, lpMidiHdr
->dwBytesRecorded
,
3037 lpMidiHdr
->dwFlags
, msg
->wParam
);
3039 /* dumps content of lpMidiHdr->lpData
3040 * FIXME: there should be a debug routine somewhere that already does this
3041 * I hate spreading this type of shit all around the code
3043 for (dwToGo
= 0; dwToGo
< lpMidiHdr
->dwBufferLength
; dwToGo
+= 16) {
3047 for (i
= 0; i
< MIN(16, lpMidiHdr
->dwBufferLength
- dwToGo
); i
++)
3048 printf("%02x ", lpData
[dwToGo
+ i
]);
3051 for (i
= 0; i
< MIN(16, lpMidiHdr
->dwBufferLength
- dwToGo
); i
++) {
3052 ch
= lpData
[dwToGo
+ i
];
3053 printf("%c", (ch
>= 0x20 && ch
<= 0x7F) ? ch
: '.');
3058 if (((LPMIDIEVENT
)lpData
)->dwStreamID
!= 0 &&
3059 ((LPMIDIEVENT
)lpData
)->dwStreamID
!= 0xFFFFFFFF &&
3060 ((LPMIDIEVENT
)lpData
)->dwStreamID
!= (DWORD
)lpMidiStrm
) {
3061 FIXME("Dropping bad %s lpMidiHdr (streamID=%08lx)\n",
3062 (lpMidiHdr
->dwFlags
& MHDR_ISSTRM
) ? "stream" : "regular",
3063 ((LPMIDIEVENT
)lpData
)->dwStreamID
);
3064 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3065 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3067 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3068 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
3072 for (lpmh
= &lpMidiStrm
->lpMidiHdr
; *lpmh
; lpmh
= (LPMIDIHDR
*)&((*lpmh
)->lpNext
));
3074 lpMidiHdr
= (LPMIDIHDR
)msg
->lParam
;
3075 lpMidiHdr
->lpNext
= 0;
3076 lpMidiHdr
->dwFlags
|= MHDR_INQUEUE
;
3077 lpMidiHdr
->dwFlags
&= MHDR_DONE
;
3078 lpMidiHdr
->dwOffset
= 0;
3082 FIXME("Unknown message %d\n", msg
->message
);
3088 /**************************************************************************
3089 * MMSYSTEM_MidiStream_Player [internal]
3091 static DWORD CALLBACK
MMSYSTEM_MidiStream_Player(LPVOID pmt
)
3093 WINE_MIDIStream
* lpMidiStrm
= pmt
;
3098 LPMIDIHDR lpMidiHdr
;
3102 TRACE("(%p)!\n", lpMidiStrm
);
3105 (lpwm
= (LPWINE_MIDI
)MMDRV_Get(lpMidiStrm
->hDevice
, MMDRV_MIDIOUT
, FALSE
)) == NULL
)
3108 /* force thread's queue creation */
3109 /* Used to be InitThreadInput16(0, 5); */
3110 /* but following works also with hack in midiStreamOpen */
3111 Callout
.PeekMessageA(&msg
, 0, 0, 0, 0);
3113 /* FIXME: this next line must be called before midiStreamOut or midiStreamRestart are called */
3114 SetEvent(lpMidiStrm
->hEvent
);
3115 TRACE("Ready to go 1\n");
3116 /* thread is started in paused mode */
3117 SuspendThread(lpMidiStrm
->hThread
);
3118 TRACE("Ready to go 2\n");
3120 lpMidiStrm
->dwStartTicks
= 0;
3121 lpMidiStrm
->dwPulses
= 0;
3123 lpMidiStrm
->lpMidiHdr
= 0;
3126 lpMidiHdr
= lpMidiStrm
->lpMidiHdr
;
3128 /* for first message, block until one arrives, then process all that are available */
3129 Callout
.GetMessageA(&msg
, 0, 0, 0);
3131 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm
, lpwm
, &msg
))
3133 } while (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
));
3139 lpData
= lpMidiHdr
->lpData
;
3141 me
= (LPMIDIEVENT
)(lpData
+ lpMidiHdr
->dwOffset
);
3143 /* do we have to wait ? */
3144 if (me
->dwDeltaTime
) {
3145 lpMidiStrm
->dwPositionMS
+= MMSYSTEM_MidiStream_Convert(lpMidiStrm
, me
->dwDeltaTime
);
3146 lpMidiStrm
->dwPulses
+= me
->dwDeltaTime
;
3148 dwToGo
= lpMidiStrm
->dwStartTicks
+ lpMidiStrm
->dwPositionMS
;
3150 TRACE("%ld/%ld/%ld\n", dwToGo
, GetTickCount(), me
->dwDeltaTime
);
3151 while ((dwCurrTC
= GetTickCount()) < dwToGo
) {
3152 if (MsgWaitForMultipleObjects(0, NULL
, FALSE
, dwToGo
- dwCurrTC
, QS_ALLINPUT
) == WAIT_OBJECT_0
) {
3153 /* got a message, handle it */
3154 while (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
3155 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm
, lpwm
, &msg
))
3160 /* timeout, so me->dwDeltaTime is elapsed, can break the while loop */
3165 switch (MEVT_EVENTTYPE(me
->dwEvent
& ~MEVT_F_CALLBACK
)) {
3167 FIXME("NIY: MEVT_COMMENT\n");
3168 /* do nothing, skip bytes */
3171 FIXME("NIY: MEVT_LONGMSG, aka sending Sysex event\n");
3176 midiOutShortMsg(lpMidiStrm
->hDevice
, MEVT_EVENTPARM(me
->dwEvent
));
3179 lpMidiStrm
->dwTempo
= MEVT_EVENTPARM(me
->dwEvent
);
3184 FIXME("Unknown MEVT (0x%02x)\n", MEVT_EVENTTYPE(me
->dwEvent
& ~MEVT_F_CALLBACK
));
3187 if (me
->dwEvent
& MEVT_F_CALLBACK
) {
3188 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3189 MM_MOM_POSITIONCB
, lpwm
->mod
.dwInstance
, (LPARAM
)lpMidiHdr
, 0L);
3191 lpMidiHdr
->dwOffset
+= sizeof(MIDIEVENT
);
3192 if (me
->dwEvent
& MEVT_F_LONG
)
3193 lpMidiHdr
->dwOffset
+= (MEVT_EVENTPARM(me
->dwEvent
) + 3) & ~3;
3194 if (lpMidiHdr
->dwOffset
>= lpMidiHdr
->dwBufferLength
) {
3195 /* done with this header */
3196 lpMidiHdr
->dwFlags
|= MHDR_DONE
;
3197 lpMidiHdr
->dwFlags
&= ~MHDR_INQUEUE
;
3199 lpMidiStrm
->lpMidiHdr
= (LPMIDIHDR
)lpMidiHdr
->lpNext
;
3200 DriverCallback(lpwm
->mod
.dwCallback
, lpMidiStrm
->wFlags
, lpMidiStrm
->hDevice
,
3201 MM_MOM_DONE
, lpwm
->mod
.dwInstance
, (DWORD
)lpMidiHdr
, 0L);
3206 TRACE("End of thread\n");
3208 return 0; /* for removing the warning, never executed */
3211 /**************************************************************************
3212 * MMSYSTEM_MidiStream_PostMessage [internal]
3214 static BOOL
MMSYSTEM_MidiStream_PostMessage(WINE_MIDIStream
* lpMidiStrm
, WORD msg
, DWORD pmt1
, DWORD pmt2
)
3216 if (Callout
.PostThreadMessageA(lpMidiStrm
->dwThreadID
, msg
, pmt1
, pmt2
)) {
3220 /* FIXME: should use the new syslevel APIs */
3221 if ((bHasWin16Lock
= _ConfirmWin16Lock()) != 0) {
3222 ReleaseThunkLock(&count
);
3224 WaitForSingleObject(lpMidiStrm
->hEvent
, INFINITE
);
3225 if (bHasWin16Lock
) {
3226 RestoreThunkLock(count
);
3229 WARN("bad PostThreadMessageA\n");
3235 /**************************************************************************
3236 * midiStreamClose [WINMM.90]
3238 MMRESULT WINAPI
midiStreamClose(HMIDISTRM hMidiStrm
)
3240 WINE_MIDIStream
* lpMidiStrm
;
3242 TRACE("(%08x)!\n", hMidiStrm
);
3244 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
))
3245 return MMSYSERR_INVALHANDLE
;
3247 midiStreamStop(hMidiStrm
);
3248 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm
, WM_QUIT
, 0, 0);
3249 HeapFree(GetProcessHeap(), 0, lpMidiStrm
);
3250 CloseHandle(lpMidiStrm
->hEvent
);
3252 return midiOutClose(hMidiStrm
);
3255 /**************************************************************************
3256 * MMSYSTEM_MidiStream_Open [internal]
3258 static MMRESULT WINAPI
MMSYSTEM_MidiStream_Open(HMIDISTRM
* lphMidiStrm
, LPUINT lpuDeviceID
,
3259 DWORD cMidi
, DWORD dwCallback
,
3260 DWORD dwInstance
, DWORD fdwOpen
, BOOL bFrom32
)
3262 WINE_MIDIStream
* lpMidiStrm
;
3264 MIDIOPENSTRMID mosm
;
3268 TRACE("(%p, %p, %ld, 0x%08lx, 0x%08lx, 0x%08lx)!\n",
3269 lphMidiStrm
, lpuDeviceID
, cMidi
, dwCallback
, dwInstance
, fdwOpen
);
3271 if (cMidi
!= 1 || lphMidiStrm
== NULL
|| lpuDeviceID
== NULL
)
3272 return MMSYSERR_INVALPARAM
;
3274 lpMidiStrm
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MIDIStream
));
3276 return MMSYSERR_NOMEM
;
3278 lpMidiStrm
->dwTempo
= 500000;
3279 lpMidiStrm
->dwTimeDiv
= 480; /* 480 is 120 quater notes per minute *//* FIXME ??*/
3280 lpMidiStrm
->dwPositionMS
= 0;
3282 mosm
.dwStreamID
= (DWORD
)lpMidiStrm
;
3283 /* FIXME: the correct value is not allocated yet for MAPPER */
3284 mosm
.wDeviceID
= *lpuDeviceID
;
3285 lpwm
= MIDI_OutAlloc(&hMidiOut
, &dwCallback
, &dwInstance
, &fdwOpen
, 1, &mosm
, bFrom32
);
3286 lpMidiStrm
->hDevice
= hMidiOut
;
3288 *lphMidiStrm
= hMidiOut
;
3290 /* FIXME: is lpuDevice initialized upon entering midiStreamOpen ? */
3291 FIXME("*lpuDeviceID=%u\n", *lpuDeviceID
);
3292 lpwm
->mld
.uDeviceID
= *lpuDeviceID
= 0;
3294 ret
= MMDRV_Open(&lpwm
->mld
, MODM_OPEN
, (DWORD
)&lpwm
->mod
, fdwOpen
);
3295 lpMidiStrm
->hEvent
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
);
3296 lpMidiStrm
->wFlags
= HIWORD(fdwOpen
);
3298 lpMidiStrm
->hThread
= CreateThread(NULL
, 0, MMSYSTEM_MidiStream_Player
,
3299 lpMidiStrm
, 0, &(lpMidiStrm
->dwThreadID
));
3301 if (!lpMidiStrm
->hThread
) {
3302 midiStreamClose((HMIDISTRM
)hMidiOut
);
3303 return MMSYSERR_NOMEM
;
3306 /* wait for thread to have started, and for it's queue to be created */
3311 /* (Release|Restore)ThunkLock() is needed when this method is called from 16 bit code,
3312 * (meaning the Win16Lock is set), so that it's released and the 32 bit thread running
3313 * MMSYSTEM_MidiStreamPlayer can acquire Win16Lock to create its queue.
3315 if ((bHasWin16Lock
= _ConfirmWin16Lock()) != 0) {
3316 ReleaseThunkLock(&count
);
3318 WaitForSingleObject(lpMidiStrm
->hEvent
, INFINITE
);
3319 if (bHasWin16Lock
) {
3320 RestoreThunkLock(count
);
3324 TRACE("=> (%u/%d) hMidi=0x%04x ret=%d lpMidiStrm=%p\n",
3325 *lpuDeviceID
, lpwm
->mld
.uDeviceID
, *lphMidiStrm
, ret
, lpMidiStrm
);
3329 /**************************************************************************
3330 * midiStreamOpen [WINMM.91]
3332 MMRESULT WINAPI
midiStreamOpen(HMIDISTRM
* lphMidiStrm
, LPUINT lpuDeviceID
,
3333 DWORD cMidi
, DWORD dwCallback
,
3334 DWORD dwInstance
, DWORD fdwOpen
)
3336 return MMSYSTEM_MidiStream_Open(lphMidiStrm
, lpuDeviceID
, cMidi
, dwCallback
,
3337 dwInstance
, fdwOpen
, TRUE
);
3340 /**************************************************************************
3341 * midiStreamOut [WINMM.92]
3343 MMRESULT WINAPI
midiStreamOut(HMIDISTRM hMidiStrm
, LPMIDIHDR lpMidiHdr
,
3346 WINE_MIDIStream
* lpMidiStrm
;
3347 DWORD ret
= MMSYSERR_NOERROR
;
3349 TRACE("(%08x, %p, %u)!\n", hMidiStrm
, lpMidiHdr
, cbMidiHdr
);
3351 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3352 ret
= MMSYSERR_INVALHANDLE
;
3354 if (!Callout
.PostThreadMessageA(lpMidiStrm
->dwThreadID
,
3355 WINE_MSM_HEADER
, cbMidiHdr
,
3356 (DWORD
)lpMidiHdr
)) {
3357 WARN("bad PostThreadMessageA\n");
3358 ret
= MMSYSERR_ERROR
;
3364 /**************************************************************************
3365 * midiStreamPause [WINMM.93]
3367 MMRESULT WINAPI
midiStreamPause(HMIDISTRM hMidiStrm
)
3369 WINE_MIDIStream
* lpMidiStrm
;
3370 DWORD ret
= MMSYSERR_NOERROR
;
3372 TRACE("(%08x)!\n", hMidiStrm
);
3374 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3375 ret
= MMSYSERR_INVALHANDLE
;
3377 if (SuspendThread(lpMidiStrm
->hThread
) == 0xFFFFFFFF) {
3378 WARN("bad Suspend (%ld)\n", GetLastError());
3379 ret
= MMSYSERR_ERROR
;
3385 /**************************************************************************
3386 * midiStreamPosition [WINMM.94]
3388 MMRESULT WINAPI
midiStreamPosition(HMIDISTRM hMidiStrm
, LPMMTIME lpMMT
, UINT cbmmt
)
3390 WINE_MIDIStream
* lpMidiStrm
;
3391 DWORD ret
= MMSYSERR_NOERROR
;
3393 TRACE("(%08x, %p, %u)!\n", hMidiStrm
, lpMMT
, cbmmt
);
3395 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3396 ret
= MMSYSERR_INVALHANDLE
;
3397 } else if (lpMMT
== NULL
|| cbmmt
!= sizeof(MMTIME
)) {
3398 ret
= MMSYSERR_INVALPARAM
;
3400 switch (lpMMT
->wType
) {
3402 lpMMT
->u
.ms
= lpMidiStrm
->dwPositionMS
;
3403 TRACE("=> %ld ms\n", lpMMT
->u
.ms
);
3406 lpMMT
->u
.ticks
= lpMidiStrm
->dwPulses
;
3407 TRACE("=> %ld ticks\n", lpMMT
->u
.ticks
);
3410 WARN("Unsupported time type %d\n", lpMMT
->wType
);
3411 lpMMT
->wType
= TIME_MS
;
3412 ret
= MMSYSERR_INVALPARAM
;
3419 /**************************************************************************
3420 * midiStreamProperty [WINMM.95]
3422 MMRESULT WINAPI
midiStreamProperty(HMIDISTRM hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
3424 WINE_MIDIStream
* lpMidiStrm
;
3425 MMRESULT ret
= MMSYSERR_NOERROR
;
3427 TRACE("(%08x, %p, %lx)\n", hMidiStrm
, lpPropData
, dwProperty
);
3429 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3430 ret
= MMSYSERR_INVALHANDLE
;
3431 } else if ((dwProperty
& (MIDIPROP_GET
|MIDIPROP_SET
)) == 0) {
3432 ret
= MMSYSERR_INVALPARAM
;
3433 } else if (dwProperty
& MIDIPROP_TEMPO
) {
3434 MIDIPROPTEMPO
* mpt
= (MIDIPROPTEMPO
*)lpPropData
;
3436 if (sizeof(MIDIPROPTEMPO
) != mpt
->cbStruct
) {
3437 ret
= MMSYSERR_INVALPARAM
;
3438 } else if (dwProperty
& MIDIPROP_SET
) {
3439 lpMidiStrm
->dwTempo
= mpt
->dwTempo
;
3440 TRACE("Setting tempo to %ld\n", mpt
->dwTempo
);
3441 } else if (dwProperty
& MIDIPROP_GET
) {
3442 mpt
->dwTempo
= lpMidiStrm
->dwTempo
;
3443 TRACE("Getting tempo <= %ld\n", mpt
->dwTempo
);
3445 } else if (dwProperty
& MIDIPROP_TIMEDIV
) {
3446 MIDIPROPTIMEDIV
* mptd
= (MIDIPROPTIMEDIV
*)lpPropData
;
3448 if (sizeof(MIDIPROPTIMEDIV
) != mptd
->cbStruct
) {
3449 ret
= MMSYSERR_INVALPARAM
;
3450 } else if (dwProperty
& MIDIPROP_SET
) {
3451 lpMidiStrm
->dwTimeDiv
= mptd
->dwTimeDiv
;
3452 TRACE("Setting time div to %ld\n", mptd
->dwTimeDiv
);
3453 } else if (dwProperty
& MIDIPROP_GET
) {
3454 mptd
->dwTimeDiv
= lpMidiStrm
->dwTimeDiv
;
3455 TRACE("Getting time div <= %ld\n", mptd
->dwTimeDiv
);
3458 ret
= MMSYSERR_INVALPARAM
;
3464 /**************************************************************************
3465 * midiStreamRestart [WINMM.96]
3467 MMRESULT WINAPI
midiStreamRestart(HMIDISTRM hMidiStrm
)
3469 WINE_MIDIStream
* lpMidiStrm
;
3470 MMRESULT ret
= MMSYSERR_NOERROR
;
3472 TRACE("(%08x)!\n", hMidiStrm
);
3474 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3475 ret
= MMSYSERR_INVALHANDLE
;
3477 if (ResumeThread(lpMidiStrm
->hThread
) == 0xFFFFFFFF) {
3478 WARN("bad Resume (%ld)\n", GetLastError());
3479 ret
= MMSYSERR_ERROR
;
3481 lpMidiStrm
->dwStartTicks
= GetTickCount() - lpMidiStrm
->dwPositionMS
;
3487 /**************************************************************************
3488 * midiStreamStop [WINMM.97]
3490 MMRESULT WINAPI
midiStreamStop(HMIDISTRM hMidiStrm
)
3492 WINE_MIDIStream
* lpMidiStrm
;
3493 MMRESULT ret
= MMSYSERR_NOERROR
;
3495 TRACE("(%08x)!\n", hMidiStrm
);
3497 if (!MMSYSTEM_GetMidiStream(hMidiStrm
, &lpMidiStrm
, NULL
)) {
3498 ret
= MMSYSERR_INVALHANDLE
;
3500 /* in case stream has been paused... FIXME is the current state correct ? */
3501 midiStreamRestart(hMidiStrm
);
3502 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm
, WINE_MSM_STOP
, 0, 0);
3507 /**************************************************************************
3508 * midiStreamClose [MMSYSTEM.252]
3510 MMRESULT16 WINAPI
midiStreamClose16(HMIDISTRM16 hMidiStrm
)
3512 return midiStreamClose(hMidiStrm
);
3515 /**************************************************************************
3516 * midiStreamOpen [MMSYSTEM.251]
3518 MMRESULT16 WINAPI
midiStreamOpen16(HMIDISTRM16
* phMidiStrm
, LPUINT16 devid
,
3519 DWORD cMidi
, DWORD dwCallback
,
3520 DWORD dwInstance
, DWORD fdwOpen
)
3522 HMIDISTRM hMidiStrm32
;
3526 if (!phMidiStrm
|| !devid
)
3527 return MMSYSERR_INVALPARAM
;
3529 ret
= MMSYSTEM_MidiStream_Open(&hMidiStrm32
, &devid32
, cMidi
, dwCallback
,
3530 dwInstance
, fdwOpen
, FALSE
);
3531 *phMidiStrm
= hMidiStrm32
;
3536 /**************************************************************************
3537 * midiStreamOut [MMSYSTEM.254]
3539 MMRESULT16 WINAPI
midiStreamOut16(HMIDISTRM16 hMidiStrm
, LPMIDIHDR16 lpMidiHdr
, UINT16 cbMidiHdr
)
3541 return midiStreamOut(hMidiStrm
, (LPMIDIHDR
)lpMidiHdr
, cbMidiHdr
);
3544 /**************************************************************************
3545 * midiStreamPause [MMSYSTEM.255]
3547 MMRESULT16 WINAPI
midiStreamPause16(HMIDISTRM16 hMidiStrm
)
3549 return midiStreamPause(hMidiStrm
);
3552 /**************************************************************************
3553 * midiStreamPosition [MMSYSTEM.253]
3555 MMRESULT16 WINAPI
midiStreamPosition16(HMIDISTRM16 hMidiStrm
, LPMMTIME16 lpmmt16
, UINT16 cbmmt
)
3561 return MMSYSERR_INVALPARAM
;
3562 MMSYSTEM_MMTIME16to32(&mmt32
, lpmmt16
);
3563 ret
= midiStreamPosition(hMidiStrm
, &mmt32
, sizeof(MMTIME
));
3564 MMSYSTEM_MMTIME32to16(lpmmt16
, &mmt32
);
3568 /**************************************************************************
3569 * midiStreamProperty [MMSYSTEM.250]
3571 MMRESULT16 WINAPI
midiStreamProperty16(HMIDISTRM16 hMidiStrm
, LPBYTE lpPropData
, DWORD dwProperty
)
3573 return midiStreamProperty(hMidiStrm
, lpPropData
, dwProperty
);
3576 /**************************************************************************
3577 * midiStreamRestart [MMSYSTEM.256]
3579 MMRESULT16 WINAPI
midiStreamRestart16(HMIDISTRM16 hMidiStrm
)
3581 return midiStreamRestart(hMidiStrm
);
3584 /**************************************************************************
3585 * midiStreamStop [MMSYSTEM.257]
3587 MMRESULT16 WINAPI
midiStreamStop16(HMIDISTRM16 hMidiStrm
)
3589 return midiStreamStop(hMidiStrm
);
3592 static UINT WINAPI
MMSYSTEM_waveOpen(HANDLE
* lphndl
, UINT uDeviceID
, UINT uType
,
3593 const LPWAVEFORMATEX lpFormat
,
3594 DWORD dwCallback
, DWORD dwInstance
,
3595 DWORD dwFlags
, BOOL bFrom32
)
3599 DWORD dwRet
= MMSYSERR_NOERROR
;
3602 TRACE("(%p, %d, %s, %p, %08lX, %08lX, %08lX, %d);\n",
3603 lphndl
, (int)uDeviceID
, (uType
==MMDRV_WAVEOUT
)?"Out":"In", lpFormat
, dwCallback
,
3604 dwInstance
, dwFlags
, bFrom32
?32:16);
3606 if (dwFlags
& WAVE_FORMAT_QUERY
) TRACE("WAVE_FORMAT_QUERY requested !\n");
3608 if (lpFormat
== NULL
) return WAVERR_BADFORMAT
;
3610 TRACE("wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u\n",
3611 lpFormat
->wFormatTag
, lpFormat
->nChannels
, lpFormat
->nSamplesPerSec
,
3612 lpFormat
->nAvgBytesPerSec
, lpFormat
->nBlockAlign
, lpFormat
->wBitsPerSample
, lpFormat
->cbSize
);
3614 if ((wmld
= MMDRV_Alloc(sizeof(WINE_WAVE
), uType
, &handle
,
3615 &dwFlags
, &dwCallback
, &dwInstance
, bFrom32
)) == NULL
)
3616 return MMSYSERR_NOMEM
;
3619 wod
.lpFormat
= lpFormat
; /* should the struct be copied iso pointer? */
3620 wod
.dwCallback
= dwCallback
;
3621 wod
.dwInstance
= dwInstance
;
3622 wod
.uMappedDeviceID
= 0;
3625 /* when called from 16 bit code, mapper will be 0x0000FFFF instead of 0xFFFFFFFF */
3626 /* this should fix it */
3627 wmld
->uDeviceID
= (uDeviceID
== (UINT16
)-1 && !bFrom32
) ? (UINT
)-1 : uDeviceID
;
3629 dwRet
= MMDRV_Open(wmld
, (uType
==MMDRV_WAVEOUT
)?WODM_OPEN
:WIDM_OPEN
, (DWORD
)&wod
, dwFlags
);
3631 if ((dwFlags
& WAVE_FORMAT_QUERY
) || dwRet
!= MMSYSERR_NOERROR
) {
3632 MMDRV_Free(handle
, wmld
);
3636 if (lphndl
!= NULL
) *lphndl
= handle
;
3637 TRACE("=> %ld hWave=%04x\n", dwRet
, handle
);
3642 /**************************************************************************
3643 * waveOutGetNumDevs [MMSYSTEM.401]
3645 UINT WINAPI
waveOutGetNumDevs(void)
3647 return MMDRV_GetNum(MMDRV_WAVEOUT
);
3650 /**************************************************************************
3651 * waveOutGetNumDevs [WINMM.167]
3653 UINT16 WINAPI
waveOutGetNumDevs16(void)
3655 return MMDRV_GetNum(MMDRV_WAVEOUT
);
3658 /**************************************************************************
3659 * waveOutGetDevCaps [MMSYSTEM.402]
3661 UINT16 WINAPI
waveOutGetDevCaps16(UINT16 uDeviceID
,
3662 LPWAVEOUTCAPS16 lpCaps
, UINT16 uSize
)
3667 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
3668 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3670 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
3672 if (ret
== MMSYSERR_NOERROR
) {
3673 lpCaps
->wMid
= wocA
.wMid
;
3674 lpCaps
->wPid
= wocA
.wPid
;
3675 lpCaps
->vDriverVersion
= wocA
.vDriverVersion
;
3676 strcpy(lpCaps
->szPname
, wocA
.szPname
);
3677 lpCaps
->dwFormats
= wocA
.dwFormats
;
3678 lpCaps
->wChannels
= wocA
.wChannels
;
3679 lpCaps
->dwSupport
= wocA
.dwSupport
;
3684 /**************************************************************************
3685 * waveOutGetDevCapsA [WINMM.162]
3687 UINT WINAPI
waveOutGetDevCapsA(UINT uDeviceID
, LPWAVEOUTCAPSA lpCaps
,
3692 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
3694 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3696 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_WAVEOUT
, TRUE
)) == NULL
)
3697 return MMSYSERR_INVALHANDLE
;
3699 return MMDRV_Message(wmld
, WODM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
3703 /**************************************************************************
3704 * waveOutGetDevCapsW [WINMM.163]
3706 UINT WINAPI
waveOutGetDevCapsW(UINT uDeviceID
, LPWAVEOUTCAPSW lpCaps
,
3712 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
3714 ret
= waveOutGetDevCapsA(uDeviceID
, &wocA
, sizeof(wocA
));
3716 if (ret
== MMSYSERR_NOERROR
) {
3717 lpCaps
->wMid
= wocA
.wMid
;
3718 lpCaps
->wPid
= wocA
.wPid
;
3719 lpCaps
->vDriverVersion
= wocA
.vDriverVersion
;
3720 lstrcpyAtoW(lpCaps
->szPname
, wocA
.szPname
);
3721 lpCaps
->dwFormats
= wocA
.dwFormats
;
3722 lpCaps
->wChannels
= wocA
.wChannels
;
3723 lpCaps
->dwSupport
= wocA
.dwSupport
;
3728 /**************************************************************************
3729 * WAVE_GetErrorText [internal]
3731 static UINT16
WAVE_GetErrorText(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
3733 UINT16 ret
= MMSYSERR_BADERRNUM
;
3735 if (lpText
== NULL
) {
3736 ret
= MMSYSERR_INVALPARAM
;
3737 } else if (uSize
== 0) {
3738 ret
= MMSYSERR_NOERROR
;
3740 /* test has been removed 'coz MMSYSERR_BASE is 0, and gcc did emit
3741 * a warning for the test was always true */
3742 (/*uError >= MMSYSERR_BASE && */uError
<= MMSYSERR_LASTERROR
) ||
3743 (uError
>= WAVERR_BASE
&& uError
<= WAVERR_LASTERROR
)) {
3745 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance
,
3746 uError
, lpText
, uSize
) > 0) {
3747 ret
= MMSYSERR_NOERROR
;
3753 /**************************************************************************
3754 * waveOutGetErrorText [MMSYSTEM.403]
3756 UINT16 WINAPI
waveOutGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
3758 return WAVE_GetErrorText(uError
, lpText
, uSize
);
3761 /**************************************************************************
3762 * waveOutGetErrorTextA [WINMM.164]
3764 UINT WINAPI
waveOutGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
3766 return WAVE_GetErrorText(uError
, lpText
, uSize
);
3769 /**************************************************************************
3770 * waveOutGetErrorTextW [WINMM.165]
3772 UINT WINAPI
waveOutGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
3774 LPSTR xstr
= HeapAlloc(GetProcessHeap(), 0, uSize
);
3775 UINT ret
= WAVE_GetErrorText(uError
, xstr
, uSize
);
3777 lstrcpyAtoW(lpText
, xstr
);
3778 HeapFree(GetProcessHeap(), 0, xstr
);
3782 /**************************************************************************
3783 * waveOutOpen [WINMM.173]
3784 * All the args/structs have the same layout as the win16 equivalents
3786 UINT WINAPI
waveOutOpen(HWAVEOUT
* lphWaveOut
, UINT uDeviceID
,
3787 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
3788 DWORD dwInstance
, DWORD dwFlags
)
3790 return MMSYSTEM_waveOpen(lphWaveOut
, uDeviceID
, MMDRV_WAVEOUT
, lpFormat
,
3791 dwCallback
, dwInstance
, dwFlags
, TRUE
);
3794 /**************************************************************************
3795 * waveOutOpen [MMSYSTEM.404]
3797 UINT16 WINAPI
waveOutOpen16(HWAVEOUT16
* lphWaveOut
, UINT16 uDeviceID
,
3798 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
3799 DWORD dwInstance
, DWORD dwFlags
)
3804 /* since layout of WAVEOFORMATEX is the same for 16/32 bits, we directly
3805 * call the 32 bit version
3807 ret
= MMSYSTEM_waveOpen(&hWaveOut
, uDeviceID
, MMDRV_WAVEOUT
, lpFormat
,
3808 dwCallback
, dwInstance
, dwFlags
, FALSE
);
3810 if (lphWaveOut
!= NULL
) *lphWaveOut
= hWaveOut
;
3814 /**************************************************************************
3815 * waveOutClose [WINMM.161]
3817 UINT WINAPI
waveOutClose(HWAVEOUT hWaveOut
)
3822 TRACE("(%04X)\n", hWaveOut
);
3824 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3825 return MMSYSERR_INVALHANDLE
;
3827 dwRet
= MMDRV_Close(wmld
, WODM_CLOSE
);
3828 MMDRV_Free(hWaveOut
, wmld
);
3833 /**************************************************************************
3834 * waveOutClose [MMSYSTEM.405]
3836 UINT16 WINAPI
waveOutClose16(HWAVEOUT16 hWaveOut
)
3838 return waveOutClose(hWaveOut
);
3841 /**************************************************************************
3842 * waveOutPrepareHeader [WINMM.175]
3844 UINT WINAPI
waveOutPrepareHeader(HWAVEOUT hWaveOut
,
3845 WAVEHDR
* lpWaveOutHdr
, UINT uSize
)
3849 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3851 if (lpWaveOutHdr
== NULL
) return MMSYSERR_INVALPARAM
;
3853 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3854 return MMSYSERR_INVALHANDLE
;
3856 return MMDRV_Message(wmld
, WODM_PREPARE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3859 /**************************************************************************
3860 * waveOutPrepareHeader [MMSYSTEM.406]
3862 UINT16 WINAPI
waveOutPrepareHeader16(HWAVEOUT16 hWaveOut
,
3863 WAVEHDR
* /*SEGPTR*/ lpsegWaveOutHdr
,
3867 LPWAVEHDR lpWaveOutHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveOutHdr
);
3869 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
3871 if (lpWaveOutHdr
== NULL
) return MMSYSERR_INVALPARAM
;
3873 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3874 return MMSYSERR_INVALHANDLE
;
3876 return MMDRV_Message(wmld
, WODM_PREPARE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
3879 /**************************************************************************
3880 * waveOutUnprepareHeader [WINMM.181]
3882 UINT WINAPI
waveOutUnprepareHeader(HWAVEOUT hWaveOut
,
3883 LPWAVEHDR lpWaveOutHdr
, UINT uSize
)
3887 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3889 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
3890 return MMSYSERR_NOERROR
;
3893 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3894 return MMSYSERR_INVALHANDLE
;
3896 return MMDRV_Message(wmld
, WODM_UNPREPARE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3899 /**************************************************************************
3900 * waveOutUnprepareHeader [MMSYSTEM.407]
3902 UINT16 WINAPI
waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut
,
3903 LPWAVEHDR
/*SEGPTR*/ lpsegWaveOutHdr
,
3907 LPWAVEHDR lpWaveOutHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveOutHdr
);
3909 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
3911 if (!(lpWaveOutHdr
->dwFlags
& WHDR_PREPARED
)) {
3912 return MMSYSERR_NOERROR
;
3915 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3916 return MMSYSERR_INVALHANDLE
;
3918 return MMDRV_Message(wmld
, WODM_UNPREPARE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
3921 /**************************************************************************
3922 * waveOutWrite [MMSYSTEM.408]
3924 UINT WINAPI
waveOutWrite(HWAVEOUT hWaveOut
, LPWAVEHDR lpWaveOutHdr
,
3929 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpWaveOutHdr
, uSize
);
3931 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3932 return MMSYSERR_INVALHANDLE
;
3934 return MMDRV_Message(wmld
, WODM_WRITE
, (DWORD
)lpWaveOutHdr
, uSize
, TRUE
);
3937 /**************************************************************************
3938 * waveOutWrite [MMSYSTEM.408]
3940 UINT16 WINAPI
waveOutWrite16(HWAVEOUT16 hWaveOut
,
3941 LPWAVEHDR
/*SEGPTR*/ lpsegWaveOutHdr
,
3946 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpsegWaveOutHdr
, uSize
);
3948 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3949 return MMSYSERR_INVALHANDLE
;
3951 return MMDRV_Message(wmld
, WODM_WRITE
, (DWORD
)lpsegWaveOutHdr
, uSize
, FALSE
);
3954 #define WAVEOUT_SHORTCUT_0(xx, XX) \
3955 UINT WINAPI waveOut##xx(HWAVEOUT hWaveOut) \
3958 TRACE("(%04X);\n", hWaveOut); \
3959 if ((wmld = MMDRV_Get(hWaveOut,MMDRV_WAVEOUT,FALSE))==NULL) \
3960 return MMSYSERR_INVALHANDLE; \
3961 return MMDRV_Message(wmld,WODM_##XX,0L,0L,TRUE); \
3963 UINT16 WINAPI waveOut##xx##16(HWAVEOUT16 hWaveOut16) \
3964 {return waveOut##xx(hWaveOut16);}
3966 WAVEOUT_SHORTCUT_0(BreakLoop
, BREAKLOOP
)
3967 WAVEOUT_SHORTCUT_0(Pause
, PAUSE
)
3968 WAVEOUT_SHORTCUT_0(Reset
, RESET
)
3969 WAVEOUT_SHORTCUT_0(Restart
, RESTART
)
3970 #undef WAVEOUT_SHORTCUT_0
3972 /**************************************************************************
3973 * waveOutGetPosition [WINMM.170]
3975 UINT WINAPI
waveOutGetPosition(HWAVEOUT hWaveOut
, LPMMTIME lpTime
,
3980 TRACE("(%04X, %p, %u);\n", hWaveOut
, lpTime
, uSize
);
3982 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
3983 return MMSYSERR_INVALHANDLE
;
3985 return MMDRV_Message(wmld
, WODM_GETPOS
, (DWORD
)lpTime
, uSize
, TRUE
);
3988 /**************************************************************************
3989 * waveOutGetPosition [MMSYSTEM.412]
3991 UINT16 WINAPI
waveOutGetPosition16(HWAVEOUT16 hWaveOut
, LPMMTIME16 lpTime
,
3997 mmt
.wType
= lpTime
->wType
;
3998 ret
= waveOutGetPosition(hWaveOut
, &mmt
, sizeof(mmt
));
3999 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
4003 #define WAVEOUT_SHORTCUT_1(xx, XX, atype) \
4004 UINT WINAPI waveOut##xx(HWAVEOUT hWaveOut, atype x) \
4007 TRACE("(%04X, %08lx);\n", hWaveOut, (DWORD)x); \
4008 if ((wmld = MMDRV_Get(hWaveOut,MMDRV_WAVEOUT,FALSE))==NULL) \
4009 return MMSYSERR_INVALHANDLE; \
4010 return MMDRV_Message(wmld,WODM_##XX,(DWORD)x,0L,TRUE); \
4012 UINT16 WINAPI waveOut##xx##16(HWAVEOUT16 hWaveOut16, atype x) \
4013 {return waveOut##xx(hWaveOut16, x);}
4015 WAVEOUT_SHORTCUT_1(GetPitch
, GETPITCH
, LPDWORD
)
4016 WAVEOUT_SHORTCUT_1(SetPitch
, SETPITCH
, DWORD
)
4017 WAVEOUT_SHORTCUT_1(GetPlaybackRate
, GETPLAYBACKRATE
, LPDWORD
)
4018 WAVEOUT_SHORTCUT_1(SetPlaybackRate
, SETPLAYBACKRATE
, DWORD
)
4019 #undef WAVEOUT_SHORTCUT_1
4021 #define WAVEOUT_SHORTCUT_2(xx, XX, atype) \
4022 UINT WINAPI waveOut##xx(UINT devid, atype x) \
4025 TRACE("(%04X, %08lx);\n", devid, (DWORD)x); \
4026 if ((wmld = MMDRV_Get(devid,MMDRV_WAVEOUT,TRUE))==NULL) \
4027 return MMSYSERR_INVALHANDLE; \
4028 return MMDRV_Message(wmld, WODM_##XX, (DWORD)x, 0L, TRUE); \
4030 UINT16 WINAPI waveOut##xx##16(UINT16 devid, atype x) \
4031 {return waveOut##xx(devid, x);}
4033 WAVEOUT_SHORTCUT_2(GetVolume
, GETVOLUME
, LPDWORD
)
4034 WAVEOUT_SHORTCUT_2(SetVolume
, SETVOLUME
, DWORD
)
4035 #undef WAVEOUT_SHORTCUT_2
4037 /**************************************************************************
4038 * waveOutGetID [MMSYSTEM.420]
4040 UINT WINAPI
waveOutGetID(HWAVEOUT hWaveOut
, UINT
* lpuDeviceID
)
4044 TRACE("(%04X, %p);\n", hWaveOut
, lpuDeviceID
);
4046 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4048 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4049 return MMSYSERR_INVALHANDLE
;
4051 *lpuDeviceID
= wmld
->uDeviceID
;
4055 /**************************************************************************
4056 * waveOutGetID [MMSYSTEM.420]
4058 UINT16 WINAPI
waveOutGetID16(HWAVEOUT16 hWaveOut
, UINT16
* lpuDeviceID
)
4062 TRACE("(%04X, %p);\n", hWaveOut
, lpuDeviceID
);
4064 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4066 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4067 return MMSYSERR_INVALHANDLE
;
4069 *lpuDeviceID
= wmld
->uDeviceID
;
4073 /**************************************************************************
4074 * waveOutMessage [WINMM.172]
4076 DWORD WINAPI
waveOutMessage(HWAVEOUT hWaveOut
, UINT uMessage
,
4077 DWORD dwParam1
, DWORD dwParam2
)
4081 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
4084 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4085 return MMSYSERR_INVALPARAM
;
4087 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
)
4088 return MMSYSERR_INVALHANDLE
;
4090 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4093 /**************************************************************************
4094 * waveOutMessage [MMSYSTEM.421]
4096 DWORD WINAPI
waveOutMessage16(HWAVEOUT16 hWaveOut
, UINT16 uMessage
,
4097 DWORD dwParam1
, DWORD dwParam2
)
4101 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut
, uMessage
, dwParam1
, dwParam2
);
4103 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, FALSE
)) == NULL
) {
4104 if ((wmld
= MMDRV_Get(hWaveOut
, MMDRV_WAVEOUT
, TRUE
)) != NULL
) {
4105 return MMDRV_PhysicalFeatures(wmld
, uMessage
, dwParam1
, dwParam2
);
4107 return MMSYSERR_INVALHANDLE
;
4111 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4112 return MMSYSERR_INVALPARAM
;
4114 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, FALSE
);
4117 /**************************************************************************
4118 * waveInGetNumDevs [WINMM.151]
4120 UINT WINAPI
waveInGetNumDevs(void)
4122 return MMDRV_GetNum(MMDRV_WAVEIN
);
4125 /**************************************************************************
4126 * waveInGetNumDevs [MMSYSTEM.501]
4128 UINT16 WINAPI
waveInGetNumDevs16(void)
4130 return MMDRV_GetNum(MMDRV_WAVEIN
);
4133 /**************************************************************************
4134 * waveInGetDevCapsA [WINMM.147]
4136 UINT WINAPI
waveInGetDevCapsW(UINT uDeviceID
, LPWAVEINCAPSW lpCaps
, UINT uSize
)
4139 UINT ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, uSize
);
4141 if (ret
== MMSYSERR_NOERROR
) {
4142 lpCaps
->wMid
= wicA
.wMid
;
4143 lpCaps
->wPid
= wicA
.wPid
;
4144 lpCaps
->vDriverVersion
= wicA
.vDriverVersion
;
4145 lstrcpyAtoW(lpCaps
->szPname
, wicA
.szPname
);
4146 lpCaps
->dwFormats
= wicA
.dwFormats
;
4147 lpCaps
->wChannels
= wicA
.wChannels
;
4153 /**************************************************************************
4154 * waveInGetDevCapsA [WINMM.146]
4156 UINT WINAPI
waveInGetDevCapsA(UINT uDeviceID
, LPWAVEINCAPSA lpCaps
, UINT uSize
)
4160 TRACE("(%u %p %u)!\n", uDeviceID
, lpCaps
, uSize
);
4162 if ((wmld
= MMDRV_Get(uDeviceID
, MMDRV_WAVEIN
, TRUE
)) == NULL
)
4163 return MMSYSERR_INVALHANDLE
;
4165 return MMDRV_Message(wmld
, WIDM_GETDEVCAPS
, (DWORD
)lpCaps
, uSize
, TRUE
);
4168 /**************************************************************************
4169 * waveInGetDevCaps [MMSYSTEM.502]
4171 UINT16 WINAPI
waveInGetDevCaps16(UINT16 uDeviceID
, LPWAVEINCAPS16 lpCaps
,
4175 UINT ret
= waveInGetDevCapsA(uDeviceID
, &wicA
, sizeof(wicA
));
4177 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
4179 if (ret
== MMSYSERR_NOERROR
) {
4180 lpCaps
->wMid
= wicA
.wMid
;
4181 lpCaps
->wPid
= wicA
.wPid
;
4182 lpCaps
->vDriverVersion
= wicA
.vDriverVersion
;
4183 strcpy(lpCaps
->szPname
, wicA
.szPname
);
4184 lpCaps
->dwFormats
= wicA
.dwFormats
;
4185 lpCaps
->wChannels
= wicA
.wChannels
;
4190 /**************************************************************************
4191 * waveInGetErrorTextA [WINMM.148]
4193 UINT WINAPI
waveInGetErrorTextA(UINT uError
, LPSTR lpText
, UINT uSize
)
4195 return WAVE_GetErrorText(uError
, lpText
, uSize
);
4198 /**************************************************************************
4199 * waveInGetErrorTextW [WINMM.149]
4201 UINT WINAPI
waveInGetErrorTextW(UINT uError
, LPWSTR lpText
, UINT uSize
)
4203 LPSTR txt
= HeapAlloc(GetProcessHeap(), 0, uSize
);
4204 UINT ret
= WAVE_GetErrorText(uError
, txt
, uSize
);
4206 lstrcpyAtoW(lpText
, txt
);
4207 HeapFree(GetProcessHeap(), 0, txt
);
4211 /**************************************************************************
4212 * waveInGetErrorText [MMSYSTEM.503]
4214 UINT16 WINAPI
waveInGetErrorText16(UINT16 uError
, LPSTR lpText
, UINT16 uSize
)
4216 return WAVE_GetErrorText(uError
, lpText
, uSize
);
4219 /**************************************************************************
4220 * waveInOpen [WINMM.154]
4222 UINT WINAPI
waveInOpen(HWAVEIN
* lphWaveIn
, UINT uDeviceID
,
4223 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
4224 DWORD dwInstance
, DWORD dwFlags
)
4226 return MMSYSTEM_waveOpen(lphWaveIn
, uDeviceID
, MMDRV_WAVEIN
, lpFormat
,
4227 dwCallback
, dwInstance
, dwFlags
, TRUE
);
4230 /**************************************************************************
4231 * waveInOpen [MMSYSTEM.504]
4233 UINT16 WINAPI
waveInOpen16(HWAVEIN16
* lphWaveIn
, UINT16 uDeviceID
,
4234 const LPWAVEFORMATEX lpFormat
, DWORD dwCallback
,
4235 DWORD dwInstance
, DWORD dwFlags
)
4240 /* since layout of WAVEOFORMATEX is the same for 16/32 bits, we directly
4241 * call the 32 bit version
4243 ret
= MMSYSTEM_waveOpen(&hWaveIn
, uDeviceID
, MMDRV_WAVEIN
, lpFormat
,
4244 dwCallback
, dwInstance
, dwFlags
, FALSE
);
4246 if (lphWaveIn
!= NULL
) *lphWaveIn
= hWaveIn
;
4250 /**************************************************************************
4251 * waveInClose [WINMM.145]
4253 UINT WINAPI
waveInClose(HWAVEIN hWaveIn
)
4258 TRACE("(%04X)\n", hWaveIn
);
4260 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4261 return MMSYSERR_INVALHANDLE
;
4263 dwRet
= MMDRV_Message(wmld
, WIDM_CLOSE
, 0L, 0L, TRUE
);
4264 MMDRV_Free(hWaveIn
, wmld
);
4268 /**************************************************************************
4269 * waveInClose [MMSYSTEM.505]
4271 UINT16 WINAPI
waveInClose16(HWAVEIN16 hWaveIn
)
4273 return waveOutClose(hWaveIn
);
4276 /**************************************************************************
4277 * waveInPrepareHeader [WINMM.155]
4279 UINT WINAPI
waveInPrepareHeader(HWAVEIN hWaveIn
, WAVEHDR
* lpWaveInHdr
,
4284 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4286 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4287 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4288 return MMSYSERR_INVALHANDLE
;
4290 lpWaveInHdr
->dwBytesRecorded
= 0;
4292 return MMDRV_Message(wmld
, WIDM_PREPARE
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4295 /**************************************************************************
4296 * waveInPrepareHeader [MMSYSTEM.506]
4298 UINT16 WINAPI
waveInPrepareHeader16(HWAVEIN16 hWaveIn
,
4299 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4303 LPWAVEHDR lpWaveInHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveInHdr
);
4306 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4308 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALHANDLE
;
4309 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4310 return MMSYSERR_INVALHANDLE
;
4312 lpWaveInHdr
->dwBytesRecorded
= 0;
4314 ret
= MMDRV_Message(wmld
, WIDM_PREPARE
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4318 /**************************************************************************
4319 * waveInUnprepareHeader [WINMM.159]
4321 UINT WINAPI
waveInUnprepareHeader(HWAVEIN hWaveIn
, WAVEHDR
* lpWaveInHdr
,
4326 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4328 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4329 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
4330 return MMSYSERR_NOERROR
;
4333 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4334 return MMSYSERR_INVALHANDLE
;
4336 return MMDRV_Message(wmld
, WIDM_UNPREPARE
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4339 /**************************************************************************
4340 * waveInUnprepareHeader [MMSYSTEM.507]
4342 UINT16 WINAPI
waveInUnprepareHeader16(HWAVEIN16 hWaveIn
,
4343 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4347 LPWAVEHDR lpWaveInHdr
= (LPWAVEHDR
)PTR_SEG_TO_LIN(lpsegWaveInHdr
);
4349 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
4351 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4353 if (!(lpWaveInHdr
->dwFlags
& WHDR_PREPARED
)) {
4354 return MMSYSERR_NOERROR
;
4357 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4358 return MMSYSERR_INVALHANDLE
;
4360 return MMDRV_Message(wmld
, WIDM_UNPREPARE
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4363 /**************************************************************************
4364 * waveInAddBuffer [WINMM.144]
4366 UINT WINAPI
waveInAddBuffer(HWAVEIN hWaveIn
,
4367 WAVEHDR
* lpWaveInHdr
, UINT uSize
)
4371 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpWaveInHdr
, uSize
);
4373 if (lpWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4374 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4375 return MMSYSERR_INVALHANDLE
;
4377 return MMDRV_Message(wmld
, WIDM_ADDBUFFER
, (DWORD
)lpWaveInHdr
, uSize
, TRUE
);
4380 /**************************************************************************
4381 * waveInAddBuffer [MMSYSTEM.508]
4383 UINT16 WINAPI
waveInAddBuffer16(HWAVEIN16 hWaveIn
,
4384 WAVEHDR
* /* SEGPTR */ lpsegWaveInHdr
,
4389 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpsegWaveInHdr
, uSize
);
4391 if (lpsegWaveInHdr
== NULL
) return MMSYSERR_INVALPARAM
;
4392 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4393 return MMSYSERR_INVALHANDLE
;
4395 return MMDRV_Message(wmld
, WIDM_ADDBUFFER
, (DWORD
)lpsegWaveInHdr
, uSize
, FALSE
);
4398 #define WAVEIN_SHORTCUT_0(xx, XX) \
4399 UINT WINAPI waveIn##xx(HWAVEIN hWaveIn) \
4402 TRACE("(%04X);\n", hWaveIn); \
4403 if ((wmld=MMDRV_Get(hWaveIn,MMDRV_WAVEIN,FALSE)) == NULL) \
4404 return MMSYSERR_INVALHANDLE; \
4405 return MMDRV_Message(wmld,WIDM_##XX,0L,0L,TRUE); \
4407 UINT16 WINAPI waveIn##xx##16(HWAVEIN16 hWaveIn16) \
4408 {return waveIn##xx(hWaveIn16);}
4410 WAVEIN_SHORTCUT_0(Reset
, RESET
)
4411 WAVEIN_SHORTCUT_0(Start
, START
)
4412 WAVEIN_SHORTCUT_0(Stop
, STOP
)
4413 #undef WAVEIN_SHORTCUT_0
4415 /**************************************************************************
4416 * waveInGetPosition [WINMM.152]
4418 UINT WINAPI
waveInGetPosition(HWAVEIN hWaveIn
, LPMMTIME lpTime
,
4423 TRACE("(%04X, %p, %u);\n", hWaveIn
, lpTime
, uSize
);
4425 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4426 return MMSYSERR_INVALHANDLE
;
4428 return MMDRV_Message(wmld
, WIDM_GETPOS
, (DWORD
)lpTime
, uSize
, TRUE
);
4431 /**************************************************************************
4432 * waveInGetPosition [MMSYSTEM.512]
4434 UINT16 WINAPI
waveInGetPosition16(HWAVEIN16 hWaveIn
, LPMMTIME16 lpTime
,
4440 mmt
.wType
= lpTime
->wType
;
4441 ret
= waveInGetPosition(hWaveIn
, &mmt
, sizeof(mmt
));
4442 MMSYSTEM_MMTIME32to16(lpTime
, &mmt
);
4446 /**************************************************************************
4447 * waveInGetID [WINMM.150]
4449 UINT WINAPI
waveInGetID(HWAVEIN hWaveIn
, UINT
* lpuDeviceID
)
4453 TRACE("(%04X, %p);\n", hWaveIn
, lpuDeviceID
);
4455 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4457 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4458 return MMSYSERR_INVALHANDLE
;
4460 *lpuDeviceID
= wmld
->uDeviceID
;
4461 return MMSYSERR_NOERROR
;
4464 /**************************************************************************
4465 * waveInGetID [MMSYSTEM.513]
4467 UINT16 WINAPI
waveInGetID16(HWAVEIN16 hWaveIn
, UINT16
* lpuDeviceID
)
4471 TRACE("(%04X, %p);\n", hWaveIn
, lpuDeviceID
);
4473 if (lpuDeviceID
== NULL
) return MMSYSERR_INVALHANDLE
;
4475 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4476 return MMSYSERR_INVALHANDLE
;
4478 *lpuDeviceID
= wmld
->uDeviceID
;
4479 return MMSYSERR_NOERROR
;
4482 /**************************************************************************
4483 * waveInMessage [WINMM.153]
4485 DWORD WINAPI
waveInMessage(HWAVEIN hWaveIn
, UINT uMessage
,
4486 DWORD dwParam1
, DWORD dwParam2
)
4490 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
4493 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4494 return MMSYSERR_INVALPARAM
;
4496 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4497 return MMSYSERR_INVALHANDLE
;
4499 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4502 /**************************************************************************
4503 * waveInMessage [MMSYSTEM.514]
4505 DWORD WINAPI
waveInMessage16(HWAVEIN16 hWaveIn
, UINT16 uMessage
,
4506 DWORD dwParam1
, DWORD dwParam2
)
4510 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn
, uMessage
, dwParam1
, dwParam2
);
4513 if (uMessage
< DRVM_IOCTL
|| (uMessage
>= DRVM_IOCTL_LAST
&& uMessage
< DRVM_MAPPER
))
4514 return MMSYSERR_INVALPARAM
;
4516 if ((wmld
= MMDRV_Get(hWaveIn
, MMDRV_WAVEIN
, FALSE
)) == NULL
)
4517 return MMSYSERR_INVALHANDLE
;
4519 return MMDRV_Message(wmld
, uMessage
, dwParam1
, dwParam2
, TRUE
);
4522 /**************************************************************************
4523 * DrvOpen [MMSYSTEM.1100]
4525 HDRVR16 WINAPI
DrvOpen(LPSTR lpDriverName
, LPSTR lpSectionName
, LPARAM lParam
)
4527 TRACE("('%s','%s', %08lX);\n", lpDriverName
, lpSectionName
, lParam
);
4529 return OpenDriver16(lpDriverName
, lpSectionName
, lParam
);
4532 /**************************************************************************
4533 * DrvClose [MMSYSTEM.1101]
4535 LRESULT WINAPI
DrvClose(HDRVR16 hDrv
, LPARAM lParam1
, LPARAM lParam2
)
4537 TRACE("(%04X, %08lX, %08lX);\n", hDrv
, lParam1
, lParam2
);
4539 return CloseDriver16(hDrv
, lParam1
, lParam2
);
4542 /**************************************************************************
4543 * DrvSendMessage [MMSYSTEM.1102]
4545 LRESULT WINAPI
DrvSendMessage(HDRVR16 hDrv
, WORD msg
, LPARAM lParam1
,
4548 return SendDriverMessage(hDrv
, msg
, lParam1
, lParam2
);
4551 /**************************************************************************
4552 * DrvGetModuleHandle [MMSYSTEM.1103]
4554 HANDLE16 WINAPI
DrvGetModuleHandle16(HDRVR16 hDrv
)
4556 return GetDriverModuleHandle16(hDrv
);
4559 /**************************************************************************
4560 * DrvDefDriverProc [MMSYSTEM.1104]
4562 LRESULT WINAPI
DrvDefDriverProc(DWORD dwDriverID
, HDRVR16 hDrv
, WORD wMsg
,
4563 DWORD dwParam1
, DWORD dwParam2
)
4565 /* FIXME : any mapping from 32 to 16 bit structure ? */
4566 return DefDriverProc16(dwDriverID
, hDrv
, wMsg
, dwParam1
, dwParam2
);
4569 /**************************************************************************
4570 * DefDriverProc [WINMM.5]
4572 LRESULT WINAPI
DefDriverProc(DWORD dwDriverIdentifier
, HDRVR hDrv
,
4573 UINT Msg
, LPARAM lParam1
, LPARAM lParam2
)
4589 /*#define USE_MM_TSK_WINE*/
4591 /**************************************************************************
4592 * mmTaskCreate [MMSYSTEM.900]
4594 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
4595 * called upon creation with dwPmt as parameter.
4597 HINSTANCE16 WINAPI
mmTaskCreate16(SEGPTR spProc
, HINSTANCE16
*lphMmTask
, DWORD dwPmt
)
4599 DWORD showCmd
= 0x40002;
4606 TRACE("(%08lx, %p, %08lx);\n", spProc
, lphMmTask
, dwPmt
);
4607 /* This to work requires NE modules to be started with a binary command line
4608 * which is not currently the case. A patch exists but has never been committed.
4609 * A workaround would be to integrate code for mmtask.tsk into Wine, but
4610 * this requires tremendous work (starting with patching tools/build to
4611 * create NE executables (and not only DLLs) for builtins modules.
4614 FIXME("This is currently broken. It will fail\n");
4616 cmdline
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, 0x0d);
4618 *(LPDWORD
)(cmdline
+ 1) = (DWORD
)spProc
;
4619 *(LPDWORD
)(cmdline
+ 5) = dwPmt
;
4620 *(LPDWORD
)(cmdline
+ 9) = 0;
4622 sel1
= SELECTOR_AllocBlock(cmdline
, 0x0d, SEGMENT_DATA
, FALSE
, FALSE
);
4623 sel2
= SELECTOR_AllocBlock(&showCmd
, sizeof(showCmd
),
4624 SEGMENT_DATA
, FALSE
, FALSE
);
4626 lp
= (LOADPARAMS16
*)HeapAlloc(GetProcessHeap(), 0, sizeof(LOADPARAMS16
));
4627 lp
->hEnvironment
= 0;
4628 lp
->cmdLine
= PTR_SEG_OFF_TO_SEGPTR(sel1
, 0);
4629 lp
->showCmd
= PTR_SEG_OFF_TO_SEGPTR(sel2
, 0);
4632 #ifndef USE_MM_TSK_WINE
4633 handle
= LoadModule16("c:\\windows\\system\\mmtask.tsk", lp
);
4635 handle
= LoadModule16("mmtask.tsk", lp
);
4638 ret
= (handle
) ? 1 : 2;
4644 *lphMmTask
= handle
;
4646 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel2
, 0));
4647 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel1
, 0));
4649 HeapFree(GetProcessHeap(), 0, lp
);
4650 HeapFree(GetProcessHeap(), 0, cmdline
);
4652 TRACE("=> 0x%04x/%d\n", handle
, ret
);
4656 #ifdef USE_MM_TSK_WINE
4657 /* C equivalent to mmtask.tsk binary content */
4658 void mmTaskEntryPoint16(LPSTR cmdLine
, WORD di
, WORD si
)
4660 int len
= cmdLine
[0x80];
4663 void (*fpProc
)(DWORD
) = (void (*)(DWORD
))PTR_SEG_TO_LIN(*((DWORD
*)(cmdLine
+ 1)));
4664 DWORD dwPmt
= *((DWORD
*)(cmdLine
+ 5));
4667 InitTask16(); /* fixme: pmts / from context ? */
4670 if (SetMessageQueue16(0x40)) {
4672 if (HIWORD(fpProc
)) {
4674 /* EPP StackEnter16(); */
4686 /**************************************************************************
4687 * mmTaskBlock [MMSYSTEM.902]
4689 void WINAPI
mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst
)
4694 GetMessageA(&msg
, 0, 0, 0);
4696 TranslateMessage(&msg
);
4697 DispatchMessageA(&msg
);
4699 } while (msg
.message
< 0x3A0);
4702 /**************************************************************************
4703 * mmTaskSignal [MMSYSTEM.903]
4705 LRESULT WINAPI
mmTaskSignal16(HTASK16 ht
)
4707 TRACE("(%04x);\n", ht
);
4708 return Callout
.PostAppMessage16(ht
, WM_USER
, 0, 0);
4711 /**************************************************************************
4712 * mmTaskYield16 [MMSYSTEM.905]
4714 void WINAPI
mmTaskYield16(void)
4718 if (PeekMessageA(&msg
, 0, 0, 0, 0)) {
4723 DWORD WINAPI
GetProcessFlags(DWORD
);
4725 /**************************************************************************
4726 * mmThreadCreate [MMSYSTEM.1120]
4729 * Creates a MM thread, calling fpThreadAddr(dwPmt).
4731 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
4732 * bit.1 set means to open a VxD for this thread (unsupported)
4734 LRESULT WINAPI
mmThreadCreate16(FARPROC16 fpThreadAddr
, LPHANDLE lpHndl
, DWORD dwPmt
, DWORD dwFlags
)
4739 TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr
, lpHndl
, dwPmt
, dwFlags
);
4741 hndl
= GlobalAlloc16(sizeof(WINE_MMTHREAD
), GMEM_SHARE
|GMEM_ZEROINIT
);
4746 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4749 /* force mmtask routines even if mmthread is required */
4750 /* this will work only if the patch about binary cmd line and NE tasks
4756 lpMMThd
->dwSignature
= WINE_MMTHREAD_CREATED
;
4757 lpMMThd
->dwCounter
= 0;
4758 lpMMThd
->hThread
= 0;
4759 lpMMThd
->dwThreadID
= 0;
4760 lpMMThd
->fpThread
= fpThreadAddr
;
4761 lpMMThd
->dwThreadPmt
= dwPmt
;
4762 lpMMThd
->dwSignalCount
= 0;
4763 lpMMThd
->hEvent
= 0;
4765 lpMMThd
->dwStatus
= 0;
4766 lpMMThd
->dwFlags
= dwFlags
;
4769 if ((dwFlags
& 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
4770 lpMMThd
->hEvent
= CreateEventA(0, 0, 1, 0);
4772 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd
);
4773 if (lpMMThd
->dwFlags
& 2) {
4774 /* as long as we don't support MM VxD in wine, we don't need
4775 * to care about this flag
4777 /* FIXME("Don't know how to properly open VxD handles\n"); */
4778 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
4781 lpMMThd
->hThread
= CreateThread(0, 0, (LPTHREAD_START_ROUTINE
)WINE_mmThreadEntryPoint
,
4782 (LPVOID
)(DWORD
)hndl
, CREATE_SUSPENDED
, &lpMMThd
->dwThreadID
);
4783 if (lpMMThd
->hThread
== 0) {
4784 WARN("Couldn't create thread\n");
4785 /* clean-up(VxDhandle...); devicedirectio... */
4786 if (lpMMThd
->hEvent
!= 0)
4787 CloseHandle(lpMMThd
->hEvent
);
4790 TRACE("Got a nice thread hndl=0x%04x id=0x%08lx\n", lpMMThd
->hThread
, lpMMThd
->dwThreadID
);
4794 /* get WINE_mmThreadEntryPoint()
4795 * 2047 is its ordinal in mmsystem.spec
4797 FARPROC16 fp
= GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (SEGPTR
)2047);
4799 TRACE("farproc seg=0x%08lx lin=%p\n", (DWORD
)fp
, PTR_SEG_TO_LIN(fp
));
4801 ret
= (fp
== 0) ? 2 : mmTaskCreate16((DWORD
)fp
, 0, hndl
);
4805 if (lpMMThd
->hThread
&& !ResumeThread(lpMMThd
->hThread
))
4806 WARN("Couldn't resume thread\n");
4808 while (lpMMThd
->dwStatus
!= 0x10) { /* test also HIWORD of dwStatus */
4822 TRACE("ok => %ld\n", ret
);
4826 /**************************************************************************
4827 * mmThreadSignal [MMSYSTEM.1121]
4829 void WINAPI
mmThreadSignal16(HANDLE16 hndl
)
4831 TRACE("(%04x)!\n", hndl
);
4834 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4836 lpMMThd
->dwCounter
++;
4837 if (lpMMThd
->hThread
!= 0) {
4838 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
4839 SetEvent(lpMMThd
->hEvent
);
4841 mmTaskSignal16(lpMMThd
->hTask
);
4843 lpMMThd
->dwCounter
--;
4847 /**************************************************************************
4848 * MMSYSTEM_ThreadBlock [internal]
4850 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD
* lpMMThd
)
4855 if (lpMMThd
->dwThreadID
!= GetCurrentThreadId())
4856 ERR("Not called by thread itself\n");
4859 ResetEvent(lpMMThd
->hEvent
);
4860 if (InterlockedDecrement(&lpMMThd
->dwSignalCount
) >= 0)
4862 InterlockedIncrement(&lpMMThd
->dwSignalCount
);
4866 ret
= MsgWaitForMultipleObjects(1, &lpMMThd
->hEvent
, FALSE
, INFINITE
, QS_ALLINPUT
);
4868 case WAIT_OBJECT_0
: /* Event */
4871 case WAIT_OBJECT_0
+ 1: /* Msg */
4873 if (Callout
.PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) {
4874 Callout
.TranslateMessage(&msg
);
4875 Callout
.DispatchMessageA(&msg
);
4879 WARN("S2.x unsupported ret val 0x%08lx\n", ret
);
4885 /**************************************************************************
4886 * mmThreadBlock [MMSYSTEM.1122]
4888 void WINAPI
mmThreadBlock16(HANDLE16 hndl
)
4890 TRACE("(%04x)!\n", hndl
);
4893 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4895 if (lpMMThd
->hThread
!= 0) {
4896 SYSLEVEL_ReleaseWin16Lock();
4897 MMSYSTEM_ThreadBlock(lpMMThd
);
4898 SYSLEVEL_RestoreWin16Lock();
4900 mmTaskBlock16(lpMMThd
->hTask
);
4906 /**************************************************************************
4907 * mmThreadIsCurrent [MMSYSTEM.1123]
4909 BOOL16 WINAPI
mmThreadIsCurrent16(HANDLE16 hndl
)
4913 TRACE("(%04x)!\n", hndl
);
4915 if (hndl
&& mmThreadIsValid16(hndl
)) {
4916 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4917 ret
= (GetCurrentThreadId() == lpMMThd
->dwThreadID
);
4919 TRACE("=> %d\n", ret
);
4923 /**************************************************************************
4924 * mmThreadIsValid [MMSYSTEM.1124]
4926 BOOL16 WINAPI
mmThreadIsValid16(HANDLE16 hndl
)
4930 TRACE("(%04x)!\n", hndl
);
4933 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4935 if (!IsBadWritePtr(lpMMThd
, sizeof(WINE_MMTHREAD
)) &&
4936 lpMMThd
->dwSignature
== WINE_MMTHREAD_CREATED
&&
4937 IsTask16(lpMMThd
->hTask
)) {
4938 lpMMThd
->dwCounter
++;
4939 if (lpMMThd
->hThread
!= 0) {
4941 if (GetExitCodeThread(lpMMThd
->hThread
, &dwThreadRet
) &&
4942 dwThreadRet
== STATUS_PENDING
) {
4948 lpMMThd
->dwCounter
--;
4951 TRACE("=> %d\n", ret
);
4955 /**************************************************************************
4956 * mmThreadGetTask [MMSYSTEM.1125]
4958 HANDLE16 WINAPI
mmThreadGetTask16(HANDLE16 hndl
)
4962 TRACE("(%04x)\n", hndl
);
4964 if (mmThreadIsValid16(hndl
)) {
4965 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4966 ret
= lpMMThd
->hTask
;
4971 /* ### start build ### */
4972 extern LONG CALLBACK
MMSYSTEM_CallTo16_long_l (FARPROC16
,LONG
);
4973 /* ### stop build ### */
4975 /**************************************************************************
4976 * mmThreadGetTask [internal]
4978 void WINAPI
WINE_mmThreadEntryPoint(DWORD _pmt
)
4980 HANDLE16 hndl
= (HANDLE16
)_pmt
;
4981 WINE_MMTHREAD
* lpMMThd
= (WINE_MMTHREAD
*)PTR_SEG_OFF_TO_LIN(hndl
, 0);
4983 TRACE("(%04x %p)\n", hndl
, lpMMThd
);
4985 lpMMThd
->hTask
= LOWORD(GetCurrentTask());
4986 TRACE("[10-%08x] setting hTask to 0x%08x\n", lpMMThd
->hThread
, lpMMThd
->hTask
);
4987 lpMMThd
->dwStatus
= 0x10;
4988 MMSYSTEM_ThreadBlock(lpMMThd
);
4989 TRACE("[20-%08x]\n", lpMMThd
->hThread
);
4990 lpMMThd
->dwStatus
= 0x20;
4991 if (lpMMThd
->fpThread
) {
4992 MMSYSTEM_CallTo16_long_l(lpMMThd
->fpThread
, lpMMThd
->dwThreadPmt
);
4994 lpMMThd
->dwStatus
= 0x30;
4995 TRACE("[30-%08x]\n", lpMMThd
->hThread
);
4996 while (lpMMThd
->dwCounter
) {
5000 TRACE("[XX-%08x]\n", lpMMThd
->hThread
);
5002 lpMMThd
->dwSignature
= WINE_MMTHREAD_DELETED
;
5003 /* close lpMMThread->hVxD directio */
5004 if (lpMMThd
->hEvent
)
5005 CloseHandle(lpMMThd
->hEvent
);
5010 typedef BOOL16 (WINAPI
*MMCPLCALLBACK
)(HWND
, LPCSTR
, LPCSTR
, LPCSTR
);
5012 /**************************************************************************
5013 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
5015 BOOL16 WINAPI
mmShowMMCPLPropertySheet16(HWND hWnd
, LPCSTR lpStrDevice
,
5016 LPCSTR lpStrTab
, LPCSTR lpStrTitle
)
5021 TRACE("(%04x \"%s\" \"%s\" \"%s\")\n", hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
5023 hndl
= LoadLibraryA("MMSYS.CPL");
5025 MMCPLCALLBACK fp
= (MMCPLCALLBACK
)GetProcAddress(hndl
, "ShowMMCPLPropertySheet");
5027 SYSLEVEL_ReleaseWin16Lock();
5028 ret
= (fp
)(hWnd
, lpStrDevice
, lpStrTab
, lpStrTitle
);
5029 SYSLEVEL_RestoreWin16Lock();
5037 /**************************************************************************
5038 * StackEnter & StackLeave [MMSYSTEM.32][MMSYSTEM.33]
5040 void WINAPI
StackEnterLeave16(void)
5043 /* mmsystem.dll from Win 95 does only this: so does Wine */