1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1993 Martin Ayotte
11 * 98/9 added Win32 MCI support
12 * 99/4 added mmTask and mmThread functions support
13 * added midiStream support
14 * 99/9 added support for loadable low level drivers
17 /* FIXME: I think there are some segmented vs. linear pointer weirdnesses
18 * and long term pointers to 16 bit space in here
25 #include "wine/winuser16.h"
28 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(mmsys);
33 static LPWINE_MM_IDATA lpFirstIData = NULL;
35 static LPWINE_MM_IDATA MULTIMEDIA_GetIDataNoCheck(void)
37 DWORD pid = GetCurrentProcessId();
38 LPWINE_MM_IDATA iData;
40 for (iData = lpFirstIData; iData; iData = iData->lpNextIData) {
41 if (iData->dwThisProcess == pid)
47 /**************************************************************************
48 * MULTIMEDIA_GetIData [internal]
50 LPWINE_MM_IDATA MULTIMEDIA_GetIData(void)
52 LPWINE_MM_IDATA iData = MULTIMEDIA_GetIDataNoCheck();
55 ERR("IData not found for pid=%08lx. Suicide !!!\n", GetCurrentProcessId());
62 /**************************************************************************
63 * MULTIMEDIA_CreateIData [internal]
65 static BOOL MULTIMEDIA_CreateIData(HINSTANCE hInstDLL)
67 LPWINE_MM_IDATA iData;
69 iData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MM_IDATA));
73 iData->hWinMM32Instance = hInstDLL;
74 iData->dwThisProcess = GetCurrentProcessId();
75 iData->lpNextIData = lpFirstIData;
77 InitializeCriticalSection(&iData->cs);
78 TRACE("Created IData (%p) for pid %08lx\n", iData, iData->dwThisProcess);
82 /**************************************************************************
83 * MULTIMEDIA_DeleteIData [internal]
85 static void MULTIMEDIA_DeleteIData(void)
87 LPWINE_MM_IDATA iData = MULTIMEDIA_GetIDataNoCheck();
88 LPWINE_MM_IDATA* ppid;
93 for (ppid = &lpFirstIData; *ppid; ppid = &(*ppid)->lpNextIData) {
95 *ppid = iData->lpNextIData;
99 /* FIXME: should also free content and resources allocated
101 HeapFree(GetProcessHeap(), 0, iData);
105 /**************************************************************************
106 * WINMM_LibMain [EntryPoint]
108 * WINMM DLL entry point
111 BOOL WINAPI WINMM_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
113 TRACE("0x%x 0x%lx %p\n", hInstDLL, fdwReason, fImpLoad);
116 case DLL_PROCESS_ATTACH:
117 if (!MULTIMEDIA_CreateIData(hInstDLL))
119 if (!MULTIMEDIA_MciInit() || !MMDRV_Init()) {
120 MULTIMEDIA_DeleteIData();
124 case DLL_PROCESS_DETACH:
125 MULTIMEDIA_DeleteIData();
127 case DLL_THREAD_ATTACH:
128 case DLL_THREAD_DETACH:
134 /**************************************************************************
135 * MMSYSTEM_LibMain [EntryPoint]
137 * MMSYSTEM DLL entry point
140 BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
141 WORD wHeapSize, DWORD dwReserved1, WORD wReserved2)
144 LPWINE_MM_IDATA iData;
146 TRACE("0x%x 0x%lx\n", hinstDLL, fdwReason);
149 case DLL_PROCESS_ATTACH:
150 /* need to load WinMM in order to:
151 * - initiate correctly shared variables (MULTIMEDIA_Init())
152 * - create correctly the per process WINE_MM_IDATA chunk
154 hndl = LoadLibraryA("WINMM.DLL");
157 ERR("Could not load sibling WinMM.dll\n");
160 iData = MULTIMEDIA_GetIData();
161 iData->hWinMM16Instance = hinstDLL;
162 iData->h16Module32 = hndl;
164 case DLL_PROCESS_DETACH:
165 iData = MULTIMEDIA_GetIData();
166 FreeLibrary(iData->h16Module32);
168 case DLL_THREAD_ATTACH:
169 case DLL_THREAD_DETACH:
175 /**************************************************************************
176 * MMSYSTEM_WEP [MMSYSTEM.1]
178 int WINAPI MMSYSTEM_WEP(HINSTANCE16 hInstance, WORD wDataSeg,
179 WORD cbHeapSize, LPSTR lpCmdLine)
181 FIXME("STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance);
185 void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16, const MMTIME* mmt32)
187 mmt16->wType = mmt32->wType;
188 /* layout of rest is the same for 32/16,
189 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
191 memcpy(&(mmt16->u), &(mmt32->u), sizeof(mmt16->u));
194 void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16)
196 mmt32->wType = mmt16->wType;
197 /* layout of rest is the same for 32/16,
198 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
200 memcpy(&(mmt32->u), &(mmt16->u), sizeof(mmt16->u));
203 static HANDLE PlaySound_hThread = 0;
204 static HANDLE PlaySound_hPlayEvent = 0;
205 static HANDLE PlaySound_hReadyEvent = 0;
206 static HANDLE PlaySound_hMiddleEvent = 0;
207 static BOOL PlaySound_Result = FALSE;
208 static int PlaySound_Stop = FALSE;
209 static int PlaySound_Playing = FALSE;
211 static LPCSTR PlaySound_pszSound = NULL;
212 static HMODULE PlaySound_hmod = 0;
213 static DWORD PlaySound_fdwSound = 0;
214 static int PlaySound_Loop = FALSE;
215 static int PlaySound_SearchMode = 0; /* 1 - sndPlaySound search order
216 2 - PlaySound order */
218 static HMMIO get_mmioFromFile(LPCSTR lpszName)
220 return mmioOpenA((LPSTR)lpszName, NULL,
221 MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
224 static HMMIO get_mmioFromProfile(UINT uFlags, LPCSTR lpszName)
230 TRACE("searching in SystemSound List !\n");
231 GetProfileStringA("Sounds", (LPSTR)lpszName, "", str, sizeof(str));
232 if (strlen(str) == 0) {
233 if (uFlags & SND_NODEFAULT) return 0;
234 GetProfileStringA("Sounds", "Default", "", str, sizeof(str));
235 if (strlen(str) == 0) return 0;
237 if ((ptr = (LPSTR)strchr(str, ',')) != NULL) *ptr = '\0';
238 hmmio = get_mmioFromFile(str);
240 WARN("can't find SystemSound='%s' !\n", str);
246 struct playsound_data {
251 static void CALLBACK PlaySound_Callback(HWAVEOUT hwo, UINT uMsg,
253 DWORD dwParam1, DWORD dwParam2)
255 struct playsound_data* s = (struct playsound_data*)dwInstance;
262 InterlockedIncrement(&s->dwEventCount);
263 TRACE("Returning waveHdr=%lx\n", dwParam1);
267 ERR("Unknown uMsg=%d\n", uMsg);
271 static void PlaySound_WaitDone(struct playsound_data* s)
274 ResetEvent(s->hEvent);
275 if (InterlockedDecrement(&s->dwEventCount) >= 0) {
278 InterlockedIncrement(&s->dwEventCount);
280 WaitForSingleObject(s->hEvent, INFINITE);
284 static BOOL WINAPI proc_PlaySound(LPCSTR lpszSoundName, UINT uFlags)
290 LPWAVEFORMATEX lpWaveFormat = NULL;
292 LPWAVEHDR waveHdr = NULL;
293 INT count, bufsize, left, index;
294 struct playsound_data s;
298 TRACE("SoundName='%s' uFlags=%04X !\n", lpszSoundName, uFlags);
299 if (lpszSoundName == NULL) {
303 if (uFlags & SND_MEMORY) {
305 memset(&mminfo, 0, sizeof(mminfo));
306 mminfo.fccIOProc = FOURCC_MEM;
307 mminfo.pchBuffer = (LPSTR)lpszSoundName;
308 mminfo.cchBuffer = -1;
309 TRACE("Memory sound %p\n", lpszSoundName);
310 hmmio = mmioOpenA(NULL, &mminfo, MMIO_READ);
313 if (uFlags & SND_ALIAS)
314 if ((hmmio = get_mmioFromProfile(uFlags, lpszSoundName)) == 0)
317 if (uFlags & SND_FILENAME)
318 if ((hmmio=get_mmioFromFile(lpszSoundName)) == 0) return FALSE;
320 if (PlaySound_SearchMode == 1) {
321 PlaySound_SearchMode = 0;
322 if ((hmmio = get_mmioFromFile(lpszSoundName)) == 0)
323 hmmio = get_mmioFromProfile(uFlags, lpszSoundName);
326 if (PlaySound_SearchMode == 2) {
327 PlaySound_SearchMode = 0;
328 if ((hmmio = get_mmioFromProfile(uFlags | SND_NODEFAULT, lpszSoundName)) == 0)
329 if ((hmmio = get_mmioFromFile(lpszSoundName)) == 0)
330 hmmio = get_mmioFromProfile(uFlags, lpszSoundName);
333 if (hmmio == 0) return FALSE;
335 if (mmioDescend(hmmio, &ckMainRIFF, NULL, 0))
338 TRACE("ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX \n",
339 (LPSTR)&ckMainRIFF.ckid, (LPSTR)&ckMainRIFF.fccType, ckMainRIFF.cksize);
341 if ((ckMainRIFF.ckid != FOURCC_RIFF) ||
342 (ckMainRIFF.fccType != mmioFOURCC('W', 'A', 'V', 'E')))
345 mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' ');
346 if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK))
349 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n",
350 (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize);
352 lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
353 if (mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize) < sizeof(WAVEFORMAT))
356 TRACE("wFormatTag=%04X !\n", lpWaveFormat->wFormatTag);
357 TRACE("nChannels=%d \n", lpWaveFormat->nChannels);
358 TRACE("nSamplesPerSec=%ld\n", lpWaveFormat->nSamplesPerSec);
359 TRACE("nAvgBytesPerSec=%ld\n", lpWaveFormat->nAvgBytesPerSec);
360 TRACE("nBlockAlign=%d \n", lpWaveFormat->nBlockAlign);
361 TRACE("wBitsPerSample=%u !\n", lpWaveFormat->wBitsPerSample);
363 /* move to end of 'fmt ' chunk */
364 mmioAscend(hmmio, &mmckInfo, 0);
366 mmckInfo.ckid = mmioFOURCC('d', 'a', 't', 'a');
367 if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK))
370 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n",
371 (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize);
373 s.hEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
375 if (waveOutOpen(&hWave, WAVE_MAPPER, lpWaveFormat, (DWORD)PlaySound_Callback,
376 (DWORD)&s, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
379 /* make it so that 3 buffers per second are needed */
380 bufsize = (((lpWaveFormat->nAvgBytesPerSec / 3) - 1) / lpWaveFormat->nBlockAlign + 1) *
381 lpWaveFormat->nBlockAlign;
382 waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize);
383 waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
384 waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
385 waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
386 waveHdr[0].dwLoops = waveHdr[1].dwLoops = 0L;
387 waveHdr[0].dwFlags = waveHdr[1].dwFlags = 0L;
388 waveHdr[0].dwBufferLength = waveHdr[1].dwBufferLength = bufsize;
389 if (waveOutPrepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR)) ||
390 waveOutPrepareHeader(hWave, &waveHdr[1], sizeof(WAVEHDR))) {
396 left = mmckInfo.cksize;
397 s.dwEventCount = 1L; /* for first buffer */
399 mmioSeek(hmmio, mmckInfo.dwDataOffset, SEEK_SET);
401 if (PlaySound_Stop) {
402 PlaySound_Stop = PlaySound_Loop = FALSE;
405 count = mmioRead(hmmio, waveHdr[index].lpData, min(bufsize, left));
406 if (count < 1) break;
408 waveHdr[index].dwBufferLength = count;
409 waveHdr[index].dwFlags &= ~WHDR_DONE;
410 waveOutWrite(hWave, &waveHdr[index], sizeof(WAVEHDR));
412 PlaySound_WaitDone(&s);
415 } while (PlaySound_Loop);
417 PlaySound_WaitDone(&s);
420 waveOutUnprepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR));
421 waveOutUnprepareHeader(hWave, &waveHdr[1], sizeof(WAVEHDR));
424 CloseHandle(s.hEvent);
425 HeapFree(GetProcessHeap(), 0, waveHdr);
426 HeapFree(GetProcessHeap(), 0, lpWaveFormat);
427 if (hWave) while (waveOutClose(hWave) == WAVERR_STILLPLAYING) Sleep(100);
428 if (hmmio) mmioClose(hmmio, 0);
433 static DWORD WINAPI PlaySound_Thread(LPVOID arg)
438 PlaySound_Playing = FALSE;
439 SetEvent(PlaySound_hReadyEvent);
440 res = WaitForSingleObject(PlaySound_hPlayEvent, INFINITE);
441 ResetEvent(PlaySound_hReadyEvent);
442 SetEvent(PlaySound_hMiddleEvent);
443 if (res == WAIT_FAILED) ExitThread(2);
444 if (res != WAIT_OBJECT_0) continue;
445 PlaySound_Playing = TRUE;
447 if ((PlaySound_fdwSound & SND_RESOURCE) == SND_RESOURCE) {
452 if ((hRES = FindResourceA(PlaySound_hmod, PlaySound_pszSound, "WAVE")) == 0) {
453 PlaySound_Result = FALSE;
456 if ((hGLOB = LoadResource(PlaySound_hmod, hRES)) == 0) {
457 PlaySound_Result = FALSE;
460 if ((ptr = LockResource(hGLOB)) == NULL) {
462 PlaySound_Result = FALSE;
465 PlaySound_Result = proc_PlaySound(ptr,
466 ((UINT16)PlaySound_fdwSound ^ SND_RESOURCE) | SND_MEMORY);
470 PlaySound_Result = proc_PlaySound(PlaySound_pszSound, (UINT16)PlaySound_fdwSound);
474 /**************************************************************************
475 * PlaySoundA [WINMM.1]
477 BOOL WINAPI PlaySoundA(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound)
479 static LPSTR StrDup = NULL;
481 TRACE("pszSound='%p' hmod=%04X fdwSound=%08lX\n",
482 pszSound, hmod, fdwSound);
484 if (PlaySound_hThread == 0) { /* This is the first time they called us */
486 if ((PlaySound_hReadyEvent = CreateEventA(NULL, TRUE, FALSE, NULL)) == 0)
488 if ((PlaySound_hMiddleEvent = CreateEventA(NULL, FALSE, FALSE, NULL)) == 0)
490 if ((PlaySound_hPlayEvent = CreateEventA(NULL, FALSE, FALSE, NULL)) == 0)
492 if ((PlaySound_hThread = CreateThread(NULL, 0, PlaySound_Thread, 0, 0, &id)) == 0)
496 /* FIXME? I see no difference between SND_WAIT and SND_NOSTOP ! */
497 if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && PlaySound_Playing)
500 /* Trying to stop if playing */
501 if (PlaySound_Playing) PlaySound_Stop = TRUE;
503 /* Waiting playing thread to get ready. I think 10 secs is ok & if not then leave*/
504 if (WaitForSingleObject(PlaySound_hReadyEvent, 1000*10) != WAIT_OBJECT_0)
507 if (!pszSound || (fdwSound & SND_PURGE))
508 return FALSE; /* We stoped playing so leaving */
510 if (PlaySound_SearchMode != 1) PlaySound_SearchMode = 2;
511 if (!(fdwSound & SND_ASYNC)) {
512 if (fdwSound & SND_LOOP)
514 PlaySound_pszSound = pszSound;
515 PlaySound_hmod = hmod;
516 PlaySound_fdwSound = fdwSound;
517 PlaySound_Result = FALSE;
518 SetEvent(PlaySound_hPlayEvent);
519 if (WaitForSingleObject(PlaySound_hMiddleEvent, INFINITE) != WAIT_OBJECT_0)
521 if (WaitForSingleObject(PlaySound_hReadyEvent, INFINITE) != WAIT_OBJECT_0)
523 return PlaySound_Result;
525 PlaySound_hmod = hmod;
526 PlaySound_fdwSound = fdwSound;
527 PlaySound_Result = FALSE;
529 HeapFree(GetProcessHeap(), 0, StrDup);
532 if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) &&
533 !((DWORD)pszSound >> 16)) || !pszSound)) {
534 StrDup = HEAP_strdupA(GetProcessHeap(), 0,pszSound);
535 PlaySound_pszSound = StrDup;
536 } else PlaySound_pszSound = pszSound;
537 PlaySound_Loop = fdwSound & SND_LOOP;
538 SetEvent(PlaySound_hPlayEvent);
539 ResetEvent(PlaySound_hMiddleEvent);
545 /**************************************************************************
546 * PlaySoundW [WINMM.18]
548 BOOL WINAPI PlaySoundW(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
553 if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) &&
554 !((DWORD)pszSound >> 16)) || !pszSound)) {
555 pszSoundA = HEAP_strdupWtoA(GetProcessHeap(), 0,pszSound);
556 bSound = PlaySoundA(pszSoundA, hmod, fdwSound);
557 HeapFree(GetProcessHeap(), 0, pszSoundA);
559 bSound = PlaySoundA((LPCSTR)pszSound, hmod, fdwSound);
564 /**************************************************************************
565 * PlaySound16 [MMSYSTEM.3]
567 BOOL16 WINAPI PlaySound16(LPCSTR pszSound, HMODULE16 hmod, DWORD fdwSound)
572 ReleaseThunkLock(&lc);
573 retv = PlaySoundA(pszSound, hmod, fdwSound);
574 RestoreThunkLock(lc);
579 /**************************************************************************
580 * sndPlaySoundA [WINMM135]
582 BOOL WINAPI sndPlaySoundA(LPCSTR lpszSoundName, UINT uFlags)
584 PlaySound_SearchMode = 1;
585 return PlaySoundA(lpszSoundName, 0, uFlags);
588 /**************************************************************************
589 * sndPlaySoundW [WINMM.136]
591 BOOL WINAPI sndPlaySoundW(LPCWSTR lpszSoundName, UINT uFlags)
593 PlaySound_SearchMode = 1;
594 return PlaySoundW(lpszSoundName, 0, uFlags);
597 /**************************************************************************
598 * sndPlaySound16 [MMSYSTEM.2]
600 BOOL16 WINAPI sndPlaySound16(LPCSTR lpszSoundName, UINT16 uFlags)
605 ReleaseThunkLock(&lc);
606 retv = sndPlaySoundA( lpszSoundName, uFlags );
607 RestoreThunkLock(lc);
613 /**************************************************************************
614 * mmsystemGetVersion [WINMM.134]
616 UINT WINAPI mmsystemGetVersion(void)
618 return mmsystemGetVersion16();
621 /**************************************************************************
622 * mmsystemGetVersion [MMSYSTEM.5]
623 * return value borrowed from Win95 winmm.dll ;)
625 UINT16 WINAPI mmsystemGetVersion16(void)
627 TRACE("3.10 (Win95?)\n");
631 /**************************************************************************
632 * DriverCallback [MMSYSTEM.31]
634 BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
635 UINT wMsg, DWORD dwUser, DWORD dwParam1,
638 TRACE("(%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n",
639 dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
641 switch (uFlags & DCB_TYPEMASK) {
645 WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags, dwCallBack);
648 TRACE("Window(%04lX) handle=%04X!\n", dwCallBack, hDev);
649 if (!IsWindow(dwCallBack))
651 PostMessageA((HWND16)dwCallBack, wMsg, hDev, dwParam1);
653 case DCB_TASK: /* aka DCB_THREAD */
654 TRACE("Task(%04lx) !\n", dwCallBack);
655 PostThreadMessageA(dwCallBack, wMsg, hDev, dwParam1);
658 TRACE("Function (32 bit) !\n");
659 ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2);
662 TRACE("Event(%08lx) !\n", dwCallBack);
663 SetEvent((HANDLE)dwCallBack);
665 case 6: /* I would dub it DCB_MMTHREADSIGNAL */
666 /* this is an undocumented DCB_ value used for mmThreads
667 * loword of dwCallBack contains the handle of the lpMMThd block
668 * which dwSignalCount has to be incremented
671 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(LOWORD(dwCallBack), 0) );
673 TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd);
674 /* same as mmThreadSignal16 */
675 InterlockedIncrement(&lpMMThd->dwSignalCount);
676 SetEvent(lpMMThd->hEvent);
677 /* some other stuff on lpMMThd->hVxD */
682 /* this is an undocumented DCB_ value for... I don't know */
686 WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK);
693 /**************************************************************************
694 * DriverCallback [MMSYSTEM.31]
696 BOOL16 WINAPI DriverCallback16(DWORD dwCallBack, UINT16 uFlags, HDRVR16 hDev,
697 WORD wMsg, DWORD dwUser, DWORD dwParam1,
700 return DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
703 /**************************************************************************
704 * Mixer devices. New to Win95
707 /**************************************************************************
708 * find out the real mixer ID depending on hmix (depends on dwFlags)
710 static LPWINE_MIXER MIXER_GetDev(HMIXEROBJ hmix, DWORD dwFlags)
712 LPWINE_MIXER lpwm = NULL;
714 switch (dwFlags & 0xF0000000ul) {
715 case MIXER_OBJECTF_MIXER:
716 lpwm = (LPWINE_MIXER)MMDRV_Get(hmix, MMDRV_MIXER, TRUE);
718 case MIXER_OBJECTF_HMIXER:
719 lpwm = (LPWINE_MIXER)MMDRV_Get(hmix, MMDRV_MIXER, FALSE);
721 case MIXER_OBJECTF_WAVEOUT:
722 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_WAVEOUT, TRUE, MMDRV_MIXER);
724 case MIXER_OBJECTF_HWAVEOUT:
725 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_WAVEOUT, FALSE, MMDRV_MIXER);
727 case MIXER_OBJECTF_WAVEIN:
728 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_WAVEIN, TRUE, MMDRV_MIXER);
730 case MIXER_OBJECTF_HWAVEIN:
731 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_WAVEIN, FALSE, MMDRV_MIXER);
733 case MIXER_OBJECTF_MIDIOUT:
734 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_MIDIOUT, TRUE, MMDRV_MIXER);
736 case MIXER_OBJECTF_HMIDIOUT:
737 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_MIDIOUT, FALSE, MMDRV_MIXER);
739 case MIXER_OBJECTF_MIDIIN:
740 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_MIDIIN, TRUE, MMDRV_MIXER);
742 case MIXER_OBJECTF_HMIDIIN:
743 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_MIDIIN, FALSE, MMDRV_MIXER);
745 case MIXER_OBJECTF_AUX:
746 lpwm = (LPWINE_MIXER)MMDRV_GetRelated(hmix, MMDRV_AUX, TRUE, MMDRV_MIXER);
749 FIXME("Unsupported flag (%08lx)\n", dwFlags & 0xF0000000ul);
755 /**************************************************************************
756 * mixerGetNumDevs [WINMM.108]
758 UINT WINAPI mixerGetNumDevs(void)
760 return MMDRV_GetNum(MMDRV_MIXER);
763 /**************************************************************************
764 * mixerGetNumDevs [MMSYSTEM.800]
766 UINT16 WINAPI mixerGetNumDevs16(void)
768 return MMDRV_GetNum(MMDRV_MIXER);
771 /**************************************************************************
772 * mixerGetDevCapsA [WINMM.101]
774 UINT WINAPI mixerGetDevCapsA(UINT devid, LPMIXERCAPSA mixcaps, UINT size)
778 if ((wmld = MMDRV_Get(devid, MMDRV_MIXER, TRUE)) == NULL)
779 return MMSYSERR_BADDEVICEID;
781 return MMDRV_Message(wmld, MXDM_GETDEVCAPS, (DWORD)mixcaps, size, TRUE);
784 /**************************************************************************
785 * mixerGetDevCapsW [WINMM.102]
787 UINT WINAPI mixerGetDevCapsW(UINT devid, LPMIXERCAPSW mixcaps, UINT size)
790 UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
792 if (ret == MMSYSERR_NOERROR) {
793 mixcaps->wMid = micA.wMid;
794 mixcaps->wPid = micA.wPid;
795 mixcaps->vDriverVersion = micA.vDriverVersion;
796 MultiByteToWideChar( CP_ACP, 0, micA.szPname, -1, mixcaps->szPname,
797 sizeof(mixcaps->szPname)/sizeof(WCHAR) );
798 mixcaps->fdwSupport = micA.fdwSupport;
799 mixcaps->cDestinations = micA.cDestinations;
804 /**************************************************************************
805 * mixerGetDevCaps [MMSYSTEM.801]
807 UINT16 WINAPI mixerGetDevCaps16(UINT16 devid, LPMIXERCAPS16 mixcaps,
811 UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
813 if (ret == MMSYSERR_NOERROR) {
814 mixcaps->wMid = micA.wMid;
815 mixcaps->wPid = micA.wPid;
816 mixcaps->vDriverVersion = micA.vDriverVersion;
817 strcpy(mixcaps->szPname, micA.szPname);
818 mixcaps->fdwSupport = micA.fdwSupport;
819 mixcaps->cDestinations = micA.cDestinations;
824 static UINT MMSYSTEM_mixerOpen(LPHMIXER lphMix, UINT uDeviceID, DWORD dwCallback,
825 DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32)
832 TRACE("(%p, %d, %08lx, %08lx, %08lx)\n",
833 lphMix, uDeviceID, dwCallback, dwInstance, fdwOpen);
835 wmld = MMDRV_Alloc(sizeof(WINE_MIXER), MMDRV_MIXER, &hMix, &fdwOpen,
836 &dwCallback, &dwInstance, bFrom32);
838 wmld->uDeviceID = uDeviceID;
840 mod.dwCallback = dwCallback;
841 mod.dwInstance = dwInstance;
843 dwRet = MMDRV_Open(wmld, MXDM_OPEN, (DWORD)&mod, fdwOpen);
845 if (dwRet != MMSYSERR_NOERROR) {
846 MMDRV_Free(hMix, wmld);
849 if (lphMix) *lphMix = hMix;
850 TRACE("=> %ld hMixer=%04x\n", dwRet, hMix);
855 /**************************************************************************
856 * mixerOpen [WINMM.110]
858 UINT WINAPI mixerOpen(LPHMIXER lphMix, UINT uDeviceID, DWORD dwCallback,
859 DWORD dwInstance, DWORD fdwOpen)
861 return MMSYSTEM_mixerOpen(lphMix, uDeviceID,
862 dwCallback, dwInstance, fdwOpen, TRUE);
865 /**************************************************************************
866 * mixerOpen [MMSYSTEM.803]
868 UINT16 WINAPI mixerOpen16(LPHMIXER16 lphmix, UINT16 uDeviceID, DWORD dwCallback,
869 DWORD dwInstance, DWORD fdwOpen)
874 ret = MMSYSTEM_mixerOpen(&hmix, uDeviceID,
875 dwCallback, dwInstance, fdwOpen, FALSE);
876 if (lphmix) *lphmix = hmix;
880 /**************************************************************************
881 * mixerClose [WINMM.98]
883 UINT WINAPI mixerClose(HMIXER hMix)
888 TRACE("(%04x)\n", hMix);
890 if ((wmld = MMDRV_Get(hMix, MMDRV_MIXER, FALSE)) == NULL) return MMSYSERR_INVALHANDLE;
892 dwRet = MMDRV_Close(wmld, MXDM_CLOSE);
893 MMDRV_Free(hMix, wmld);
898 /**************************************************************************
899 * mixerClose [MMSYSTEM.803]
901 UINT16 WINAPI mixerClose16(HMIXER16 hMix)
903 return mixerClose(hMix);
906 /**************************************************************************
907 * mixerGetID [WINMM.103]
909 UINT WINAPI mixerGetID(HMIXEROBJ hmix, LPUINT lpid, DWORD fdwID)
913 TRACE("(%04x %p %08lx)\n", hmix, lpid, fdwID);
915 if ((lpwm = MIXER_GetDev(hmix, fdwID)) == NULL) {
916 return MMSYSERR_INVALHANDLE;
920 *lpid = lpwm->mld.uDeviceID;
922 return MMSYSERR_NOERROR;
925 /**************************************************************************
928 UINT16 WINAPI mixerGetID16(HMIXEROBJ16 hmix, LPUINT16 lpid, DWORD fdwID)
931 UINT ret = mixerGetID(hmix, &xid, fdwID);
938 /**************************************************************************
939 * mixerGetControlDetailsA [WINMM.99]
941 UINT WINAPI mixerGetControlDetailsA(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcdA,
946 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcdA, fdwDetails);
948 if ((lpwm = MIXER_GetDev(hmix, fdwDetails)) == NULL)
949 return MMSYSERR_INVALHANDLE;
951 if (lpmcdA == NULL || lpmcdA->cbStruct != sizeof(*lpmcdA))
952 return MMSYSERR_INVALPARAM;
954 return MMDRV_Message(&lpwm->mld, MXDM_GETCONTROLDETAILS, (DWORD)lpmcdA,
958 /**************************************************************************
959 * mixerGetControlDetailsW [WINMM.100]
961 UINT WINAPI mixerGetControlDetailsW(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
963 DWORD ret = MMSYSERR_NOTENABLED;
965 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
967 if (lpmcd == NULL || lpmcd->cbStruct != sizeof(*lpmcd))
968 return MMSYSERR_INVALPARAM;
970 switch (fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK) {
971 case MIXER_GETCONTROLDETAILSF_VALUE:
972 /* can savely use W structure as it is, no string inside */
973 ret = mixerGetControlDetailsA(hmix, lpmcd, fdwDetails);
975 case MIXER_GETCONTROLDETAILSF_LISTTEXT:
977 LPVOID paDetailsW = lpmcd->paDetails;
978 int size = max(1, lpmcd->cChannels) * sizeof(MIXERCONTROLDETAILS_LISTTEXTA);
980 if (lpmcd->u.cMultipleItems != 0 && lpmcd->u.cMultipleItems != lpmcd->u.hwndOwner) {
981 size *= lpmcd->u.cMultipleItems;
983 lpmcd->paDetails = HeapAlloc(GetProcessHeap(), 0, size);
984 /* set up lpmcd->paDetails */
985 ret = mixerGetControlDetailsA(hmix, lpmcd, fdwDetails);
986 /* copy from lpmcd->paDetails back to paDetailsW; */
987 HeapFree(GetProcessHeap(), 0, lpmcd->paDetails);
988 lpmcd->paDetails = paDetailsW;
992 ERR("Unsupported fdwDetails=0x%08lx\n", fdwDetails);
998 /**************************************************************************
999 * mixerGetControlDetails [MMSYSTEM.808]
1001 UINT16 WINAPI mixerGetControlDetails16(HMIXEROBJ16 hmix,
1002 LPMIXERCONTROLDETAILS16 lpmcd,
1005 DWORD ret = MMSYSERR_NOTENABLED;
1008 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
1010 if (lpmcd == NULL || lpmcd->cbStruct != sizeof(*lpmcd))
1011 return MMSYSERR_INVALPARAM;
1013 sppaDetails = (SEGPTR)lpmcd->paDetails;
1014 lpmcd->paDetails = MapSL(sppaDetails);
1015 ret = mixerGetControlDetailsA(hmix, (LPMIXERCONTROLDETAILS)lpmcd, fdwDetails);
1016 lpmcd->paDetails = (LPVOID)sppaDetails;
1021 /**************************************************************************
1022 * mixerGetLineControlsA [WINMM.104]
1024 UINT WINAPI mixerGetLineControlsA(HMIXEROBJ hmix, LPMIXERLINECONTROLSA lpmlcA,
1029 TRACE("(%04x, %p, %08lx)\n", hmix, lpmlcA, fdwControls);
1031 if ((lpwm = MIXER_GetDev(hmix, fdwControls)) == NULL)
1032 return MMSYSERR_INVALHANDLE;
1034 if (lpmlcA == NULL || lpmlcA->cbStruct != sizeof(*lpmlcA))
1035 return MMSYSERR_INVALPARAM;
1037 return MMDRV_Message(&lpwm->mld, MXDM_GETLINECONTROLS, (DWORD)lpmlcA,
1041 /**************************************************************************
1042 * mixerGetLineControlsW [WINMM.105]
1044 UINT WINAPI mixerGetLineControlsW(HMIXEROBJ hmix, LPMIXERLINECONTROLSW lpmlcW,
1047 MIXERLINECONTROLSA mlcA;
1051 TRACE("(%04x, %p, %08lx)\n", hmix, lpmlcW, fdwControls);
1053 if (lpmlcW == NULL || lpmlcW->cbStruct != sizeof(*lpmlcW) ||
1054 lpmlcW->cbmxctrl != sizeof(MIXERCONTROLW))
1055 return MMSYSERR_INVALPARAM;
1057 mlcA.cbStruct = sizeof(mlcA);
1058 mlcA.dwLineID = lpmlcW->dwLineID;
1059 mlcA.u.dwControlID = lpmlcW->u.dwControlID;
1060 mlcA.u.dwControlType = lpmlcW->u.dwControlType;
1061 mlcA.cControls = lpmlcW->cControls;
1062 mlcA.cbmxctrl = sizeof(MIXERCONTROLA);
1063 mlcA.pamxctrl = HeapAlloc(GetProcessHeap(), 0,
1064 mlcA.cControls * mlcA.cbmxctrl);
1066 ret = mixerGetLineControlsA(hmix, &mlcA, fdwControls);
1068 if (ret == MMSYSERR_NOERROR) {
1069 lpmlcW->dwLineID = mlcA.dwLineID;
1070 lpmlcW->u.dwControlID = mlcA.u.dwControlID;
1071 lpmlcW->u.dwControlType = mlcA.u.dwControlType;
1072 lpmlcW->cControls = mlcA.cControls;
1074 for (i = 0; i < mlcA.cControls; i++) {
1075 lpmlcW->pamxctrl[i].cbStruct = sizeof(MIXERCONTROLW);
1076 lpmlcW->pamxctrl[i].dwControlID = mlcA.pamxctrl[i].dwControlID;
1077 lpmlcW->pamxctrl[i].dwControlType = mlcA.pamxctrl[i].dwControlType;
1078 lpmlcW->pamxctrl[i].fdwControl = mlcA.pamxctrl[i].fdwControl;
1079 lpmlcW->pamxctrl[i].cMultipleItems = mlcA.pamxctrl[i].cMultipleItems;
1080 MultiByteToWideChar( CP_ACP, 0, mlcA.pamxctrl[i].szShortName, -1,
1081 lpmlcW->pamxctrl[i].szShortName,
1082 sizeof(lpmlcW->pamxctrl[i].szShortName)/sizeof(WCHAR) );
1083 MultiByteToWideChar( CP_ACP, 0, mlcA.pamxctrl[i].szName, -1,
1084 lpmlcW->pamxctrl[i].szName,
1085 sizeof(lpmlcW->pamxctrl[i].szName)/sizeof(WCHAR) );
1086 /* sizeof(lpmlcW->pamxctrl[i].Bounds) ==
1087 * sizeof(mlcA.pamxctrl[i].Bounds) */
1088 memcpy(&lpmlcW->pamxctrl[i].Bounds, &mlcA.pamxctrl[i].Bounds,
1089 sizeof(mlcA.pamxctrl[i].Bounds));
1090 /* sizeof(lpmlcW->pamxctrl[i].Metrics) ==
1091 * sizeof(mlcA.pamxctrl[i].Metrics) */
1092 memcpy(&lpmlcW->pamxctrl[i].Metrics, &mlcA.pamxctrl[i].Metrics,
1093 sizeof(mlcA.pamxctrl[i].Metrics));
1097 HeapFree(GetProcessHeap(), 0, mlcA.pamxctrl);
1102 /**************************************************************************
1103 * mixerGetLineControls [MMSYSTEM.807]
1105 UINT16 WINAPI mixerGetLineControls16(HMIXEROBJ16 hmix,
1106 LPMIXERLINECONTROLS16 lpmlc16,
1109 MIXERLINECONTROLSA mlcA;
1112 LPMIXERCONTROL16 lpmc16;
1114 TRACE("(%04x, %p, %08lx)\n", hmix, lpmlc16, fdwControls);
1116 if (lpmlc16 == NULL || lpmlc16->cbStruct != sizeof(*lpmlc16) ||
1117 lpmlc16->cbmxctrl != sizeof(MIXERCONTROL16))
1118 return MMSYSERR_INVALPARAM;
1120 mlcA.cbStruct = sizeof(mlcA);
1121 mlcA.dwLineID = lpmlc16->dwLineID;
1122 mlcA.u.dwControlID = lpmlc16->u.dwControlID;
1123 mlcA.u.dwControlType = lpmlc16->u.dwControlType;
1124 mlcA.cControls = lpmlc16->cControls;
1125 mlcA.cbmxctrl = sizeof(MIXERCONTROLA);
1126 mlcA.pamxctrl = HeapAlloc(GetProcessHeap(), 0,
1127 mlcA.cControls * mlcA.cbmxctrl);
1129 ret = mixerGetLineControlsA(hmix, &mlcA, fdwControls);
1131 if (ret == MMSYSERR_NOERROR) {
1132 lpmlc16->dwLineID = mlcA.dwLineID;
1133 lpmlc16->u.dwControlID = mlcA.u.dwControlID;
1134 lpmlc16->u.dwControlType = mlcA.u.dwControlType;
1135 lpmlc16->cControls = mlcA.cControls;
1137 lpmc16 = MapSL(lpmlc16->pamxctrl);
1139 for (i = 0; i < mlcA.cControls; i++) {
1140 lpmc16[i].cbStruct = sizeof(MIXERCONTROL16);
1141 lpmc16[i].dwControlID = mlcA.pamxctrl[i].dwControlID;
1142 lpmc16[i].dwControlType = mlcA.pamxctrl[i].dwControlType;
1143 lpmc16[i].fdwControl = mlcA.pamxctrl[i].fdwControl;
1144 lpmc16[i].cMultipleItems = mlcA.pamxctrl[i].cMultipleItems;
1145 strcpy(lpmc16[i].szShortName, mlcA.pamxctrl[i].szShortName);
1146 strcpy(lpmc16[i].szName, mlcA.pamxctrl[i].szName);
1147 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
1148 memcpy(&lpmc16[i].Bounds, &mlcA.pamxctrl[i].Bounds,
1149 sizeof(mlcA.pamxctrl[i].Bounds));
1150 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
1151 memcpy(&lpmc16[i].Metrics, &mlcA.pamxctrl[i].Metrics,
1152 sizeof(mlcA.pamxctrl[i].Metrics));
1156 HeapFree(GetProcessHeap(), 0, mlcA.pamxctrl);
1161 /**************************************************************************
1162 * mixerGetLineInfoA [WINMM.106]
1164 UINT WINAPI mixerGetLineInfoA(HMIXEROBJ hmix, LPMIXERLINEA lpmliW, DWORD fdwInfo)
1168 TRACE("(%04x, %p, %08lx)\n", hmix, lpmliW, fdwInfo);
1170 if ((lpwm = MIXER_GetDev(hmix, fdwInfo)) == NULL)
1171 return MMSYSERR_INVALHANDLE;
1173 return MMDRV_Message(&lpwm->mld, MXDM_GETLINEINFO, (DWORD)lpmliW,
1177 /**************************************************************************
1178 * mixerGetLineInfoW [WINMM.107]
1180 UINT WINAPI mixerGetLineInfoW(HMIXEROBJ hmix, LPMIXERLINEW lpmliW,
1186 TRACE("(%04x, %p, %08lx)\n", hmix, lpmliW, fdwInfo);
1188 if (lpmliW == NULL || lpmliW->cbStruct != sizeof(*lpmliW))
1189 return MMSYSERR_INVALPARAM;
1191 mliA.cbStruct = sizeof(mliA);
1192 switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK) {
1193 case MIXER_GETLINEINFOF_COMPONENTTYPE:
1194 mliA.dwComponentType = lpmliW->dwComponentType;
1196 case MIXER_GETLINEINFOF_DESTINATION:
1197 mliA.dwDestination = lpmliW->dwDestination;
1199 case MIXER_GETLINEINFOF_LINEID:
1200 mliA.dwLineID = lpmliW->dwLineID;
1202 case MIXER_GETLINEINFOF_SOURCE:
1203 mliA.dwDestination = lpmliW->dwDestination;
1204 mliA.dwSource = lpmliW->dwSource;
1206 case MIXER_GETLINEINFOF_TARGETTYPE:
1207 mliA.Target.dwType = lpmliW->Target.dwType;
1208 mliA.Target.wMid = lpmliW->Target.wMid;
1209 mliA.Target.wPid = lpmliW->Target.wPid;
1210 mliA.Target.vDriverVersion = lpmliW->Target.vDriverVersion;
1211 WideCharToMultiByte( CP_ACP, 0, lpmliW->Target.szPname, -1, mliA.Target.szPname, sizeof(mliA.Target.szPname), NULL, NULL);
1214 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo);
1217 ret = mixerGetLineInfoA(hmix, &mliA, fdwInfo);
1219 lpmliW->dwDestination = mliA.dwDestination;
1220 lpmliW->dwSource = mliA.dwSource;
1221 lpmliW->dwLineID = mliA.dwLineID;
1222 lpmliW->fdwLine = mliA.fdwLine;
1223 lpmliW->dwUser = mliA.dwUser;
1224 lpmliW->dwComponentType = mliA.dwComponentType;
1225 lpmliW->cChannels = mliA.cChannels;
1226 lpmliW->cConnections = mliA.cConnections;
1227 lpmliW->cControls = mliA.cControls;
1228 MultiByteToWideChar( CP_ACP, 0, mliA.szShortName, -1, lpmliW->szShortName,
1229 sizeof(lpmliW->szShortName)/sizeof(WCHAR) );
1230 MultiByteToWideChar( CP_ACP, 0, mliA.szName, -1, lpmliW->szName,
1231 sizeof(lpmliW->szName)/sizeof(WCHAR) );
1232 lpmliW->Target.dwType = mliA.Target.dwType;
1233 lpmliW->Target.dwDeviceID = mliA.Target.dwDeviceID;
1234 lpmliW->Target.wMid = mliA.Target.wMid;
1235 lpmliW->Target.wPid = mliA.Target.wPid;
1236 lpmliW->Target.vDriverVersion = mliA.Target.vDriverVersion;
1237 MultiByteToWideChar( CP_ACP, 0, mliA.Target.szPname, -1, lpmliW->Target.szPname,
1238 sizeof(lpmliW->Target.szPname)/sizeof(WCHAR) );
1243 /**************************************************************************
1244 * mixerGetLineInfo [MMSYSTEM.805]
1246 UINT16 WINAPI mixerGetLineInfo16(HMIXEROBJ16 hmix, LPMIXERLINE16 lpmli16,
1252 TRACE("(%04x, %p, %08lx)\n", hmix, lpmli16, fdwInfo);
1254 if (lpmli16 == NULL || lpmli16->cbStruct != sizeof(*lpmli16))
1255 return MMSYSERR_INVALPARAM;
1257 mliA.cbStruct = sizeof(mliA);
1258 switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK) {
1259 case MIXER_GETLINEINFOF_COMPONENTTYPE:
1260 mliA.dwComponentType = lpmli16->dwComponentType;
1262 case MIXER_GETLINEINFOF_DESTINATION:
1263 mliA.dwDestination = lpmli16->dwDestination;
1265 case MIXER_GETLINEINFOF_LINEID:
1266 mliA.dwLineID = lpmli16->dwLineID;
1268 case MIXER_GETLINEINFOF_SOURCE:
1269 mliA.dwDestination = lpmli16->dwDestination;
1270 mliA.dwSource = lpmli16->dwSource;
1272 case MIXER_GETLINEINFOF_TARGETTYPE:
1273 mliA.Target.dwType = lpmli16->Target.dwType;
1274 mliA.Target.wMid = lpmli16->Target.wMid;
1275 mliA.Target.wPid = lpmli16->Target.wPid;
1276 mliA.Target.vDriverVersion = lpmli16->Target.vDriverVersion;
1277 strcpy(mliA.Target.szPname, lpmli16->Target.szPname);
1280 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo);
1283 ret = mixerGetLineInfoA(hmix, &mliA, fdwInfo);
1285 lpmli16->dwDestination = mliA.dwDestination;
1286 lpmli16->dwSource = mliA.dwSource;
1287 lpmli16->dwLineID = mliA.dwLineID;
1288 lpmli16->fdwLine = mliA.fdwLine;
1289 lpmli16->dwUser = mliA.dwUser;
1290 lpmli16->dwComponentType = mliA.dwComponentType;
1291 lpmli16->cChannels = mliA.cChannels;
1292 lpmli16->cConnections = mliA.cConnections;
1293 lpmli16->cControls = mliA.cControls;
1294 strcpy(lpmli16->szShortName, mliA.szShortName);
1295 strcpy(lpmli16->szName, mliA.szName);
1296 lpmli16->Target.dwType = mliA.Target.dwType;
1297 lpmli16->Target.dwDeviceID = mliA.Target.dwDeviceID;
1298 lpmli16->Target.wMid = mliA.Target.wMid;
1299 lpmli16->Target.wPid = mliA.Target.wPid;
1300 lpmli16->Target.vDriverVersion = mliA.Target.vDriverVersion;
1301 strcpy(lpmli16->Target.szPname, mliA.Target.szPname);
1306 /**************************************************************************
1307 * mixerSetControlDetails [WINMM.111]
1309 UINT WINAPI mixerSetControlDetails(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcdA,
1314 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcdA, fdwDetails);
1316 if ((lpwm = MIXER_GetDev(hmix, fdwDetails)) == NULL)
1317 return MMSYSERR_INVALHANDLE;
1319 return MMDRV_Message(&lpwm->mld, MXDM_SETCONTROLDETAILS, (DWORD)lpmcdA,
1323 /**************************************************************************
1324 * mixerSetControlDetails [MMSYSTEM.809]
1326 UINT16 WINAPI mixerSetControlDetails16(HMIXEROBJ16 hmix,
1327 LPMIXERCONTROLDETAILS16 lpmcd,
1330 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
1331 return MMSYSERR_NOTENABLED;
1334 /**************************************************************************
1335 * mixerMessage [WINMM.109]
1337 UINT WINAPI mixerMessage(HMIXER hmix, UINT uMsg, DWORD dwParam1, DWORD dwParam2)
1341 TRACE("(%04lx, %d, %08lx, %08lx): semi-stub?\n",
1342 (DWORD)hmix, uMsg, dwParam1, dwParam2);
1344 if ((wmld = MMDRV_Get(hmix, MMDRV_MIXER, FALSE)) == NULL)
1345 return MMSYSERR_INVALHANDLE;
1347 return MMDRV_Message(wmld, uMsg, dwParam1, dwParam2, TRUE);
1350 /**************************************************************************
1351 * mixerMessage [MMSYSTEM.804]
1353 DWORD WINAPI mixerMessage16(HMIXER16 hmix, UINT16 uMsg, DWORD dwParam1,
1356 return mixerMessage(hmix, uMsg, dwParam1, dwParam2);
1359 /**************************************************************************
1360 * auxGetNumDevs [WINMM.22]
1362 UINT WINAPI auxGetNumDevs(void)
1364 return MMDRV_GetNum(MMDRV_AUX);
1367 /**************************************************************************
1368 * auxGetNumDevs [MMSYSTEM.350]
1370 UINT16 WINAPI auxGetNumDevs16(void)
1372 return MMDRV_GetNum(MMDRV_AUX);
1375 /**************************************************************************
1376 * auxGetDevCapsW [WINMM.20]
1378 UINT WINAPI auxGetDevCapsW(UINT uDeviceID, LPAUXCAPSW lpCaps, UINT uSize)
1381 UINT ret = auxGetDevCapsA(uDeviceID, &acA, sizeof(acA));
1383 lpCaps->wMid = acA.wMid;
1384 lpCaps->wPid = acA.wPid;
1385 lpCaps->vDriverVersion = acA.vDriverVersion;
1386 MultiByteToWideChar( CP_ACP, 0, acA.szPname, -1, lpCaps->szPname,
1387 sizeof(lpCaps->szPname)/sizeof(WCHAR) );
1388 lpCaps->wTechnology = acA.wTechnology;
1389 lpCaps->dwSupport = acA.dwSupport;
1393 /**************************************************************************
1394 * auxGetDevCapsA [WINMM.21]
1396 UINT WINAPI auxGetDevCapsA(UINT uDeviceID, LPAUXCAPSA lpCaps, UINT uSize)
1400 TRACE("(%04X, %p, %d) !\n", uDeviceID, lpCaps, uSize);
1402 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
1403 return MMSYSERR_INVALHANDLE;
1404 return MMDRV_Message(wmld, AUXDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
1407 /**************************************************************************
1408 * auxGetDevCaps [MMSYSTEM.351]
1410 UINT16 WINAPI auxGetDevCaps16(UINT16 uDeviceID, LPAUXCAPS16 lpCaps, UINT16 uSize)
1414 TRACE("(%04X, %p, %d) !\n", uDeviceID, lpCaps, uSize);
1416 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
1417 return MMSYSERR_INVALHANDLE;
1418 return MMDRV_Message(wmld, AUXDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
1421 /**************************************************************************
1422 * auxGetVolume [WINM.23]
1424 UINT WINAPI auxGetVolume(UINT uDeviceID, DWORD* lpdwVolume)
1428 TRACE("(%04X, %p) !\n", uDeviceID, lpdwVolume);
1430 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
1431 return MMSYSERR_INVALHANDLE;
1432 return MMDRV_Message(wmld, AUXDM_GETVOLUME, (DWORD)lpdwVolume, 0L, TRUE);
1435 /**************************************************************************
1436 * auxGetVolume [MMSYSTEM.352]
1438 UINT16 WINAPI auxGetVolume16(UINT16 uDeviceID, LPDWORD lpdwVolume)
1442 TRACE("(%04X, %p) !\n", uDeviceID, lpdwVolume);
1444 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
1445 return MMSYSERR_INVALHANDLE;
1446 return MMDRV_Message(wmld, AUXDM_GETVOLUME, (DWORD)lpdwVolume, 0L, TRUE);
1449 /**************************************************************************
1450 * auxSetVolume [WINMM.25]
1452 UINT WINAPI auxSetVolume(UINT uDeviceID, DWORD dwVolume)
1456 TRACE("(%04X, %lu) !\n", uDeviceID, dwVolume);
1458 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
1459 return MMSYSERR_INVALHANDLE;
1460 return MMDRV_Message(wmld, AUXDM_SETVOLUME, dwVolume, 0L, TRUE);
1463 /**************************************************************************
1464 * auxSetVolume [MMSYSTEM.353]
1466 UINT16 WINAPI auxSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
1470 TRACE("(%04X, %lu) !\n", uDeviceID, dwVolume);
1472 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
1473 return MMSYSERR_INVALHANDLE;
1474 return MMDRV_Message(wmld, AUXDM_SETVOLUME, dwVolume, 0L, TRUE);
1477 /**************************************************************************
1478 * auxOutMessage [MMSYSTEM.354]
1480 DWORD WINAPI auxOutMessage(UINT uDeviceID, UINT uMessage, DWORD dw1, DWORD dw2)
1484 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
1485 return MMSYSERR_INVALHANDLE;
1487 return MMDRV_Message(wmld, uMessage, dw1, dw2, TRUE);
1490 /**************************************************************************
1491 * auxOutMessage [MMSYSTEM.354]
1493 DWORD WINAPI auxOutMessage16(UINT16 uDeviceID, UINT16 uMessage, DWORD dw1, DWORD dw2)
1497 TRACE("(%04X, %04X, %08lX, %08lX)\n", uDeviceID, uMessage, dw1, dw2);
1500 case AUXDM_GETNUMDEVS:
1501 case AUXDM_SETVOLUME:
1502 /* no argument conversion needed */
1504 case AUXDM_GETVOLUME:
1505 return auxGetVolume16(uDeviceID, MapSL(dw1));
1506 case AUXDM_GETDEVCAPS:
1507 return auxGetDevCaps16(uDeviceID, MapSL(dw1), dw2);
1509 TRACE("(%04x, %04x, %08lx, %08lx): unhandled message\n",
1510 uDeviceID, uMessage, dw1, dw2);
1513 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
1514 return MMSYSERR_INVALHANDLE;
1516 return MMDRV_Message(wmld, uMessage, dw1, dw2, TRUE);
1519 /**************************************************************************
1520 * mciGetErrorStringW [WINMM.46]
1522 BOOL WINAPI mciGetErrorStringW(DWORD wError, LPWSTR lpstrBuffer, UINT uLength)
1524 LPSTR bufstr = HeapAlloc(GetProcessHeap(), 0, uLength);
1525 BOOL ret = mciGetErrorStringA(wError, bufstr, uLength);
1527 MultiByteToWideChar( CP_ACP, 0, bufstr, -1, lpstrBuffer, uLength );
1528 HeapFree(GetProcessHeap(), 0, bufstr);
1532 /**************************************************************************
1533 * mciGetErrorStringA [WINMM.45]
1535 BOOL WINAPI mciGetErrorStringA(DWORD wError, LPSTR lpstrBuffer, UINT uLength)
1537 return mciGetErrorString16(wError, lpstrBuffer, uLength);
1540 /**************************************************************************
1541 * mciGetErrorString [MMSYSTEM.706]
1543 BOOL16 WINAPI mciGetErrorString16(DWORD dwError, LPSTR lpstrBuffer, UINT16 uLength)
1547 if (lpstrBuffer != NULL && uLength > 0 &&
1548 dwError >= MCIERR_BASE && dwError <= MCIERR_CUSTOM_DRIVER_BASE) {
1550 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
1551 dwError, lpstrBuffer, uLength) > 0) {
1558 /**************************************************************************
1559 * mciDriverNotify [MMSYSTEM.711]
1561 BOOL16 WINAPI mciDriverNotify16(HWND16 hWndCallBack, UINT16 wDevID, UINT16 wStatus)
1563 TRACE("(%04X, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
1565 if (!IsWindow(hWndCallBack)) {
1566 WARN("bad hWnd for call back (0x%04x)\n", hWndCallBack);
1569 TRACE("before PostMessage\n");
1570 PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
1574 /**************************************************************************
1575 * mciDriverNotify [WINMM.36]
1577 BOOL WINAPI mciDriverNotify(HWND hWndCallBack, UINT wDevID, UINT wStatus)
1580 TRACE("(%08X, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
1582 if (!IsWindow(hWndCallBack)) {
1583 WARN("bad hWnd for call back (0x%04x)\n", hWndCallBack);
1586 TRACE("before PostMessage\n");
1587 PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
1591 /**************************************************************************
1592 * mciGetDriverData [MMSYSTEM.708]
1594 DWORD WINAPI mciGetDriverData16(UINT16 uDeviceID)
1596 return mciGetDriverData(uDeviceID);
1599 /**************************************************************************
1600 * mciGetDriverData [WINMM.44]
1602 DWORD WINAPI mciGetDriverData(UINT uDeviceID)
1604 LPWINE_MCIDRIVER wmd;
1606 TRACE("(%04x)\n", uDeviceID);
1608 wmd = MCI_GetDriver(uDeviceID);
1611 WARN("Bad uDeviceID\n");
1615 return wmd->dwPrivate;
1618 /**************************************************************************
1619 * mciSetDriverData [MMSYSTEM.707]
1621 BOOL16 WINAPI mciSetDriverData16(UINT16 uDeviceID, DWORD data)
1623 return mciSetDriverData(uDeviceID, data);
1626 /**************************************************************************
1627 * mciSetDriverData [WINMM.53]
1629 BOOL WINAPI mciSetDriverData(UINT uDeviceID, DWORD data)
1631 LPWINE_MCIDRIVER wmd;
1633 TRACE("(%04x, %08lx)\n", uDeviceID, data);
1635 wmd = MCI_GetDriver(uDeviceID);
1638 WARN("Bad uDeviceID\n");
1642 wmd->dwPrivate = data;
1646 /**************************************************************************
1647 * mciSendCommandA [WINMM.49]
1649 DWORD WINAPI mciSendCommandA(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2)
1653 TRACE("(%08x, %s, %08lx, %08lx)\n",
1654 wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
1656 dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, TRUE);
1657 dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2, TRUE);
1658 TRACE("=> %08lx\n", dwRet);
1662 /**************************************************************************
1663 * mciSendCommandW [WINMM.50]
1665 DWORD WINAPI mciSendCommandW(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2)
1667 FIXME("(%08x, %s, %08lx, %08lx): stub\n",
1668 wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
1669 return MCIERR_UNSUPPORTED_FUNCTION;
1672 /**************************************************************************
1673 * mciSendCommand [MMSYSTEM.701]
1675 DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
1679 TRACE("(%04X, %s, %08lX, %08lX)\n",
1680 wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
1682 dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, FALSE);
1683 dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2, FALSE);
1684 TRACE("=> %ld\n", dwRet);
1688 /**************************************************************************
1689 * mciGetDeviceID [MMSYSTEM.703]
1691 UINT16 WINAPI mciGetDeviceID16(LPCSTR lpstrName)
1693 TRACE("(\"%s\")\n", lpstrName);
1695 return MCI_GetDriverFromString(lpstrName);
1698 /**************************************************************************
1699 * mciGetDeviceIDA [WINMM.41]
1701 UINT WINAPI mciGetDeviceIDA(LPCSTR lpstrName)
1703 return MCI_GetDriverFromString(lpstrName);
1706 /**************************************************************************
1707 * mciGetDeviceIDW [WINMM.43]
1709 UINT WINAPI mciGetDeviceIDW(LPCWSTR lpwstrName)
1714 lpstrName = HEAP_strdupWtoA(GetProcessHeap(), 0, lpwstrName);
1715 ret = MCI_GetDriverFromString(lpstrName);
1716 HeapFree(GetProcessHeap(), 0, lpstrName);
1720 /**************************************************************************
1721 * MCI_DefYieldProc [internal]
1723 UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data)
1727 TRACE("(0x%04x, 0x%08lx)\n", wDevID, data);
1729 if ((HIWORD(data) != 0 && GetActiveWindow() != HIWORD(data)) ||
1730 (GetAsyncKeyState(LOWORD(data)) & 1) == 0) {
1736 msg.hwnd = HIWORD(data);
1737 while (!PeekMessageA(&msg, HIWORD(data), WM_KEYFIRST, WM_KEYLAST, PM_REMOVE));
1743 /**************************************************************************
1744 * mciSetYieldProc [MMSYSTEM.714]
1746 BOOL16 WINAPI mciSetYieldProc16(UINT16 uDeviceID, YIELDPROC16 fpYieldProc, DWORD dwYieldData)
1748 LPWINE_MCIDRIVER wmd;
1750 TRACE("(%u, %p, %08lx)\n", uDeviceID, fpYieldProc, dwYieldData);
1752 if (!(wmd = MCI_GetDriver(uDeviceID))) {
1753 WARN("Bad uDeviceID\n");
1757 wmd->lpfnYieldProc = (YIELDPROC)fpYieldProc;
1758 wmd->dwYieldData = dwYieldData;
1764 /**************************************************************************
1765 * mciSetYieldProc [WINMM.54]
1767 BOOL WINAPI mciSetYieldProc(UINT uDeviceID, YIELDPROC fpYieldProc, DWORD dwYieldData)
1769 LPWINE_MCIDRIVER wmd;
1771 TRACE("(%u, %p, %08lx)\n", uDeviceID, fpYieldProc, dwYieldData);
1773 if (!(wmd = MCI_GetDriver(uDeviceID))) {
1774 WARN("Bad uDeviceID\n");
1778 wmd->lpfnYieldProc = fpYieldProc;
1779 wmd->dwYieldData = dwYieldData;
1785 /**************************************************************************
1786 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
1788 UINT16 WINAPI mciGetDeviceIDFromElementID16(DWORD dwElementID, LPCSTR lpstrType)
1790 FIXME("(%lu, %s) stub\n", dwElementID, lpstrType);
1794 /**************************************************************************
1795 * mciGetDeviceIDFromElementIDW [WINMM.42]
1797 UINT WINAPI mciGetDeviceIDFromElementIDW(DWORD dwElementID, LPCWSTR lpstrType)
1799 /* FIXME: that's rather strange, there is no
1800 * mciGetDeviceIDFromElementID32A in winmm.spec
1802 FIXME("(%lu, %p) stub\n", dwElementID, lpstrType);
1806 /**************************************************************************
1807 * mciGetYieldProc [MMSYSTEM.716]
1809 YIELDPROC16 WINAPI mciGetYieldProc16(UINT16 uDeviceID, DWORD* lpdwYieldData)
1811 LPWINE_MCIDRIVER wmd;
1813 TRACE("(%u, %p)\n", uDeviceID, lpdwYieldData);
1815 if (!(wmd = MCI_GetDriver(uDeviceID))) {
1816 WARN("Bad uDeviceID\n");
1819 if (!wmd->lpfnYieldProc) {
1820 WARN("No proc set\n");
1824 WARN("Proc is 32 bit\n");
1827 return (YIELDPROC16)wmd->lpfnYieldProc;
1830 /**************************************************************************
1831 * mciGetYieldProc [WINMM.47]
1833 YIELDPROC WINAPI mciGetYieldProc(UINT uDeviceID, DWORD* lpdwYieldData)
1835 LPWINE_MCIDRIVER wmd;
1837 TRACE("(%u, %p)\n", uDeviceID, lpdwYieldData);
1839 if (!(wmd = MCI_GetDriver(uDeviceID))) {
1840 WARN("Bad uDeviceID\n");
1843 if (!wmd->lpfnYieldProc) {
1844 WARN("No proc set\n");
1848 WARN("Proc is 32 bit\n");
1851 return wmd->lpfnYieldProc;
1854 /**************************************************************************
1855 * mciGetCreatorTask [MMSYSTEM.717]
1857 HTASK16 WINAPI mciGetCreatorTask16(UINT16 uDeviceID)
1859 return mciGetCreatorTask(uDeviceID);
1862 /**************************************************************************
1863 * mciGetCreatorTask [WINMM.40]
1865 HTASK WINAPI mciGetCreatorTask(UINT uDeviceID)
1867 LPWINE_MCIDRIVER wmd;
1870 TRACE("(%u)\n", uDeviceID);
1872 ret = (!(wmd = MCI_GetDriver(uDeviceID))) ? 0 : wmd->hCreatorTask;
1874 TRACE("=> %04x\n", ret);
1878 /**************************************************************************
1879 * mciDriverYield [MMSYSTEM.710]
1881 UINT16 WINAPI mciDriverYield16(UINT16 uDeviceID)
1883 LPWINE_MCIDRIVER wmd;
1886 /* TRACE("(%04x)\n", uDeviceID); */
1888 if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc || wmd->bIs32) {
1891 ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData);
1897 /**************************************************************************
1898 * mciDriverYield [WINMM.37]
1900 UINT WINAPI mciDriverYield(UINT uDeviceID)
1902 LPWINE_MCIDRIVER wmd;
1905 TRACE("(%04x)\n", uDeviceID);
1907 if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc || !wmd->bIs32) {
1910 ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData);
1916 /**************************************************************************
1917 * midiOutGetNumDevs [WINMM.80]
1919 UINT WINAPI midiOutGetNumDevs(void)
1921 return MMDRV_GetNum(MMDRV_MIDIOUT);
1924 /**************************************************************************
1925 * midiOutGetNumDevs [MMSYSTEM.201]
1927 UINT16 WINAPI midiOutGetNumDevs16(void)
1929 return MMDRV_GetNum(MMDRV_MIDIOUT);
1932 /**************************************************************************
1933 * midiOutGetDevCapsW [WINMM.76]
1935 UINT WINAPI midiOutGetDevCapsW(UINT uDeviceID, LPMIDIOUTCAPSW lpCaps,
1941 ret = midiOutGetDevCapsA(uDeviceID, &mocA, sizeof(mocA));
1942 lpCaps->wMid = mocA.wMid;
1943 lpCaps->wPid = mocA.wPid;
1944 lpCaps->vDriverVersion = mocA.vDriverVersion;
1945 MultiByteToWideChar( CP_ACP, 0, mocA.szPname, -1, lpCaps->szPname,
1946 sizeof(lpCaps->szPname)/sizeof(WCHAR) );
1947 lpCaps->wTechnology = mocA.wTechnology;
1948 lpCaps->wVoices = mocA.wVoices;
1949 lpCaps->wNotes = mocA.wNotes;
1950 lpCaps->wChannelMask = mocA.wChannelMask;
1951 lpCaps->dwSupport = mocA.dwSupport;
1955 /**************************************************************************
1956 * midiOutGetDevCapsA [WINMM.75]
1958 UINT WINAPI midiOutGetDevCapsA(UINT uDeviceID, LPMIDIOUTCAPSA lpCaps,
1963 TRACE("(%u, %p, %u);\n", uDeviceID, lpCaps, uSize);
1965 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
1967 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_MIDIOUT, TRUE)) == NULL)
1968 return MMSYSERR_INVALHANDLE;
1970 return MMDRV_Message(wmld, MODM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
1973 /**************************************************************************
1974 * midiOutGetDevCaps [MMSYSTEM.202]
1976 UINT16 WINAPI midiOutGetDevCaps16(UINT16 uDeviceID, LPMIDIOUTCAPS16 lpCaps,
1982 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
1984 dwRet = midiOutGetDevCapsA(uDeviceID, &capsA, sizeof(capsA));
1985 if (dwRet == MMSYSERR_NOERROR) {
1986 lpCaps->wMid = capsA.wMid;
1987 lpCaps->wPid = capsA.wPid;
1988 lpCaps->vDriverVersion = capsA.vDriverVersion;
1989 strcpy(lpCaps->szPname, capsA.szPname);
1990 lpCaps->wTechnology = capsA.wTechnology;
1991 lpCaps->wVoices = capsA.wVoices;
1992 lpCaps->wNotes = capsA.wNotes;
1993 lpCaps->wChannelMask = capsA.wChannelMask;
1994 lpCaps->dwSupport = capsA.dwSupport;
1999 /**************************************************************************
2000 * MIDI_GetErrorText [internal]
2002 static UINT16 MIDI_GetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
2004 UINT16 ret = MMSYSERR_BADERRNUM;
2006 if (lpText == NULL) {
2007 ret = MMSYSERR_INVALPARAM;
2008 } else if (uSize == 0) {
2009 ret = MMSYSERR_NOERROR;
2011 /* test has been removed 'coz MMSYSERR_BASE is 0, and gcc did emit
2012 * a warning for the test was always true */
2013 (/*uError >= MMSYSERR_BASE && */ uError <= MMSYSERR_LASTERROR) ||
2014 (uError >= MIDIERR_BASE && uError <= MIDIERR_LASTERROR)) {
2016 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
2017 uError, lpText, uSize) > 0) {
2018 ret = MMSYSERR_NOERROR;
2024 /**************************************************************************
2025 * midiOutGetErrorTextA [WINMM.77]
2027 UINT WINAPI midiOutGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
2029 return MIDI_GetErrorText(uError, lpText, uSize);
2032 /**************************************************************************
2033 * midiOutGetErrorTextW [WINMM.78]
2035 UINT WINAPI midiOutGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
2037 LPSTR xstr = HeapAlloc(GetProcessHeap(), 0, uSize);
2040 ret = MIDI_GetErrorText(uError, xstr, uSize);
2041 MultiByteToWideChar( CP_ACP, 0, xstr, -1, lpText, uSize );
2042 HeapFree(GetProcessHeap(), 0, xstr);
2046 /**************************************************************************
2047 * midiOutGetErrorText [MMSYSTEM.203]
2049 UINT16 WINAPI midiOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
2051 return MIDI_GetErrorText(uError, lpText, uSize);
2054 /**************************************************************************
2055 * MIDI_OutAlloc [internal]
2057 static LPWINE_MIDI MIDI_OutAlloc(HMIDIOUT* lphMidiOut, LPDWORD lpdwCallback,
2058 LPDWORD lpdwInstance, LPDWORD lpdwFlags,
2059 DWORD cIDs, MIDIOPENSTRMID* lpIDs, BOOL bFrom32)
2065 size = sizeof(WINE_MIDI) + (cIDs ? (cIDs-1) : 0) * sizeof(MIDIOPENSTRMID);
2067 lpwm = (LPWINE_MIDI)MMDRV_Alloc(size, MMDRV_MIDIOUT, &hMidiOut, lpdwFlags,
2068 lpdwCallback, lpdwInstance, bFrom32);
2070 if (lphMidiOut != NULL)
2071 *lphMidiOut = hMidiOut;
2074 lpwm->mod.hMidi = hMidiOut;
2075 lpwm->mod.dwCallback = *lpdwCallback;
2076 lpwm->mod.dwInstance = *lpdwInstance;
2077 lpwm->mod.dnDevNode = 0;
2078 lpwm->mod.cIds = cIDs;
2080 memcpy(&(lpwm->mod.rgIds), lpIDs, cIDs * sizeof(MIDIOPENSTRMID));
2085 UINT MMSYSTEM_midiOutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD dwCallback,
2086 DWORD dwInstance, DWORD dwFlags, BOOL bFrom32)
2092 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2093 lphMidiOut, uDeviceID, dwCallback, dwInstance, dwFlags);
2095 if (lphMidiOut != NULL) *lphMidiOut = 0;
2097 lpwm = MIDI_OutAlloc(&hMidiOut, &dwCallback, &dwInstance, &dwFlags,
2101 return MMSYSERR_NOMEM;
2103 lpwm->mld.uDeviceID = uDeviceID;
2105 dwRet = MMDRV_Open((LPWINE_MLD)lpwm, MODM_OPEN, (DWORD)&lpwm->mod,
2108 if (dwRet != MMSYSERR_NOERROR) {
2109 MMDRV_Free(hMidiOut, (LPWINE_MLD)lpwm);
2113 if (lphMidiOut) *lphMidiOut = hMidiOut;
2114 TRACE("=> %d hMidi=%04x\n", dwRet, hMidiOut);
2119 /**************************************************************************
2120 * midiOutOpen [WINM.84]
2122 UINT WINAPI midiOutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID,
2123 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
2125 return MMSYSTEM_midiOutOpen(lphMidiOut, uDeviceID, dwCallback,
2126 dwInstance, dwFlags, TRUE);
2129 /**************************************************************************
2130 * midiOutOpen [MMSYSTEM.204]
2132 UINT16 WINAPI midiOutOpen16(HMIDIOUT16* lphMidiOut, UINT16 uDeviceID,
2133 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
2138 ret = MMSYSTEM_midiOutOpen(&hmo, uDeviceID, dwCallback, dwInstance,
2141 if (lphMidiOut != NULL) *lphMidiOut = hmo;
2145 /**************************************************************************
2146 * midiOutClose [WINMM.74]
2148 UINT WINAPI midiOutClose(HMIDIOUT hMidiOut)
2153 TRACE("(%04X)\n", hMidiOut);
2155 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2156 return MMSYSERR_INVALHANDLE;
2158 dwRet = MMDRV_Close(wmld, MODM_CLOSE);
2159 MMDRV_Free(hMidiOut, wmld);
2164 /**************************************************************************
2165 * midiOutClose [MMSYSTEM.205]
2167 UINT16 WINAPI midiOutClose16(HMIDIOUT16 hMidiOut)
2169 return midiOutClose(hMidiOut);
2172 /**************************************************************************
2173 * midiOutPrepareHeader [WINMM.85]
2175 UINT WINAPI midiOutPrepareHeader(HMIDIOUT hMidiOut,
2176 MIDIHDR* lpMidiOutHdr, UINT uSize)
2180 TRACE("(%04X, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize);
2182 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2183 return MMSYSERR_INVALHANDLE;
2185 return MMDRV_Message(wmld, MODM_PREPARE, (DWORD)lpMidiOutHdr, uSize, TRUE);
2188 /**************************************************************************
2189 * midiOutPrepareHeader [MMSYSTEM.206]
2191 UINT16 WINAPI midiOutPrepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
2192 SEGPTR lpsegMidiOutHdr, /* [???] */
2193 UINT16 uSize) /* [in] */
2197 TRACE("(%04X, %08lx, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
2199 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2200 return MMSYSERR_INVALHANDLE;
2202 return MMDRV_Message(wmld, MODM_PREPARE, lpsegMidiOutHdr, uSize, FALSE);
2205 /**************************************************************************
2206 * midiOutUnprepareHeader [WINMM.89]
2208 UINT WINAPI midiOutUnprepareHeader(HMIDIOUT hMidiOut,
2209 MIDIHDR* lpMidiOutHdr, UINT uSize)
2213 TRACE("(%04X, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize);
2215 if (!(lpMidiOutHdr->dwFlags & MHDR_PREPARED)) {
2216 return MMSYSERR_NOERROR;
2219 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2220 return MMSYSERR_INVALHANDLE;
2222 return MMDRV_Message(wmld, MODM_UNPREPARE, (DWORD)lpMidiOutHdr, uSize, TRUE);
2225 /**************************************************************************
2226 * midiOutUnprepareHeader [MMSYSTEM.207]
2228 UINT16 WINAPI midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
2229 SEGPTR lpsegMidiOutHdr, /* [???] */
2230 UINT16 uSize) /* [in] */
2233 LPMIDIHDR16 lpMidiOutHdr = MapSL(lpsegMidiOutHdr);
2235 TRACE("(%04X, %08lx, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
2237 if (!(lpMidiOutHdr->dwFlags & MHDR_PREPARED)) {
2238 return MMSYSERR_NOERROR;
2241 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2242 return MMSYSERR_INVALHANDLE;
2244 return MMDRV_Message(wmld, MODM_UNPREPARE, (DWORD)lpsegMidiOutHdr, uSize, FALSE);
2247 /**************************************************************************
2248 * midiOutShortMsg [WINMM.88]
2250 UINT WINAPI midiOutShortMsg(HMIDIOUT hMidiOut, DWORD dwMsg)
2254 TRACE("(%04X, %08lX)\n", hMidiOut, dwMsg);
2256 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2257 return MMSYSERR_INVALHANDLE;
2259 return MMDRV_Message(wmld, MODM_DATA, dwMsg, 0L, FALSE);
2262 /**************************************************************************
2263 * midiOutShortMsg [MMSYSTEM.208]
2265 UINT16 WINAPI midiOutShortMsg16(HMIDIOUT16 hMidiOut, DWORD dwMsg)
2267 return midiOutShortMsg(hMidiOut, dwMsg);
2270 /**************************************************************************
2271 * midiOutLongMsg [WINMM.82]
2273 UINT WINAPI midiOutLongMsg(HMIDIOUT hMidiOut,
2274 MIDIHDR* lpMidiOutHdr, UINT uSize)
2278 TRACE("(%04X, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize);
2280 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2281 return MMSYSERR_INVALHANDLE;
2283 return MMDRV_Message(wmld, MODM_LONGDATA, (DWORD)lpMidiOutHdr, uSize, TRUE);
2286 /**************************************************************************
2287 * midiOutLongMsg [MMSYSTEM.209]
2289 UINT16 WINAPI midiOutLongMsg16(HMIDIOUT16 hMidiOut, /* [in] */
2290 LPMIDIHDR16 lpsegMidiOutHdr, /* [???] NOTE: SEGPTR */
2291 UINT16 uSize) /* [in] */
2295 TRACE("(%04X, %p, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
2297 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2298 return MMSYSERR_INVALHANDLE;
2300 return MMDRV_Message(wmld, MODM_LONGDATA, (DWORD)lpsegMidiOutHdr, uSize, FALSE);
2303 /**************************************************************************
2304 * midiOutReset [WINMM.86]
2306 UINT WINAPI midiOutReset(HMIDIOUT hMidiOut)
2310 TRACE("(%04X)\n", hMidiOut);
2312 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2313 return MMSYSERR_INVALHANDLE;
2315 return MMDRV_Message(wmld, MODM_RESET, 0L, 0L, TRUE);
2318 /**************************************************************************
2319 * midiOutReset [MMSYSTEM.210]
2321 UINT16 WINAPI midiOutReset16(HMIDIOUT16 hMidiOut)
2323 return midiOutReset(hMidiOut);
2326 /**************************************************************************
2327 * midiOutGetVolume [WINM.81]
2329 UINT WINAPI midiOutGetVolume(UINT uDeviceID, DWORD* lpdwVolume)
2333 TRACE("(%04X, %p);\n", uDeviceID, lpdwVolume);
2335 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_MIDIOUT, TRUE)) == NULL)
2336 return MMSYSERR_INVALHANDLE;
2338 return MMDRV_Message(wmld, MODM_GETVOLUME, (DWORD)lpdwVolume, 0L, TRUE);
2341 /**************************************************************************
2342 * midiOutGetVolume [MMSYSTEM.211]
2344 UINT16 WINAPI midiOutGetVolume16(UINT16 uDeviceID, DWORD* lpdwVolume)
2346 return midiOutGetVolume(uDeviceID, lpdwVolume);
2349 /**************************************************************************
2350 * midiOutSetVolume [WINMM.87]
2352 UINT WINAPI midiOutSetVolume(UINT uDeviceID, DWORD dwVolume)
2356 TRACE("(%04X, %ld);\n", uDeviceID, dwVolume);
2358 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_MIDIOUT, TRUE)) == NULL)
2359 return MMSYSERR_INVALHANDLE;
2361 return MMDRV_Message(wmld, MODM_SETVOLUME, dwVolume, 0L, TRUE);
2364 /**************************************************************************
2365 * midiOutSetVolume [MMSYSTEM.212]
2367 UINT16 WINAPI midiOutSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
2369 return midiOutSetVolume(uDeviceID, dwVolume);
2372 /**************************************************************************
2373 * midiOutCachePatches [WINMM.73]
2375 UINT WINAPI midiOutCachePatches(HMIDIOUT hMidiOut, UINT uBank,
2376 WORD* lpwPatchArray, UINT uFlags)
2378 /* not really necessary to support this */
2379 FIXME("not supported yet\n");
2380 return MMSYSERR_NOTSUPPORTED;
2383 /**************************************************************************
2384 * midiOutCachePatches [MMSYSTEM.213]
2386 UINT16 WINAPI midiOutCachePatches16(HMIDIOUT16 hMidiOut, UINT16 uBank,
2387 WORD* lpwPatchArray, UINT16 uFlags)
2389 return midiOutCachePatches(hMidiOut, uBank, lpwPatchArray, uFlags);
2392 /**************************************************************************
2393 * midiOutCacheDrumPatches [WINMM.72]
2395 UINT WINAPI midiOutCacheDrumPatches(HMIDIOUT hMidiOut, UINT uPatch,
2396 WORD* lpwKeyArray, UINT uFlags)
2398 FIXME("not supported yet\n");
2399 return MMSYSERR_NOTSUPPORTED;
2402 /**************************************************************************
2403 * midiOutCacheDrumPatches [MMSYSTEM.214]
2405 UINT16 WINAPI midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut, UINT16 uPatch,
2406 WORD* lpwKeyArray, UINT16 uFlags)
2408 return midiOutCacheDrumPatches16(hMidiOut, uPatch, lpwKeyArray, uFlags);
2411 /**************************************************************************
2412 * midiOutGetID [WINMM.79]
2414 UINT WINAPI midiOutGetID(HMIDIOUT hMidiOut, UINT* lpuDeviceID)
2418 TRACE("(%04X, %p)\n", hMidiOut, lpuDeviceID);
2420 if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
2421 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2422 return MMSYSERR_INVALHANDLE;
2424 *lpuDeviceID = wmld->uDeviceID;
2425 return MMSYSERR_NOERROR;
2428 /**************************************************************************
2429 * midiOutGetID [MMSYSTEM.215]
2431 UINT16 WINAPI midiOutGetID16(HMIDIOUT16 hMidiOut, UINT16* lpuDeviceID)
2435 TRACE("(%04X, %p)\n", hMidiOut, lpuDeviceID);
2437 if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
2438 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2439 return MMSYSERR_INVALHANDLE;
2441 *lpuDeviceID = wmld->uDeviceID;
2442 return MMSYSERR_NOERROR;
2445 /**************************************************************************
2446 * midiOutMessage [WINMM.83]
2448 DWORD WINAPI midiOutMessage(HMIDIOUT hMidiOut, UINT uMessage,
2449 DWORD dwParam1, DWORD dwParam2)
2453 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut, uMessage, dwParam1, dwParam2);
2455 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2456 return MMSYSERR_INVALHANDLE;
2461 FIXME("can't handle OPEN or CLOSE message!\n");
2462 return MMSYSERR_NOTSUPPORTED;
2464 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
2467 /**************************************************************************
2468 * midiOutMessage [MMSYSTEM.216]
2470 DWORD WINAPI midiOutMessage16(HMIDIOUT16 hMidiOut, UINT16 uMessage,
2471 DWORD dwParam1, DWORD dwParam2)
2475 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut, uMessage, dwParam1, dwParam2);
2477 if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL)
2478 return MMSYSERR_INVALHANDLE;
2483 FIXME("can't handle OPEN or CLOSE message!\n");
2484 return MMSYSERR_NOTSUPPORTED;
2486 case MODM_GETVOLUME:
2487 return midiOutGetVolume16(hMidiOut, MapSL(dwParam1));
2489 return midiOutLongMsg16(hMidiOut, MapSL(dwParam1), dwParam2);
2491 /* lpMidiOutHdr is still a segmented pointer for this function */
2492 return midiOutPrepareHeader16(hMidiOut, dwParam1, dwParam2);
2493 case MODM_UNPREPARE:
2494 return midiOutUnprepareHeader16(hMidiOut, dwParam1, dwParam2);
2496 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
2499 /**************************************************************************
2500 * midiInGetNumDevs [WINMM.64]
2502 UINT WINAPI midiInGetNumDevs(void)
2504 return MMDRV_GetNum(MMDRV_MIDIIN);
2507 /**************************************************************************
2508 * midiInGetNumDevs [MMSYSTEM.301]
2510 UINT16 WINAPI midiInGetNumDevs16(void)
2512 return MMDRV_GetNum(MMDRV_MIDIIN);
2515 /**************************************************************************
2516 * midiInGetDevCapsW [WINMM.60]
2518 UINT WINAPI midiInGetDevCapsW(UINT uDeviceID, LPMIDIINCAPSW lpCaps, UINT uSize)
2521 UINT ret = midiInGetDevCapsA(uDeviceID, &micA, uSize);
2523 if (ret == MMSYSERR_NOERROR) {
2524 lpCaps->wMid = micA.wMid;
2525 lpCaps->wPid = micA.wPid;
2526 lpCaps->vDriverVersion = micA.vDriverVersion;
2527 MultiByteToWideChar( CP_ACP, 0, micA.szPname, -1, lpCaps->szPname,
2528 sizeof(lpCaps->szPname)/sizeof(WCHAR) );
2529 lpCaps->dwSupport = micA.dwSupport;
2534 /**************************************************************************
2535 * midiInGetDevCapsA [WINMM.59]
2537 UINT WINAPI midiInGetDevCapsA(UINT uDeviceID, LPMIDIINCAPSA lpCaps, UINT uSize)
2541 TRACE("(%d, %p, %d);\n", uDeviceID, lpCaps, uSize);
2543 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_MIDIIN, TRUE)) == NULL)
2544 return MMSYSERR_INVALHANDLE;
2546 return MMDRV_Message(wmld, MIDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
2549 /**************************************************************************
2550 * midiInGetDevCaps [MMSYSTEM.302]
2552 UINT16 WINAPI midiInGetDevCaps16(UINT16 uDeviceID, LPMIDIINCAPS16 lpCaps,
2556 UINT ret = midiInGetDevCapsA(uDeviceID, &micA, uSize);
2558 if (ret == MMSYSERR_NOERROR) {
2559 lpCaps->wMid = micA.wMid;
2560 lpCaps->wPid = micA.wPid;
2561 lpCaps->vDriverVersion = micA.vDriverVersion;
2562 strcpy(lpCaps->szPname, micA.szPname);
2563 lpCaps->dwSupport = micA.dwSupport;
2569 /**************************************************************************
2570 * midiInGetErrorTextW [WINMM.62]
2572 UINT WINAPI midiInGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
2574 LPSTR xstr = HeapAlloc(GetProcessHeap(), 0, uSize);
2575 UINT ret = MIDI_GetErrorText(uError, xstr, uSize);
2577 MultiByteToWideChar( CP_ACP, 0, xstr, -1, lpText, uSize );
2578 HeapFree(GetProcessHeap(), 0, xstr);
2582 /**************************************************************************
2583 * midiInGetErrorTextA [WINMM.61]
2585 UINT WINAPI midiInGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
2587 return MIDI_GetErrorText(uError, lpText, uSize);
2590 /**************************************************************************
2591 * midiInGetErrorText [MMSYSTEM.303]
2593 UINT16 WINAPI midiInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
2595 return MIDI_GetErrorText(uError, lpText, uSize);
2598 static UINT MMSYSTEM_midiInOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD dwCallback,
2599 DWORD dwInstance, DWORD dwFlags, BOOL bFrom32)
2605 TRACE("(%p, %d, %08lX, %08lX, %08lX);\n",
2606 lphMidiIn, uDeviceID, dwCallback, dwInstance, dwFlags);
2608 if (lphMidiIn != NULL) *lphMidiIn = 0;
2610 lpwm = (LPWINE_MIDI)MMDRV_Alloc(sizeof(WINE_MIDI), MMDRV_MIDIIN, &hMidiIn,
2611 &dwFlags, &dwCallback, &dwInstance, bFrom32);
2614 return MMSYSERR_NOMEM;
2616 lpwm->mod.hMidi = hMidiIn;
2617 lpwm->mod.dwCallback = dwCallback;
2618 lpwm->mod.dwInstance = dwInstance;
2620 lpwm->mld.uDeviceID = uDeviceID;
2621 dwRet = MMDRV_Open(&lpwm->mld, MIDM_OPEN, (DWORD)&lpwm->mod, dwFlags);
2623 if (dwRet != MMSYSERR_NOERROR) {
2624 MMDRV_Free(hMidiIn, &lpwm->mld);
2627 if (lphMidiIn != NULL) *lphMidiIn = hMidiIn;
2628 TRACE("=> %ld hMidi=%04x\n", dwRet, hMidiIn);
2633 /**************************************************************************
2634 * midiInOpen [WINMM.66]
2636 UINT WINAPI midiInOpen(HMIDIIN* lphMidiIn, UINT uDeviceID,
2637 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
2639 return MMSYSTEM_midiInOpen(lphMidiIn, uDeviceID, dwCallback,
2640 dwInstance, dwFlags, TRUE);
2643 /**************************************************************************
2644 * midiInOpen [MMSYSTEM.304]
2646 UINT16 WINAPI midiInOpen16(HMIDIIN16* lphMidiIn, UINT16 uDeviceID,
2647 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
2652 ret = MMSYSTEM_midiInOpen(&xhmid, uDeviceID, dwCallback, dwInstance,
2655 if (lphMidiIn) *lphMidiIn = xhmid;
2659 /**************************************************************************
2660 * midiInClose [WINMM.58]
2662 UINT WINAPI midiInClose(HMIDIIN hMidiIn)
2667 TRACE("(%04X)\n", hMidiIn);
2669 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2670 return MMSYSERR_INVALHANDLE;
2672 dwRet = MMDRV_Close(wmld, MIDM_CLOSE);
2673 MMDRV_Free(hMidiIn, wmld);
2677 /**************************************************************************
2678 * midiInClose [MMSYSTEM.305]
2680 UINT16 WINAPI midiInClose16(HMIDIIN16 hMidiIn)
2682 return midiInClose(hMidiIn);
2685 /**************************************************************************
2686 * midiInPrepareHeader [WINMM.67]
2688 UINT WINAPI midiInPrepareHeader(HMIDIIN hMidiIn,
2689 MIDIHDR* lpMidiInHdr, UINT uSize)
2693 TRACE("(%04X, %p, %d)\n", hMidiIn, lpMidiInHdr, uSize);
2695 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2696 return MMSYSERR_INVALHANDLE;
2698 return MMDRV_Message(wmld, MIDM_PREPARE, (DWORD)lpMidiInHdr, uSize, TRUE);
2701 /**************************************************************************
2702 * midiInPrepareHeader [MMSYSTEM.306]
2704 UINT16 WINAPI midiInPrepareHeader16(HMIDIIN16 hMidiIn, /* [in] */
2705 SEGPTR lpsegMidiInHdr, /* [???] */
2706 UINT16 uSize) /* [in] */
2710 TRACE("(%04X, %08lx, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
2712 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2713 return MMSYSERR_INVALHANDLE;
2715 return MMDRV_Message(wmld, MIDM_PREPARE, (DWORD)lpsegMidiInHdr, uSize, FALSE);
2718 /**************************************************************************
2719 * midiInUnprepareHeader [WINMM.71]
2721 UINT WINAPI midiInUnprepareHeader(HMIDIIN hMidiIn,
2722 MIDIHDR* lpMidiInHdr, UINT uSize)
2726 TRACE("(%04X, %p, %d)\n", hMidiIn, lpMidiInHdr, uSize);
2728 if (!(lpMidiInHdr->dwFlags & MHDR_PREPARED)) {
2729 return MMSYSERR_NOERROR;
2732 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2733 return MMSYSERR_INVALHANDLE;
2735 return MMDRV_Message(wmld, MIDM_UNPREPARE, (DWORD)lpMidiInHdr, uSize, TRUE);
2738 /**************************************************************************
2739 * midiInUnprepareHeader [MMSYSTEM.307]
2741 UINT16 WINAPI midiInUnprepareHeader16(HMIDIIN16 hMidiIn, /* [in] */
2742 SEGPTR lpsegMidiInHdr, /* [???] */
2743 UINT16 uSize) /* [in] */
2746 LPMIDIHDR16 lpMidiInHdr = MapSL(lpsegMidiInHdr);
2748 TRACE("(%04X, %08lx, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
2750 if (!(lpMidiInHdr->dwFlags & MHDR_PREPARED)) {
2751 return MMSYSERR_NOERROR;
2754 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2755 return MMSYSERR_INVALHANDLE;
2757 return MMDRV_Message(wmld, MIDM_UNPREPARE, (DWORD)lpsegMidiInHdr, uSize, FALSE);
2760 /**************************************************************************
2761 * midiInAddBuffer [WINMM.57]
2763 UINT WINAPI midiInAddBuffer(HMIDIIN hMidiIn,
2764 MIDIHDR* lpMidiInHdr, UINT uSize)
2768 TRACE("(%04X, %p, %d)\n", hMidiIn, lpMidiInHdr, uSize);
2770 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2771 return MMSYSERR_INVALHANDLE;
2773 return MMDRV_Message(wmld, MIDM_ADDBUFFER, (DWORD)lpMidiInHdr, uSize, TRUE);
2776 /**************************************************************************
2777 * midiInAddBuffer [MMSYSTEM.308]
2779 UINT16 WINAPI midiInAddBuffer16(HMIDIIN16 hMidiIn, /* [in] */
2780 MIDIHDR16* lpsegMidiInHdr, /* [???] NOTE: SEGPTR */
2781 UINT16 uSize) /* [in] */
2785 TRACE("(%04X, %p, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
2787 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2788 return MMSYSERR_INVALHANDLE;
2790 return MMDRV_Message(wmld, MIDM_ADDBUFFER, (DWORD)lpsegMidiInHdr, uSize, FALSE);
2793 /**************************************************************************
2794 * midiInStart [WINMM.69]
2796 UINT WINAPI midiInStart(HMIDIIN hMidiIn)
2800 TRACE("(%04X)\n", hMidiIn);
2802 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2803 return MMSYSERR_INVALHANDLE;
2805 return MMDRV_Message(wmld, MIDM_START, 0L, 0L, TRUE);
2808 /**************************************************************************
2809 * midiInStart [MMSYSTEM.309]
2811 UINT16 WINAPI midiInStart16(HMIDIIN16 hMidiIn)
2813 return midiInStart(hMidiIn);
2816 /**************************************************************************
2817 * midiInStop [WINMM.70]
2819 UINT WINAPI midiInStop(HMIDIIN hMidiIn)
2823 TRACE("(%04X)\n", hMidiIn);
2825 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2826 return MMSYSERR_INVALHANDLE;
2828 return MMDRV_Message(wmld, MIDM_STOP, 0L, 0L, TRUE);
2831 /**************************************************************************
2832 * midiInStop [MMSYSTEM.310]
2834 UINT16 WINAPI midiInStop16(HMIDIIN16 hMidiIn)
2836 return midiInStop(hMidiIn);
2839 /**************************************************************************
2840 * midiInReset [WINMM.68]
2842 UINT WINAPI midiInReset(HMIDIIN hMidiIn)
2846 TRACE("(%04X)\n", hMidiIn);
2848 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2849 return MMSYSERR_INVALHANDLE;
2851 return MMDRV_Message(wmld, MIDM_RESET, 0L, 0L, TRUE);
2854 /**************************************************************************
2855 * midiInReset [MMSYSTEM.311]
2857 UINT16 WINAPI midiInReset16(HMIDIIN16 hMidiIn)
2859 return midiInReset(hMidiIn);
2862 /**************************************************************************
2863 * midiInGetID [WINMM.63]
2865 UINT WINAPI midiInGetID(HMIDIIN hMidiIn, UINT* lpuDeviceID)
2869 TRACE("(%04X, %p)\n", hMidiIn, lpuDeviceID);
2871 if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
2873 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, TRUE)) == NULL)
2874 return MMSYSERR_INVALHANDLE;
2876 *lpuDeviceID = wmld->uDeviceID;
2878 return MMSYSERR_NOERROR;
2881 /**************************************************************************
2882 * midiInGetID [MMSYSTEM.312]
2884 UINT16 WINAPI midiInGetID16(HMIDIIN16 hMidiIn, UINT16* lpuDeviceID)
2888 TRACE("(%04X, %p)\n", hMidiIn, lpuDeviceID);
2890 if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
2892 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, TRUE)) == NULL)
2893 return MMSYSERR_INVALHANDLE;
2895 *lpuDeviceID = wmld->uDeviceID;
2897 return MMSYSERR_NOERROR;
2900 /**************************************************************************
2901 * midiInMessage [WINMM.65]
2903 DWORD WINAPI midiInMessage(HMIDIIN hMidiIn, UINT uMessage,
2904 DWORD dwParam1, DWORD dwParam2)
2908 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn, uMessage, dwParam1, dwParam2);
2910 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2911 return MMSYSERR_INVALHANDLE;
2916 FIXME("can't handle OPEN or CLOSE message!\n");
2917 return MMSYSERR_NOTSUPPORTED;
2919 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
2922 /**************************************************************************
2923 * midiInMessage [MMSYSTEM.313]
2925 DWORD WINAPI midiInMessage16(HMIDIIN16 hMidiIn, UINT16 uMessage,
2926 DWORD dwParam1, DWORD dwParam2)
2930 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn, uMessage, dwParam1, dwParam2);
2935 FIXME("can't handle OPEN or CLOSE message!\n");
2936 return MMSYSERR_NOTSUPPORTED;
2938 case MIDM_GETDEVCAPS:
2939 return midiInGetDevCaps16(hMidiIn, MapSL(dwParam1), dwParam2);
2941 return midiInPrepareHeader16(hMidiIn, dwParam1, dwParam2);
2942 case MIDM_UNPREPARE:
2943 return midiInUnprepareHeader16(hMidiIn, dwParam1, dwParam2);
2944 case MIDM_ADDBUFFER:
2945 return midiInAddBuffer16(hMidiIn, MapSL(dwParam1), dwParam2);
2948 if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL)
2949 return MMSYSERR_INVALHANDLE;
2951 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
2954 typedef struct WINE_MIDIStream {
2965 LPMIDIHDR lpMidiHdr;
2968 #define WINE_MSM_HEADER (WM_USER+0)
2969 #define WINE_MSM_STOP (WM_USER+1)
2971 /**************************************************************************
2972 * MMSYSTEM_GetMidiStream [internal]
2974 static BOOL MMSYSTEM_GetMidiStream(HMIDISTRM hMidiStrm, WINE_MIDIStream** lpMidiStrm, WINE_MIDI** lplpwm)
2976 WINE_MIDI* lpwm = (LPWINE_MIDI)MMDRV_Get(hMidiStrm, MMDRV_MIDIOUT, FALSE);
2985 *lpMidiStrm = (WINE_MIDIStream*)lpwm->mod.rgIds.dwStreamID;
2987 return *lpMidiStrm != NULL;
2990 /**************************************************************************
2991 * MMSYSTEM_MidiStream_Convert [internal]
2993 static DWORD MMSYSTEM_MidiStream_Convert(WINE_MIDIStream* lpMidiStrm, DWORD pulse)
2997 if (lpMidiStrm->dwTimeDiv == 0) {
2998 FIXME("Shouldn't happen. lpMidiStrm->dwTimeDiv = 0\n");
2999 } else if (lpMidiStrm->dwTimeDiv > 0x8000) { /* SMPTE, unchecked FIXME? */
3000 int nf = -(char)HIBYTE(lpMidiStrm->dwTimeDiv); /* number of frames */
3001 int nsf = LOBYTE(lpMidiStrm->dwTimeDiv); /* number of sub-frames */
3002 ret = (pulse * 1000) / (nf * nsf);
3004 ret = (DWORD)((double)pulse * ((double)lpMidiStrm->dwTempo / 1000) /
3005 (double)lpMidiStrm->dwTimeDiv);
3011 /**************************************************************************
3012 * MMSYSTEM_MidiStream_MessageHandler [internal]
3014 static BOOL MMSYSTEM_MidiStream_MessageHandler(WINE_MIDIStream* lpMidiStrm, LPWINE_MIDI lpwm, LPMSG msg)
3016 LPMIDIHDR lpMidiHdr;
3020 switch (msg->message) {
3022 SetEvent(lpMidiStrm->hEvent);
3026 /* this is not quite what MS doc says... */
3027 midiOutReset(lpMidiStrm->hDevice);
3028 /* empty list of already submitted buffers */
3029 for (lpMidiHdr = lpMidiStrm->lpMidiHdr; lpMidiHdr; lpMidiHdr = (LPMIDIHDR)lpMidiHdr->lpNext) {
3030 lpMidiHdr->dwFlags |= MHDR_DONE;
3031 lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
3033 DriverCallback(lpwm->mod.dwCallback, lpMidiStrm->wFlags, lpMidiStrm->hDevice,
3034 MM_MOM_DONE, lpwm->mod.dwInstance, (DWORD)lpMidiHdr, 0L);
3036 lpMidiStrm->lpMidiHdr = 0;
3037 SetEvent(lpMidiStrm->hEvent);
3039 case WINE_MSM_HEADER:
3040 /* sets initial tick count for first MIDIHDR */
3041 if (!lpMidiStrm->dwStartTicks)
3042 lpMidiStrm->dwStartTicks = GetTickCount();
3044 /* FIXME(EPP): "I don't understand the content of the first MIDIHDR sent
3045 * by native mcimidi, it doesn't look like a correct one".
3046 * this trick allows to throw it away... but I don't like it.
3047 * It looks like part of the file I'm trying to play and definitively looks
3048 * like raw midi content
3049 * I'd really like to understand why native mcimidi sends it. Perhaps a bad
3050 * synchronization issue where native mcimidi is still processing raw MIDI
3051 * content before generating MIDIEVENTs ?
3053 * 4c 04 89 3b 00 81 7c 99 3b 43 00 99 23 5e 04 89 L..;..|.;C..#^..
3054 * 3b 00 00 89 23 00 7c 99 3b 45 00 99 28 62 04 89 ;...#.|.;E..(b..
3055 * 3b 00 00 89 28 00 81 7c 99 3b 4e 00 99 23 5e 04 ;...(..|.;N..#^.
3056 * 89 3b 00 00 89 23 00 7c 99 3b 45 00 99 23 78 04 .;...#.|.;E..#x.
3057 * 89 3b 00 00 89 23 00 81 7c 99 3b 48 00 99 23 5e .;...#..|.;H..#^
3058 * 04 89 3b 00 00 89 23 00 7c 99 3b 4e 00 99 28 62 ..;...#.|.;N..(b
3059 * 04 89 3b 00 00 89 28 00 81 7c 99 39 4c 00 99 23 ..;...(..|.9L..#
3060 * 5e 04 89 39 00 00 89 23 00 82 7c 99 3b 4c 00 99 ^..9...#..|.;L..
3061 * 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 00 99 #^..;...#.|.;H..
3062 * 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b 3f 04 (b..;...(..|.;?.
3063 * 89 3b 00 1c 99 23 5e 04 89 23 00 5c 99 3b 45 00 .;...#^..#.\.;E.
3064 * 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 3b 46 .#x..;...#..|.;F
3065 * 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b 48 ..#^..;...#.|.;H
3066 * 00 99 28 62 04 89 3b 00 00 89 28 00 81 7c 99 3b ..(b..;...(..|.;
3067 * 46 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 3b F..#^..;...#.|.;
3068 * 48 00 99 23 78 04 89 3b 00 00 89 23 00 81 7c 99 H..#x..;...#..|.
3069 * 3b 4c 00 99 23 5e 04 89 3b 00 00 89 23 00 7c 99 ;L..#^..;...#.|.
3071 lpMidiHdr = (LPMIDIHDR)msg->lParam;
3072 lpData = lpMidiHdr->lpData;
3073 TRACE("Adding %s lpMidiHdr=%p [lpData=0x%08lx dwBufferLength=%lu/%lu dwFlags=0x%08lx size=%u]\n",
3074 (lpMidiHdr->dwFlags & MHDR_ISSTRM) ? "stream" : "regular", lpMidiHdr,
3075 (DWORD)lpMidiHdr, lpMidiHdr->dwBufferLength, lpMidiHdr->dwBytesRecorded,
3076 lpMidiHdr->dwFlags, msg->wParam);
3078 /* dumps content of lpMidiHdr->lpData
3079 * FIXME: there should be a debug routine somewhere that already does this
3080 * I hate spreading this type of shit all around the code
3082 for (dwToGo = 0; dwToGo < lpMidiHdr->dwBufferLength; dwToGo += 16) {
3086 for (i = 0; i < min(16, lpMidiHdr->dwBufferLength - dwToGo); i++)
3087 printf("%02x ", lpData[dwToGo + i]);
3090 for (i = 0; i < min(16, lpMidiHdr->dwBufferLength - dwToGo); i++) {
3091 ch = lpData[dwToGo + i];
3092 printf("%c", (ch >= 0x20 && ch <= 0x7F) ? ch : '.');
3097 if (((LPMIDIEVENT)lpData)->dwStreamID != 0 &&
3098 ((LPMIDIEVENT)lpData)->dwStreamID != 0xFFFFFFFF &&
3099 ((LPMIDIEVENT)lpData)->dwStreamID != (DWORD)lpMidiStrm) {
3100 FIXME("Dropping bad %s lpMidiHdr (streamID=%08lx)\n",
3101 (lpMidiHdr->dwFlags & MHDR_ISSTRM) ? "stream" : "regular",
3102 ((LPMIDIEVENT)lpData)->dwStreamID);
3103 lpMidiHdr->dwFlags |= MHDR_DONE;
3104 lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
3106 DriverCallback(lpwm->mod.dwCallback, lpMidiStrm->wFlags, lpMidiStrm->hDevice,
3107 MM_MOM_DONE, lpwm->mod.dwInstance, (DWORD)lpMidiHdr, 0L);
3111 for (lpmh = &lpMidiStrm->lpMidiHdr; *lpmh; lpmh = (LPMIDIHDR*)&((*lpmh)->lpNext));
3113 lpMidiHdr = (LPMIDIHDR)msg->lParam;
3114 lpMidiHdr->lpNext = 0;
3115 lpMidiHdr->dwFlags |= MHDR_INQUEUE;
3116 lpMidiHdr->dwFlags &= MHDR_DONE;
3117 lpMidiHdr->dwOffset = 0;
3121 FIXME("Unknown message %d\n", msg->message);
3127 /**************************************************************************
3128 * MMSYSTEM_MidiStream_Player [internal]
3130 static DWORD CALLBACK MMSYSTEM_MidiStream_Player(LPVOID pmt)
3132 WINE_MIDIStream* lpMidiStrm = pmt;
3137 LPMIDIHDR lpMidiHdr;
3141 TRACE("(%p)!\n", lpMidiStrm);
3144 (lpwm = (LPWINE_MIDI)MMDRV_Get(lpMidiStrm->hDevice, MMDRV_MIDIOUT, FALSE)) == NULL)
3147 /* force thread's queue creation */
3148 /* Used to be InitThreadInput16(0, 5); */
3149 /* but following works also with hack in midiStreamOpen */
3150 PeekMessageA(&msg, 0, 0, 0, 0);
3152 /* FIXME: this next line must be called before midiStreamOut or midiStreamRestart are called */
3153 SetEvent(lpMidiStrm->hEvent);
3154 TRACE("Ready to go 1\n");
3155 /* thread is started in paused mode */
3156 SuspendThread(lpMidiStrm->hThread);
3157 TRACE("Ready to go 2\n");
3159 lpMidiStrm->dwStartTicks = 0;
3160 lpMidiStrm->dwPulses = 0;
3162 lpMidiStrm->lpMidiHdr = 0;
3165 lpMidiHdr = lpMidiStrm->lpMidiHdr;
3167 /* for first message, block until one arrives, then process all that are available */
3168 GetMessageA(&msg, 0, 0, 0);
3170 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm, lpwm, &msg))
3172 } while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE));
3178 lpData = lpMidiHdr->lpData;
3180 me = (LPMIDIEVENT)(lpData + lpMidiHdr->dwOffset);
3182 /* do we have to wait ? */
3183 if (me->dwDeltaTime) {
3184 lpMidiStrm->dwPositionMS += MMSYSTEM_MidiStream_Convert(lpMidiStrm, me->dwDeltaTime);
3185 lpMidiStrm->dwPulses += me->dwDeltaTime;
3187 dwToGo = lpMidiStrm->dwStartTicks + lpMidiStrm->dwPositionMS;
3189 TRACE("%ld/%ld/%ld\n", dwToGo, GetTickCount(), me->dwDeltaTime);
3190 while ((dwCurrTC = GetTickCount()) < dwToGo) {
3191 if (MsgWaitForMultipleObjects(0, NULL, FALSE, dwToGo - dwCurrTC, QS_ALLINPUT) == WAIT_OBJECT_0) {
3192 /* got a message, handle it */
3193 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
3194 if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm, lpwm, &msg))
3199 /* timeout, so me->dwDeltaTime is elapsed, can break the while loop */
3204 switch (MEVT_EVENTTYPE(me->dwEvent & ~MEVT_F_CALLBACK)) {
3206 FIXME("NIY: MEVT_COMMENT\n");
3207 /* do nothing, skip bytes */
3210 FIXME("NIY: MEVT_LONGMSG, aka sending Sysex event\n");
3215 midiOutShortMsg(lpMidiStrm->hDevice, MEVT_EVENTPARM(me->dwEvent));
3218 lpMidiStrm->dwTempo = MEVT_EVENTPARM(me->dwEvent);
3223 FIXME("Unknown MEVT (0x%02x)\n", MEVT_EVENTTYPE(me->dwEvent & ~MEVT_F_CALLBACK));
3226 if (me->dwEvent & MEVT_F_CALLBACK) {
3227 DriverCallback(lpwm->mod.dwCallback, lpMidiStrm->wFlags, lpMidiStrm->hDevice,
3228 MM_MOM_POSITIONCB, lpwm->mod.dwInstance, (LPARAM)lpMidiHdr, 0L);
3230 lpMidiHdr->dwOffset += sizeof(MIDIEVENT) - sizeof(me->dwParms);
3231 if (me->dwEvent & MEVT_F_LONG)
3232 lpMidiHdr->dwOffset += (MEVT_EVENTPARM(me->dwEvent) + 3) & ~3;
3233 if (lpMidiHdr->dwOffset >= lpMidiHdr->dwBufferLength) {
3234 /* done with this header */
3235 lpMidiHdr->dwFlags |= MHDR_DONE;
3236 lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
3238 lpMidiStrm->lpMidiHdr = (LPMIDIHDR)lpMidiHdr->lpNext;
3239 DriverCallback(lpwm->mod.dwCallback, lpMidiStrm->wFlags, lpMidiStrm->hDevice,
3240 MM_MOM_DONE, lpwm->mod.dwInstance, (DWORD)lpMidiHdr, 0L);
3245 TRACE("End of thread\n");
3247 return 0; /* for removing the warning, never executed */
3250 /**************************************************************************
3251 * MMSYSTEM_MidiStream_PostMessage [internal]
3253 static BOOL MMSYSTEM_MidiStream_PostMessage(WINE_MIDIStream* lpMidiStrm, WORD msg, DWORD pmt1, DWORD pmt2)
3255 if (PostThreadMessageA(lpMidiStrm->dwThreadID, msg, pmt1, pmt2)) {
3258 ReleaseThunkLock(&count);
3259 WaitForSingleObject(lpMidiStrm->hEvent, INFINITE);
3260 RestoreThunkLock(count);
3262 WARN("bad PostThreadMessageA\n");
3268 /**************************************************************************
3269 * midiStreamClose [WINMM.90]
3271 MMRESULT WINAPI midiStreamClose(HMIDISTRM hMidiStrm)
3273 WINE_MIDIStream* lpMidiStrm;
3275 TRACE("(%08x)!\n", hMidiStrm);
3277 if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL))
3278 return MMSYSERR_INVALHANDLE;
3280 midiStreamStop(hMidiStrm);
3281 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm, WM_QUIT, 0, 0);
3282 HeapFree(GetProcessHeap(), 0, lpMidiStrm);
3283 CloseHandle(lpMidiStrm->hEvent);
3285 return midiOutClose(hMidiStrm);
3288 /**************************************************************************
3289 * MMSYSTEM_MidiStream_Open [internal]
3291 static MMRESULT WINAPI MMSYSTEM_MidiStream_Open(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
3292 DWORD cMidi, DWORD dwCallback,
3293 DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32)
3295 WINE_MIDIStream* lpMidiStrm;
3297 MIDIOPENSTRMID mosm;
3301 TRACE("(%p, %p, %ld, 0x%08lx, 0x%08lx, 0x%08lx)!\n",
3302 lphMidiStrm, lpuDeviceID, cMidi, dwCallback, dwInstance, fdwOpen);
3304 if (cMidi != 1 || lphMidiStrm == NULL || lpuDeviceID == NULL)
3305 return MMSYSERR_INVALPARAM;
3307 lpMidiStrm = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MIDIStream));
3309 return MMSYSERR_NOMEM;
3311 lpMidiStrm->dwTempo = 500000;
3312 lpMidiStrm->dwTimeDiv = 480; /* 480 is 120 quater notes per minute *//* FIXME ??*/
3313 lpMidiStrm->dwPositionMS = 0;
3315 mosm.dwStreamID = (DWORD)lpMidiStrm;
3316 /* FIXME: the correct value is not allocated yet for MAPPER */
3317 mosm.wDeviceID = *lpuDeviceID;
3318 lpwm = MIDI_OutAlloc(&hMidiOut, &dwCallback, &dwInstance, &fdwOpen, 1, &mosm, bFrom32);
3319 lpMidiStrm->hDevice = hMidiOut;
3321 *lphMidiStrm = hMidiOut;
3323 /* FIXME: is lpuDevice initialized upon entering midiStreamOpen ? */
3324 FIXME("*lpuDeviceID=%x\n", *lpuDeviceID);
3325 lpwm->mld.uDeviceID = *lpuDeviceID = 0;
3327 ret = MMDRV_Open(&lpwm->mld, MODM_OPEN, (DWORD)&lpwm->mod, fdwOpen);
3328 lpMidiStrm->hEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
3329 lpMidiStrm->wFlags = HIWORD(fdwOpen);
3331 lpMidiStrm->hThread = CreateThread(NULL, 0, MMSYSTEM_MidiStream_Player,
3332 lpMidiStrm, 0, &(lpMidiStrm->dwThreadID));
3334 if (!lpMidiStrm->hThread) {
3335 midiStreamClose((HMIDISTRM)hMidiOut);
3336 return MMSYSERR_NOMEM;
3339 /* wait for thread to have started, and for its queue to be created */
3343 /* (Release|Restore)ThunkLock() is needed when this method is called from 16 bit code,
3344 * (meaning the Win16Lock is set), so that it's released and the 32 bit thread running
3345 * MMSYSTEM_MidiStreamPlayer can acquire Win16Lock to create its queue.
3347 ReleaseThunkLock(&count);
3348 WaitForSingleObject(lpMidiStrm->hEvent, INFINITE);
3349 RestoreThunkLock(count);
3352 TRACE("=> (%u/%d) hMidi=0x%04x ret=%d lpMidiStrm=%p\n",
3353 *lpuDeviceID, lpwm->mld.uDeviceID, *lphMidiStrm, ret, lpMidiStrm);
3357 /**************************************************************************
3358 * midiStreamOpen [WINMM.91]
3360 MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
3361 DWORD cMidi, DWORD dwCallback,
3362 DWORD dwInstance, DWORD fdwOpen)
3364 return MMSYSTEM_MidiStream_Open(lphMidiStrm, lpuDeviceID, cMidi, dwCallback,
3365 dwInstance, fdwOpen, TRUE);
3368 /**************************************************************************
3369 * midiStreamOut [WINMM.92]
3371 MMRESULT WINAPI midiStreamOut(HMIDISTRM hMidiStrm, LPMIDIHDR lpMidiHdr,
3374 WINE_MIDIStream* lpMidiStrm;
3375 DWORD ret = MMSYSERR_NOERROR;
3377 TRACE("(%08x, %p, %u)!\n", hMidiStrm, lpMidiHdr, cbMidiHdr);
3379 if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL)) {
3380 ret = MMSYSERR_INVALHANDLE;
3382 if (!PostThreadMessageA(lpMidiStrm->dwThreadID,
3383 WINE_MSM_HEADER, cbMidiHdr,
3384 (DWORD)lpMidiHdr)) {
3385 WARN("bad PostThreadMessageA\n");
3386 ret = MMSYSERR_ERROR;
3392 /**************************************************************************
3393 * midiStreamPause [WINMM.93]
3395 MMRESULT WINAPI midiStreamPause(HMIDISTRM hMidiStrm)
3397 WINE_MIDIStream* lpMidiStrm;
3398 DWORD ret = MMSYSERR_NOERROR;
3400 TRACE("(%08x)!\n", hMidiStrm);
3402 if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL)) {
3403 ret = MMSYSERR_INVALHANDLE;
3405 if (SuspendThread(lpMidiStrm->hThread) == 0xFFFFFFFF) {
3406 WARN("bad Suspend (%ld)\n", GetLastError());
3407 ret = MMSYSERR_ERROR;
3413 /**************************************************************************
3414 * midiStreamPosition [WINMM.94]
3416 MMRESULT WINAPI midiStreamPosition(HMIDISTRM hMidiStrm, LPMMTIME lpMMT, UINT cbmmt)
3418 WINE_MIDIStream* lpMidiStrm;
3419 DWORD ret = MMSYSERR_NOERROR;
3421 TRACE("(%08x, %p, %u)!\n", hMidiStrm, lpMMT, cbmmt);
3423 if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL)) {
3424 ret = MMSYSERR_INVALHANDLE;
3425 } else if (lpMMT == NULL || cbmmt != sizeof(MMTIME)) {
3426 ret = MMSYSERR_INVALPARAM;
3428 switch (lpMMT->wType) {
3430 lpMMT->u.ms = lpMidiStrm->dwPositionMS;
3431 TRACE("=> %ld ms\n", lpMMT->u.ms);
3434 lpMMT->u.ticks = lpMidiStrm->dwPulses;
3435 TRACE("=> %ld ticks\n", lpMMT->u.ticks);
3438 WARN("Unsupported time type %d\n", lpMMT->wType);
3439 lpMMT->wType = TIME_MS;
3440 ret = MMSYSERR_INVALPARAM;
3447 /**************************************************************************
3448 * midiStreamProperty [WINMM.95]
3450 MMRESULT WINAPI midiStreamProperty(HMIDISTRM hMidiStrm, LPBYTE lpPropData, DWORD dwProperty)
3452 WINE_MIDIStream* lpMidiStrm;
3453 MMRESULT ret = MMSYSERR_NOERROR;
3455 TRACE("(%08x, %p, %lx)\n", hMidiStrm, lpPropData, dwProperty);
3457 if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL)) {
3458 ret = MMSYSERR_INVALHANDLE;
3459 } else if ((dwProperty & (MIDIPROP_GET|MIDIPROP_SET)) == 0) {
3460 ret = MMSYSERR_INVALPARAM;
3461 } else if (dwProperty & MIDIPROP_TEMPO) {
3462 MIDIPROPTEMPO* mpt = (MIDIPROPTEMPO*)lpPropData;
3464 if (sizeof(MIDIPROPTEMPO) != mpt->cbStruct) {
3465 ret = MMSYSERR_INVALPARAM;
3466 } else if (dwProperty & MIDIPROP_SET) {
3467 lpMidiStrm->dwTempo = mpt->dwTempo;
3468 TRACE("Setting tempo to %ld\n", mpt->dwTempo);
3469 } else if (dwProperty & MIDIPROP_GET) {
3470 mpt->dwTempo = lpMidiStrm->dwTempo;
3471 TRACE("Getting tempo <= %ld\n", mpt->dwTempo);
3473 } else if (dwProperty & MIDIPROP_TIMEDIV) {
3474 MIDIPROPTIMEDIV* mptd = (MIDIPROPTIMEDIV*)lpPropData;
3476 if (sizeof(MIDIPROPTIMEDIV) != mptd->cbStruct) {
3477 ret = MMSYSERR_INVALPARAM;
3478 } else if (dwProperty & MIDIPROP_SET) {
3479 lpMidiStrm->dwTimeDiv = mptd->dwTimeDiv;
3480 TRACE("Setting time div to %ld\n", mptd->dwTimeDiv);
3481 } else if (dwProperty & MIDIPROP_GET) {
3482 mptd->dwTimeDiv = lpMidiStrm->dwTimeDiv;
3483 TRACE("Getting time div <= %ld\n", mptd->dwTimeDiv);
3486 ret = MMSYSERR_INVALPARAM;
3492 /**************************************************************************
3493 * midiStreamRestart [WINMM.96]
3495 MMRESULT WINAPI midiStreamRestart(HMIDISTRM hMidiStrm)
3497 WINE_MIDIStream* lpMidiStrm;
3498 MMRESULT ret = MMSYSERR_NOERROR;
3500 TRACE("(%08x)!\n", hMidiStrm);
3502 if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL)) {
3503 ret = MMSYSERR_INVALHANDLE;
3507 /* since we increase the thread suspend count on each midiStreamPause
3508 * there may be a need for several midiStreamResume
3511 ret = ResumeThread(lpMidiStrm->hThread);
3512 } while (ret != 0xFFFFFFFF && ret != 0);
3513 if (ret == 0xFFFFFFFF) {
3514 WARN("bad Resume (%ld)\n", GetLastError());
3515 ret = MMSYSERR_ERROR;
3517 lpMidiStrm->dwStartTicks = GetTickCount() - lpMidiStrm->dwPositionMS;
3523 /**************************************************************************
3524 * midiStreamStop [WINMM.97]
3526 MMRESULT WINAPI midiStreamStop(HMIDISTRM hMidiStrm)
3528 WINE_MIDIStream* lpMidiStrm;
3529 MMRESULT ret = MMSYSERR_NOERROR;
3531 TRACE("(%08x)!\n", hMidiStrm);
3533 if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL)) {
3534 ret = MMSYSERR_INVALHANDLE;
3536 /* in case stream has been paused... FIXME is the current state correct ? */
3537 midiStreamRestart(hMidiStrm);
3538 MMSYSTEM_MidiStream_PostMessage(lpMidiStrm, WINE_MSM_STOP, 0, 0);
3543 /**************************************************************************
3544 * midiStreamClose [MMSYSTEM.252]
3546 MMRESULT16 WINAPI midiStreamClose16(HMIDISTRM16 hMidiStrm)
3548 return midiStreamClose(hMidiStrm);
3551 /**************************************************************************
3552 * midiStreamOpen [MMSYSTEM.251]
3554 MMRESULT16 WINAPI midiStreamOpen16(HMIDISTRM16* phMidiStrm, LPUINT16 devid,
3555 DWORD cMidi, DWORD dwCallback,
3556 DWORD dwInstance, DWORD fdwOpen)
3558 HMIDISTRM hMidiStrm32;
3562 if (!phMidiStrm || !devid)
3563 return MMSYSERR_INVALPARAM;
3565 ret = MMSYSTEM_MidiStream_Open(&hMidiStrm32, &devid32, cMidi, dwCallback,
3566 dwInstance, fdwOpen, FALSE);
3567 *phMidiStrm = hMidiStrm32;
3572 /**************************************************************************
3573 * midiStreamOut [MMSYSTEM.254]
3575 MMRESULT16 WINAPI midiStreamOut16(HMIDISTRM16 hMidiStrm, LPMIDIHDR16 lpMidiHdr, UINT16 cbMidiHdr)
3577 return midiStreamOut(hMidiStrm, (LPMIDIHDR)lpMidiHdr, cbMidiHdr);
3580 /**************************************************************************
3581 * midiStreamPause [MMSYSTEM.255]
3583 MMRESULT16 WINAPI midiStreamPause16(HMIDISTRM16 hMidiStrm)
3585 return midiStreamPause(hMidiStrm);
3588 /**************************************************************************
3589 * midiStreamPosition [MMSYSTEM.253]
3591 MMRESULT16 WINAPI midiStreamPosition16(HMIDISTRM16 hMidiStrm, LPMMTIME16 lpmmt16, UINT16 cbmmt)
3597 return MMSYSERR_INVALPARAM;
3598 MMSYSTEM_MMTIME16to32(&mmt32, lpmmt16);
3599 ret = midiStreamPosition(hMidiStrm, &mmt32, sizeof(MMTIME));
3600 MMSYSTEM_MMTIME32to16(lpmmt16, &mmt32);
3604 /**************************************************************************
3605 * midiStreamProperty [MMSYSTEM.250]
3607 MMRESULT16 WINAPI midiStreamProperty16(HMIDISTRM16 hMidiStrm, LPBYTE lpPropData, DWORD dwProperty)
3609 return midiStreamProperty(hMidiStrm, lpPropData, dwProperty);
3612 /**************************************************************************
3613 * midiStreamRestart [MMSYSTEM.256]
3615 MMRESULT16 WINAPI midiStreamRestart16(HMIDISTRM16 hMidiStrm)
3617 return midiStreamRestart(hMidiStrm);
3620 /**************************************************************************
3621 * midiStreamStop [MMSYSTEM.257]
3623 MMRESULT16 WINAPI midiStreamStop16(HMIDISTRM16 hMidiStrm)
3625 return midiStreamStop(hMidiStrm);
3628 static UINT WINAPI MMSYSTEM_waveOpen(HANDLE* lphndl, UINT uDeviceID, UINT uType,
3629 const LPWAVEFORMATEX lpFormat,
3630 DWORD dwCallback, DWORD dwInstance,
3631 DWORD dwFlags, BOOL bFrom32)
3635 DWORD dwRet = MMSYSERR_NOERROR;
3638 TRACE("(%p, %d, %s, %p, %08lX, %08lX, %08lX, %d);\n",
3639 lphndl, (int)uDeviceID, (uType==MMDRV_WAVEOUT)?"Out":"In", lpFormat, dwCallback,
3640 dwInstance, dwFlags, bFrom32?32:16);
3642 if (dwFlags & WAVE_FORMAT_QUERY) TRACE("WAVE_FORMAT_QUERY requested !\n");
3644 if (lpFormat == NULL) return WAVERR_BADFORMAT;
3646 TRACE("wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u\n",
3647 lpFormat->wFormatTag, lpFormat->nChannels, lpFormat->nSamplesPerSec,
3648 lpFormat->nAvgBytesPerSec, lpFormat->nBlockAlign, lpFormat->wBitsPerSample, lpFormat->cbSize);
3650 if ((wmld = MMDRV_Alloc(sizeof(WINE_WAVE), uType, &handle,
3651 &dwFlags, &dwCallback, &dwInstance, bFrom32)) == NULL)
3652 return MMSYSERR_NOMEM;
3655 wod.lpFormat = lpFormat; /* should the struct be copied iso pointer? */
3656 wod.dwCallback = dwCallback;
3657 wod.dwInstance = dwInstance;
3658 wod.uMappedDeviceID = 0;
3661 /* when called from 16 bit code, mapper will be 0x0000FFFF instead of 0xFFFFFFFF */
3662 /* this should fix it */
3663 wmld->uDeviceID = (uDeviceID == (UINT16)-1 && !bFrom32) ? (UINT)-1 : uDeviceID;
3665 dwRet = MMDRV_Open(wmld, (uType==MMDRV_WAVEOUT)?WODM_OPEN:WIDM_OPEN, (DWORD)&wod, dwFlags);
3667 if ((dwFlags & WAVE_FORMAT_QUERY) || dwRet != MMSYSERR_NOERROR) {
3668 MMDRV_Free(handle, wmld);
3672 if (lphndl != NULL) *lphndl = handle;
3673 TRACE("=> %ld hWave=%04x\n", dwRet, handle);
3678 /**************************************************************************
3679 * waveOutGetNumDevs [MMSYSTEM.401]
3681 UINT WINAPI waveOutGetNumDevs(void)
3683 return MMDRV_GetNum(MMDRV_WAVEOUT);
3686 /**************************************************************************
3687 * waveOutGetNumDevs [WINMM.167]
3689 UINT16 WINAPI waveOutGetNumDevs16(void)
3691 return MMDRV_GetNum(MMDRV_WAVEOUT);
3694 /**************************************************************************
3695 * waveOutGetDevCaps [MMSYSTEM.402]
3697 UINT16 WINAPI waveOutGetDevCaps16(UINT16 uDeviceID,
3698 LPWAVEOUTCAPS16 lpCaps, UINT16 uSize)
3703 TRACE("(%u %p %u)!\n", uDeviceID, lpCaps, uSize);
3704 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
3706 ret = waveOutGetDevCapsA(uDeviceID, &wocA, sizeof(wocA));
3708 if (ret == MMSYSERR_NOERROR) {
3709 lpCaps->wMid = wocA.wMid;
3710 lpCaps->wPid = wocA.wPid;
3711 lpCaps->vDriverVersion = wocA.vDriverVersion;
3712 strcpy(lpCaps->szPname, wocA.szPname);
3713 lpCaps->dwFormats = wocA.dwFormats;
3714 lpCaps->wChannels = wocA.wChannels;
3715 lpCaps->dwSupport = wocA.dwSupport;
3720 /**************************************************************************
3721 * waveOutGetDevCapsA [WINMM.162]
3723 UINT WINAPI waveOutGetDevCapsA(UINT uDeviceID, LPWAVEOUTCAPSA lpCaps,
3728 TRACE("(%u %p %u)!\n", uDeviceID, lpCaps, uSize);
3730 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
3732 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_WAVEOUT, TRUE)) == NULL)
3733 return MMSYSERR_INVALHANDLE;
3735 return MMDRV_Message(wmld, WODM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
3739 /**************************************************************************
3740 * waveOutGetDevCapsW [WINMM.163]
3742 UINT WINAPI waveOutGetDevCapsW(UINT uDeviceID, LPWAVEOUTCAPSW lpCaps,
3748 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
3750 ret = waveOutGetDevCapsA(uDeviceID, &wocA, sizeof(wocA));
3752 if (ret == MMSYSERR_NOERROR) {
3753 lpCaps->wMid = wocA.wMid;
3754 lpCaps->wPid = wocA.wPid;
3755 lpCaps->vDriverVersion = wocA.vDriverVersion;
3756 MultiByteToWideChar( CP_ACP, 0, wocA.szPname, -1, lpCaps->szPname,
3757 sizeof(lpCaps->szPname)/sizeof(WCHAR) );
3758 lpCaps->dwFormats = wocA.dwFormats;
3759 lpCaps->wChannels = wocA.wChannels;
3760 lpCaps->dwSupport = wocA.dwSupport;
3765 /**************************************************************************
3766 * WAVE_GetErrorText [internal]
3768 static UINT16 WAVE_GetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
3770 UINT16 ret = MMSYSERR_BADERRNUM;
3772 if (lpText == NULL) {
3773 ret = MMSYSERR_INVALPARAM;
3774 } else if (uSize == 0) {
3775 ret = MMSYSERR_NOERROR;
3777 /* test has been removed 'coz MMSYSERR_BASE is 0, and gcc did emit
3778 * a warning for the test was always true */
3779 (/*uError >= MMSYSERR_BASE && */uError <= MMSYSERR_LASTERROR) ||
3780 (uError >= WAVERR_BASE && uError <= WAVERR_LASTERROR)) {
3782 if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
3783 uError, lpText, uSize) > 0) {
3784 ret = MMSYSERR_NOERROR;
3790 /**************************************************************************
3791 * waveOutGetErrorText [MMSYSTEM.403]
3793 UINT16 WINAPI waveOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
3795 return WAVE_GetErrorText(uError, lpText, uSize);
3798 /**************************************************************************
3799 * waveOutGetErrorTextA [WINMM.164]
3801 UINT WINAPI waveOutGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
3803 return WAVE_GetErrorText(uError, lpText, uSize);
3806 /**************************************************************************
3807 * waveOutGetErrorTextW [WINMM.165]
3809 UINT WINAPI waveOutGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
3811 LPSTR xstr = HeapAlloc(GetProcessHeap(), 0, uSize);
3812 UINT ret = WAVE_GetErrorText(uError, xstr, uSize);
3814 MultiByteToWideChar( CP_ACP, 0, xstr, -1, lpText, uSize );
3815 HeapFree(GetProcessHeap(), 0, xstr);
3819 /**************************************************************************
3820 * waveOutOpen [WINMM.173]
3821 * All the args/structs have the same layout as the win16 equivalents
3823 UINT WINAPI waveOutOpen(HWAVEOUT* lphWaveOut, UINT uDeviceID,
3824 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
3825 DWORD dwInstance, DWORD dwFlags)
3827 return MMSYSTEM_waveOpen(lphWaveOut, uDeviceID, MMDRV_WAVEOUT, lpFormat,
3828 dwCallback, dwInstance, dwFlags, TRUE);
3831 /**************************************************************************
3832 * waveOutOpen [MMSYSTEM.404]
3834 UINT16 WINAPI waveOutOpen16(HWAVEOUT16* lphWaveOut, UINT16 uDeviceID,
3835 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
3836 DWORD dwInstance, DWORD dwFlags)
3841 /* since layout of WAVEOFORMATEX is the same for 16/32 bits, we directly
3842 * call the 32 bit version
3844 ret = MMSYSTEM_waveOpen(&hWaveOut, uDeviceID, MMDRV_WAVEOUT, lpFormat,
3845 dwCallback, dwInstance, dwFlags, FALSE);
3847 if (lphWaveOut != NULL) *lphWaveOut = hWaveOut;
3851 /**************************************************************************
3852 * waveOutClose [WINMM.161]
3854 UINT WINAPI waveOutClose(HWAVEOUT hWaveOut)
3859 TRACE("(%04X)\n", hWaveOut);
3861 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
3862 return MMSYSERR_INVALHANDLE;
3864 dwRet = MMDRV_Close(wmld, WODM_CLOSE);
3865 MMDRV_Free(hWaveOut, wmld);
3870 /**************************************************************************
3871 * waveOutClose [MMSYSTEM.405]
3873 UINT16 WINAPI waveOutClose16(HWAVEOUT16 hWaveOut)
3878 ReleaseThunkLock(&level);
3879 ret = waveOutClose(hWaveOut);
3880 RestoreThunkLock(level);
3884 /**************************************************************************
3885 * waveOutPrepareHeader [WINMM.175]
3887 UINT WINAPI waveOutPrepareHeader(HWAVEOUT hWaveOut,
3888 WAVEHDR* lpWaveOutHdr, UINT uSize)
3892 TRACE("(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
3894 if (lpWaveOutHdr == NULL) return MMSYSERR_INVALPARAM;
3896 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
3897 return MMSYSERR_INVALHANDLE;
3899 return MMDRV_Message(wmld, WODM_PREPARE, (DWORD)lpWaveOutHdr, uSize, TRUE);
3902 /**************************************************************************
3903 * waveOutPrepareHeader [MMSYSTEM.406]
3905 UINT16 WINAPI waveOutPrepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
3906 SEGPTR lpsegWaveOutHdr, /* [???] */
3907 UINT16 uSize) /* [in] */
3910 LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
3912 TRACE("(%04X, %08lx, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
3914 if (lpWaveOutHdr == NULL) return MMSYSERR_INVALPARAM;
3916 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
3917 return MMSYSERR_INVALHANDLE;
3919 return MMDRV_Message(wmld, WODM_PREPARE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
3922 /**************************************************************************
3923 * waveOutUnprepareHeader [WINMM.181]
3925 UINT WINAPI waveOutUnprepareHeader(HWAVEOUT hWaveOut,
3926 LPWAVEHDR lpWaveOutHdr, UINT uSize)
3930 TRACE("(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
3932 if (!(lpWaveOutHdr->dwFlags & WHDR_PREPARED)) {
3933 return MMSYSERR_NOERROR;
3936 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
3937 return MMSYSERR_INVALHANDLE;
3939 return MMDRV_Message(wmld, WODM_UNPREPARE, (DWORD)lpWaveOutHdr, uSize, TRUE);
3942 /**************************************************************************
3943 * waveOutUnprepareHeader [MMSYSTEM.407]
3945 UINT16 WINAPI waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
3946 SEGPTR lpsegWaveOutHdr, /* [???] */
3947 UINT16 uSize) /* [in] */
3950 LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
3952 TRACE("(%04X, %08lx, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
3954 if (!(lpWaveOutHdr->dwFlags & WHDR_PREPARED)) {
3955 return MMSYSERR_NOERROR;
3958 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
3959 return MMSYSERR_INVALHANDLE;
3961 return MMDRV_Message(wmld, WODM_UNPREPARE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
3964 /**************************************************************************
3965 * waveOutWrite [MMSYSTEM.408]
3967 UINT WINAPI waveOutWrite(HWAVEOUT hWaveOut, LPWAVEHDR lpWaveOutHdr,
3972 TRACE("(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
3974 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
3975 return MMSYSERR_INVALHANDLE;
3977 return MMDRV_Message(wmld, WODM_WRITE, (DWORD)lpWaveOutHdr, uSize, TRUE);
3980 /**************************************************************************
3981 * waveOutWrite [MMSYSTEM.408]
3983 UINT16 WINAPI waveOutWrite16(HWAVEOUT16 hWaveOut, /* [in] */
3984 LPWAVEHDR lpsegWaveOutHdr, /* [???] NOTE: SEGPTR */
3985 UINT16 uSize) /* [in] */
3989 TRACE("(%04X, %p, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
3991 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
3992 return MMSYSERR_INVALHANDLE;
3994 return MMDRV_Message(wmld, WODM_WRITE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
3997 /**************************************************************************
3998 * waveOutBreakLoop [WINMM.160]
4000 UINT WINAPI waveOutBreakLoop(HWAVEOUT hWaveOut)
4004 TRACE("(%04X);\n", hWaveOut);
4006 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4007 return MMSYSERR_INVALHANDLE;
4008 return MMDRV_Message(wmld, WODM_BREAKLOOP, 0L, 0L, TRUE);
4011 /**************************************************************************
4012 * waveOutBreakLoop16 [MMSYSTEM.419]
4014 UINT16 WINAPI waveOutBreakLoop16(HWAVEOUT16 hWaveOut16)
4019 ReleaseThunkLock(&level);
4020 ret = waveOutBreakLoop(hWaveOut16);
4021 RestoreThunkLock(level);
4025 /**************************************************************************
4026 * waveOutPause [WINMM.174]
4028 UINT WINAPI waveOutPause(HWAVEOUT hWaveOut)
4032 TRACE("(%04X);\n", hWaveOut);
4034 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4035 return MMSYSERR_INVALHANDLE;
4036 return MMDRV_Message(wmld, WODM_PAUSE, 0L, 0L, TRUE);
4039 /**************************************************************************
4040 * waveOutPause16 [MMSYSTEM.409]
4042 UINT16 WINAPI waveOutPause16(HWAVEOUT16 hWaveOut16)
4047 ReleaseThunkLock(&level);
4048 ret = waveOutPause(hWaveOut16);
4049 RestoreThunkLock(level);
4053 /**************************************************************************
4054 * waveOutReset [WINMM.176]
4056 UINT WINAPI waveOutReset(HWAVEOUT hWaveOut)
4060 TRACE("(%04X);\n", hWaveOut);
4062 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4063 return MMSYSERR_INVALHANDLE;
4064 return MMDRV_Message(wmld, WODM_RESET, 0L, 0L, TRUE);
4067 /**************************************************************************
4068 * waveOutReset16 [MMSYSTEM.411]
4070 UINT16 WINAPI waveOutReset16(HWAVEOUT16 hWaveOut16)
4075 ReleaseThunkLock(&level);
4076 ret = waveOutReset(hWaveOut16);
4077 RestoreThunkLock(level);
4081 /**************************************************************************
4082 * waveOutRestart [WINMM.177]
4084 UINT WINAPI waveOutRestart(HWAVEOUT hWaveOut)
4088 TRACE("(%04X);\n", hWaveOut);
4090 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4091 return MMSYSERR_INVALHANDLE;
4092 return MMDRV_Message(wmld, WODM_RESTART, 0L, 0L, TRUE);
4095 /**************************************************************************
4096 * waveOutRestart16 [MMSYSTEM.410]
4098 UINT16 WINAPI waveOutRestart16(HWAVEOUT16 hWaveOut16)
4103 ReleaseThunkLock(&level);
4104 ret = waveOutRestart(hWaveOut16);
4105 RestoreThunkLock(level);
4109 /**************************************************************************
4110 * waveOutGetPosition [WINMM.170]
4112 UINT WINAPI waveOutGetPosition(HWAVEOUT hWaveOut, LPMMTIME lpTime,
4117 TRACE("(%04X, %p, %u);\n", hWaveOut, lpTime, uSize);
4119 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4120 return MMSYSERR_INVALHANDLE;
4122 return MMDRV_Message(wmld, WODM_GETPOS, (DWORD)lpTime, uSize, TRUE);
4125 /**************************************************************************
4126 * waveOutGetPosition [MMSYSTEM.412]
4128 UINT16 WINAPI waveOutGetPosition16(HWAVEOUT16 hWaveOut, LPMMTIME16 lpTime,
4134 mmt.wType = lpTime->wType;
4135 ret = waveOutGetPosition(hWaveOut, &mmt, sizeof(mmt));
4136 MMSYSTEM_MMTIME32to16(lpTime, &mmt);
4140 /**************************************************************************
4141 * waveOutGetPitch [WINMM.168]
4143 UINT WINAPI waveOutGetPitch(HWAVEOUT hWaveOut, LPDWORD lpdw)
4147 TRACE("(%04X, %08lx);\n", hWaveOut, (DWORD)lpdw);
4149 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4150 return MMSYSERR_INVALHANDLE;
4151 return MMDRV_Message(wmld, WODM_GETPITCH, (DWORD)lpdw, 0L, TRUE);
4154 /**************************************************************************
4155 * waveOutGetPitch [MMSYSTEM.413]
4157 UINT16 WINAPI waveOutGetPitch16(HWAVEOUT16 hWaveOut16, LPDWORD lpdw)
4159 return waveOutGetPitch(hWaveOut16, lpdw);
4162 /**************************************************************************
4163 * waveOutSetPitch [WINMM.178]
4165 UINT WINAPI waveOutSetPitch(HWAVEOUT hWaveOut, DWORD dw)
4169 TRACE("(%04X, %08lx);\n", hWaveOut, (DWORD)dw);
4171 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4172 return MMSYSERR_INVALHANDLE;
4173 return MMDRV_Message(wmld, WODM_SETPITCH, dw, 0L, TRUE);
4176 /**************************************************************************
4177 * waveOutSetPitch [MMSYSTEM.414]
4179 UINT16 WINAPI waveOutSetPitch16(HWAVEOUT16 hWaveOut16, DWORD dw)
4181 return waveOutSetPitch(hWaveOut16, dw);
4184 /**************************************************************************
4185 * waveOutGetPlaybackRate [WINMM.169]
4187 UINT WINAPI waveOutGetPlaybackRate(HWAVEOUT hWaveOut, LPDWORD lpdw)
4191 TRACE("(%04X, %08lx);\n", hWaveOut, (DWORD)lpdw);
4193 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4194 return MMSYSERR_INVALHANDLE;
4195 return MMDRV_Message(wmld, WODM_GETPLAYBACKRATE, (DWORD)lpdw, 0L, TRUE);
4198 /**************************************************************************
4199 * waveOutGetPlaybackRate [MMSYSTEM.417]
4201 UINT16 WINAPI waveOutGetPlaybackRate16(HWAVEOUT16 hWaveOut16, LPDWORD lpdw)
4203 return waveOutGetPlaybackRate(hWaveOut16, lpdw);
4206 /**************************************************************************
4207 * waveOutSetPlaybackRate [WINMM.179]
4209 UINT WINAPI waveOutSetPlaybackRate(HWAVEOUT hWaveOut, DWORD dw)
4213 TRACE("(%04X, %08lx);\n", hWaveOut, (DWORD)dw);
4215 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4216 return MMSYSERR_INVALHANDLE;
4217 return MMDRV_Message(wmld, WODM_SETPLAYBACKRATE, dw, 0L, TRUE);
4220 /**************************************************************************
4221 * waveOutSetPlaybackRate [MMSYSTEM.418]
4223 UINT16 WINAPI waveOutSetPlaybackRate16(HWAVEOUT16 hWaveOut16, DWORD dw)
4225 return waveOutSetPlaybackRate(hWaveOut16, dw);
4228 /**************************************************************************
4229 * waveOutGetVolume [WINMM.171]
4231 UINT WINAPI waveOutGetVolume(UINT devid, LPDWORD lpdw)
4235 TRACE("(%04X, %08lx);\n", devid, (DWORD)lpdw);
4237 if ((wmld = MMDRV_Get(devid, MMDRV_WAVEOUT, TRUE)) == NULL)
4238 return MMSYSERR_INVALHANDLE;
4240 return MMDRV_Message(wmld, WODM_GETVOLUME, (DWORD)lpdw, 0L, TRUE);
4243 /**************************************************************************
4244 * waveOutGetVolume [MMSYSTEM.415]
4246 UINT16 WINAPI waveOutGetVolume16(UINT16 devid, LPDWORD lpdw)
4248 return waveOutGetVolume(devid, lpdw);
4251 /**************************************************************************
4252 * waveOutSetVolume [WINMM.180]
4254 UINT WINAPI waveOutSetVolume(UINT devid, DWORD dw)
4258 TRACE("(%04X, %08lx);\n", devid, dw);
4260 if ((wmld = MMDRV_Get(devid, MMDRV_WAVEOUT, TRUE)) == NULL)
4261 return MMSYSERR_INVALHANDLE;
4263 return MMDRV_Message(wmld, WODM_SETVOLUME, dw, 0L, TRUE);
4266 /**************************************************************************
4267 * waveOutSetVolume [MMSYSTEM.416]
4269 UINT16 WINAPI waveOutSetVolume16(UINT16 devid, DWORD dw)
4271 return waveOutSetVolume(devid, dw);
4274 /**************************************************************************
4275 * waveOutGetID [MMSYSTEM.420]
4277 UINT WINAPI waveOutGetID(HWAVEOUT hWaveOut, UINT* lpuDeviceID)
4281 TRACE("(%04X, %p);\n", hWaveOut, lpuDeviceID);
4283 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
4285 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4286 return MMSYSERR_INVALHANDLE;
4288 *lpuDeviceID = wmld->uDeviceID;
4292 /**************************************************************************
4293 * waveOutGetID [MMSYSTEM.420]
4295 UINT16 WINAPI waveOutGetID16(HWAVEOUT16 hWaveOut, UINT16* lpuDeviceID)
4299 TRACE("(%04X, %p);\n", hWaveOut, lpuDeviceID);
4301 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
4303 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL)
4304 return MMSYSERR_INVALHANDLE;
4306 *lpuDeviceID = wmld->uDeviceID;
4310 /**************************************************************************
4311 * waveOutMessage [WINMM.172]
4313 DWORD WINAPI waveOutMessage(HWAVEOUT hWaveOut, UINT uMessage,
4314 DWORD dwParam1, DWORD dwParam2)
4318 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut, uMessage, dwParam1, dwParam2);
4320 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL) {
4321 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, TRUE)) != NULL) {
4322 return MMDRV_PhysicalFeatures(wmld, uMessage, dwParam1, dwParam2);
4324 return MMSYSERR_INVALHANDLE;
4328 if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
4329 return MMSYSERR_INVALPARAM;
4331 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
4334 /**************************************************************************
4335 * waveOutMessage [MMSYSTEM.421]
4337 DWORD WINAPI waveOutMessage16(HWAVEOUT16 hWaveOut, UINT16 uMessage,
4338 DWORD dwParam1, DWORD dwParam2)
4342 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut, uMessage, dwParam1, dwParam2);
4344 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL) {
4345 if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, TRUE)) != NULL) {
4346 return MMDRV_PhysicalFeatures(wmld, uMessage, dwParam1, dwParam2);
4348 return MMSYSERR_INVALHANDLE;
4352 if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
4353 return MMSYSERR_INVALPARAM;
4355 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
4358 /**************************************************************************
4359 * waveInGetNumDevs [WINMM.151]
4361 UINT WINAPI waveInGetNumDevs(void)
4363 return MMDRV_GetNum(MMDRV_WAVEIN);
4366 /**************************************************************************
4367 * waveInGetNumDevs [MMSYSTEM.501]
4369 UINT16 WINAPI waveInGetNumDevs16(void)
4371 return MMDRV_GetNum(MMDRV_WAVEIN);
4374 /**************************************************************************
4375 * waveInGetDevCapsW [WINMM.147]
4377 UINT WINAPI waveInGetDevCapsW(UINT uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSize)
4380 UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, uSize);
4382 if (ret == MMSYSERR_NOERROR) {
4383 lpCaps->wMid = wicA.wMid;
4384 lpCaps->wPid = wicA.wPid;
4385 lpCaps->vDriverVersion = wicA.vDriverVersion;
4386 MultiByteToWideChar( CP_ACP, 0, wicA.szPname, -1, lpCaps->szPname,
4387 sizeof(lpCaps->szPname)/sizeof(WCHAR) );
4388 lpCaps->dwFormats = wicA.dwFormats;
4389 lpCaps->wChannels = wicA.wChannels;
4395 /**************************************************************************
4396 * waveInGetDevCapsA [WINMM.146]
4398 UINT WINAPI waveInGetDevCapsA(UINT uDeviceID, LPWAVEINCAPSA lpCaps, UINT uSize)
4402 TRACE("(%u %p %u)!\n", uDeviceID, lpCaps, uSize);
4404 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_WAVEIN, TRUE)) == NULL)
4405 return MMSYSERR_INVALHANDLE;
4407 return MMDRV_Message(wmld, WIDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
4410 /**************************************************************************
4411 * waveInGetDevCaps [MMSYSTEM.502]
4413 UINT16 WINAPI waveInGetDevCaps16(UINT16 uDeviceID, LPWAVEINCAPS16 lpCaps,
4417 UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, sizeof(wicA));
4419 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
4421 if (ret == MMSYSERR_NOERROR) {
4422 lpCaps->wMid = wicA.wMid;
4423 lpCaps->wPid = wicA.wPid;
4424 lpCaps->vDriverVersion = wicA.vDriverVersion;
4425 strcpy(lpCaps->szPname, wicA.szPname);
4426 lpCaps->dwFormats = wicA.dwFormats;
4427 lpCaps->wChannels = wicA.wChannels;
4432 /**************************************************************************
4433 * waveInGetErrorTextA [WINMM.148]
4435 UINT WINAPI waveInGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
4437 return WAVE_GetErrorText(uError, lpText, uSize);
4440 /**************************************************************************
4441 * waveInGetErrorTextW [WINMM.149]
4443 UINT WINAPI waveInGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
4445 LPSTR txt = HeapAlloc(GetProcessHeap(), 0, uSize);
4446 UINT ret = WAVE_GetErrorText(uError, txt, uSize);
4448 MultiByteToWideChar( CP_ACP, 0, txt, -1, lpText, uSize );
4449 HeapFree(GetProcessHeap(), 0, txt);
4453 /**************************************************************************
4454 * waveInGetErrorText [MMSYSTEM.503]
4456 UINT16 WINAPI waveInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
4458 return WAVE_GetErrorText(uError, lpText, uSize);
4461 /**************************************************************************
4462 * waveInOpen [WINMM.154]
4464 UINT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
4465 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
4466 DWORD dwInstance, DWORD dwFlags)
4468 return MMSYSTEM_waveOpen(lphWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat,
4469 dwCallback, dwInstance, dwFlags, TRUE);
4472 /**************************************************************************
4473 * waveInOpen [MMSYSTEM.504]
4475 UINT16 WINAPI waveInOpen16(HWAVEIN16* lphWaveIn, UINT16 uDeviceID,
4476 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
4477 DWORD dwInstance, DWORD dwFlags)
4482 /* since layout of WAVEOFORMATEX is the same for 16/32 bits, we directly
4483 * call the 32 bit version
4485 ret = MMSYSTEM_waveOpen(&hWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat,
4486 dwCallback, dwInstance, dwFlags, FALSE);
4488 if (lphWaveIn != NULL) *lphWaveIn = hWaveIn;
4492 /**************************************************************************
4493 * waveInClose [WINMM.145]
4495 UINT WINAPI waveInClose(HWAVEIN hWaveIn)
4500 TRACE("(%04X)\n", hWaveIn);
4502 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4503 return MMSYSERR_INVALHANDLE;
4505 dwRet = MMDRV_Message(wmld, WIDM_CLOSE, 0L, 0L, TRUE);
4506 MMDRV_Free(hWaveIn, wmld);
4510 /**************************************************************************
4511 * waveInClose [MMSYSTEM.505]
4513 UINT16 WINAPI waveInClose16(HWAVEIN16 hWaveIn)
4518 ReleaseThunkLock(&level);
4519 ret = waveInClose(hWaveIn);
4520 RestoreThunkLock(level);
4524 /**************************************************************************
4525 * waveInPrepareHeader [WINMM.155]
4527 UINT WINAPI waveInPrepareHeader(HWAVEIN hWaveIn, WAVEHDR* lpWaveInHdr,
4532 TRACE("(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
4534 if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
4535 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4536 return MMSYSERR_INVALHANDLE;
4538 lpWaveInHdr->dwBytesRecorded = 0;
4540 return MMDRV_Message(wmld, WIDM_PREPARE, (DWORD)lpWaveInHdr, uSize, TRUE);
4543 /**************************************************************************
4544 * waveInPrepareHeader [MMSYSTEM.506]
4546 UINT16 WINAPI waveInPrepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
4547 SEGPTR lpsegWaveInHdr, /* [???] */
4548 UINT16 uSize) /* [in] */
4551 LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
4554 TRACE("(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
4556 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
4557 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4558 return MMSYSERR_INVALHANDLE;
4560 lpWaveInHdr->dwBytesRecorded = 0;
4562 ret = MMDRV_Message(wmld, WIDM_PREPARE, (DWORD)lpsegWaveInHdr, uSize, FALSE);
4566 /**************************************************************************
4567 * waveInUnprepareHeader [WINMM.159]
4569 UINT WINAPI waveInUnprepareHeader(HWAVEIN hWaveIn, WAVEHDR* lpWaveInHdr,
4574 TRACE("(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
4576 if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
4577 if (!(lpWaveInHdr->dwFlags & WHDR_PREPARED)) {
4578 return MMSYSERR_NOERROR;
4581 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4582 return MMSYSERR_INVALHANDLE;
4584 return MMDRV_Message(wmld, WIDM_UNPREPARE, (DWORD)lpWaveInHdr, uSize, TRUE);
4587 /**************************************************************************
4588 * waveInUnprepareHeader [MMSYSTEM.507]
4590 UINT16 WINAPI waveInUnprepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
4591 SEGPTR lpsegWaveInHdr, /* [???] */
4592 UINT16 uSize) /* [in] */
4595 LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
4597 TRACE("(%04X, %08lx, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
4599 if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
4601 if (!(lpWaveInHdr->dwFlags & WHDR_PREPARED)) {
4602 return MMSYSERR_NOERROR;
4605 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4606 return MMSYSERR_INVALHANDLE;
4608 return MMDRV_Message(wmld, WIDM_UNPREPARE, (DWORD)lpsegWaveInHdr, uSize, FALSE);
4611 /**************************************************************************
4612 * waveInAddBuffer [WINMM.144]
4614 UINT WINAPI waveInAddBuffer(HWAVEIN hWaveIn,
4615 WAVEHDR* lpWaveInHdr, UINT uSize)
4619 TRACE("(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
4621 if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
4622 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4623 return MMSYSERR_INVALHANDLE;
4625 return MMDRV_Message(wmld, WIDM_ADDBUFFER, (DWORD)lpWaveInHdr, uSize, TRUE);
4628 /**************************************************************************
4629 * waveInAddBuffer [MMSYSTEM.508]
4631 UINT16 WINAPI waveInAddBuffer16(HWAVEIN16 hWaveIn, /* [in] */
4632 WAVEHDR* lpsegWaveInHdr, /* [???] NOTE: SEGPTR */
4633 UINT16 uSize) /* [in] */
4637 TRACE("(%04X, %p, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
4639 if (lpsegWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
4640 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4641 return MMSYSERR_INVALHANDLE;
4643 return MMDRV_Message(wmld, WIDM_ADDBUFFER, (DWORD)lpsegWaveInHdr, uSize, FALSE);
4646 /**************************************************************************
4647 * waveInReset [WINMM.156]
4649 UINT WINAPI waveInReset(HWAVEIN hWaveIn)
4653 TRACE("(%04X);\n", hWaveIn);
4655 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4656 return MMSYSERR_INVALHANDLE;
4658 return MMDRV_Message(wmld, WIDM_RESET, 0L, 0L, TRUE);
4661 /**************************************************************************
4662 * waveInReset [MMSYSTEM.511]
4664 UINT16 WINAPI waveInReset16(HWAVEIN16 hWaveIn16)
4669 ReleaseThunkLock(&level);
4670 ret = waveInReset(hWaveIn16);
4671 RestoreThunkLock(level);
4675 /**************************************************************************
4676 * waveInStart [WINMM.157]
4678 UINT WINAPI waveInStart(HWAVEIN hWaveIn)
4682 TRACE("(%04X);\n", hWaveIn);
4684 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4685 return MMSYSERR_INVALHANDLE;
4687 return MMDRV_Message(wmld, WIDM_START, 0L, 0L, TRUE);
4690 /**************************************************************************
4691 * waveInStart [MMSYSTEM.509]
4693 UINT16 WINAPI waveInStart16(HWAVEIN16 hWaveIn16)
4698 ReleaseThunkLock(&level);
4699 ret = waveInStart(hWaveIn16);
4700 RestoreThunkLock(level);
4704 /**************************************************************************
4705 * waveInStop [WINMM.158]
4707 UINT WINAPI waveInStop(HWAVEIN hWaveIn)
4711 TRACE("(%04X);\n", hWaveIn);
4713 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4714 return MMSYSERR_INVALHANDLE;
4716 return MMDRV_Message(wmld,WIDM_STOP, 0L, 0L, TRUE);
4719 /**************************************************************************
4720 * waveInStop [MMSYSTEM.510]
4722 UINT16 WINAPI waveInStop16(HWAVEIN16 hWaveIn16)
4727 ReleaseThunkLock(&level);
4728 ret = waveInStop(hWaveIn16);
4729 RestoreThunkLock(level);
4733 /**************************************************************************
4734 * waveInGetPosition [WINMM.152]
4736 UINT WINAPI waveInGetPosition(HWAVEIN hWaveIn, LPMMTIME lpTime,
4741 TRACE("(%04X, %p, %u);\n", hWaveIn, lpTime, uSize);
4743 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4744 return MMSYSERR_INVALHANDLE;
4746 return MMDRV_Message(wmld, WIDM_GETPOS, (DWORD)lpTime, uSize, TRUE);
4749 /**************************************************************************
4750 * waveInGetPosition [MMSYSTEM.512]
4752 UINT16 WINAPI waveInGetPosition16(HWAVEIN16 hWaveIn, LPMMTIME16 lpTime,
4758 mmt.wType = lpTime->wType;
4759 ret = waveInGetPosition(hWaveIn, &mmt, sizeof(mmt));
4760 MMSYSTEM_MMTIME32to16(lpTime, &mmt);
4764 /**************************************************************************
4765 * waveInGetID [WINMM.150]
4767 UINT WINAPI waveInGetID(HWAVEIN hWaveIn, UINT* lpuDeviceID)
4771 TRACE("(%04X, %p);\n", hWaveIn, lpuDeviceID);
4773 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
4775 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4776 return MMSYSERR_INVALHANDLE;
4778 *lpuDeviceID = wmld->uDeviceID;
4779 return MMSYSERR_NOERROR;
4782 /**************************************************************************
4783 * waveInGetID [MMSYSTEM.513]
4785 UINT16 WINAPI waveInGetID16(HWAVEIN16 hWaveIn, UINT16* lpuDeviceID)
4789 TRACE("(%04X, %p);\n", hWaveIn, lpuDeviceID);
4791 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
4793 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4794 return MMSYSERR_INVALHANDLE;
4796 *lpuDeviceID = wmld->uDeviceID;
4797 return MMSYSERR_NOERROR;
4800 /**************************************************************************
4801 * waveInMessage [WINMM.153]
4803 DWORD WINAPI waveInMessage(HWAVEIN hWaveIn, UINT uMessage,
4804 DWORD dwParam1, DWORD dwParam2)
4808 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn, uMessage, dwParam1, dwParam2);
4811 if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
4812 return MMSYSERR_INVALPARAM;
4814 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4815 return MMSYSERR_INVALHANDLE;
4817 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
4820 /**************************************************************************
4821 * waveInMessage [MMSYSTEM.514]
4823 DWORD WINAPI waveInMessage16(HWAVEIN16 hWaveIn, UINT16 uMessage,
4824 DWORD dwParam1, DWORD dwParam2)
4828 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn, uMessage, dwParam1, dwParam2);
4831 if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
4832 return MMSYSERR_INVALPARAM;
4834 if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL)
4835 return MMSYSERR_INVALHANDLE;
4837 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
4840 /*#define USE_MM_TSK_WINE*/
4842 /**************************************************************************
4843 * mmTaskCreate [MMSYSTEM.900]
4845 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
4846 * called upon creation with dwPmt as parameter.
4848 HINSTANCE16 WINAPI mmTaskCreate16(SEGPTR spProc, HINSTANCE16 *lphMmTask, DWORD dwPmt)
4856 TRACE("(%08lx, %p, %08lx);\n", spProc, lphMmTask, dwPmt);
4857 /* This to work requires NE modules to be started with a binary command line
4858 * which is not currently the case. A patch exists but has never been committed.
4859 * A workaround would be to integrate code for mmtask.tsk into Wine, but
4860 * this requires tremendous work (starting with patching tools/build to
4861 * create NE executables (and not only DLLs) for builtins modules.
4864 FIXME("This is currently broken. It will fail\n");
4866 cmdline = SEGPTR_ALLOC(0x0d);
4868 *(LPDWORD)(cmdline + 1) = (DWORD)spProc;
4869 *(LPDWORD)(cmdline + 5) = dwPmt;
4870 *(LPDWORD)(cmdline + 9) = 0;
4872 pShowCmd = SEGPTR_ALLOC(sizeof(DWORD));
4873 *pShowCmd = 0x40002;
4875 lp = (LOADPARAMS16*)HeapAlloc(GetProcessHeap(), 0, sizeof(LOADPARAMS16));
4876 lp->hEnvironment = 0;
4877 lp->cmdLine = SEGPTR_GET(cmdline);
4878 lp->showCmd = SEGPTR_GET(pShowCmd);
4881 #ifndef USE_MM_TSK_WINE
4882 handle = LoadModule16("c:\\windows\\system\\mmtask.tsk", lp);
4884 handle = LoadModule16("mmtask.tsk", lp);
4887 ret = (handle) ? 1 : 2;
4893 *lphMmTask = handle;
4895 HeapFree(GetProcessHeap(), 0, lp);
4896 SEGPTR_FREE(pShowCmd);
4897 SEGPTR_FREE(cmdline);
4899 TRACE("=> 0x%04x/%d\n", handle, ret);
4903 #ifdef USE_MM_TSK_WINE
4904 /* C equivalent to mmtask.tsk binary content */
4905 void mmTaskEntryPoint16(LPSTR cmdLine, WORD di, WORD si)
4907 int len = cmdLine[0x80];
4910 void (*fpProc)(DWORD) = MapSL(*((DWORD*)(cmdLine + 1)));
4911 DWORD dwPmt = *((DWORD*)(cmdLine + 5));
4914 InitTask16(); /* fixme: pmts / from context ? */
4917 if (SetMessageQueue16(0x40)) {
4919 if (HIWORD(fpProc)) {
4921 /* EPP StackEnter16(); */
4933 /**************************************************************************
4934 * mmTaskBlock [MMSYSTEM.902]
4936 void WINAPI mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst)
4941 GetMessageA(&msg, 0, 0, 0);
4943 TranslateMessage(&msg);
4944 DispatchMessageA(&msg);
4946 } while (msg.message < 0x3A0);
4949 /**************************************************************************
4950 * mmTaskSignal [MMSYSTEM.903]
4952 LRESULT WINAPI mmTaskSignal16(HTASK16 ht)
4954 TRACE("(%04x);\n", ht);
4955 return PostAppMessage16(ht, WM_USER, 0, 0);
4958 /**************************************************************************
4959 * mmTaskYield16 [MMSYSTEM.905]
4961 void WINAPI mmTaskYield16(void)
4965 if (PeekMessageA(&msg, 0, 0, 0, 0)) {
4970 DWORD WINAPI GetProcessFlags(DWORD);
4972 /**************************************************************************
4973 * mmThreadCreate [MMSYSTEM.1120]
4976 * Creates a MM thread, calling fpThreadAddr(dwPmt).
4978 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
4979 * bit.1 set means to open a VxD for this thread (unsupported)
4981 LRESULT WINAPI mmThreadCreate16(FARPROC16 fpThreadAddr, LPHANDLE lpHndl, DWORD dwPmt, DWORD dwFlags)
4986 TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr, lpHndl, dwPmt, dwFlags);
4988 hndl = GlobalAlloc16(sizeof(WINE_MMTHREAD), GMEM_SHARE|GMEM_ZEROINIT);
4993 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
4996 /* force mmtask routines even if mmthread is required */
4997 /* this will work only if the patch about binary cmd line and NE tasks
5003 lpMMThd->dwSignature = WINE_MMTHREAD_CREATED;
5004 lpMMThd->dwCounter = 0;
5005 lpMMThd->hThread = 0;
5006 lpMMThd->dwThreadID = 0;
5007 lpMMThd->fpThread = fpThreadAddr;
5008 lpMMThd->dwThreadPmt = dwPmt;
5009 lpMMThd->dwSignalCount = 0;
5010 lpMMThd->hEvent = 0;
5012 lpMMThd->dwStatus = 0;
5013 lpMMThd->dwFlags = dwFlags;
5016 if ((dwFlags & 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
5017 lpMMThd->hEvent = CreateEventA(0, 0, 1, 0);
5019 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd);
5020 if (lpMMThd->dwFlags & 2) {
5021 /* as long as we don't support MM VxD in wine, we don't need
5022 * to care about this flag
5024 /* FIXME("Don't know how to properly open VxD handles\n"); */
5025 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
5028 lpMMThd->hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)WINE_mmThreadEntryPoint,
5029 (LPVOID)(DWORD)hndl, CREATE_SUSPENDED, &lpMMThd->dwThreadID);
5030 if (lpMMThd->hThread == 0) {
5031 WARN("Couldn't create thread\n");
5032 /* clean-up(VxDhandle...); devicedirectio... */
5033 if (lpMMThd->hEvent != 0)
5034 CloseHandle(lpMMThd->hEvent);
5037 TRACE("Got a nice thread hndl=0x%04x id=0x%08lx\n", lpMMThd->hThread, lpMMThd->dwThreadID);
5041 /* get WINE_mmThreadEntryPoint()
5042 * 2047 is its ordinal in mmsystem.spec
5044 FARPROC16 fp = GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (LPCSTR)2047);
5046 TRACE("farproc seg=0x%08lx lin=%p\n", (DWORD)fp, MapSL((SEGPTR)fp));
5048 ret = (fp == 0) ? 2 : mmTaskCreate16((DWORD)fp, 0, hndl);
5052 if (lpMMThd->hThread && !ResumeThread(lpMMThd->hThread))
5053 WARN("Couldn't resume thread\n");
5055 while (lpMMThd->dwStatus != 0x10) { /* test also HIWORD of dwStatus */
5069 TRACE("ok => %ld\n", ret);
5073 /**************************************************************************
5074 * mmThreadSignal [MMSYSTEM.1121]
5076 void WINAPI mmThreadSignal16(HANDLE16 hndl)
5078 TRACE("(%04x)!\n", hndl);
5081 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
5083 lpMMThd->dwCounter++;
5084 if (lpMMThd->hThread != 0) {
5085 InterlockedIncrement(&lpMMThd->dwSignalCount);
5086 SetEvent(lpMMThd->hEvent);
5088 mmTaskSignal16(lpMMThd->hTask);
5090 lpMMThd->dwCounter--;
5094 /**************************************************************************
5095 * MMSYSTEM_ThreadBlock [internal]
5097 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD* lpMMThd)
5102 if (lpMMThd->dwThreadID != GetCurrentThreadId())
5103 ERR("Not called by thread itself\n");
5106 ResetEvent(lpMMThd->hEvent);
5107 if (InterlockedDecrement(&lpMMThd->dwSignalCount) >= 0)
5109 InterlockedIncrement(&lpMMThd->dwSignalCount);
5113 ret = MsgWaitForMultipleObjects(1, &lpMMThd->hEvent, FALSE, INFINITE, QS_ALLINPUT);
5115 case WAIT_OBJECT_0: /* Event */
5118 case WAIT_OBJECT_0 + 1: /* Msg */
5120 if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
5121 TranslateMessage(&msg);
5122 DispatchMessageA(&msg);
5126 WARN("S2.x unsupported ret val 0x%08lx\n", ret);
5132 /**************************************************************************
5133 * mmThreadBlock [MMSYSTEM.1122]
5135 void WINAPI mmThreadBlock16(HANDLE16 hndl)
5137 TRACE("(%04x)!\n", hndl);
5140 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
5142 if (lpMMThd->hThread != 0) {
5145 ReleaseThunkLock(&lc);
5146 MMSYSTEM_ThreadBlock(lpMMThd);
5147 RestoreThunkLock(lc);
5149 mmTaskBlock16(lpMMThd->hTask);
5155 /**************************************************************************
5156 * mmThreadIsCurrent [MMSYSTEM.1123]
5158 BOOL16 WINAPI mmThreadIsCurrent16(HANDLE16 hndl)
5162 TRACE("(%04x)!\n", hndl);
5164 if (hndl && mmThreadIsValid16(hndl)) {
5165 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
5166 ret = (GetCurrentThreadId() == lpMMThd->dwThreadID);
5168 TRACE("=> %d\n", ret);
5172 /**************************************************************************
5173 * mmThreadIsValid [MMSYSTEM.1124]
5175 BOOL16 WINAPI mmThreadIsValid16(HANDLE16 hndl)
5179 TRACE("(%04x)!\n", hndl);
5182 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
5184 if (!IsBadWritePtr(lpMMThd, sizeof(WINE_MMTHREAD)) &&
5185 lpMMThd->dwSignature == WINE_MMTHREAD_CREATED &&
5186 IsTask16(lpMMThd->hTask)) {
5187 lpMMThd->dwCounter++;
5188 if (lpMMThd->hThread != 0) {
5190 if (GetExitCodeThread(lpMMThd->hThread, &dwThreadRet) &&
5191 dwThreadRet == STATUS_PENDING) {
5197 lpMMThd->dwCounter--;
5200 TRACE("=> %d\n", ret);
5204 /**************************************************************************
5205 * mmThreadGetTask [MMSYSTEM.1125]
5207 HANDLE16 WINAPI mmThreadGetTask16(HANDLE16 hndl)
5211 TRACE("(%04x)\n", hndl);
5213 if (mmThreadIsValid16(hndl)) {
5214 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
5215 ret = lpMMThd->hTask;
5220 /* ### start build ### */
5221 extern LONG CALLBACK MMSYSTEM_CallTo16_long_l (FARPROC16,LONG);
5222 /* ### stop build ### */
5224 /**************************************************************************
5225 * WINE_mmThreadEntryPoint [internal]
5227 void WINAPI WINE_mmThreadEntryPoint(DWORD _pmt)
5229 HANDLE16 hndl = (HANDLE16)_pmt;
5230 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
5232 TRACE("(%04x %p)\n", hndl, lpMMThd);
5234 lpMMThd->hTask = LOWORD(GetCurrentTask());
5235 TRACE("[10-%08x] setting hTask to 0x%08x\n", lpMMThd->hThread, lpMMThd->hTask);
5236 lpMMThd->dwStatus = 0x10;
5237 MMSYSTEM_ThreadBlock(lpMMThd);
5238 TRACE("[20-%08x]\n", lpMMThd->hThread);
5239 lpMMThd->dwStatus = 0x20;
5240 if (lpMMThd->fpThread) {
5241 MMSYSTEM_CallTo16_long_l(lpMMThd->fpThread, lpMMThd->dwThreadPmt);
5243 lpMMThd->dwStatus = 0x30;
5244 TRACE("[30-%08x]\n", lpMMThd->hThread);
5245 while (lpMMThd->dwCounter) {
5247 /* K32WOWYield16();*/
5249 TRACE("[XX-%08x]\n", lpMMThd->hThread);
5251 lpMMThd->dwSignature = WINE_MMTHREAD_DELETED;
5252 /* close lpMMThread->hVxD directIO */
5253 if (lpMMThd->hEvent)
5254 CloseHandle(lpMMThd->hEvent);
5259 typedef BOOL16 WINAPI (*MMCPLCALLBACK)(HWND, LPCSTR, LPCSTR, LPCSTR);
5261 /**************************************************************************
5262 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
5264 BOOL16 WINAPI mmShowMMCPLPropertySheet16(HWND hWnd, LPCSTR lpStrDevice,
5265 LPCSTR lpStrTab, LPCSTR lpStrTitle)
5270 TRACE("(%04x \"%s\" \"%s\" \"%s\")\n", hWnd, lpStrDevice, lpStrTab, lpStrTitle);
5272 hndl = LoadLibraryA("MMSYS.CPL");
5274 MMCPLCALLBACK fp = (MMCPLCALLBACK)GetProcAddress(hndl, "ShowMMCPLPropertySheet");
5277 ReleaseThunkLock(&lc);
5278 ret = (fp)(hWnd, lpStrDevice, lpStrTab, lpStrTitle);
5279 RestoreThunkLock(lc);
5287 /**************************************************************************
5288 * StackEnter [MMSYSTEM.32]
5290 void WINAPI StackEnter16(void)
5293 /* mmsystem.dll from Win 95 does only this: so does Wine */
5298 /**************************************************************************
5299 * StackLeave [MMSYSTEM.33]
5301 void WINAPI StackLeave16(void)
5304 /* mmsystem.dll from Win 95 does only this: so does Wine */
5309 /**************************************************************************
5310 * WMMMidiRunOnce [MMSYSTEM.8]
5312 void WINAPI WMMMidiRunOnce16(void)
5314 FIXME("(), stub!\n");