1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1993 Martin Ayotte
11 * 98/9 added support for Win32 MCI
14 /* FIXME: I think there are some segmented vs. linear pointer weirdnesses
15 * and long term pointers to 16 bit space in here
22 #include <sys/ioctl.h>
26 #include "wine/winbase16.h"
31 #include "multimedia.h"
34 #include "selectors.h"
38 int mciInstalledCount;
39 int mciInstalledListLen;
40 LPSTR lpmciInstallNames = NULL;
42 struct WINE_MCIDRIVER mciDrv[MAXMCIDRIVERS];
44 UINT16 WINAPI midiGetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize);
45 static UINT16 waveGetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize);
46 LONG WINAPI DrvDefDriverProc(DWORD dwDevID, HDRVR16 hDriv, WORD wMsg,
47 DWORD dwParam1, DWORD dwParam2);
49 #define MCI_GetDrv(wDevID) (&mciDrv[MCI_DevIDToIndex(wDevID)])
50 #define MCI_GetOpenDrv(wDevID) (&(MCI_GetDrv(wDevID)->mop))
52 /* The wDevID's returned by wine were originally in the range
53 * 0 - (MAXMCIDRIVERS - 1) and used directly as array indices.
54 * Unfortunately, ms-windows uses wDevID of zero to indicate
55 * errors. Now, multimedia drivers must pass the wDevID through
56 * MCI_DevIDToIndex to get an index in that range. An
57 * arbitrary value, MCI_MAGIC is added to the wDevID seen
58 * by the windows programs.
61 #define MCI_MAGIC 0x0F00
63 /**************************************************************************
64 * MCI_GetProc32 [internal]
66 MCIPROC MCI_GetProc(UINT16 uDevType)
71 case MCI_DEVTYPE_CD_AUDIO: proc = MCICDAUDIO_DriverProc; break;
72 case MCI_DEVTYPE_WAVEFORM_AUDIO: proc = MCIWAVE_DriverProc; break;
73 case MCI_DEVTYPE_SEQUENCER: proc = MCIMIDI_DriverProc; break;
74 case MCI_DEVTYPE_ANIMATION: proc = MCIANIM_DriverProc; break;
75 case MCI_DEVTYPE_DIGITAL_VIDEO: proc = MCIAVI_DriverProc32; break;
76 default: TRACE(mci, "Unknown device type %u\n", uDevType);
81 /**************************************************************************
82 * MCI_GetDevType [internal]
84 WORD MCI_GetDevType(LPCSTR str)
88 if (lstrcmpiA(str, "CDAUDIO") == 0) {
89 uDevTyp = MCI_DEVTYPE_CD_AUDIO;
90 } else if (lstrcmpiA(str, "WAVEAUDIO") == 0) {
91 uDevTyp = MCI_DEVTYPE_WAVEFORM_AUDIO;
92 } else if (lstrcmpiA(str, "SEQUENCER") == 0) {
93 uDevTyp = MCI_DEVTYPE_SEQUENCER;
94 } else if (lstrcmpiA(str, "ANIMATION1") == 0) {
95 uDevTyp = MCI_DEVTYPE_ANIMATION;
96 } else if (lstrcmpiA(str, "AVIVIDEO") == 0) {
97 uDevTyp = MCI_DEVTYPE_DIGITAL_VIDEO;
99 TRACE(mci, "str = %s => %u\n", str, uDevTyp);
103 /**************************************************************************
104 * MCI_GetDevTypeString [internal]
106 static LPCSTR MCI_GetDevTypeString(WORD uDevTyp)
108 LPCSTR str = "??? MCI ???";
111 case MCI_DEVTYPE_CD_AUDIO: str = "CDAUDIO"; break;
112 case MCI_DEVTYPE_WAVEFORM_AUDIO: str = "WAVEAUDIO"; break;
113 case MCI_DEVTYPE_SEQUENCER: str = "SEQUENCER"; break;
114 case MCI_DEVTYPE_ANIMATION: str = "ANIMATION1"; break;
115 case MCI_DEVTYPE_DIGITAL_VIDEO: str = "AVIVIDEO"; break;
116 default: FIXME(mci, "Incohenrent MCI definitions\n");
118 TRACE(mci, "devType=%u => %s\n", uDevTyp, str);
122 /**************************************************************************
123 * MCI_DevIDToIndex [internal]
125 int MCI_DevIDToIndex(UINT16 wDevID)
127 return wDevID - MCI_MAGIC;
130 /**************************************************************************
131 * MCI_FirstDevId [internal]
133 UINT16 MCI_FirstDevID(void)
138 /**************************************************************************
139 * MCI_NextDevId [internal]
141 UINT16 MCI_NextDevID(UINT16 wDevID)
146 /**************************************************************************
147 * MCI_DevIDValid [internal]
149 BOOL MCI_DevIDValid(UINT16 wDevID)
151 return wDevID >= MCI_MAGIC && wDevID < (MCI_MAGIC + MAXMCIDRIVERS);
154 /**************************************************************************
155 * MMSYSTEM_WEP [MMSYSTEM.1]
157 int WINAPI MMSYSTEM_WEP(HINSTANCE16 hInstance, WORD wDataSeg,
158 WORD cbHeapSize, LPSTR lpCmdLine)
160 FIXME(mmsys, "STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance);
164 static void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16, LPMMTIME mmt32)
166 mmt16->wType = mmt32->wType;
167 /* layout of rest is the same for 32/16 */
168 memcpy(&(mmt32->u), &(mmt16->u), sizeof(mmt16->u));
171 static void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, LPMMTIME16 mmt16)
173 mmt32->wType = mmt16->wType;
174 /* layout of rest is the same for 32/16,
175 * Note: mmt16->u is 2 bytes smaller than mmt32->u
177 memcpy(&(mmt16->u), &(mmt32->u), sizeof(mmt16->u));
180 static HANDLE PlaySound_hThread = 0;
181 static HANDLE PlaySound_hPlayEvent = 0;
182 static HANDLE PlaySound_hReadyEvent = 0;
183 static HANDLE PlaySound_hMiddleEvent = 0;
184 static BOOL PlaySound_Result = FALSE;
185 static int PlaySound_Stop = FALSE;
186 static int PlaySound_Playing = FALSE;
188 static LPCSTR PlaySound_pszSound = NULL;
189 static HMODULE PlaySound_hmod = 0;
190 static DWORD PlaySound_fdwSound = 0;
191 static int PlaySound_Loop = FALSE;
192 static int PlaySound_SearchMode = 0; /* 1 - sndPlaySound search order
193 2 - PlaySound order */
195 static HMMIO16 get_mmioFromFile(LPCSTR lpszName)
197 return mmioOpen16((LPSTR)lpszName, NULL,
198 MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
201 static HMMIO16 get_mmioFromProfile(UINT uFlags, LPCSTR lpszName)
207 TRACE(mmsys, "searching in SystemSound List !\n");
208 GetProfileStringA("Sounds", (LPSTR)lpszName, "", str, sizeof(str));
209 if (strlen(str) == 0) {
210 if (uFlags & SND_NODEFAULT) return 0;
211 GetProfileStringA("Sounds", "Default", "", str, sizeof(str));
212 if (strlen(str) == 0) return 0;
214 if ((ptr = (LPSTR)strchr(str, ',')) != NULL) *ptr = '\0';
215 hmmio = get_mmioFromFile(str);
217 WARN(mmsys, "can't find SystemSound='%s' !\n", str);
223 static BOOL16 WINAPI proc_PlaySound(LPCSTR lpszSoundName, UINT uFlags)
229 TRACE(mmsys, "SoundName='%s' uFlags=%04X !\n", lpszSoundName, uFlags);
230 if (lpszSoundName == NULL) {
231 TRACE(mmsys, "Stop !\n");
234 if (uFlags & SND_MEMORY) {
236 memset(&mminfo, 0, sizeof(mminfo));
237 mminfo.fccIOProc = FOURCC_MEM;
238 mminfo.pchBuffer = (LPSTR)lpszSoundName;
239 mminfo.cchBuffer = -1;
240 TRACE(mmsys, "Memory sound %p\n", lpszSoundName);
241 hmmio = mmioOpen16(NULL, &mminfo, MMIO_READ);
244 if (uFlags & SND_ALIAS)
245 if ((hmmio=get_mmioFromProfile(uFlags, lpszSoundName)) == 0)
248 if (uFlags & SND_FILENAME)
249 if ((hmmio=get_mmioFromFile(lpszSoundName)) == 0) return FALSE;
251 if (PlaySound_SearchMode == 1) {
252 PlaySound_SearchMode = 0;
253 if ((hmmio=get_mmioFromFile(lpszSoundName)) == 0)
254 if ((hmmio=get_mmioFromProfile(uFlags, lpszSoundName)) == 0)
258 if (PlaySound_SearchMode == 2) {
259 PlaySound_SearchMode = 0;
260 if ((hmmio=get_mmioFromProfile(uFlags | SND_NODEFAULT, lpszSoundName)) == 0)
261 if ((hmmio=get_mmioFromFile(lpszSoundName)) == 0)
262 if ((hmmio=get_mmioFromProfile(uFlags, lpszSoundName)) == 0) return FALSE;
266 if (mmioDescend(hmmio, &ckMainRIFF, NULL, 0) == 0)
268 TRACE(mmsys, "ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX \n",
269 (LPSTR)&ckMainRIFF.ckid, (LPSTR)&ckMainRIFF.fccType,
272 if ((ckMainRIFF.ckid == FOURCC_RIFF) &&
273 (ckMainRIFF.fccType == mmioFOURCC('W', 'A', 'V', 'E'))) {
276 mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' ');
278 if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK) == 0) {
279 PCMWAVEFORMAT pcmWaveFormat;
281 TRACE(mmsys, "Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n",
282 (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize);
284 if (mmioRead(hmmio, (HPSTR)&pcmWaveFormat,
285 (long) sizeof(PCMWAVEFORMAT)) == (long) sizeof(PCMWAVEFORMAT)) {
286 TRACE(mmsys, "wFormatTag=%04X !\n", pcmWaveFormat.wf.wFormatTag);
287 TRACE(mmsys, "nChannels=%d \n", pcmWaveFormat.wf.nChannels);
288 TRACE(mmsys, "nSamplesPerSec=%ld\n", pcmWaveFormat.wf.nSamplesPerSec);
289 TRACE(mmsys, "nAvgBytesPerSec=%ld\n", pcmWaveFormat.wf.nAvgBytesPerSec);
290 TRACE(mmsys, "nBlockAlign=%d \n", pcmWaveFormat.wf.nBlockAlign);
291 TRACE(mmsys, "wBitsPerSample=%u !\n", pcmWaveFormat.wBitsPerSample);
293 mmckInfo.ckid = mmioFOURCC('d', 'a', 't', 'a');
294 if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK) == 0) {
295 WAVEOPENDESC waveDesc;
298 TRACE(mmsys, "Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n",
299 (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize);
301 pcmWaveFormat.wf.nAvgBytesPerSec = pcmWaveFormat.wf.nSamplesPerSec *
302 pcmWaveFormat.wf.nBlockAlign;
304 waveDesc.lpFormat = (LPWAVEFORMAT)&pcmWaveFormat;
306 dwRet = wodMessage(0, WODM_OPEN, 0, (DWORD)&waveDesc, CALLBACK_NULL);
307 if (dwRet == MMSYSERR_NOERROR) {
310 INT count, bufsize, left = mmckInfo.cksize;
313 hData = GlobalAlloc16(GMEM_MOVEABLE, bufsize);
314 waveHdr.lpData = (LPSTR)GlobalLock16(hData);
315 waveHdr.dwBufferLength = bufsize;
317 waveHdr.dwFlags = 0L;
318 waveHdr.dwLoops = 0L;
320 dwRet = wodMessage(0, WODM_PREPARE, 0, (DWORD)&waveHdr, sizeof(WAVEHDR));
321 if (dwRet == MMSYSERR_NOERROR) {
323 if (PlaySound_Stop) {
324 PlaySound_Stop = FALSE;
325 PlaySound_Loop = FALSE;
328 if (bufsize > left) bufsize = left;
329 count = mmioRead(hmmio, waveHdr.lpData,bufsize);
330 if (count < 1) break;
332 waveHdr.dwBufferLength = count;
333 /* waveHdr.dwBytesRecorded = count; */
334 /* FIXME: doesn't expect async ops */
335 wodMessage(0, WODM_WRITE, 0, (DWORD)&waveHdr, sizeof(WAVEHDR));
337 wodMessage(0, WODM_UNPREPARE, 0, (DWORD)&waveHdr, sizeof(WAVEHDR));
338 wodMessage(0, WODM_CLOSE, 0, 0L, 0L);
342 WARN(mmsys, "can't prepare WaveOut device !\n");
344 GlobalUnlock16(hData);
351 } while (PlaySound_Loop);
353 if (hmmio != 0) mmioClose(hmmio, 0);
357 static DWORD WINAPI PlaySound_Thread(LPVOID arg)
362 PlaySound_Playing = FALSE;
363 SetEvent(PlaySound_hReadyEvent);
364 res = WaitForSingleObject(PlaySound_hPlayEvent, INFINITE);
365 ResetEvent(PlaySound_hReadyEvent);
366 SetEvent(PlaySound_hMiddleEvent);
367 if (res == WAIT_FAILED) ExitThread(2);
368 if (res != WAIT_OBJECT_0) continue;
369 PlaySound_Playing = TRUE;
371 if ((PlaySound_fdwSound & SND_RESOURCE) == SND_RESOURCE) {
376 if ((hRES = FindResourceA(PlaySound_hmod, PlaySound_pszSound, "WAVE")) == 0) {
377 PlaySound_Result = FALSE;
380 if ((hGLOB = LoadResource(PlaySound_hmod, hRES)) == 0) {
381 PlaySound_Result = FALSE;
384 if ((ptr = LockResource(hGLOB)) == NULL) {
386 PlaySound_Result = FALSE;
389 PlaySound_Result = proc_PlaySound(ptr,
390 ((UINT16)PlaySound_fdwSound ^ SND_RESOURCE) | SND_MEMORY);
394 PlaySound_Result=proc_PlaySound(PlaySound_pszSound, (UINT16)PlaySound_fdwSound);
398 /**************************************************************************
399 * PlaySoundA [WINMM.1]
401 BOOL WINAPI PlaySoundA(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound)
403 static LPSTR StrDup = NULL;
405 TRACE(mmsys, "pszSound='%p' hmod=%04X fdwSound=%08lX\n",
406 pszSound, hmod, fdwSound);
408 if (PlaySound_hThread == 0) { /* This is the first time they called us */
410 if ((PlaySound_hReadyEvent = CreateEventA(NULL, TRUE, FALSE, NULL)) == 0)
412 if ((PlaySound_hMiddleEvent = CreateEventA(NULL, FALSE, FALSE, NULL)) == 0)
414 if ((PlaySound_hPlayEvent = CreateEventA(NULL, FALSE, FALSE, NULL)) == 0)
416 if ((PlaySound_hThread = CreateThread(NULL, 0, PlaySound_Thread, 0, 0, &id)) == 0)
420 /* FIXME? I see no difference between SND_WAIT and SND_NOSTOP ! */
421 if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && PlaySound_Playing)
424 /* Trying to stop if playing */
425 if (PlaySound_Playing) PlaySound_Stop = TRUE;
427 /* Waiting playing thread to get ready. I think 10 secs is ok & if not then leave*/
428 if (WaitForSingleObject(PlaySound_hReadyEvent, 1000*10) != WAIT_OBJECT_0)
431 if (!pszSound || (fdwSound & SND_PURGE))
432 return FALSE; /* We stoped playing so leaving */
434 if (PlaySound_SearchMode != 1) PlaySound_SearchMode = 2;
435 if (!(fdwSound & SND_ASYNC)) {
436 if (fdwSound & SND_LOOP)
438 PlaySound_pszSound = pszSound;
439 PlaySound_hmod = hmod;
440 PlaySound_fdwSound = fdwSound;
441 PlaySound_Result = FALSE;
442 SetEvent(PlaySound_hPlayEvent);
443 if (WaitForSingleObject(PlaySound_hMiddleEvent, INFINITE) != WAIT_OBJECT_0)
445 if (WaitForSingleObject(PlaySound_hReadyEvent, INFINITE) != WAIT_OBJECT_0)
447 return PlaySound_Result;
449 PlaySound_hmod = hmod;
450 PlaySound_fdwSound = fdwSound;
451 PlaySound_Result = FALSE;
453 HeapFree(GetProcessHeap(), 0, StrDup);
456 if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) &&
457 !((DWORD)pszSound >> 16)) || !pszSound)) {
458 StrDup = HEAP_strdupA(GetProcessHeap(), 0,pszSound);
459 PlaySound_pszSound = StrDup;
460 } else PlaySound_pszSound = pszSound;
461 PlaySound_Loop = fdwSound & SND_LOOP;
462 SetEvent(PlaySound_hPlayEvent);
463 ResetEvent(PlaySound_hMiddleEvent);
469 /**************************************************************************
470 * PlaySoundW [WINMM.18]
472 BOOL WINAPI PlaySoundW(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
477 if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) &&
478 !((DWORD)pszSound >> 16)) || !pszSound)) {
479 pszSoundA = HEAP_strdupWtoA(GetProcessHeap(), 0,pszSound);
480 bSound = PlaySoundA(pszSoundA, hmod, fdwSound);
481 HeapFree(GetProcessHeap(), 0,pszSoundA);
483 bSound = PlaySoundA((LPCSTR)pszSound, hmod, fdwSound);
488 /**************************************************************************
489 * sndPlaySound [MMSYSTEM.2][WINMM135]
491 BOOL16 WINAPI sndPlaySound(LPCSTR lpszSoundName, UINT16 uFlags)
493 PlaySound_SearchMode = 1;
494 return PlaySoundA(lpszSoundName, 0, uFlags);
497 /**************************************************************************
498 * sndPlaySound [WINMM.136]
500 BOOL16 WINAPI sndPlaySound32W(LPCWSTR lpszSoundName, UINT16 uFlags)
502 PlaySound_SearchMode = 1;
503 return PlaySoundW(lpszSoundName, 0, uFlags);
506 /**************************************************************************
507 * mmsystemGetVersion [WINMM.134]
509 UINT WINAPI mmsystemGetVersion()
511 return mmsystemGetVersion16();
514 /**************************************************************************
515 * mmsystemGetVersion [MMSYSTEM.5]
516 * return value borrowed from Win95 winmm.dll ;)
518 UINT16 WINAPI mmsystemGetVersion16()
520 TRACE(mmsys, "3.10 (Win95?)\n");
524 /**************************************************************************
525 * DriverProc [MMSYSTEM.6]
527 LRESULT WINAPI DriverProc16(DWORD dwDevID, HDRVR16 hDriv, WORD wMsg,
528 DWORD dwParam1, DWORD dwParam2)
530 return DrvDefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
533 /**************************************************************************
534 * DriverCallback [MMSYSTEM.31]
536 BOOL16 WINAPI DriverCallback16(DWORD dwCallBack, UINT16 uFlags, HANDLE16 hDev,
537 WORD wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
539 TRACE(mmsys, "(%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n",
540 dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
542 switch (uFlags & DCB_TYPEMASK) {
544 TRACE(mmsys, "CALLBACK_NULL !\n");
547 TRACE(mmsys, "CALLBACK_WINDOW = %04lX handle = %04X!\n",
549 if (!IsWindow(dwCallBack) || USER_HEAP_LIN_ADDR(hDev) == NULL)
552 PostMessageA((HWND16)dwCallBack, wMsg, hDev, dwParam1);
555 TRACE(mmsys, "CALLBACK_TASK !\n");
558 TRACE(mmsys, "CALLBACK_FUNCTION !\n");
559 Callbacks->CallDriverCallback((FARPROC16)dwCallBack,
561 dwParam1, dwParam2 );
564 TRACE(mmsys, "CALLBACK_FUNCTION !\n");
565 ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser,
566 dwParam1, dwParam2 );
569 WARN(mmsys, "Unknown callback type\n");
575 /**************************************************************************
576 * Mixer devices. New to Win95
578 /**************************************************************************
579 * find out the real mixer ID depending on hmix (depends on dwFlags)
580 * FIXME: also fix dwInstance passing to mixMessage
582 static UINT _get_mixerID_from_handle(HMIXEROBJ hmix, DWORD dwFlags)
584 /* FIXME: Check dwFlags for MIXER_OBJECTF_xxxx entries and modify hmix
585 * accordingly. For now we always use mixerdevice 0.
590 /**************************************************************************
591 * mixerGetNumDevs [WINMM.108]
593 UINT WINAPI mixerGetNumDevs()
595 return mixerGetNumDevs16();
598 /**************************************************************************
601 UINT16 WINAPI mixerGetNumDevs16()
603 UINT16 count = mixMessage(0, MXDM_GETNUMDEVS, 0L, 0L, 0L);
605 TRACE(mmaux,"mixerGetNumDevs returns %d\n",count);
609 /**************************************************************************
610 * mixerGetDevCapsW [WINMM.102]
612 UINT WINAPI mixerGetDevCapsW(UINT devid, LPMIXERCAPSW mixcaps,UINT size)
615 UINT ret = mixerGetDevCaps16(devid, &mic16, sizeof(mic16));
617 mixcaps->wMid = mic16.wMid;
618 mixcaps->wPid = mic16.wPid;
619 mixcaps->vDriverVersion = mic16.vDriverVersion;
620 lstrcpyAtoW(mixcaps->szPname, mic16.szPname);
621 mixcaps->fdwSupport = mic16.fdwSupport;
622 mixcaps->cDestinations = mic16.cDestinations;
626 /**************************************************************************
627 * mixerGetDevCaps [WINMM.101]
629 UINT WINAPI mixerGetDevCapsA(UINT devid, LPMIXERCAPSA mixcaps,UINT size)
632 UINT ret = mixerGetDevCaps16(devid, &mic16, sizeof(mic16));
634 mixcaps->wMid = mic16.wMid;
635 mixcaps->wPid = mic16.wPid;
636 mixcaps->vDriverVersion = mic16.vDriverVersion;
637 strcpy(mixcaps->szPname, mic16.szPname);
638 mixcaps->fdwSupport = mic16.fdwSupport;
639 mixcaps->cDestinations = mic16.cDestinations;
643 /**************************************************************************
646 UINT16 WINAPI mixerGetDevCaps16(UINT16 devid, LPMIXERCAPS16 mixcaps,UINT16 size)
648 FIXME(mmsys,"should this be a fixme?\n");
649 return mixMessage(devid, MXDM_GETDEVCAPS, 0L, (DWORD)mixcaps, (DWORD)size);
652 /**************************************************************************
653 * mixerOpen [WINMM.110]
655 UINT WINAPI mixerOpen(LPHMIXER lphmix,UINT uDeviceID, DWORD dwCallback,
656 DWORD dwInstance, DWORD fdwOpen)
661 FIXME(mmsys,"(%p,%d,%08lx,%08lx,%08lx): semi stub?\n",
662 lphmix,uDeviceID, dwCallback, dwInstance, fdwOpen);
663 ret = mixerOpen16(&hmix16,uDeviceID, dwCallback, dwInstance,fdwOpen);
664 if (lphmix) *lphmix = hmix16;
668 /**************************************************************************
671 UINT16 WINAPI mixerOpen16(LPHMIXER16 lphmix,UINT16 uDeviceID, DWORD dwCallback,
672 DWORD dwInstance, DWORD fdwOpen)
675 LPMIXEROPENDESC lpmod;
676 BOOL mapperflag = (uDeviceID==0);
679 TRACE(mmsys,"(%p,%d,%08lx,%08lx,%08lx)\n",
680 lphmix,uDeviceID, dwCallback, dwInstance, fdwOpen);
681 hmix = USER_HEAP_ALLOC(sizeof(MIXEROPENDESC));
682 if (lphmix) *lphmix = hmix;
683 lpmod = (LPMIXEROPENDESC)USER_HEAP_LIN_ADDR(hmix);
685 lpmod->dwCallback = dwCallback;
686 lpmod->dwInstance = dwInstance;
687 if (uDeviceID >= MAXMIXERDRIVERS)
689 while (uDeviceID < MAXMIXERDRIVERS) {
690 dwRet=mixMessage(uDeviceID, MXDM_OPEN, dwInstance, (DWORD)lpmod, fdwOpen);
691 if (dwRet == MMSYSERR_NOERROR) break;
692 if (!mapperflag) break;
695 lpmod->uDeviceID = uDeviceID;
699 /**************************************************************************
700 * mixerClose [WINMM.98]
702 UINT WINAPI mixerClose(HMIXER hmix)
704 return mixerClose16(hmix);
707 /**************************************************************************
710 UINT16 WINAPI mixerClose16(HMIXER16 hmix)
712 LPMIXEROPENDESC lpmod;
714 FIXME(mmsys,"(%04x): semi-stub?\n", hmix);
715 lpmod = (LPMIXEROPENDESC)USER_HEAP_LIN_ADDR(hmix);
716 return mixMessage(lpmod->uDeviceID, MXDM_CLOSE, lpmod->dwInstance, 0L, 0L);
719 /**************************************************************************
720 * mixerGetID [WINMM.103]
722 UINT WINAPI mixerGetID(HMIXEROBJ hmix, LPUINT lpid, DWORD fdwID)
725 UINT ret = mixerGetID16(hmix, &xid, fdwID);
727 if (lpid) *lpid = xid;
731 /**************************************************************************
734 UINT16 WINAPI mixerGetID16(HMIXEROBJ16 hmix,LPUINT16 lpid,DWORD fdwID)
736 FIXME(mmsys,"(%04x): semi-stub\n",hmix);
738 *lpid = _get_mixerID_from_handle(hmix,fdwID);
739 return MMSYSERR_NOERROR; /* FIXME: many error possibilities */
742 /**************************************************************************
743 * mixerGetControlDetailsA [WINMM.99]
745 UINT WINAPI mixerGetControlDetailsA(HMIXEROBJ hmix,LPMIXERCONTROLDETAILS lpmcd,DWORD fdwDetails)
747 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmcd,fdwDetails);
748 return MMSYSERR_NOTENABLED;
751 /**************************************************************************
752 * mixerGetControlDetailsW [WINMM.100]
754 UINT WINAPI mixerGetControlDetailsW(HMIXEROBJ hmix,LPMIXERCONTROLDETAILS lpmcd,DWORD fdwDetails)
756 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n", hmix,lpmcd,fdwDetails);
757 return MMSYSERR_NOTENABLED;
760 /**************************************************************************
761 * mixerGetControlDetails [MMSYSTEM.808]
763 UINT16 WINAPI mixerGetControlDetails16(HMIXEROBJ16 hmix,LPMIXERCONTROLDETAILS16 lpmcd,DWORD fdwDetails)
765 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmcd,fdwDetails);
766 return MMSYSERR_NOTENABLED;
769 /**************************************************************************
770 * mixerGetLineControlsA [WINMM.104]
772 UINT WINAPI mixerGetLineControlsA(HMIXEROBJ hmix,LPMIXERLINECONTROLSA lpmlc,DWORD fdwControls)
774 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmlc,fdwControls);
775 return MMSYSERR_NOTENABLED;
778 /**************************************************************************
779 * mixerGetLineControlsW [WINMM.105]
781 UINT WINAPI mixerGetLineControlsW(HMIXEROBJ hmix,LPMIXERLINECONTROLSW lpmlc,DWORD fdwControls)
783 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmlc,fdwControls);
784 return MMSYSERR_NOTENABLED;
787 /**************************************************************************
788 * mixerGetLineControls [MMSYSTEM.807]
790 UINT16 WINAPI mixerGetLineControls16(HMIXEROBJ16 hmix,LPMIXERLINECONTROLS16 lpmlc,DWORD fdwControls)
792 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpmlc,fdwControls);
793 return MMSYSERR_NOTENABLED;
796 /**************************************************************************
797 * mixerGetLineInfoA [WINMM.106]
799 UINT WINAPI mixerGetLineInfoA(HMIXEROBJ hmix,LPMIXERLINEA lpml,DWORD fdwInfo)
804 ml16.dwDestination = lpml->dwDestination;
805 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n",hmix,lpml,fdwInfo);
806 ret = mixerGetLineInfo16(hmix,&ml16,fdwInfo);
807 lpml->cbStruct = sizeof(*lpml);
808 lpml->dwSource = ml16.dwSource;
809 lpml->dwLineID = ml16.dwLineID;
810 lpml->fdwLine = ml16.fdwLine;
811 lpml->dwUser = ml16.dwUser;
812 lpml->dwComponentType = ml16.dwComponentType;
813 lpml->cChannels = ml16.cChannels;
814 lpml->cConnections = ml16.cConnections;
815 lpml->cControls = ml16.cControls;
816 strcpy(lpml->szShortName, ml16.szShortName);
817 strcpy(lpml->szName, ml16.szName);
818 lpml->Target.dwType = ml16.Target.dwType;
819 lpml->Target.dwDeviceID = ml16.Target.dwDeviceID;
820 lpml->Target.wMid = ml16.Target.wMid;
821 lpml->Target.wPid = ml16.Target.wPid;
822 lpml->Target.vDriverVersion = ml16.Target.vDriverVersion;
823 strcpy(lpml->Target.szPname, ml16.Target.szPname);
827 /**************************************************************************
828 * mixerGetLineInfoW [WINMM.107]
830 UINT WINAPI mixerGetLineInfoW(HMIXEROBJ hmix, LPMIXERLINEW lpml, DWORD fdwInfo)
835 TRACE(mmsys,"(%04x,%p,%08lx)\n", hmix, lpml, fdwInfo);
837 if (lpml == NULL || lpml->cbStruct != sizeof(*lpml))
838 return MMSYSERR_INVALPARAM;
840 ml16.cbStruct = sizeof(ml16);
841 ml16.dwDestination = lpml->dwDestination;
842 ml16.dwSource = lpml->dwSource;
843 ml16.dwLineID = lpml->dwLineID;
844 ml16.dwUser = lpml->dwUser;
845 ml16.dwComponentType = lpml->dwComponentType;
846 ml16.cChannels = lpml->cChannels;
847 ml16.cConnections = lpml->cConnections;
848 ml16.cControls = lpml->cControls;
850 ret = mixerGetLineInfo16(hmix, &ml16, fdwInfo);
852 lpml->dwSource = ml16.dwSource;
853 lpml->dwLineID = ml16.dwLineID;
854 lpml->fdwLine = ml16.fdwLine;
855 lpml->dwUser = ml16.dwUser;
856 lpml->dwComponentType = ml16.dwComponentType;
857 lpml->cChannels = ml16.cChannels;
858 lpml->cConnections = ml16.cConnections;
859 lpml->cControls = ml16.cControls;
860 lstrcpyAtoW(lpml->szShortName, ml16.szShortName);
861 lstrcpyAtoW(lpml->szName, ml16.szName);
862 lpml->Target.dwType = ml16.Target.dwType;
863 lpml->Target.dwDeviceID = ml16.Target.dwDeviceID;
864 lpml->Target.wMid = ml16.Target.wMid;
865 lpml->Target.wPid = ml16.Target.wPid;
866 lpml->Target.vDriverVersion = ml16.Target.vDriverVersion;
867 /*lstrcpyAtoW(lpml->Target.szPname, ml16.Target.szPname);*/
871 /**************************************************************************
872 * mixerGetLineInfo [MMSYSTEM.805]
874 UINT16 WINAPI mixerGetLineInfo16(HMIXEROBJ16 hmix, LPMIXERLINE16 lpml, DWORD fdwInfo)
876 UINT16 devid = _get_mixerID_from_handle(hmix, fdwInfo);
878 FIXME(mmsys, "(%04x, %p[line %08lx], %08lx)\n",
879 hmix, lpml, lpml->dwDestination, fdwInfo);
880 return mixMessage(devid, MXDM_GETLINEINFO, 0, (DWORD)lpml, fdwInfo);
883 /**************************************************************************
884 * mixerSetControlDetails [WINMM.111]
886 UINT WINAPI mixerSetControlDetails(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
888 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n", hmix, lpmcd, fdwDetails);
889 return MMSYSERR_NOTENABLED;
892 /**************************************************************************
893 * mixerSetControlDetails [MMSYSTEM.809]
895 UINT16 WINAPI mixerSetControlDetails16(HMIXEROBJ16 hmix, LPMIXERCONTROLDETAILS16 lpmcd, DWORD fdwDetails)
897 FIXME(mmsys,"(%04x,%p,%08lx): stub!\n", hmix, lpmcd, fdwDetails);
898 return MMSYSERR_NOTENABLED;
901 /**************************************************************************
902 * mixerMessage [WINMM.109]
904 UINT WINAPI mixerMessage(HMIXER hmix,UINT uMsg, DWORD dwParam1, DWORD dwParam2)
906 LPMIXEROPENDESC lpmod;
909 lpmod = (LPMIXEROPENDESC)USER_HEAP_LIN_ADDR(hmix);
911 uDeviceID = lpmod->uDeviceID;
914 FIXME(mmsys,"(%04lx,%d,%08lx,%08lx): semi-stub?\n",
915 (DWORD)hmix,uMsg, dwParam1, dwParam2);
916 return mixMessage(uDeviceID,uMsg, 0L, dwParam1, dwParam2);
919 /**************************************************************************
920 * mixerMessage [MMSYSTEM.804]
922 UINT16 WINAPI mixerMessage16(HMIXER16 hmix,UINT16 uMsg, DWORD dwParam1, DWORD dwParam2)
924 LPMIXEROPENDESC lpmod;
927 lpmod = (LPMIXEROPENDESC)USER_HEAP_LIN_ADDR(hmix);
928 uDeviceID = (lpmod) ? lpmod->uDeviceID : 0;
929 FIXME(mmsys,"(%04x,%d,%08lx,%08lx) - semi-stub?\n",
930 hmix,uMsg, dwParam1, dwParam2);
931 return mixMessage(uDeviceID,uMsg, 0L, dwParam1, dwParam2);
934 /**************************************************************************
935 * auxGetNumDevs [WINMM.22]
937 UINT WINAPI auxGetNumDevs()
939 return auxGetNumDevs16();
942 /**************************************************************************
943 * auxGetNumDevs [MMSYSTEM.350]
945 UINT16 WINAPI auxGetNumDevs16()
950 count = auxMessage(0, AUXDM_GETNUMDEVS, 0L, 0L, 0L);
951 TRACE(mmsys, "=> %u\n", count);
955 /**************************************************************************
956 * auxGetDevCaps [WINMM.20]
958 UINT WINAPI auxGetDevCapsW(UINT uDeviceID, LPAUXCAPSW lpCaps,UINT uSize)
961 UINT ret = auxGetDevCaps16(uDeviceID, &ac16, sizeof(ac16));
963 lpCaps->wMid = ac16.wMid;
964 lpCaps->wPid = ac16.wPid;
965 lpCaps->vDriverVersion = ac16.vDriverVersion;
966 lstrcpyAtoW(lpCaps->szPname,ac16.szPname);
967 lpCaps->wTechnology = ac16.wTechnology;
968 lpCaps->dwSupport = ac16.dwSupport;
972 /**************************************************************************
973 * auxGetDevCaps [WINMM.21]
975 UINT WINAPI auxGetDevCapsA(UINT uDeviceID, LPAUXCAPSA lpCaps,UINT uSize)
978 UINT ret = auxGetDevCaps16(uDeviceID, &ac16, sizeof(ac16));
980 lpCaps->wMid = ac16.wMid;
981 lpCaps->wPid = ac16.wPid;
982 lpCaps->vDriverVersion = ac16.vDriverVersion;
983 strcpy(lpCaps->szPname,ac16.szPname);
984 lpCaps->wTechnology = ac16.wTechnology;
985 lpCaps->dwSupport = ac16.dwSupport;
989 /**************************************************************************
990 * auxGetDevCaps [MMSYSTEM.351]
992 UINT16 WINAPI auxGetDevCaps16(UINT16 uDeviceID, LPAUXCAPS16 lpCaps, UINT16 uSize)
994 TRACE(mmsys, "(%04X, %p, %d) !\n", uDeviceID, lpCaps, uSize);
996 return auxMessage(uDeviceID, AUXDM_GETDEVCAPS,
997 0L, (DWORD)lpCaps, (DWORD)uSize);
1000 /**************************************************************************
1001 * auxGetVolume [WINM.23]
1003 UINT WINAPI auxGetVolume(UINT uDeviceID, DWORD * lpdwVolume)
1005 return auxGetVolume16(uDeviceID, lpdwVolume);
1008 /**************************************************************************
1009 * auxGetVolume [MMSYSTEM.352]
1011 UINT16 WINAPI auxGetVolume16(UINT16 uDeviceID, DWORD * lpdwVolume)
1013 TRACE(mmsys, "(%04X, %p) !\n", uDeviceID, lpdwVolume);
1015 return auxMessage(uDeviceID, AUXDM_GETVOLUME, 0L, (DWORD)lpdwVolume, 0L);
1018 /**************************************************************************
1019 * auxSetVolume [WINMM.25]
1021 UINT WINAPI auxSetVolume(UINT uDeviceID, DWORD dwVolume)
1023 return auxSetVolume16(uDeviceID, dwVolume);
1026 /**************************************************************************
1027 * auxSetVolume [MMSYSTEM.353]
1029 UINT16 WINAPI auxSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
1031 TRACE(mmsys, "(%04X, %08lX) !\n", uDeviceID, dwVolume);
1033 return auxMessage(uDeviceID, AUXDM_SETVOLUME, 0L, dwVolume, 0L);
1036 /**************************************************************************
1037 * auxOutMessage [MMSYSTEM.354]
1039 DWORD WINAPI auxOutMessage(UINT uDeviceID,UINT uMessage, DWORD dw1, DWORD dw2)
1042 case AUXDM_GETNUMDEVS:
1043 case AUXDM_GETVOLUME:
1044 case AUXDM_SETVOLUME:
1045 /* no argument conversion needed */
1047 case AUXDM_GETDEVCAPS:
1048 return auxGetDevCapsA(uDeviceID, (LPAUXCAPSA)dw1, dw2);
1050 ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
1051 uDeviceID,uMessage, dw1, dw2);
1054 return auxMessage(uDeviceID,uMessage, 0L, dw1, dw2);
1057 /**************************************************************************
1058 * auxOutMessage [MMSYSTEM.354]
1060 DWORD WINAPI auxOutMessage16(UINT16 uDeviceID, UINT16 uMessage, DWORD dw1, DWORD dw2)
1062 TRACE(mmsys, "(%04X, %04X, %08lX, %08lX)\n", uDeviceID, uMessage, dw1, dw2);
1065 case AUXDM_GETNUMDEVS:
1066 case AUXDM_SETVOLUME:
1067 /* no argument conversion needed */
1069 case AUXDM_GETVOLUME:
1070 return auxGetVolume16(uDeviceID, (LPDWORD)PTR_SEG_TO_LIN(dw1));
1071 case AUXDM_GETDEVCAPS:
1072 return auxGetDevCaps16(uDeviceID, (LPAUXCAPS16)PTR_SEG_TO_LIN(dw1), dw2);
1074 ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
1075 uDeviceID,uMessage, dw1, dw2);
1078 return auxMessage(uDeviceID, uMessage, 0L, dw1, dw2);
1081 /**************************************************************************
1082 * mciGetErrorStringW [WINMM.46]
1084 BOOL WINAPI mciGetErrorStringW(DWORD wError, LPWSTR lpstrBuffer,UINT uLength)
1086 LPSTR bufstr = HeapAlloc(GetProcessHeap(), 0,uLength);
1087 BOOL ret = mciGetErrorStringA(wError,bufstr,uLength);
1089 lstrcpyAtoW(lpstrBuffer,bufstr);
1090 HeapFree(GetProcessHeap(), 0,bufstr);
1094 /**************************************************************************
1095 * mciGetErrorStringA [WINMM.45]
1097 BOOL WINAPI mciGetErrorStringA(DWORD wError, LPSTR lpstrBuffer,UINT uLength)
1099 return mciGetErrorString16(wError, lpstrBuffer,uLength);
1102 /**************************************************************************
1103 * mciGetErrorString [MMSYSTEM.706]
1105 BOOL16 WINAPI mciGetErrorString16(DWORD wError, LPSTR lpstrBuffer,UINT16 uLength)
1109 TRACE(mmsys, "(%08lX, %p, %d);\n", wError, lpstrBuffer, uLength);
1111 if ((lpstrBuffer == NULL) || (uLength < 1))
1113 lpstrBuffer[0] = '\0';
1117 msgptr = "The specified command has been executed.";
1119 case MCIERR_INVALID_DEVICE_ID:
1120 msgptr = "Invalid MCI device ID. Use the ID returned when opening the MCI device.";
1122 case MCIERR_UNRECOGNIZED_KEYWORD:
1123 msgptr = "The driver cannot recognize the specified command parameter.";
1125 case MCIERR_UNRECOGNIZED_COMMAND:
1126 msgptr = "The driver cannot recognize the specified command.";
1128 case MCIERR_HARDWARE:
1129 msgptr = "There is a problem with your media device. Make sure it is working correctly or contact the device manufacturer.";
1131 case MCIERR_INVALID_DEVICE_NAME:
1132 msgptr = "The specified device is not open or is not recognized by MCI.";
1134 case MCIERR_OUT_OF_MEMORY:
1135 msgptr = "Not enough memory available for this task. \nQuit one or more applications to increase available memory, and then try again.";
1137 case MCIERR_DEVICE_OPEN:
1138 msgptr = "The device name is already being used as an alias by this application. Use a unique alias.";
1140 case MCIERR_CANNOT_LOAD_DRIVER:
1141 msgptr = "There is an undetectable problem in loading the specified device driver.";
1143 case MCIERR_MISSING_COMMAND_STRING:
1144 msgptr = "No command was specified.";
1146 case MCIERR_PARAM_OVERFLOW:
1147 msgptr = "The output string was to large to fit in the return buffer. Increase the size of the buffer.";
1149 case MCIERR_MISSING_STRING_ARGUMENT:
1150 msgptr = "The specified command requires a character-string parameter. Please provide one.";
1152 case MCIERR_BAD_INTEGER:
1153 msgptr = "The specified integer is invalid for this command.";
1155 case MCIERR_PARSER_INTERNAL:
1156 msgptr = "The device driver returned an invalid return type. Check with the device manufacturer about obtaining a new driver.";
1158 case MCIERR_DRIVER_INTERNAL:
1159 msgptr = "There is a problem with the device driver. Check with the device manufacturer about obtaining a new driver.";
1161 case MCIERR_MISSING_PARAMETER:
1162 msgptr = "The specified command requires a parameter. Please supply one.";
1164 case MCIERR_UNSUPPORTED_FUNCTION:
1165 msgptr = "The MCI device you are using does not support the specified command.";
1167 case MCIERR_FILE_NOT_FOUND:
1168 msgptr = "Cannot find the specified file. Make sure the path and filename are correct.";
1170 case MCIERR_DEVICE_NOT_READY:
1171 msgptr = "The device driver is not ready.";
1173 case MCIERR_INTERNAL:
1174 msgptr = "A problem occurred in initializing MCI. Try restarting Windows.";
1177 msgptr = "There is a problem with the device driver. The driver has closed. Cannot access error.";
1179 case MCIERR_CANNOT_USE_ALL:
1180 msgptr = "Cannot use 'all' as the device name with the specified command.";
1182 case MCIERR_MULTIPLE:
1183 msgptr = "Errors occurred in more than one device. Specify each command and device separately to determine which devices caused the error";
1185 case MCIERR_EXTENSION_NOT_FOUND:
1186 msgptr = "Cannot determine the device type from the given filename extension.";
1188 case MCIERR_OUTOFRANGE:
1189 msgptr = "The specified parameter is out of range for the specified command.";
1191 case MCIERR_FLAGS_NOT_COMPATIBLE:
1192 msgptr = "The specified parameters cannot be used together.";
1194 case MCIERR_FILE_NOT_SAVED:
1195 msgptr = "Cannot save the specified file. Make sure you have enough disk space or are still connected to the network.";
1197 case MCIERR_DEVICE_TYPE_REQUIRED:
1198 msgptr = "Cannot find the specified device. Make sure it is installed or that the device name is spelled correctly.";
1200 case MCIERR_DEVICE_LOCKED:
1201 msgptr = "The specified device is now being closed. Wait a few seconds, and then try again.";
1203 case MCIERR_DUPLICATE_ALIAS:
1204 msgptr = "The specified alias is already being used in this application. Use a unique alias.";
1206 case MCIERR_BAD_CONSTANT:
1207 msgptr = "The specified parameter is invalid for this command.";
1209 case MCIERR_MUST_USE_SHAREABLE:
1210 msgptr = "The device driver is already in use. To share it, use the 'shareable' parameter with each 'open' command.";
1212 case MCIERR_MISSING_DEVICE_NAME:
1213 msgptr = "The specified command requires an alias, file, driver, or device name. Please supply one.";
1215 case MCIERR_BAD_TIME_FORMAT:
1216 msgptr = "The specified value for the time format is invalid. Refer to the MCI documentation for valid formats.";
1218 case MCIERR_NO_CLOSING_QUOTE:
1219 msgptr = "A closing double-quotation mark is missing from the parameter value. Please supply one.";
1221 case MCIERR_DUPLICATE_FLAGS:
1222 msgptr = "A parameter or value was specified twice. Only specify it once.";
1224 case MCIERR_INVALID_FILE:
1225 msgptr = "The specified file cannot be played on the specified MCI device. The file may be corrupt, or not in the correct format.";
1227 case MCIERR_NULL_PARAMETER_BLOCK:
1228 msgptr = "A null parameter block was passed to MCI.";
1230 case MCIERR_UNNAMED_RESOURCE:
1231 msgptr = "Cannot save an unnamed file. Supply a filename.";
1233 case MCIERR_NEW_REQUIRES_ALIAS:
1234 msgptr = "You must specify an alias when using the 'new' parameter.";
1236 case MCIERR_NOTIFY_ON_AUTO_OPEN:
1237 msgptr = "Cannot use the 'notify' flag with auto-opened devices.";
1239 case MCIERR_NO_ELEMENT_ALLOWED:
1240 msgptr = "Cannot use a filename with the specified device.";
1242 case MCIERR_NONAPPLICABLE_FUNCTION:
1243 msgptr = "Cannot carry out the commands in the order specified. Correct the command sequence, and then try again.";
1245 case MCIERR_ILLEGAL_FOR_AUTO_OPEN:
1246 msgptr = "Cannot carry out the specified command on an auto-opened device. Wait until the device is closed, and then try again.";
1248 case MCIERR_FILENAME_REQUIRED:
1249 msgptr = "The filename is invalid. Make sure the filename is not longer than 8 characters, followed by a period and an extension.";
1251 case MCIERR_EXTRA_CHARACTERS:
1252 msgptr = "Cannot specify extra characters after a string enclosed in quotation marks.";
1254 case MCIERR_DEVICE_NOT_INSTALLED:
1255 msgptr = "The specified device is not installed on the system. Use the Drivers option in Control Panel to install the device.";
1258 msgptr = "Cannot access the specified file or MCI device. Try changing directories or restarting your computer.";
1261 msgptr = "Cannot access the specified file or MCI device because the application cannot change directories.";
1263 case MCIERR_SET_DRIVE:
1264 msgptr = "Cannot access specified file or MCI device because the application cannot change drives.";
1266 case MCIERR_DEVICE_LENGTH:
1267 msgptr = "Specify a device or driver name that is less than 79 characters.";
1269 case MCIERR_DEVICE_ORD_LENGTH:
1270 msgptr = "Specify a device or driver name that is less than 69 characters.";
1272 case MCIERR_NO_INTEGER:
1273 msgptr = "The specified command requires an integer parameter. Please provide one.";
1275 case MCIERR_WAVE_OUTPUTSINUSE:
1276 msgptr = "All wave devices that can play files in the current format are in use. Wait until a wave device is free, and then try again.";
1278 case MCIERR_WAVE_SETOUTPUTINUSE:
1279 msgptr = "Cannot set the current wave device for play back because it is in use. Wait until the device is free, and then try again.";
1281 case MCIERR_WAVE_INPUTSINUSE:
1282 msgptr = "All wave devices that can record files in the current format are in use. Wait until a wave device is free, and then try again.";
1284 case MCIERR_WAVE_SETINPUTINUSE:
1285 msgptr = "Cannot set the current wave device for recording because it is in use. Wait until the device is free, and then try again.";
1287 case MCIERR_WAVE_OUTPUTUNSPECIFIED:
1288 msgptr = "Any compatible waveform playback device may be used.";
1290 case MCIERR_WAVE_INPUTUNSPECIFIED:
1291 msgptr = "Any compatible waveform recording device may be used.";
1293 case MCIERR_WAVE_OUTPUTSUNSUITABLE:
1294 msgptr = "No wave device that can play files in the current format is installed. Use the Drivers option to install the wave device.";
1296 case MCIERR_WAVE_SETOUTPUTUNSUITABLE:
1297 msgptr = "The device you are trying to play to cannot recognize the current file format.";
1299 case MCIERR_WAVE_INPUTSUNSUITABLE:
1300 msgptr = "No wave device that can record files in the current format is installed. Use the Drivers option to install the wave device.";
1302 case MCIERR_WAVE_SETINPUTUNSUITABLE:
1303 msgptr = "The device you are trying to record from cannot recognize the current file format.";
1305 case MCIERR_NO_WINDOW:
1306 msgptr = "There is no display window.";
1308 case MCIERR_CREATEWINDOW:
1309 msgptr = "Could not create or use window.";
1311 case MCIERR_FILE_READ:
1312 msgptr = "Cannot read the specified file. Make sure the file is still present, or check your disk or network connection.";
1314 case MCIERR_FILE_WRITE:
1315 msgptr = "Cannot write to the specified file. Make sure you have enough disk space or are still connected to the network.";
1317 case MCIERR_SEQ_DIV_INCOMPATIBLE:
1318 msgptr = "The time formats of the \"song pointer\" and SMPTE are mutually exclusive. You can't use them together.";
1320 case MCIERR_SEQ_NOMIDIPRESENT:
1321 msgptr = "The system has no installed MIDI devices. Use the Drivers option from the Control Panel to install a MIDI driver.";
1323 case MCIERR_SEQ_PORT_INUSE:
1324 msgptr = "The specified MIDI port is already in use. Wait until it is free; the try again.";
1326 case MCIERR_SEQ_PORT_MAPNODEVICE:
1327 msgptr = "The current MIDI Mapper setup refers to a MIDI device that is not installed on the system. Use the MIDI Mapper option from the Control Panel to edit the setup.";
1329 case MCIERR_SEQ_PORT_MISCERROR:
1330 msgptr = "An error occurred with the specified port.";
1332 case MCIERR_SEQ_PORT_NONEXISTENT:
1333 msgptr = "The specified MIDI device is not installed on the system. Use the Drivers option from the Control Panel to install a MIDI device.";
1335 case MCIERR_SEQ_PORTUNSPECIFIED:
1336 msgptr = "The system doesnot have a current MIDI port specified.";
1338 case MCIERR_SEQ_TIMER:
1339 msgptr = "All multimedia timers are being used by other applications. Quit one of these applications; then, try again.";
1344 msg# 514 : videodisc
1349 msg# 519 : animation
1350 msg# 520 : digitalvideo
1352 msg# 522 : waveaudio
1353 msg# 523 : sequencer
1354 msg# 524 : not ready
1357 msg# 527 : recording
1363 msg# 533 : milliseconds
1370 msg# 540 : smpte 30 drop
1376 msgptr = "Unknown MCI Error !\n";
1379 lstrcpynA(lpstrBuffer, msgptr, uLength);
1380 TRACE(mmsys, "msg = %s;\n", msgptr);
1384 /**************************************************************************
1385 * mciDriverNotify [MMSYSTEM.711]
1387 BOOL16 WINAPI mciDriverNotify16(HWND16 hWndCallBack, UINT16 wDevID, UINT16 wStatus)
1389 TRACE(mmsys, "(%04X, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
1391 if (!IsWindow(hWndCallBack)) {
1392 WARN(mmsys, "bad hWnd for call back\n");
1395 TRACE(mmsys, "before PostMessage\n");
1396 PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
1400 /**************************************************************************
1401 * mciDriverNotify32 [WINMM.36]
1403 BOOL WINAPI mciDriverNotify(HWND hWndCallBack, UINT wDevID, UINT wStatus)
1405 FIXME(mmsys, "(%08X, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
1407 if (!IsWindow(hWndCallBack)) {
1408 WARN(mmsys, "bad hWnd for call back\n");
1411 TRACE(mmsys, "before PostMessage\n");
1412 PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
1416 /**************************************************************************
1417 * mciGetDriverData [MMSYSTEM.708]
1419 DWORD WINAPI mciGetDriverData16(HDRVR16 hdrv)
1421 return mciGetDriverData(hdrv);
1424 /**************************************************************************
1425 * mciGetDriverData [WINMM.44]
1427 DWORD WINAPI mciGetDriverData(HDRVR hdrv)
1429 TRACE(mmsys,"(%04x)\n", hdrv);
1430 if (!MCI_DevIDValid(hdrv) || MCI_GetDrv(hdrv)->modp.wType == 0) {
1434 return MCI_GetDrv(hdrv)->dwPrivate;
1437 /**************************************************************************
1438 * mciSetDriverData [MMSYSTEM.707]
1440 BOOL16 WINAPI mciSetDriverData16(HDRVR16 hdrv, DWORD data)
1442 return mciSetDriverData(hdrv, data);
1445 /**************************************************************************
1446 * mciSetDriverData [WINMM.53]
1448 BOOL WINAPI mciSetDriverData(HDRVR hdrv, DWORD data)
1450 TRACE(mmsys,"(%04x,%08lx)\n", hdrv, data);
1451 if (!MCI_DevIDValid(hdrv) || MCI_GetDrv(hdrv)->modp.wType == 0) {
1455 MCI_GetDrv(hdrv)->dwPrivate = data;
1459 /**************************************************************************
1460 * mciLoadCommandResource [MMSYSTEM.705]
1462 UINT16 WINAPI mciLoadCommandResource16(HANDLE16 hinst, LPCSTR resname,UINT16 type)
1472 static UINT16 mcidevtype = 0;
1474 FIXME(mmsys,"(%04x,%s,%d): stub!\n", hinst, resname, type);
1475 if (!lstrcmpiA(resname,"core")) {
1476 FIXME(mmsys, "(...,\"core\",...), have to use internal tables... (not there yet)\n");
1479 /* if file exists "resname.mci", then load resource "resname" from it
1480 * otherwise directly from driver
1482 strcpy(buf,resname);
1484 if (OpenFile(buf, &ofs,OF_EXIST) != HFILE_ERROR) {
1485 xhinst = LoadLibrary16(buf);
1488 } /* else use passed hinst */
1489 segstr = SEGPTR_STRDUP(resname);
1490 hrsrc = FindResource16(hinst, SEGPTR_GET(segstr), type);
1491 SEGPTR_FREE(segstr);
1493 WARN(mmsys,"no special commandlist found in resource\n");
1494 return MCI_NO_COMMAND_TABLE;
1496 hmem = LoadResource16(hinst, hrsrc);
1498 WARN(mmsys,"couldn't load resource??\n");
1499 return MCI_NO_COMMAND_TABLE;
1501 xmem = WIN16_LockResource16(hmem);
1503 WARN(mmsys,"couldn't lock resource??\n");
1504 FreeResource16(hmem);
1505 return MCI_NO_COMMAND_TABLE;
1507 lmem = PTR_SEG_TO_LIN(xmem);
1508 TRACE(mmsys, "first resource entry is %s\n", (char*)lmem);
1509 /* parse resource, register stuff, return unique id */
1510 return ++mcidevtype;
1513 /**************************************************************************
1514 * mciFreeCommandResource [MMSYSTEM.713]
1516 BOOL16 WINAPI mciFreeCommandResource16(UINT16 uTable)
1518 FIXME(mci, "(%04x) stub\n", uTable);
1522 /**************************************************************************
1523 * mciFreeCommandResource [WINMM.39]
1525 BOOL WINAPI mciFreeCommandResource(UINT uTable)
1527 FIXME(mci, "(%08x) stub\n", uTable);
1531 /**************************************************************************
1532 * mciLoadCommandResource [WINMM.48]
1534 UINT WINAPI mciLoadCommandResource(HANDLE hinst, LPCWSTR resname,UINT type)
1536 FIXME(mmsys,"(%04x,%s,%d): stub!\n", hinst, debugstr_w(resname), type);
1539 const char* MCI_CommandToString(UINT16 wMsg)
1541 static char buffer[100];
1543 #define CASE(s) case (s): return #s
1554 CASE(MCI_GETDEVCAPS);
1578 sprintf(buffer, "MCI_<<%04X>>", wMsg);
1583 /**************************************************************************
1584 * MCI_SendCommand32 [internal]
1586 DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
1588 DWORD dwRet = MCIERR_DEVICE_NOT_INSTALLED;
1590 if (!MCI_DevIDValid(wDevID)) {
1591 dwRet = MCIERR_INVALID_DEVICE_ID;
1593 MCIPROC proc = MCI_GetProc(MCI_GetDrv(wDevID)->modp.wType);
1596 dwRet = (*proc)(MCI_GetDrv(wDevID)->modp.wDeviceID,
1597 MCI_GetDrv(wDevID)->hDrv,
1598 wMsg, dwParam1, dwParam2);
1599 } else if (MCI_GetDrv(wDevID)->driverProc) {
1600 FIXME(mmsys, "is that correct ?\n");
1601 dwRet = Callbacks->CallDriverProc(MCI_GetDrv(wDevID)->driverProc,
1602 MCI_GetDrv(wDevID)->modp.wDeviceID,
1603 MCI_GetDrv(wDevID)->hDrv,
1604 wMsg, dwParam1, dwParam2);
1606 WARN(mmsys, "unknown device type=%04X !\n", MCI_GetDrv(wDevID)->modp.wType);
1612 /**************************************************************************
1613 * MCI_Open [internal]
1615 static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSA lpParms)
1619 UINT16 wDevID = MCI_FirstDevID();
1622 TRACE(mmsys, "(%08lX, %p)\n", dwParam, lpParms);
1623 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
1625 if ((dwParam & ~(MCI_OPEN_SHAREABLE|MCI_OPEN_ELEMENT|MCI_OPEN_ALIAS|MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID|MCI_NOTIFY|MCI_WAIT)) != 0) {
1626 FIXME(mmsys, "unsupported yet dwFlags=%08lX\n",
1627 (dwParam & ~(MCI_OPEN_SHAREABLE|MCI_OPEN_ELEMENT|MCI_OPEN_ALIAS|MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID|MCI_NOTIFY|MCI_WAIT)));
1630 while (MCI_GetDrv(wDevID)->modp.wType != 0) {
1631 wDevID = MCI_NextDevID(wDevID);
1632 if (!MCI_DevIDValid(wDevID)) {
1633 TRACE(mmsys, "MAXMCIDRIVERS reached !\n");
1634 return MCIERR_OUT_OF_MEMORY;
1638 TRACE(mmsys, "wDevID=%04X \n", wDevID);
1639 memcpy(MCI_GetOpenDrv(wDevID), lpParms, sizeof(*lpParms));
1641 if (dwParam & MCI_OPEN_ELEMENT) {
1644 TRACE(mmsys,"lpstrElementName='%s'\n", lpParms->lpstrElementName);
1645 s = lpParms->lpstrElementName;
1646 t = strrchr(s, '.');
1648 GetProfileStringA("mci extensions", t+1, "*", str, sizeof(str));
1650 uDevTyp = MCI_GetDevType(str);
1652 if (strcmp(str,"*") == 0) {
1653 TRACE(mmsys,"No [mci extensions] entry for %s found.\n", t);
1654 return MCIERR_EXTENSION_NOT_FOUND;
1657 /* FIXME has to be re-written, seems to be experimental 16 bit code anyway */
1659 HDRVR16 hdrv = OpenDriver32(str, "mci", NULL);
1663 hmod = GetDriverModuleHandle(hdrv);
1664 MCI_GetDrv(wDevID)->hDrv = hdrv;
1665 MCI_GetDrv(wDevID)->driverProc = GetProcAddress(hmod,oouch SEGPTR_GET(SEGPTR_STRDUP("DRIVERPROC")));
1666 uDevTyp = MCI_DEVTYPE_OTHER;
1668 FIXME(mmsys, "[mci extensions] entry %s for %s not supported.\n", str, t);
1669 return MCIERR_DEVICE_NOT_INSTALLED;
1674 } else if (GetDriveTypeA(s) == DRIVE_CDROM) {
1675 /* FIXME: this will not work if several CDROM drives are installed on the machine */
1676 uDevTyp = MCI_DEVTYPE_CD_AUDIO;
1678 return MCIERR_EXTENSION_NOT_FOUND;
1682 if (dwParam & MCI_OPEN_ALIAS) {
1683 TRACE(mmsys, "Alias='%s' !\n", lpParms->lpstrAlias);
1684 /* FIXME is there any memory leak here ? */
1685 MCI_GetOpenDrv(wDevID)->lpstrAlias = strdup(lpParms->lpstrAlias);
1686 /* mplayer does allocate alias to CDAUDIO */
1688 if (dwParam & MCI_OPEN_TYPE) {
1689 if (dwParam & MCI_OPEN_TYPE_ID) {
1690 TRACE(mmsys, "Dev=%08lx!\n", (DWORD)lpParms->lpstrDeviceType);
1691 uDevTyp = LOWORD((DWORD)lpParms->lpstrDeviceType);
1692 MCI_GetOpenDrv(wDevID)->lpstrDeviceType = lpParms->lpstrDeviceType;
1694 if (lpParms->lpstrDeviceType == NULL)
1695 return MCIERR_NULL_PARAMETER_BLOCK;
1696 TRACE(mmsys, "Dev='%s' !\n", lpParms->lpstrDeviceType);
1697 /* FIXME is there any memory leak here ? */
1698 MCI_GetOpenDrv(wDevID)->lpstrDeviceType = strdup(lpParms->lpstrDeviceType);
1699 strcpy(str, lpParms->lpstrDeviceType);
1701 uDevTyp = MCI_GetDevType(str);
1704 /* FIXME has to be re-written, seems to be experimental 16 bit code anyway */
1706 TRACE(mmsys,"trying to load driver...\n");
1707 hdrv = OpenDriver32(str,"mci",NULL);
1711 hmod = GetDriverModuleHandle(hdrv);
1712 MCI_GetDrv(wDevID)->hDrv = hdrv;
1713 MCI_GetDrv(wDevID)->driverProc = GetProcAddress(hmod,oouch SEGPTR_GET(SEGPTR_STRDUP("DriverProc")));
1714 uDevTyp = MCI_DEVTYPE_OTHER;
1717 return MCIERR_DEVICE_NOT_INSTALLED;
1721 MCI_GetDrv(wDevID)->modp.wType = uDevTyp;
1722 MCI_GetDrv(wDevID)->modp.wDeviceID = 0; /* FIXME? for multiple devices */
1723 MCI_GetDrv(wDevID)->dwPrivate = 0;
1724 lpParms->wDeviceID = wDevID;
1725 TRACE(mmsys, "mcidev=%d, uDevTyp=%04X wDeviceID=%04X !\n",
1726 wDevID, uDevTyp, lpParms->wDeviceID);
1727 dwRet = MCI_SendCommand(wDevID, MCI_OPEN_DRIVER, dwParam, (DWORD)lpParms);
1730 /* only handled devices fall through */
1731 TRACE(mmsys, "wDevID = %04X wDeviceID = %d dwRet = %ld\n", wDevID, lpParms->wDeviceID, dwRet);
1733 TRACE(mmsys, "failed to open driver (MCI_OPEN_DRIVER msg) [%08lx], closing\n", dwRet);
1734 MCI_GetDrv(wDevID)->modp.wType = 0;
1736 if (dwParam & MCI_NOTIFY)
1737 mciDriverNotify16(lpParms->dwCallback, wDevID, dwRet == 0 ? MCI_NOTIFY_SUCCESSFUL : MCI_NOTIFY_FAILURE);
1742 /**************************************************************************
1743 * MCI_Close [internal]
1745 static DWORD MCI_Close(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
1749 TRACE(mmsys, "(%04x, %08lX, %p)\n", wDevID, dwParam, lpParms);
1751 if (wDevID == MCI_ALL_DEVICE_ID) {
1752 FIXME(mmsys, "unhandled MCI_ALL_DEVICE_ID\n");
1753 return MCIERR_CANNOT_USE_ALL;
1756 dwRet = MCI_SendCommand(wDevID, MCI_CLOSE_DRIVER, dwParam, (DWORD)lpParms);
1757 MCI_GetDrv(wDevID)->modp.wType = 0;
1759 if (dwParam&MCI_NOTIFY)
1760 mciDriverNotify16(lpParms->dwCallback, wDevID,
1761 (dwRet==0?MCI_NOTIFY_SUCCESSFUL:MCI_NOTIFY_FAILURE));
1763 TRACE(mmsys, "returns %ld\n", dwRet);
1767 /**************************************************************************
1768 * MCI_WriteString [internal]
1770 DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr)
1774 if (dstSize <= strlen(lpSrcStr)) {
1775 lstrcpynA(lpDstStr, lpSrcStr, dstSize - 1);
1776 ret = MCIERR_PARAM_OVERFLOW;
1778 strcpy(lpDstStr, lpSrcStr);
1784 /**************************************************************************
1785 * MCI_Sysinfo [internal]
1787 static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParms)
1789 DWORD ret = MCIERR_INVALID_DEVICE_ID;
1791 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
1793 TRACE(mci, "(%08x, %08lX, %08lX[num=%ld, wDevTyp=%u])\n",
1794 uDevID, dwFlags, (DWORD)lpParms, lpParms->dwNumber, lpParms->wDeviceType);
1796 switch (dwFlags & ~MCI_SYSINFO_OPEN) {
1797 case MCI_SYSINFO_QUANTITY:
1802 if (lpParms->wDeviceType < MCI_DEVTYPE_FIRST || lpParms->wDeviceType > MCI_DEVTYPE_LAST) {
1803 if (dwFlags & MCI_SYSINFO_OPEN) {
1804 TRACE(mci, "MCI_SYSINFO_QUANTITY: # of open MCI drivers\n");
1805 for (i = 0; i < MAXMCIDRIVERS; i++) {
1806 if (mciDrv[i].modp.wType != 0) cnt++;
1809 TRACE(mci, "MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n");
1810 cnt = mciInstalledCount;
1813 if (dwFlags & MCI_SYSINFO_OPEN) {
1814 TRACE(mci, "MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n", lpParms->wDeviceType);
1815 for (i = 0; i < MAXMCIDRIVERS; i++) {
1816 if (mciDrv[i].modp.wType == lpParms->wDeviceType) cnt++;
1819 TRACE(mci, "MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n", lpParms->wDeviceType);
1820 FIXME(mci, "Don't know how to get # of MCI devices of a given type\n");
1824 *(DWORD*)lpParms->lpstrReturn = cnt;
1826 TRACE(mci, "(%ld) => '%ld'\n", lpParms->dwNumber, *(DWORD*)lpParms->lpstrReturn);
1829 case MCI_SYSINFO_INSTALLNAME:
1830 TRACE(mci, "MCI_SYSINFO_INSTALLNAME \n");
1831 if (MCI_DevIDValid(uDevID)) {
1832 LPCSTR str = MCI_GetDevTypeString(MCI_GetDrv(uDevID)->modp.wType);
1833 ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, str);
1835 *lpParms->lpstrReturn = 0;
1836 ret = MCIERR_INVALID_DEVICE_ID;
1838 TRACE(mci, "(%ld) => '%s'\n", lpParms->dwNumber, lpParms->lpstrReturn);
1840 case MCI_SYSINFO_NAME:
1841 TRACE(mci, "MCI_SYSINFO_NAME\n");
1842 if (dwFlags & MCI_SYSINFO_OPEN) {
1843 FIXME(mci, "Don't handle MCI_SYSINFO_NAME|MCI_SYSINFO_OPEN (yet)\n");
1844 ret = MCIERR_UNRECOGNIZED_COMMAND;
1845 } else if (lpParms->dwNumber > mciInstalledCount) {
1846 ret = MCIERR_OUTOFRANGE;
1848 DWORD count = lpParms->dwNumber;
1849 LPSTR ptr = lpmciInstallNames;
1851 while (--count > 0) ptr += strlen(ptr) + 1;
1852 ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, ptr);
1854 TRACE(mci, "(%ld) => '%s'\n", lpParms->dwNumber, lpParms->lpstrReturn);
1857 TRACE(mci, "Unsupported flag value=%08lx\n", dwFlags);
1858 ret = MCIERR_UNRECOGNIZED_COMMAND;
1871 DWORD WINAPI mciSendCommandA(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2);
1873 /**************************************************************************
1874 * MCI_SCAStarter32 [internal]
1876 static DWORD WINAPI MCI_SCAStarter(LPVOID arg)
1878 struct SCA* sca = (struct SCA*)arg;
1881 TRACE(mci, "In thread before async command (%08x,%s,%08lx,%08lx)\n",
1882 sca->wDevID, MCI_CommandToString(sca->wMsg), sca->dwParam1, sca->dwParam2);
1883 ret = mciSendCommandA(sca->wDevID, sca->wMsg, sca->dwParam1 | MCI_WAIT, sca->dwParam2);
1884 TRACE(mci, "In thread after async command (%08x,%s,%08lx,%08lx)\n",
1885 sca->wDevID, MCI_CommandToString(sca->wMsg), sca->dwParam1, sca->dwParam2);
1886 if (sca->allocatedCopy)
1887 HeapFree(GetProcessHeap(), 0, (LPVOID)sca->dwParam2);
1888 HeapFree(GetProcessHeap(), 0, sca);
1890 WARN(mci, "Should not happen ? what's wrong \n");
1891 /* should not go after this point */
1895 /**************************************************************************
1896 * MCI_SendCommandAsync32 [internal]
1898 DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2, UINT size)
1900 struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA));
1903 return MCIERR_OUT_OF_MEMORY;
1905 sca->wDevID = wDevID;
1907 sca->dwParam1 = dwParam1;
1910 sca->dwParam2 = (DWORD)HeapAlloc(GetProcessHeap(), 0, size);
1911 if (sca->dwParam2 == 0) {
1912 HeapFree(GetProcessHeap(), 0, sca);
1913 return MCIERR_OUT_OF_MEMORY;
1915 sca->allocatedCopy = TRUE;
1916 /* copy structure passed by program in dwParam2 to be sure
1917 * we can still use it whatever the program does
1919 memcpy((LPVOID)sca->dwParam2, (LPVOID)dwParam2, size);
1921 sca->dwParam2 = dwParam2;
1922 sca->allocatedCopy = FALSE;
1925 if (CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL) == 0) {
1926 WARN(mci, "Couldn't allocate thread for async command handling, sending synchonously\n");
1927 return MCI_SCAStarter(&sca);
1932 /**************************************************************************
1933 * MCI_MapMsg16To32A [internal]
1935 int MCI_MapMsg16To32A(WORD uDevType, WORD wMsg, DWORD* lParam)
1939 /* FIXME: to add also (with seg/linear modifications to do):
1940 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
1941 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO, MCI_WINDOW
1944 /* case MCI_CAPTURE */
1946 case MCI_CLOSE_DRIVER:
1947 /* case MCI_CONFIGURE:*/
1953 case MCI_GETDEVCAPS:
1954 /* case MCI_INDEX: */
1955 /* case MCI_MARK: */
1956 /* case MCI_MONITOR: */
1966 /* case MCI_SETTIMECODE:*/
1967 /* case MCI_SIGNAL:*/
1969 case MCI_STATUS: /* FIXME: is wrong for digital video */
1972 /* case MCI_UNDO: */
1976 *lParam = (DWORD)PTR_SEG_TO_LIN(*lParam);
1980 LPMCI_BREAK_PARMS mbp32 = HeapAlloc(SystemHeap, 0, sizeof(MCI_BREAK_PARMS));
1981 LPMCI_BREAK_PARMS16 mbp16 = PTR_SEG_TO_LIN(*lParam);
1984 mbp32->dwCallback = mbp16->dwCallback;
1985 mbp32->nVirtKey = mbp16->nVirtKey;
1986 mbp32->hwndBreak = mbp16->hwndBreak;
1990 *lParam = (DWORD)mbp32;
1995 LPMCI_VD_ESCAPE_PARMSA mvep32a = HeapAlloc(SystemHeap, 0, sizeof(MCI_VD_ESCAPE_PARMSA));
1996 LPMCI_VD_ESCAPE_PARMS16 mvep16 = PTR_SEG_TO_LIN(*lParam);
1999 mvep32a->dwCallback = mvep16->dwCallback;
2000 mvep32a->lpstrCommand = PTR_SEG_TO_LIN(mvep16->lpstrCommand);
2004 *lParam = (DWORD)mvep32a;
2009 LPMCI_INFO_PARMSA mip32a = HeapAlloc(SystemHeap, 0, sizeof(MCI_INFO_PARMSA));
2010 LPMCI_INFO_PARMS16 mip16 = PTR_SEG_TO_LIN(*lParam);
2012 /* FIXME this is wrong if device is of type
2013 * MCI_DEVTYPE_DIGITAL_VIDEO, some members are not mapped
2016 mip32a->dwCallback = mip16->dwCallback;
2017 mip32a->lpstrReturn = PTR_SEG_TO_LIN(mip16->lpstrReturn);
2018 mip32a->dwRetSize = mip16->dwRetSize;
2022 *lParam = (DWORD)mip32a;
2026 case MCI_OPEN_DRIVER:
2028 LPMCI_OPEN_PARMSA mop32a = HeapAlloc(SystemHeap, 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_OPEN_PARMSA) + 2 * sizeof(DWORD));
2029 LPMCI_OPEN_PARMS16 mop16 = PTR_SEG_TO_LIN(*lParam);
2032 *(LPMCI_OPEN_PARMS16*)(mop32a) = mop16;
2033 mop32a = (LPMCI_OPEN_PARMSA)((char*)mop32a + sizeof(LPMCI_OPEN_PARMS16));
2034 mop32a->dwCallback = mop16->dwCallback;
2035 mop32a->wDeviceID = mop16->wDeviceID;
2036 mop32a->lpstrDeviceType = PTR_SEG_TO_LIN(mop16->lpstrDeviceType);
2037 mop32a->lpstrElementName = PTR_SEG_TO_LIN(mop16->lpstrElementName);
2038 mop32a->lpstrAlias = PTR_SEG_TO_LIN(mop16->lpstrAlias);
2039 /* copy extended information if any...
2040 * FIXME: this may seg fault if initial structure does not contain them and
2041 * the reads after msip16 fail under LDT limits...
2042 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
2043 * should not take care of extended parameters, and should be used by MCI_Open
2044 * to fetch uDevTyp. When, this is known, the mapping for sending the
2045 * MCI_OPEN_DRIVER shall be done depending on uDevTyp.
2047 ((DWORD*)(mop32a + 1))[0] = ((DWORD*)(mop16 + 1))[0];
2048 ((DWORD*)(mop32a + 1))[1] = ((DWORD*)(mop16 + 1))[1];
2052 *lParam = (DWORD)mop32a;
2057 LPMCI_SYSINFO_PARMSA msip32a = HeapAlloc(SystemHeap, 0, sizeof(MCI_SYSINFO_PARMSA));
2058 LPMCI_SYSINFO_PARMS16 msip16 = PTR_SEG_TO_LIN(*lParam);
2061 msip32a->dwCallback = msip16->dwCallback;
2062 msip32a->lpstrReturn = PTR_SEG_TO_LIN(msip16->lpstrReturn);
2063 msip32a->dwRetSize = msip16->dwRetSize;
2064 msip32a->dwNumber = msip16->dwNumber;
2065 msip32a->wDeviceType = msip16->wDeviceType;
2069 *lParam = (DWORD)msip32a;
2079 case DRV_QUERYCONFIGURE:
2082 case DRV_EXITSESSION:
2083 case DRV_EXITAPPLICATION:
2085 FIXME(mci, "This is a hack\n");
2089 WARN(mci, "Don't know how to map msg=%s\n", MCI_CommandToString(wMsg));
2094 /**************************************************************************
2095 * MCI_UnMapMsg16To32A [internal]
2097 int MCI_UnMapMsg16To32A(WORD uDevTyp, WORD wMsg, DWORD lParam)
2100 /* case MCI_CAPTURE */
2102 case MCI_CLOSE_DRIVER:
2103 /* case MCI_CONFIGURE:*/
2109 case MCI_GETDEVCAPS:
2110 /* case MCI_INDEX: */
2111 /* case MCI_MARK: */
2112 /* case MCI_MONITOR: */
2122 /* case MCI_SETTIMECODE:*/
2123 /* case MCI_SIGNAL:*/
2128 /* case MCI_UNDO: */
2138 HeapFree(SystemHeap, 0, (LPVOID)lParam);
2141 case MCI_OPEN_DRIVER:
2143 LPMCI_OPEN_PARMSA mop32a = (MCI_OPEN_PARMSA*)lParam;
2144 LPMCI_OPEN_PARMS16 mop16 = *(LPMCI_OPEN_PARMS16*)((char*)mop32a - sizeof(LPMCI_OPEN_PARMS16*));
2146 mop16->wDeviceID = mop32a->wDeviceID;
2147 HeapFree(SystemHeap, 0, (LPVOID)(lParam - sizeof(LPMCI_OPEN_PARMS16)));
2157 case DRV_QUERYCONFIGURE:
2160 case DRV_EXITSESSION:
2161 case DRV_EXITAPPLICATION:
2163 FIXME(mci, "This is a hack\n");
2166 FIXME(mci, "Map/Unmap internal error on msg=%s\n", MCI_CommandToString(wMsg));
2171 /**************************************************************************
2172 * mciSendCommandA [WINMM.49]
2174 DWORD WINAPI mciSendCommandA(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2)
2176 TRACE(mci, "(%08x,%s,%08lx,%08lx)\n", wDevID, MCI_CommandToString(wMsg), dwParam1, dwParam2);
2180 return MCI_Open(dwParam1, (LPMCI_OPEN_PARMSA)dwParam2);
2182 return MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
2184 return MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSA)dwParam2);
2186 if (wDevID == MCI_ALL_DEVICE_ID) {
2187 FIXME(mci, "unhandled MCI_ALL_DEVICE_ID\n");
2188 return MCIERR_CANNOT_USE_ALL;
2191 return MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2);
2195 /**************************************************************************
2196 * mciSendCommandW [WINMM.50]
2198 DWORD WINAPI mciSendCommandW(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2)
2200 return 0x1; /* !ok */
2203 /**************************************************************************
2204 * mciSendCommand [MMSYSTEM.701]
2206 DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
2208 DWORD dwRet = MCIERR_UNRECOGNIZED_COMMAND;
2210 TRACE(mmsys, "(%04X, %s, %08lX, %08lX)\n",
2211 wDevID, MCI_CommandToString(wMsg), dwParam1, dwParam2);
2215 if (MCI_MapMsg16To32A(MCI_GetDrv(wDevID)->modp.wType, wMsg, &dwParam2) >= 0) {
2216 dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSA)dwParam2);
2217 MCI_UnMapMsg16To32A(MCI_GetDrv(wDevID)->modp.wType, wMsg, dwParam2);
2221 if (wDevID == MCI_ALL_DEVICE_ID) {
2222 FIXME(mci, "unhandled MCI_ALL_DEVICE_ID\n");
2223 dwRet = MCIERR_CANNOT_USE_ALL;
2224 } else if (!MCI_DevIDValid(wDevID)) {
2225 dwRet = MCIERR_INVALID_DEVICE_ID;
2226 } else if (MCI_MapMsg16To32A(MCI_GetDrv(wDevID)->modp.wType, wMsg, &dwParam2) >= 0) {
2227 dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
2228 MCI_UnMapMsg16To32A(MCI_GetDrv(wDevID)->modp.wType, wMsg, dwParam2);
2232 if (MCI_MapMsg16To32A(0, wDevID, &dwParam2) >= 0) {
2233 dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSA)dwParam2);
2234 MCI_UnMapMsg16To32A(0, wDevID, dwParam2);
2237 /* FIXME: it seems that MCI_BREAK and MCI_SOUND need the same handling */
2239 if (wDevID == MCI_ALL_DEVICE_ID) {
2240 FIXME(mci, "unhandled MCI_ALL_DEVICE_ID\n");
2241 dwRet = MCIERR_CANNOT_USE_ALL;
2242 } else if (!MCI_DevIDValid(wDevID)) {
2243 dwRet = MCIERR_INVALID_DEVICE_ID;
2247 switch (res = MCI_MapMsg16To32A(MCI_GetDrv(wDevID)->modp.wType, wMsg, &dwParam2)) {
2249 TRACE(mci, "Not handled yet (%s)\n", MCI_CommandToString(wMsg));
2252 TRACE(mci, "Problem mapping msg=%s from 16 to 32a\n", MCI_CommandToString(wMsg));
2255 dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2);
2257 MCI_UnMapMsg16To32A(MCI_GetDrv(wDevID)->modp.wType, wMsg, dwParam2);
2265 /**************************************************************************
2266 * mciGetDeviceID [MMSYSTEM.703]
2268 UINT16 WINAPI mciGetDeviceID16(LPCSTR lpstrName)
2271 TRACE(mmsys, "(\"%s\")\n", lpstrName);
2276 if (!lstrcmpiA(lpstrName, "ALL"))
2277 return MCI_ALL_DEVICE_ID;
2279 for (wDevID = MCI_FirstDevID(); MCI_DevIDValid(wDevID); wDevID = MCI_NextDevID(wDevID)) {
2280 if (MCI_GetDrv(wDevID)->modp.wType) {
2281 FIXME(mmsys, "This is wrong for compound devices\n");
2282 /* FIXME: for compound devices, lpstrName is matched against
2283 * the name of the file, not the name of the device...
2285 if (MCI_GetOpenDrv(wDevID)->lpstrDeviceType &&
2286 strcmp(MCI_GetOpenDrv(wDevID)->lpstrDeviceType, lpstrName) == 0)
2289 if (MCI_GetOpenDrv(wDevID)->lpstrAlias &&
2290 strcmp(MCI_GetOpenDrv(wDevID)->lpstrAlias, lpstrName) == 0)
2298 /**************************************************************************
2299 * mciGetDeviceIDA [WINMM.41]
2301 UINT WINAPI mciGetDeviceIDA(LPCSTR lpstrName)
2303 return mciGetDeviceID16(lpstrName);
2306 /**************************************************************************
2307 * mciGetDeviceIDW [WINMM.43]
2309 UINT WINAPI mciGetDeviceIDW(LPCWSTR lpwstrName)
2314 lpstrName = HEAP_strdupWtoA(GetProcessHeap(), 0, lpwstrName);
2315 ret = mciGetDeviceID16(lpstrName);
2316 HeapFree(GetProcessHeap(), 0, lpstrName);
2320 /**************************************************************************
2321 * mciSetYieldProc [MMSYSTEM.714]
2323 BOOL16 WINAPI mciSetYieldProc16(UINT16 uDeviceID,
2324 YIELDPROC fpYieldProc, DWORD dwYieldData)
2326 FIXME(mci, "(%u, %p, %08lx) stub\n", uDeviceID, fpYieldProc, dwYieldData);
2330 /**************************************************************************
2331 * mciSetYieldProc [WINMM.54]
2333 BOOL WINAPI mciSetYieldProc(UINT uDeviceID,
2334 YIELDPROC fpYieldProc, DWORD dwYieldData)
2336 FIXME(mci, "(%u, %p, %08lx) stub\n", uDeviceID, fpYieldProc, dwYieldData);
2340 /**************************************************************************
2341 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
2343 UINT16 WINAPI mciGetDeviceIDFromElementID16(DWORD dwElementID, LPCSTR lpstrType)
2345 FIXME(mci, "(%lu, %s) stub\n", dwElementID, lpstrType);
2349 /**************************************************************************
2350 * mciGetDeviceIDFromElementIDW [WINMM.42]
2352 UINT WINAPI mciGetDeviceIDFromElementIDW(DWORD dwElementID, LPCWSTR lpstrType)
2354 /* FIXME: that's rather strange, there is no
2355 * mciGetDeviceIDFromElementID32A in winmm.spec
2357 FIXME(mci, "(%lu, %p) stub\n", dwElementID, lpstrType);
2361 /**************************************************************************
2362 * mciGetYieldProc [MMSYSTEM.716]
2364 YIELDPROC WINAPI mciGetYieldProc16(UINT16 uDeviceID, DWORD* lpdwYieldData)
2366 FIXME(mci, "(%u, %p) stub\n", uDeviceID, lpdwYieldData);
2370 /**************************************************************************
2371 * mciGetYieldProc [WINMM.47]
2373 YIELDPROC WINAPI mciGetYieldProc(UINT uDeviceID, DWORD* lpdwYieldData)
2375 FIXME(mci, "(%u, %p) stub\n", uDeviceID, lpdwYieldData);
2379 /**************************************************************************
2380 * mciGetCreatorTask [MMSYSTEM.717]
2382 HTASK16 WINAPI mciGetCreatorTask16(UINT16 uDeviceID)
2384 FIXME(mci, "(%u) stub\n", uDeviceID);
2388 /**************************************************************************
2389 * mciGetCreatorTask [WINMM.40]
2391 HTASK WINAPI mciGetCreatorTask(UINT uDeviceID)
2393 FIXME(mci, "(%u) stub\n", uDeviceID);
2397 /**************************************************************************
2398 * mciDriverYield [MMSYSTEM.710]
2400 UINT16 WINAPI mciDriverYield16(HANDLE16 hnd)
2402 FIXME(mmsys,"(%04x): stub!\n", hnd);
2406 /**************************************************************************
2407 * mciDriverYield [WINMM.37]
2409 UINT WINAPI mciDriverYield(HANDLE hnd)
2411 FIXME(mmsys,"(%04x): stub!\n", hnd);
2415 /**************************************************************************
2416 * midiOutGetNumDevs [WINMM.80]
2418 UINT WINAPI midiOutGetNumDevs(void)
2420 return midiOutGetNumDevs16();
2423 /**************************************************************************
2424 * midiOutGetNumDevs [MMSYSTEM.201]
2426 UINT16 WINAPI midiOutGetNumDevs16(void)
2428 UINT16 count = modMessage(0, MODM_GETNUMDEVS, 0L, 0L, 0L);
2430 TRACE(mmsys, "returns %u\n", count);
2434 /**************************************************************************
2435 * midiOutGetDevCapsW [WINMM.76]
2437 UINT WINAPI midiOutGetDevCapsW(UINT uDeviceID, LPMIDIOUTCAPSW lpCaps, UINT uSize)
2439 MIDIOUTCAPS16 moc16;
2442 ret = midiOutGetDevCaps16(uDeviceID, &moc16, sizeof(moc16));
2443 lpCaps->wMid = moc16.wMid;
2444 lpCaps->wPid = moc16.wPid;
2445 lpCaps->vDriverVersion = moc16.vDriverVersion;
2446 lstrcpyAtoW(lpCaps->szPname, moc16.szPname);
2447 lpCaps->wTechnology = moc16.wTechnology;
2448 lpCaps->wVoices = moc16.wVoices;
2449 lpCaps->wNotes = moc16.wNotes;
2450 lpCaps->wChannelMask = moc16.wChannelMask;
2451 lpCaps->dwSupport = moc16.dwSupport;
2455 /**************************************************************************
2456 * midiOutGetDevCapsA [WINMM.75]
2458 UINT WINAPI midiOutGetDevCapsA(UINT uDeviceID, LPMIDIOUTCAPSA lpCaps, UINT uSize)
2460 MIDIOUTCAPS16 moc16;
2463 ret = midiOutGetDevCaps16(uDeviceID, &moc16, sizeof(moc16));
2464 lpCaps->wMid = moc16.wMid;
2465 lpCaps->wPid = moc16.wPid;
2466 lpCaps->vDriverVersion = moc16.vDriverVersion;
2467 strcpy(lpCaps->szPname, moc16.szPname);
2468 lpCaps->wTechnology = moc16.wTechnology;
2469 lpCaps->wVoices = moc16.wVoices;
2470 lpCaps->wNotes = moc16.wNotes;
2471 lpCaps->wChannelMask = moc16.wChannelMask;
2472 lpCaps->dwSupport = moc16.dwSupport;
2476 /**************************************************************************
2477 * midiOutGetDevCaps [MMSYSTEM.202]
2479 UINT16 WINAPI midiOutGetDevCaps16(UINT16 uDeviceID, LPMIDIOUTCAPS16 lpCaps, UINT16 uSize)
2481 TRACE(mmsys, "midiOutGetDevCaps\n");
2482 return modMessage(uDeviceID, MODM_GETDEVCAPS, 0, (DWORD)lpCaps,uSize);
2485 /**************************************************************************
2486 * midiOutGetErrorTextA [WINMM.77]
2488 UINT WINAPI midiOutGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
2490 TRACE(mmsys, "midiOutGetErrorText\n");
2491 return midiGetErrorText(uError, lpText, uSize);
2494 /**************************************************************************
2495 * midiOutGetErrorTextW [WINMM.78]
2497 UINT WINAPI midiOutGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
2499 LPSTR xstr = HeapAlloc(GetProcessHeap(), 0,uSize);
2502 TRACE(mmsys, "midiOutGetErrorText\n");
2503 ret = midiGetErrorText(uError, xstr, uSize);
2504 lstrcpyAtoW(lpText,xstr);
2505 HeapFree(GetProcessHeap(), 0,xstr);
2509 /**************************************************************************
2510 * midiOutGetErrorText [MMSYSTEM.203]
2512 UINT16 WINAPI midiOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
2514 TRACE(mmsys, "midiOutGetErrorText\n");
2515 return midiGetErrorText(uError, lpText, uSize);
2518 /**************************************************************************
2519 * midiGetErrorText [internal]
2521 UINT16 WINAPI midiGetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
2524 if ((lpText == NULL) || (uSize < 1)) return(FALSE);
2527 case MIDIERR_UNPREPARED:
2528 msgptr = "The MIDI header was not prepared. Use the Prepare function to prepare the header, and then try again.";
2530 case MIDIERR_STILLPLAYING:
2531 msgptr = "Cannot perform this operation while media data is still playing. Reset the device, or wait until the data is finished playing.";
2534 msgptr = "A MIDI map was not found. There may be a problem with the driver, or the MIDIMAP.CFG file may be corrupt or missing.";
2536 case MIDIERR_NOTREADY:
2537 msgptr = "The port is transmitting data to the device. Wait until the data has been transmitted, and then try again.";
2539 case MIDIERR_NODEVICE:
2540 msgptr = "The current MIDI Mapper setup refers to a MIDI device that is not installed on the system. Use MIDI Mapper to edit the setup.";
2542 case MIDIERR_INVALIDSETUP:
2543 msgptr = "The current MIDI setup is damaged. Copy the original MIDIMAP.CFG file to the Windows SYSTEM directory, and then try again.";
2546 msg# 336 : Cannot use the song-pointer time format and the SMPTE time-format together.
2547 msg# 337 : The specified MIDI device is already in use. Wait until it is free, and then try again.
2548 msg# 338 : The specified MIDI device is not installed on the system. Use the Drivers option in Control Panel to install the driver.
2549 msg# 339 : The current MIDI Mapper setup refers to a MIDI device that is not installed on the system. Use MIDI Mapper to edit the setup.
2550 msg# 340 : An error occurred using the specified port.
2551 msg# 341 : All multimedia timers are being used by other applications. Quit one of these applications, and then try again.
2552 msg# 342 : There is no current MIDI port.
2553 msg# 343 : There are no MIDI devices installed on the system. Use the Drivers option in Control Panel to install the driver.
2556 msgptr = "Unknown MIDI Error !\n";
2559 lstrcpynA(lpText, msgptr, uSize);
2563 /**************************************************************************
2564 * midiOutOpen [WINM.84]
2566 UINT WINAPI midiOutOpen(HMIDIOUT * lphMidiOut, UINT uDeviceID,
2567 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
2572 ret = midiOutOpen16(&hmo16,uDeviceID, dwCallback, dwInstance,
2573 CALLBACK32CONV(dwFlags));
2574 if (lphMidiOut) *lphMidiOut = hmo16;
2578 /**************************************************************************
2579 * midiOutOpen [MMSYSTEM.204]
2581 UINT16 WINAPI midiOutOpen16(HMIDIOUT16 * lphMidiOut, UINT16 uDeviceID,
2582 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
2585 LPMIDIOPENDESC lpDesc;
2587 BOOL bMapperFlg = FALSE;
2589 if (lphMidiOut != NULL) *lphMidiOut = 0;
2590 TRACE(mmsys, "(%p, %d, %08lX, %08lX, %08lX);\n",
2591 lphMidiOut, uDeviceID, dwCallback, dwInstance, dwFlags);
2592 if (uDeviceID == (UINT16)MIDI_MAPPER) {
2593 TRACE(mmsys, "MIDI_MAPPER mode requested !\n");
2597 hMidiOut = USER_HEAP_ALLOC(sizeof(MIDIOPENDESC));
2598 if (lphMidiOut != NULL)
2599 *lphMidiOut = hMidiOut;
2600 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2602 return MMSYSERR_NOMEM;
2603 lpDesc->hMidi = hMidiOut;
2604 lpDesc->dwCallback = dwCallback;
2605 lpDesc->dwInstance = dwInstance;
2607 while (uDeviceID < MAXMIDIDRIVERS) {
2608 dwRet = modMessage(uDeviceID, MODM_OPEN,
2609 lpDesc->dwInstance, (DWORD)lpDesc, dwFlags);
2610 if (dwRet == MMSYSERR_NOERROR) break;
2611 if (!bMapperFlg) break;
2613 TRACE(mmsys, "MIDI_MAPPER mode ! try next driver...\n");
2615 lpDesc->wDevID = uDeviceID;
2619 /**************************************************************************
2620 * midiOutClose [WINMM.74]
2622 UINT WINAPI midiOutClose(HMIDIOUT hMidiOut)
2624 return midiOutClose16(hMidiOut);
2627 /**************************************************************************
2628 * midiOutClose [MMSYSTEM.205]
2630 UINT16 WINAPI midiOutClose16(HMIDIOUT16 hMidiOut)
2632 LPMIDIOPENDESC lpDesc;
2634 TRACE(mmsys, "(%04X)\n", hMidiOut);
2636 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2637 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2638 return modMessage(lpDesc->wDevID, MODM_CLOSE, lpDesc->dwInstance, 0L, 0L);
2641 /**************************************************************************
2642 * midiOutPrepareHeader [WINMM.85]
2644 UINT WINAPI midiOutPrepareHeader(HMIDIOUT hMidiOut,
2645 MIDIHDR16 * lpMidiOutHdr, UINT uSize)
2647 LPMIDIOPENDESC lpDesc;
2649 TRACE(mmsys, "(%04X, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize);
2651 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2652 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2653 lpMidiOutHdr->reserved = (DWORD)lpMidiOutHdr->lpData;
2654 return modMessage(lpDesc->wDevID, MODM_PREPARE, lpDesc->dwInstance,
2655 (DWORD)lpMidiOutHdr, (DWORD)uSize);
2658 /**************************************************************************
2659 * midiOutPrepareHeader [MMSYSTEM.206]
2661 UINT16 WINAPI midiOutPrepareHeader16(HMIDIOUT16 hMidiOut,
2662 MIDIHDR16 * lpMidiOutHdr, UINT16 uSize)
2664 LPMIDIOPENDESC lpDesc;
2666 TRACE(mmsys, "(%04X, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize);
2668 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2669 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2670 lpMidiOutHdr->reserved = (DWORD)PTR_SEG_TO_LIN(lpMidiOutHdr->lpData);
2671 return modMessage(lpDesc->wDevID, MODM_PREPARE, lpDesc->dwInstance,
2672 (DWORD)lpMidiOutHdr, (DWORD)uSize);
2675 /**************************************************************************
2676 * midiOutUnprepareHeader [WINMM.89]
2678 UINT WINAPI midiOutUnprepareHeader(HMIDIOUT hMidiOut,
2679 MIDIHDR16 * lpMidiOutHdr, UINT uSize)
2681 return midiOutUnprepareHeader16(hMidiOut, lpMidiOutHdr,uSize);
2684 /**************************************************************************
2685 * midiOutUnprepareHeader [MMSYSTEM.207]
2687 UINT16 WINAPI midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut,
2688 MIDIHDR16 * lpMidiOutHdr, UINT16 uSize)
2690 LPMIDIOPENDESC lpDesc;
2692 TRACE(mmsys, "(%04X, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize);
2694 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2695 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2696 return modMessage(lpDesc->wDevID, MODM_UNPREPARE, lpDesc->dwInstance,
2697 (DWORD)lpMidiOutHdr, (DWORD)uSize);
2700 /**************************************************************************
2701 * midiOutShortMsg [WINMM.88]
2703 UINT WINAPI midiOutShortMsg(HMIDIOUT hMidiOut, DWORD dwMsg)
2705 return midiOutShortMsg16(hMidiOut, dwMsg);
2708 /**************************************************************************
2709 * midiOutShortMsg [MMSYSTEM.208]
2711 UINT16 WINAPI midiOutShortMsg16(HMIDIOUT16 hMidiOut, DWORD dwMsg)
2713 LPMIDIOPENDESC lpDesc;
2715 TRACE(mmsys, "(%04X, %08lX)\n", hMidiOut, dwMsg);
2717 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2718 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2719 return modMessage(lpDesc->wDevID, MODM_DATA, lpDesc->dwInstance, dwMsg, 0L);
2722 /**************************************************************************
2723 * midiOutLongMsg [WINMM.82]
2725 UINT WINAPI midiOutLongMsg(HMIDIOUT hMidiOut,
2726 MIDIHDR16 * lpMidiOutHdr, UINT uSize)
2728 return midiOutLongMsg16(hMidiOut, lpMidiOutHdr,uSize);
2731 /**************************************************************************
2732 * midiOutLongMsg [MMSYSTEM.209]
2734 UINT16 WINAPI midiOutLongMsg16(HMIDIOUT16 hMidiOut,
2735 MIDIHDR16 * lpMidiOutHdr, UINT16 uSize)
2737 LPMIDIOPENDESC lpDesc;
2739 TRACE(mmsys, "(%04X, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize);
2741 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2742 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2743 return modMessage(lpDesc->wDevID, MODM_LONGDATA, lpDesc->dwInstance,
2744 (DWORD)lpMidiOutHdr, (DWORD)uSize);
2747 /**************************************************************************
2748 * midiOutReset [WINMM.86]
2750 UINT WINAPI midiOutReset(HMIDIOUT hMidiOut)
2752 return midiOutReset16(hMidiOut);
2755 /**************************************************************************
2756 * midiOutReset [MMSYSTEM.210]
2758 UINT16 WINAPI midiOutReset16(HMIDIOUT16 hMidiOut)
2760 LPMIDIOPENDESC lpDesc;
2762 TRACE(mmsys, "(%04X)\n", hMidiOut);
2764 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2765 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2766 return modMessage(lpDesc->wDevID, MODM_RESET, lpDesc->dwInstance, 0L, 0L);
2769 /**************************************************************************
2770 * midiOutGetVolume [WINM.81]
2772 UINT WINAPI midiOutGetVolume(UINT uDeviceID, DWORD * lpdwVolume)
2774 return midiOutGetVolume16(uDeviceID, lpdwVolume);
2777 /**************************************************************************
2778 * midiOutGetVolume [MMSYSTEM.211]
2780 UINT16 WINAPI midiOutGetVolume16(UINT16 uDeviceID, DWORD * lpdwVolume)
2782 TRACE(mmsys, "(%04X, %p);\n", uDeviceID, lpdwVolume);
2783 return modMessage(uDeviceID, MODM_GETVOLUME, 0L, (DWORD)lpdwVolume, 0L);
2786 /**************************************************************************
2787 * midiOutSetVolume [WINMM.87]
2789 UINT WINAPI midiOutSetVolume(UINT uDeviceID, DWORD dwVolume)
2791 return midiOutSetVolume16(uDeviceID, dwVolume);
2794 /**************************************************************************
2795 * midiOutSetVolume [MMSYSTEM.212]
2797 UINT16 WINAPI midiOutSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
2799 TRACE(mmsys, "(%04X, %08lX);\n", uDeviceID, dwVolume);
2800 return modMessage(uDeviceID, MODM_SETVOLUME, 0L, dwVolume, 0L);
2803 /**************************************************************************
2804 * midiOutCachePatches [WINMM.73]
2806 UINT WINAPI midiOutCachePatches(HMIDIOUT hMidiOut, UINT uBank,
2807 WORD * lpwPatchArray, UINT uFlags)
2809 return midiOutCachePatches16(hMidiOut,uBank, lpwPatchArray,uFlags);
2812 /**************************************************************************
2813 * midiOutCachePatches [MMSYSTEM.213]
2815 UINT16 WINAPI midiOutCachePatches16(HMIDIOUT16 hMidiOut, UINT16 uBank,
2816 WORD * lpwPatchArray, UINT16 uFlags)
2818 /* not really necessary to support this */
2819 FIXME(mmsys, "not supported yet\n");
2820 return MMSYSERR_NOTSUPPORTED;
2823 /**************************************************************************
2824 * midiOutCacheDrumPatches [WINMM.72]
2826 UINT WINAPI midiOutCacheDrumPatches(HMIDIOUT hMidiOut, UINT uPatch,
2827 WORD * lpwKeyArray, UINT uFlags)
2829 return midiOutCacheDrumPatches16(hMidiOut,uPatch, lpwKeyArray,uFlags);
2832 /**************************************************************************
2833 * midiOutCacheDrumPatches [MMSYSTEM.214]
2835 UINT16 WINAPI midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut, UINT16 uPatch,
2836 WORD * lpwKeyArray, UINT16 uFlags)
2838 FIXME(mmsys, "not supported yet\n");
2839 return MMSYSERR_NOTSUPPORTED;
2842 /**************************************************************************
2843 * midiOutGetID [WINMM.79]
2845 UINT WINAPI midiOutGetID(HMIDIOUT hMidiOut, UINT * lpuDeviceID)
2850 ret = midiOutGetID16(hMidiOut, &xid);
2855 /**************************************************************************
2856 * midiOutGetID [MMSYSTEM.215]
2858 UINT16 WINAPI midiOutGetID16(HMIDIOUT16 hMidiOut, UINT16 * lpuDeviceID)
2860 TRACE(mmsys, "midiOutGetID\n");
2864 /**************************************************************************
2865 * midiOutMessage [WINMM.83]
2867 DWORD WINAPI midiOutMessage(HMIDIOUT hMidiOut, UINT uMessage,
2868 DWORD dwParam1, DWORD dwParam2)
2870 LPMIDIOPENDESC lpDesc;
2872 TRACE(mmsys, "(%04X, %04X, %08lX, %08lX)\n",
2873 hMidiOut, uMessage, dwParam1, dwParam2);
2874 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2875 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2878 FIXME(mmsys,"can't handle MODM_OPEN!\n");
2880 case MODM_GETDEVCAPS:
2881 return midiOutGetDevCapsA(hMidiOut, (LPMIDIOUTCAPSA)dwParam1, dwParam2);
2882 case MODM_GETNUMDEVS:
2885 case MODM_GETVOLUME:
2886 case MODM_SETVOLUME:
2889 case MODM_UNPREPARE:
2890 /* no argument conversion needed */
2893 ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
2894 hMidiOut,uMessage, dwParam1, dwParam2);
2897 return modMessage(lpDesc->wDevID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
2900 /**************************************************************************
2901 * midiOutMessage [MMSYSTEM.216]
2903 DWORD WINAPI midiOutMessage16(HMIDIOUT16 hMidiOut, UINT16 uMessage,
2904 DWORD dwParam1, DWORD dwParam2)
2906 LPMIDIOPENDESC lpDesc;
2908 TRACE(mmsys, "(%04X, %04X, %08lX, %08lX)\n",
2909 hMidiOut, uMessage, dwParam1, dwParam2);
2910 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiOut);
2911 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
2914 FIXME(mmsys,"can't handle MODM_OPEN!\n");
2916 case MODM_GETNUMDEVS:
2919 case MODM_SETVOLUME:
2920 /* no argument conversion needed */
2922 case MODM_GETVOLUME:
2923 return midiOutGetVolume16(hMidiOut, (LPDWORD)PTR_SEG_TO_LIN(dwParam1));
2925 return midiOutLongMsg16(hMidiOut, (LPMIDIHDR16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
2927 return midiOutPrepareHeader16(hMidiOut, (LPMIDIHDR16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
2928 case MODM_UNPREPARE:
2929 return midiOutUnprepareHeader16(hMidiOut, (LPMIDIHDR16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
2931 ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
2932 hMidiOut,uMessage, dwParam1, dwParam2);
2935 return modMessage(lpDesc->wDevID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
2938 /**************************************************************************
2939 * midiInGetNumDevs [WINMM.64]
2941 UINT WINAPI midiInGetNumDevs(void)
2943 return midiInGetNumDevs16();
2946 /**************************************************************************
2947 * midiInGetNumDevs [MMSYSTEM.301]
2949 UINT16 WINAPI midiInGetNumDevs16(void)
2952 TRACE(mmsys, "midiInGetNumDevs\n");
2953 count += midMessage(0, MIDM_GETNUMDEVS, 0L, 0L, 0L);
2954 TRACE(mmsys, "midiInGetNumDevs return %u \n", count);
2958 /**************************************************************************
2959 * midiInGetDevCaps [WINMM.60]
2961 UINT WINAPI midiInGetDevCapsW(UINT uDeviceID,
2962 LPMIDIINCAPSW lpCaps, UINT uSize)
2965 UINT ret = midiInGetDevCaps16(uDeviceID, &mic16,uSize);
2967 lpCaps->wMid = mic16.wMid;
2968 lpCaps->wPid = mic16.wPid;
2969 lpCaps->vDriverVersion = mic16.vDriverVersion;
2970 lstrcpyAtoW(lpCaps->szPname, mic16.szPname);
2971 lpCaps->dwSupport = mic16.dwSupport;
2975 /**************************************************************************
2976 * midiInGetDevCaps [WINMM.59]
2978 UINT WINAPI midiInGetDevCapsA(UINT uDeviceID,
2979 LPMIDIINCAPSA lpCaps, UINT uSize)
2982 UINT ret = midiInGetDevCaps16(uDeviceID, &mic16,uSize);
2984 lpCaps->wMid = mic16.wMid;
2985 lpCaps->wPid = mic16.wPid;
2986 lpCaps->vDriverVersion = mic16.vDriverVersion;
2987 strcpy(lpCaps->szPname, mic16.szPname);
2988 lpCaps->dwSupport = mic16.dwSupport;
2992 /**************************************************************************
2993 * midiInGetDevCaps [MMSYSTEM.302]
2995 UINT16 WINAPI midiInGetDevCaps16(UINT16 uDeviceID,
2996 LPMIDIINCAPS16 lpCaps, UINT16 uSize)
2998 TRACE(mmsys, "midiInGetDevCaps\n");
2999 return midMessage(uDeviceID, MIDM_GETDEVCAPS, 0, (DWORD)lpCaps, uSize);
3002 /**************************************************************************
3003 * midiInGetErrorText [WINMM.62]
3005 UINT WINAPI midiInGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
3007 LPSTR xstr = HeapAlloc(GetProcessHeap(), 0,uSize);
3008 UINT ret = midiInGetErrorText16(uError,xstr,uSize);
3009 lstrcpyAtoW(lpText,xstr);
3010 HeapFree(GetProcessHeap(), 0,xstr);
3014 /**************************************************************************
3015 * midiInGetErrorText [WINMM.61]
3017 UINT WINAPI midiInGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
3019 return midiInGetErrorText16(uError, lpText,uSize);
3022 /**************************************************************************
3023 * midiInGetErrorText [MMSYSTEM.303]
3025 UINT16 WINAPI midiInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
3027 TRACE(mmsys, "midiInGetErrorText\n");
3028 return (midiGetErrorText(uError, lpText, uSize));
3031 /**************************************************************************
3032 * midiInOpen [WINMM.66]
3034 UINT WINAPI midiInOpen(HMIDIIN * lphMidiIn, UINT uDeviceID,
3035 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
3038 UINT ret = midiInOpen16(&xhmid16,uDeviceID, dwCallback, dwInstance,
3039 CALLBACK32CONV(dwFlags));
3041 *lphMidiIn = xhmid16;
3045 /**************************************************************************
3046 * midiInOpen [MMSYSTEM.304]
3048 UINT16 WINAPI midiInOpen16(HMIDIIN16 * lphMidiIn, UINT16 uDeviceID,
3049 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
3052 LPMIDIOPENDESC lpDesc;
3054 BOOL bMapperFlg = FALSE;
3056 if (lphMidiIn != NULL)
3058 TRACE(mmsys, "(%p, %d, %08lX, %08lX, %08lX);\n",
3059 lphMidiIn, uDeviceID, dwCallback, dwInstance, dwFlags);
3060 if (uDeviceID == (UINT16)MIDI_MAPPER) {
3061 TRACE(mmsys, "MIDI_MAPPER mode requested !\n");
3065 hMidiIn = USER_HEAP_ALLOC(sizeof(MIDIOPENDESC));
3066 if (lphMidiIn != NULL)
3067 *lphMidiIn = hMidiIn;
3068 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3070 return MMSYSERR_NOMEM;
3071 lpDesc->hMidi = hMidiIn;
3072 lpDesc->dwCallback = dwCallback;
3073 lpDesc->dwInstance = dwInstance;
3075 while (uDeviceID < MAXMIDIDRIVERS) {
3076 dwRet = midMessage(uDeviceID, MIDM_OPEN,
3077 lpDesc->dwInstance, (DWORD)lpDesc, dwFlags);
3078 if (dwRet == MMSYSERR_NOERROR)
3083 TRACE(mmsys, "MIDI_MAPPER mode ! try next driver...\n");
3085 lpDesc->wDevID = uDeviceID;
3089 /**************************************************************************
3090 * midiInClose [WINMM.58]
3092 UINT WINAPI midiInClose(HMIDIIN hMidiIn)
3094 return midiInClose16(hMidiIn);
3097 /**************************************************************************
3098 * midiInClose [MMSYSTEM.305]
3100 UINT16 WINAPI midiInClose16(HMIDIIN16 hMidiIn)
3102 LPMIDIOPENDESC lpDesc;
3103 TRACE(mmsys, "(%04X)\n", hMidiIn);
3104 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3105 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3106 return midMessage(lpDesc->wDevID, MIDM_CLOSE, lpDesc->dwInstance, 0L, 0L);
3109 /**************************************************************************
3110 * midiInPrepareHeader [WINMM.67]
3112 UINT WINAPI midiInPrepareHeader(HMIDIIN hMidiIn,
3113 MIDIHDR16 * lpMidiInHdr, UINT uSize)
3115 LPMIDIOPENDESC lpDesc;
3117 TRACE(mmsys, "(%04X, %p, %d)\n",
3118 hMidiIn, lpMidiInHdr, uSize);
3119 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3120 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3121 lpMidiInHdr->reserved = (DWORD)lpMidiInHdr->lpData;
3122 return midMessage(lpDesc->wDevID, MIDM_PREPARE, lpDesc->dwInstance,
3123 (DWORD)lpMidiInHdr, (DWORD)uSize);
3126 /**************************************************************************
3127 * midiInPrepareHeader [MMSYSTEM.306]
3129 UINT16 WINAPI midiInPrepareHeader16(HMIDIIN16 hMidiIn,
3130 MIDIHDR16 * lpMidiInHdr, UINT16 uSize)
3132 LPMIDIOPENDESC lpDesc;
3134 TRACE(mmsys, "(%04X, %p, %d)\n",
3135 hMidiIn, lpMidiInHdr, uSize);
3136 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3137 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3138 lpMidiInHdr->reserved = (DWORD)PTR_SEG_TO_LIN(lpMidiInHdr->lpData);
3139 return midMessage(lpDesc->wDevID, MIDM_PREPARE, lpDesc->dwInstance,
3140 (DWORD)lpMidiInHdr, (DWORD)uSize);
3143 /**************************************************************************
3144 * midiInUnprepareHeader [WINMM.71]
3146 UINT WINAPI midiInUnprepareHeader(HMIDIIN hMidiIn,
3147 MIDIHDR16 * lpMidiInHdr, UINT uSize)
3149 return midiInUnprepareHeader16(hMidiIn, lpMidiInHdr,uSize);
3152 /**************************************************************************
3153 * midiInUnprepareHeader [MMSYSTEM.307]
3155 UINT16 WINAPI midiInUnprepareHeader16(HMIDIIN16 hMidiIn,
3156 MIDIHDR16 * lpMidiInHdr, UINT16 uSize)
3158 LPMIDIOPENDESC lpDesc;
3159 TRACE(mmsys, "(%04X, %p, %d)\n",
3160 hMidiIn, lpMidiInHdr, uSize);
3161 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3162 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3163 return midMessage(lpDesc->wDevID, MIDM_UNPREPARE, lpDesc->dwInstance,
3164 (DWORD)lpMidiInHdr, (DWORD)uSize);
3167 /**************************************************************************
3168 * midiInAddBuffer [WINMM.57]
3170 UINT WINAPI midiInAddBuffer(HMIDIIN hMidiIn,
3171 MIDIHDR16 * lpMidiInHdr, UINT uSize)
3173 return midiInAddBuffer16(hMidiIn, lpMidiInHdr,uSize);
3176 /**************************************************************************
3177 * midiInAddBuffer [MMSYSTEM.308]
3179 UINT16 WINAPI midiInAddBuffer16(HMIDIIN16 hMidiIn,
3180 MIDIHDR16 * lpMidiInHdr, UINT16 uSize)
3182 TRACE(mmsys, "midiInAddBuffer\n");
3186 /**************************************************************************
3187 * midiInStart [WINMM.69]
3189 UINT WINAPI midiInStart(HMIDIIN hMidiIn)
3191 return midiInStart16(hMidiIn);
3194 /**************************************************************************
3195 * midiInStart [MMSYSTEM.309]
3197 UINT16 WINAPI midiInStart16(HMIDIIN16 hMidiIn)
3199 LPMIDIOPENDESC lpDesc;
3201 TRACE(mmsys, "(%04X)\n", hMidiIn);
3202 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3204 return MMSYSERR_INVALHANDLE;
3205 return midMessage(lpDesc->wDevID, MIDM_START, lpDesc->dwInstance, 0L, 0L);
3208 /**************************************************************************
3209 * midiInStop [WINMM.70]
3211 UINT WINAPI midiInStop(HMIDIIN hMidiIn)
3213 return midiInStop16(hMidiIn);
3216 /**************************************************************************
3217 * midiInStop [MMSYSTEM.310]
3219 UINT16 WINAPI midiInStop16(HMIDIIN16 hMidiIn)
3221 LPMIDIOPENDESC lpDesc;
3223 TRACE(mmsys, "(%04X)\n", hMidiIn);
3224 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3226 return MMSYSERR_INVALHANDLE;
3227 return midMessage(lpDesc->wDevID, MIDM_STOP, lpDesc->dwInstance, 0L, 0L);
3230 /**************************************************************************
3231 * midiInReset [WINMM.68]
3233 UINT WINAPI midiInReset(HMIDIIN hMidiIn)
3235 return midiInReset16(hMidiIn);
3238 /**************************************************************************
3239 * midiInReset [MMSYSTEM.311]
3241 UINT16 WINAPI midiInReset16(HMIDIIN16 hMidiIn)
3243 LPMIDIOPENDESC lpDesc;
3245 TRACE(mmsys, "(%04X)\n", hMidiIn);
3246 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3248 return MMSYSERR_INVALHANDLE;
3249 return midMessage(lpDesc->wDevID, MIDM_RESET, lpDesc->dwInstance, 0L, 0L);
3252 /**************************************************************************
3253 * midiInGetID [WINMM.63]
3255 UINT WINAPI midiInGetID(HMIDIIN hMidiIn, UINT* lpuDeviceID)
3257 LPMIDIOPENDESC lpDesc;
3259 TRACE(mmsys, "(%04X, %p)\n", hMidiIn, lpuDeviceID);
3260 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3262 return MMSYSERR_INVALHANDLE;
3263 if (lpuDeviceID == NULL)
3264 return MMSYSERR_INVALPARAM;
3265 *lpuDeviceID = lpDesc->wDevID;
3267 return MMSYSERR_NOERROR;
3270 /**************************************************************************
3271 * midiInGetID [MMSYSTEM.312]
3273 UINT16 WINAPI midiInGetID16(HMIDIIN16 hMidiIn, UINT16* lpuDeviceID)
3275 LPMIDIOPENDESC lpDesc;
3277 TRACE(mmsys, "(%04X, %p)\n", hMidiIn, lpuDeviceID);
3278 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3280 return MMSYSERR_INVALHANDLE;
3281 if (lpuDeviceID == NULL)
3282 return MMSYSERR_INVALPARAM;
3283 *lpuDeviceID = lpDesc->wDevID;
3285 return MMSYSERR_NOERROR;
3288 /**************************************************************************
3289 * midiInMessage [WINMM.65]
3291 DWORD WINAPI midiInMessage(HMIDIIN hMidiIn, UINT uMessage,
3292 DWORD dwParam1, DWORD dwParam2)
3294 LPMIDIOPENDESC lpDesc;
3296 TRACE(mmsys, "(%04X, %04X, %08lX, %08lX)\n",
3297 hMidiIn, uMessage, dwParam1, dwParam2);
3298 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3300 return MMSYSERR_INVALHANDLE;
3304 FIXME(mmsys,"can't handle MIDM_OPEN!\n");
3306 case MIDM_GETDEVCAPS:
3307 return midiInGetDevCapsA(hMidiIn, (LPMIDIINCAPSA)dwParam1, dwParam2);
3308 case MIDM_GETNUMDEVS:
3313 /* no argument conversion needed */
3316 return midiInPrepareHeader(hMidiIn, (LPMIDIHDR16)dwParam1, dwParam2);
3317 case MIDM_UNPREPARE:
3318 return midiInUnprepareHeader(hMidiIn, (LPMIDIHDR16)dwParam1, dwParam2);
3319 case MIDM_ADDBUFFER:
3320 return midiInAddBuffer(hMidiIn, (LPMIDIHDR16)dwParam1, dwParam2);
3322 ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
3323 hMidiIn,uMessage, dwParam1, dwParam2);
3326 return midMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
3329 /**************************************************************************
3330 * midiInMessage [MMSYSTEM.313]
3332 DWORD WINAPI midiInMessage16(HMIDIIN16 hMidiIn, UINT16 uMessage,
3333 DWORD dwParam1, DWORD dwParam2)
3335 LPMIDIOPENDESC lpDesc;
3337 TRACE(mmsys, "(%04X, %04X, %08lX, %08lX)\n", hMidiIn, uMessage, dwParam1, dwParam2);
3339 lpDesc = (LPMIDIOPENDESC) USER_HEAP_LIN_ADDR(hMidiIn);
3340 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3343 WARN(mmsys,"can't handle MIDM_OPEN!\n");
3345 case MIDM_GETDEVCAPS:
3346 return midiInGetDevCaps16(hMidiIn, (LPMIDIINCAPS16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
3347 case MIDM_GETNUMDEVS:
3352 /* no argument conversion needed */
3355 return midiInPrepareHeader16(hMidiIn, (LPMIDIHDR16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
3356 case MIDM_UNPREPARE:
3357 return midiInUnprepareHeader16(hMidiIn, (LPMIDIHDR16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
3358 case MIDM_ADDBUFFER:
3359 return midiInAddBuffer16(hMidiIn, (LPMIDIHDR16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
3361 ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
3362 hMidiIn,uMessage, dwParam1, dwParam2);
3365 return midMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
3368 #define MIDI_STREAM_MAGIC 0xC9080F17
3378 LPMIDIHDR lpMidiHdr;
3381 /**************************************************************************
3382 * MMSYSTEM_MidiStreamPlayer [internal]
3384 static void MMSYSTEM_MidiStreamPlayer(WINE_MIDIStream* ms)
3386 /* FIXME: should I sleep a bit when there is no pending lpMidiHdr ?
3387 * => provide a better synchronization system
3388 * midiStreamPause/midiStreamRestart should freeze/thaw this thread
3389 * global resource should guard access to ms->lpMidiHdr list, or
3390 * use a MB to send new LPMIDIHDR
3391 * an empty ms->lpMidiHdr list should freeze this thread
3394 if (ms->dwStatus && ms->lpMidiHdr) {
3395 LPMIDIEVENT me = (LPMIDIEVENT)(ms->lpMidiHdr->lpData + ms->lpMidiHdr->dwOffset);
3397 FIXME(mmsys, "Should wait for current time to be in sync with me->dwDeltaTime\n");
3399 if (me->dwEvent & MEVT_F_CALLBACK) {
3400 WARN(mmsys, "Should generate callback when encountering F_CALLBACK flagged midi events...\n");
3402 switch (MEVT_EVENTTYPE(me->dwEvent)) {
3404 /* do nothing, skip bytes */
3407 WARN(mmsys, "NIY: sending Sysex Event");
3412 midiOutShortMsg(ms->hDevice, MEVT_EVENTPARM(me->dwEvent));
3415 ms->dwTempo = MEVT_EVENTPARM(me->dwEvent);
3420 ms->lpMidiHdr->dwOffset += sizeof(MIDIEVENT);
3421 if (me->dwEvent & MEVT_F_LONG) {
3422 ms->lpMidiHdr->dwOffset += MEVT_EVENTPARM(me->dwEvent);
3424 if (ms->lpMidiHdr->dwOffset >= ms->lpMidiHdr->dwBufferLength) {
3425 ms->lpMidiHdr->dwFlags |= MHDR_DONE;
3426 ms->lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
3427 ms->lpMidiHdr = (LPMIDIHDR)ms->lpMidiHdr->lpNext;
3428 WARN(mmsys, "Should generate callback when done with MIDIHDR...\n");
3430 FIXME(mmsys, "Should accordingly update ms->dwMS with me->dwDeltaTime\n");
3435 /**************************************************************************
3436 * midiStreamClose [WINMM.90]
3438 MMRESULT WINAPI midiStreamClose(HMIDISTRM hms)
3440 WINE_MIDIStream* ms;
3442 TRACE(midi, "(%08x)!\n", hms);
3444 ms = (WINE_MIDIStream*)hms;
3445 if (!ms || ms->dwMagic != MIDI_STREAM_MAGIC)
3446 return MMSYSERR_INVALHANDLE;
3450 return MMSYSERR_NOTSUPPORTED;
3453 /**************************************************************************
3454 * midiStreamOpen [WINMM.91]
3456 MMRESULT WINAPI midiStreamOpen(HMIDISTRM* phms, LPUINT lpuDeviceID,
3457 DWORD cMidi, DWORD dwCallback,
3458 DWORD dwInstance, DWORD fdwOpen)
3460 WINE_MIDIStream* ms;
3462 TRACE(midi, "(%p,%p,%ld, 0x%08lx, 0x%08lx, 0x%08lx), stub!\n",
3463 phms, lpuDeviceID,cMidi, dwCallback, dwInstance, fdwOpen);
3465 if (cMidi != 1 || phms == NULL || lpuDeviceID == NULL)
3466 return MMSYSERR_INVALPARAM;
3468 ms = malloc(sizeof(WINE_MIDIStream));
3469 *phms = (HMIDISTRM)ms;
3470 ms->dwMagic = MIDI_STREAM_MAGIC;
3471 ms->dwTempo = 50000; /* FIXME */
3472 ms->dwTimeDiv = 1; /* FIXME */
3476 /* FIXME is this correct ? */
3478 /* FIXME is this correct ? */
3479 return midiOutOpen(&(ms->hDevice), *lpuDeviceID, dwCallback, dwInstance, fdwOpen);
3482 /**************************************************************************
3483 * midiStreamOut [WINMM.92]
3485 MMRESULT WINAPI midiStreamOut(HMIDISTRM hms, LPMIDIHDR16 lpMidiHdr, UINT cbMidiHdr)
3487 FIXME(midi, "(%08x, %p, %u) stub!\n", hms, lpMidiHdr, cbMidiHdr);
3488 return MMSYSERR_NOTSUPPORTED;
3491 /**************************************************************************
3492 * midiStreamPause [WINMM.93]
3494 MMRESULT WINAPI midiStreamPause(HMIDISTRM hms)
3496 WINE_MIDIStream* ms;
3498 TRACE(midi, "(%08x)!\n", hms);
3500 ms = (WINE_MIDIStream*)hms;
3501 if (!ms || ms->dwMagic != MIDI_STREAM_MAGIC)
3502 return MMSYSERR_INVALHANDLE;
3505 return MMSYSERR_NOERROR;
3508 /**************************************************************************
3509 * midiStreamPosition [WINMM.94]
3511 MMRESULT WINAPI midiStreamPosition(HMIDISTRM hms, LPMMTIME lpMMT, UINT cbmmt)
3513 WINE_MIDIStream* ms;
3514 DWORD ret = MMSYSERR_NOERROR;
3516 FIXME(midi, "(%08x, %p, %u) stub!\n", hms, lpMMT, cbmmt);
3518 ms = (WINE_MIDIStream*)hms;
3520 if (!ms || ms->dwMagic != MIDI_STREAM_MAGIC) {
3521 ret = MMSYSERR_INVALHANDLE;
3522 } else if (lpMMT == NULL || cbmmt != sizeof(MMTIME)) {
3523 ret = MMSYSERR_INVALPARAM;
3525 switch (lpMMT->wType) {
3527 lpMMT->u.ms = ms->dwMS;
3530 lpMMT->wType = TIME_MS;
3531 ret = MMSYSERR_INVALPARAM;
3537 /**************************************************************************
3538 * midiStreamProperty [WINMM.95]
3540 MMRESULT WINAPI midiStreamProperty(HMIDISTRM hms, LPBYTE lpPropData, DWORD dwProperty)
3542 WINE_MIDIStream* ms = (WINE_MIDIStream*)hms;
3543 MMRESULT ret = MMSYSERR_NOERROR;
3545 TRACE(midi, "(%08x, %p, %lx)\n", hms, lpPropData, dwProperty);
3547 if (!ms || ms->dwMagic != MIDI_STREAM_MAGIC) {
3548 ret = MMSYSERR_INVALHANDLE;
3549 } else if ((dwProperty & (MIDIPROP_GET|MIDIPROP_SET)) == 0) {
3550 return MMSYSERR_INVALPARAM;
3551 } else if (dwProperty & MIDIPROP_TEMPO) {
3552 MIDIPROPTEMPO* mpt = (MIDIPROPTEMPO*)lpPropData;
3554 if (sizeof(MIDIPROPTEMPO) != mpt->cbStruct) {
3555 ret = MMSYSERR_INVALPARAM;
3556 } else if (dwProperty & MIDIPROP_GET) {
3557 ms->dwTempo = mpt->dwTempo;
3558 } else if (dwProperty & MIDIPROP_SET) {
3559 mpt->dwTempo = ms->dwTempo;
3561 } else if (dwProperty & MIDIPROP_TIMEDIV) {
3562 MIDIPROPTIMEDIV* mptd = (MIDIPROPTIMEDIV*)lpPropData;
3564 if (sizeof(MIDIPROPTIMEDIV) != mptd->cbStruct) {
3565 ret = MMSYSERR_INVALPARAM;
3566 } else if (dwProperty & MIDIPROP_GET) {
3567 ms->dwTimeDiv = mptd->dwTimeDiv;
3568 } else if (dwProperty & MIDIPROP_SET) {
3569 mptd->dwTimeDiv = ms->dwTimeDiv;
3572 ret = MMSYSERR_INVALPARAM;
3578 /**************************************************************************
3579 * midiStreamRestart [WINMM.96]
3581 MMRESULT WINAPI midiStreamRestart(HMIDISTRM hms)
3583 WINE_MIDIStream* ms;
3585 TRACE(midi, "(%08x)!\n", hms);
3587 ms = (WINE_MIDIStream*)hms;
3588 if (!ms || ms->dwMagic != MIDI_STREAM_MAGIC)
3589 return MMSYSERR_INVALHANDLE;
3592 return MMSYSERR_NOERROR;
3595 /**************************************************************************
3596 * midiStreamStop [WINMM.97]
3598 MMRESULT WINAPI midiStreamStop(HMIDISTRM hms)
3600 FIXME(midi, "(%08x stub!)\n", hms);
3601 return MMSYSERR_NOTSUPPORTED;
3604 /**************************************************************************
3605 * midiStreamClose [MMSYSTEM.252]
3607 MMRESULT16 WINAPI midiStreamClose16(HMIDISTRM16 hms)
3609 return midiStreamClose(hms);
3612 /**************************************************************************
3613 * midiStreamOpen [MMSYSTEM.251]
3615 MMRESULT16 WINAPI midiStreamOpen16(HMIDISTRM16* phms, LPUINT16 devid,
3616 DWORD cMidi, DWORD dwCallback,
3617 DWORD dwInstance, DWORD fdwOpen)
3623 if (!phms || !devid)
3624 return MMSYSERR_INVALPARAM;
3626 ret = midiStreamOpen(&hms32, &devid32, cMidi, dwCallback, dwInstance, fdwOpen);
3632 /**************************************************************************
3633 * midiStreamOut [MMSYSTEM.254]
3635 MMRESULT16 WINAPI midiStreamOut16(HMIDISTRM16 hms, LPMIDIHDR16 lpMidiHdr, UINT16 cbMidiHdr)
3637 return midiStreamOut(hms, lpMidiHdr, cbMidiHdr);
3640 /**************************************************************************
3641 * midiStreamPause [MMSYSTEM.255]
3643 MMRESULT16 WINAPI midiStreamPause16(HMIDISTRM16 hms)
3645 return midiStreamPause(hms);
3648 /**************************************************************************
3649 * midiStreamPosition [MMSYSTEM.253]
3651 MMRESULT16 WINAPI midiStreamPosition16(HMIDISTRM16 hms, LPMMTIME16 lpmmt, UINT16 cbmmt)
3657 return MMSYSERR_INVALPARAM;
3658 MMSYSTEM_MMTIME16to32(&mmt32, lpmmt);
3659 ret = midiStreamPosition(hms, &mmt32, cbmmt);
3660 MMSYSTEM_MMTIME32to16(lpmmt, &mmt32);
3664 /**************************************************************************
3665 * midiStreamProperty [MMSYSTEM.250]
3667 MMRESULT16 WINAPI midiStreamProperty16(HMIDISTRM16 hms, LPBYTE lpPropData, DWORD dwProperty)
3669 return midiStreamProperty(hms, lpPropData, dwProperty);
3672 /**************************************************************************
3673 * midiStreamRestart [MMSYSTEM.256]
3675 MMRESULT16 WINAPI midiStreamRestart16(HMIDISTRM16 hms)
3677 return midiStreamRestart(hms);
3680 /**************************************************************************
3681 * midiStreamStop [MMSYSTEM.257]
3683 MMRESULT16 WINAPI midiStreamStop16(HMIDISTRM16 hms)
3685 return midiStreamStop(hms);
3688 /**************************************************************************
3689 * waveOutGetNumDevs [MMSYSTEM.401]
3691 UINT WINAPI waveOutGetNumDevs() {
3692 return waveOutGetNumDevs16();
3695 /**************************************************************************
3696 * waveOutGetNumDevs [WINMM.167]
3698 UINT16 WINAPI waveOutGetNumDevs16()
3701 TRACE(mmsys, "waveOutGetNumDevs\n");
3702 /* FIXME: I'm not sure MCI_FirstDevID() is correct */
3703 count += wodMessage(MCI_FirstDevID(), WODM_GETNUMDEVS, 0L, 0L, 0L);
3704 TRACE(mmsys, "waveOutGetNumDevs return %u \n", count);
3708 /**************************************************************************
3709 * waveOutGetDevCaps [MMSYSTEM.402]
3711 UINT16 WINAPI waveOutGetDevCaps16(UINT16 uDeviceID, WAVEOUTCAPS16 * lpCaps,
3714 if (uDeviceID > waveOutGetNumDevs16() - 1) return MMSYSERR_BADDEVICEID;
3715 if (uDeviceID == (UINT16)WAVE_MAPPER) return MMSYSERR_BADDEVICEID; /* FIXME: do we have a wave mapper ? */
3716 TRACE(mmsys, "waveOutGetDevCaps\n");
3717 return wodMessage(uDeviceID, WODM_GETDEVCAPS, 0L, (DWORD)lpCaps, uSize);
3720 /**************************************************************************
3721 * waveOutGetDevCapsA [WINMM.162]
3723 UINT WINAPI waveOutGetDevCapsA(UINT uDeviceID, LPWAVEOUTCAPSA lpCaps,
3726 WAVEOUTCAPS16 woc16;
3727 UINT16 ret = waveOutGetDevCaps16(uDeviceID, &woc16, sizeof(woc16));
3729 lpCaps->wMid = woc16.wMid;
3730 lpCaps->wPid = woc16.wPid;
3731 lpCaps->vDriverVersion = woc16.vDriverVersion;
3732 strcpy(lpCaps->szPname, woc16.szPname);
3733 lpCaps->dwFormats = woc16.dwFormats;
3734 lpCaps->wChannels = woc16.wChannels;
3735 lpCaps->dwSupport = woc16.dwSupport;
3739 /**************************************************************************
3740 * waveOutGetDevCapsW [WINMM.163]
3742 UINT WINAPI waveOutGetDevCapsW(UINT uDeviceID, LPWAVEOUTCAPSW lpCaps,
3745 WAVEOUTCAPS16 woc16;
3746 UINT ret = waveOutGetDevCaps16(uDeviceID, &woc16, sizeof(woc16));
3748 lpCaps->wMid = woc16.wMid;
3749 lpCaps->wPid = woc16.wPid;
3750 lpCaps->vDriverVersion = woc16.vDriverVersion;
3751 lstrcpyAtoW(lpCaps->szPname, woc16.szPname);
3752 lpCaps->dwFormats = woc16.dwFormats;
3753 lpCaps->wChannels = woc16.wChannels;
3754 lpCaps->dwSupport = woc16.dwSupport;
3758 /**************************************************************************
3759 * waveOutGetErrorText [MMSYSTEM.403]
3761 UINT16 WINAPI waveOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
3763 TRACE(mmsys, "waveOutGetErrorText\n");
3764 return(waveGetErrorText(uError, lpText, uSize));
3767 /**************************************************************************
3768 * waveOutGetErrorTextA [WINMM.164]
3770 UINT WINAPI waveOutGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
3772 return(waveOutGetErrorText16(uError, lpText, uSize));
3775 /**************************************************************************
3776 * waveOutGetErrorTextW [WINMM.165]
3778 UINT WINAPI waveOutGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
3780 LPSTR xstr = HeapAlloc(GetProcessHeap(), 0,uSize);
3781 UINT ret = waveOutGetErrorTextA(uError, xstr, uSize);
3783 lstrcpyAtoW(lpText,xstr);
3784 HeapFree(GetProcessHeap(), 0,xstr);
3788 /**************************************************************************
3789 * waveGetErrorText [internal]
3791 static UINT16 waveGetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
3794 TRACE(mmsys, "(%04X, %p, %d);\n",
3795 uError, lpText, uSize);
3796 if ((lpText == NULL) || (uSize < 1)) return(FALSE);
3799 case MMSYSERR_NOERROR:
3800 msgptr = "The specified command was carried out.";
3802 case MMSYSERR_ERROR:
3803 msgptr = "Undefined external error.";
3805 case MMSYSERR_BADDEVICEID:
3806 msgptr = "A device ID has been used that is out of range for your system.";
3808 case MMSYSERR_NOTENABLED:
3809 msgptr = "The driver was not enabled.";
3811 case MMSYSERR_ALLOCATED:
3812 msgptr = "The specified device is already in use. Wait until it is free, and then try again.";
3814 case MMSYSERR_INVALHANDLE:
3815 msgptr = "The specified device handle is invalid.";
3817 case MMSYSERR_NODRIVER:
3818 msgptr = "There is no driver installed on your system !\n";
3820 case MMSYSERR_NOMEM:
3821 msgptr = "Not enough memory available for this task. Quit one or more applications to increase available memory, and then try again.";
3823 case MMSYSERR_NOTSUPPORTED:
3824 msgptr = "This function is not supported. Use the Capabilities function to determine which functions and messages the driver supports.";
3826 case MMSYSERR_BADERRNUM:
3827 msgptr = "An error number was specified that is not defined in the system.";
3829 case MMSYSERR_INVALFLAG:
3830 msgptr = "An invalid flag was passed to a system function.";
3832 case MMSYSERR_INVALPARAM:
3833 msgptr = "An invalid parameter was passed to a system function.";
3835 case WAVERR_BADFORMAT:
3836 msgptr = "The specified format is not supported or cannot be translated. Use the Capabilities function to determine the supported formats";
3838 case WAVERR_STILLPLAYING:
3839 msgptr = "Cannot perform this operation while media data is still playing. Reset the device, or wait until the data is finished playing.";
3841 case WAVERR_UNPREPARED:
3842 msgptr = "The wave header was not prepared. Use the Prepare function to prepare the header, and then try again.";
3845 msgptr = "Cannot open the device without using the WAVE_ALLOWSYNC flag. Use the flag, and then try again.";
3848 msgptr = "Unknown MMSYSTEM Error !\n";
3851 lstrcpynA(lpText, msgptr, uSize);
3855 /**************************************************************************
3856 * waveOutOpen [WINMM.173]
3857 * All the args/structs have the same layout as the win16 equivalents
3859 UINT WINAPI waveOutOpen(HWAVEOUT * lphWaveOut, UINT uDeviceID,
3860 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
3861 DWORD dwInstance, DWORD dwFlags)
3864 UINT ret = waveOutOpen16(&hwo16,uDeviceID, lpFormat, dwCallback, dwInstance,
3865 CALLBACK32CONV(dwFlags));
3867 if (lphWaveOut) *lphWaveOut=hwo16;
3871 /**************************************************************************
3872 * waveOutOpen [MMSYSTEM.404]
3874 UINT16 WINAPI waveOutOpen16(HWAVEOUT16 * lphWaveOut, UINT16 uDeviceID,
3875 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
3876 DWORD dwInstance, DWORD dwFlags)
3878 HWAVEOUT16 hWaveOut;
3879 LPWAVEOPENDESC lpDesc;
3881 BOOL bMapperFlg = FALSE;
3883 TRACE(mmsys, "(%p, %d, %p, %08lX, %08lX, %08lX);\n",
3884 lphWaveOut, uDeviceID, lpFormat, dwCallback, dwInstance, dwFlags);
3885 if (dwFlags & WAVE_FORMAT_QUERY)
3886 TRACE(mmsys, "WAVE_FORMAT_QUERY requested !\n");
3887 if (uDeviceID == (UINT16)WAVE_MAPPER) {
3888 TRACE(mmsys, "WAVE_MAPPER mode requested !\n");
3892 if (lpFormat == NULL) return WAVERR_BADFORMAT;
3894 hWaveOut = USER_HEAP_ALLOC(sizeof(WAVEOPENDESC));
3895 if (lphWaveOut != NULL) *lphWaveOut = hWaveOut;
3896 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
3897 if (lpDesc == NULL) return MMSYSERR_NOMEM;
3898 lpDesc->hWave = hWaveOut;
3899 lpDesc->lpFormat = (LPWAVEFORMAT)lpFormat; /* should the struct be copied iso pointer? */
3900 lpDesc->dwCallBack = dwCallback;
3901 lpDesc->dwInstance = dwInstance;
3902 if (uDeviceID >= MAXWAVEDRIVERS)
3904 while (uDeviceID < MAXWAVEDRIVERS) {
3905 dwRet = wodMessage(uDeviceID, WODM_OPEN,
3906 lpDesc->dwInstance, (DWORD)lpDesc, dwFlags);
3907 if (dwRet == MMSYSERR_NOERROR) break;
3908 if (!bMapperFlg) break;
3910 TRACE(mmsys, "WAVE_MAPPER mode ! try next driver...\n");
3912 lpDesc->uDeviceID = uDeviceID; /* save physical Device ID */
3913 if (dwFlags & WAVE_FORMAT_QUERY) {
3914 TRACE(mmsys, "End of WAVE_FORMAT_QUERY !\n");
3915 dwRet = waveOutClose(hWaveOut);
3920 /**************************************************************************
3921 * waveOutClose [WINMM.161]
3923 UINT WINAPI waveOutClose(HWAVEOUT hWaveOut)
3925 return waveOutClose16(hWaveOut);
3928 /**************************************************************************
3929 * waveOutClose [MMSYSTEM.405]
3931 UINT16 WINAPI waveOutClose16(HWAVEOUT16 hWaveOut)
3933 LPWAVEOPENDESC lpDesc;
3935 TRACE(mmsys, "(%04X)\n", hWaveOut);
3937 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
3938 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3939 return wodMessage(lpDesc->uDeviceID, WODM_CLOSE, lpDesc->dwInstance, 0L, 0L);
3942 /**************************************************************************
3943 * waveOutPrepareHeader [WINMM.175]
3945 UINT WINAPI waveOutPrepareHeader(HWAVEOUT hWaveOut,
3946 WAVEHDR* lpWaveOutHdr, UINT uSize)
3948 LPWAVEOPENDESC lpDesc;
3950 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
3952 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
3953 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3954 lpWaveOutHdr->reserved = (DWORD)lpWaveOutHdr->lpData;
3955 return wodMessage(lpDesc->uDeviceID, WODM_PREPARE, lpDesc->dwInstance,
3956 (DWORD)lpWaveOutHdr,uSize);
3959 /**************************************************************************
3960 * waveOutPrepareHeader [MMSYSTEM.406]
3962 UINT16 WINAPI waveOutPrepareHeader16(HWAVEOUT16 hWaveOut,
3963 WAVEHDR* lpWaveOutHdr, UINT16 uSize)
3965 LPWAVEOPENDESC lpDesc;
3968 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
3970 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
3971 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3972 lpWaveOutHdr->reserved = (DWORD)lpWaveOutHdr->lpData;
3973 lpWaveOutHdr->lpData = PTR_SEG_TO_LIN(lpWaveOutHdr->lpData);
3974 ret = wodMessage(lpDesc->uDeviceID, WODM_PREPARE, lpDesc->dwInstance,
3975 (DWORD)lpWaveOutHdr,uSize);
3976 lpWaveOutHdr->lpData = lpWaveOutHdr->lpData;
3980 /**************************************************************************
3981 * waveOutUnprepareHeader [WINMM.181]
3983 UINT WINAPI waveOutUnprepareHeader(HWAVEOUT hWaveOut,
3984 WAVEHDR* lpWaveOutHdr, UINT uSize)
3986 LPWAVEOPENDESC lpDesc;
3988 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
3990 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
3991 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
3992 lpWaveOutHdr->reserved = (DWORD)lpWaveOutHdr->lpData;
3993 return wodMessage(lpDesc->uDeviceID, WODM_UNPREPARE, lpDesc->dwInstance,
3994 (DWORD)lpWaveOutHdr, uSize);
3997 /**************************************************************************
3998 * waveOutUnprepareHeader [MMSYSTEM.407]
4000 UINT16 WINAPI waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut,
4001 WAVEHDR* lpWaveOutHdr, UINT16 uSize)
4003 LPWAVEOPENDESC lpDesc;
4006 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
4008 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4009 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4010 lpWaveOutHdr->reserved = (DWORD)lpWaveOutHdr->lpData;
4011 lpWaveOutHdr->lpData = PTR_SEG_TO_LIN(lpWaveOutHdr->lpData);
4012 ret = wodMessage(lpDesc->uDeviceID, WODM_UNPREPARE, lpDesc->dwInstance,
4013 (DWORD)lpWaveOutHdr, uSize);
4014 lpWaveOutHdr->lpData = (LPBYTE)lpWaveOutHdr->reserved;
4018 /**************************************************************************
4019 * waveOutWrite [MMSYSTEM.408]
4021 UINT WINAPI waveOutWrite(HWAVEOUT hWaveOut, WAVEHDR* lpWaveOutHdr,
4024 LPWAVEOPENDESC lpDesc;
4026 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
4028 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4029 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4030 lpWaveOutHdr->reserved = (DWORD)lpWaveOutHdr->lpData;
4031 return wodMessage(lpDesc->uDeviceID, WODM_WRITE, lpDesc->dwInstance, (DWORD)lpWaveOutHdr, uSize);
4034 /**************************************************************************
4035 * waveOutWrite [MMSYSTEM.408]
4037 UINT16 WINAPI waveOutWrite16(HWAVEOUT16 hWaveOut, WAVEHDR * lpWaveOutHdr,
4040 LPWAVEOPENDESC lpDesc;
4043 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize);
4045 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4046 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4047 lpWaveOutHdr->reserved =(DWORD)lpWaveOutHdr->lpData;/*save original ptr*/
4048 lpWaveOutHdr->lpData = PTR_SEG_TO_LIN(lpWaveOutHdr->lpData);
4049 ret = wodMessage(lpDesc->uDeviceID, WODM_WRITE, lpDesc->dwInstance, (DWORD)lpWaveOutHdr, uSize);
4050 lpWaveOutHdr->lpData = (LPBYTE)lpWaveOutHdr->reserved;
4054 /**************************************************************************
4055 * waveOutPause [WINMM.174]
4057 UINT WINAPI waveOutPause(HWAVEOUT hWaveOut)
4059 return waveOutPause16(hWaveOut);
4062 /**************************************************************************
4063 * waveOutPause [MMSYSTEM.409]
4065 UINT16 WINAPI waveOutPause16(HWAVEOUT16 hWaveOut)
4067 LPWAVEOPENDESC lpDesc;
4069 TRACE(mmsys, "(%04X)\n", hWaveOut);
4071 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4072 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4073 return wodMessage(lpDesc->uDeviceID, WODM_PAUSE, lpDesc->dwInstance, 0L, 0L);
4076 /**************************************************************************
4077 * waveOutRestart [WINMM.177]
4079 UINT WINAPI waveOutRestart(HWAVEOUT hWaveOut)
4081 return waveOutRestart16(hWaveOut);
4084 /**************************************************************************
4085 * waveOutRestart [MMSYSTEM.410]
4087 UINT16 WINAPI waveOutRestart16(HWAVEOUT16 hWaveOut)
4089 LPWAVEOPENDESC lpDesc;
4091 TRACE(mmsys, "(%04X)\n", hWaveOut);
4093 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4094 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4095 return wodMessage(lpDesc->uDeviceID, WODM_RESTART, lpDesc->dwInstance, 0L, 0L);
4098 /**************************************************************************
4099 * waveOutReset [WINMM.176]
4101 UINT WINAPI waveOutReset(HWAVEOUT hWaveOut)
4103 return waveOutReset16(hWaveOut);
4106 /**************************************************************************
4107 * waveOutReset [MMSYSTEM.411]
4109 UINT16 WINAPI waveOutReset16(HWAVEOUT16 hWaveOut)
4111 LPWAVEOPENDESC lpDesc;
4113 TRACE(mmsys, "(%04X)\n", hWaveOut);
4115 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4116 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4117 return wodMessage(lpDesc->uDeviceID, WODM_RESET, lpDesc->dwInstance, 0L, 0L);
4120 /**************************************************************************
4121 * waveOutGetPosition [WINMM.170]
4123 UINT WINAPI waveOutGetPosition(HWAVEOUT hWaveOut, LPMMTIME lpTime,
4129 mmt16.wType = lpTime->wType;
4130 ret = waveOutGetPosition16(hWaveOut, &mmt16, sizeof(mmt16));
4131 MMSYSTEM_MMTIME16to32(lpTime, &mmt16);
4135 /**************************************************************************
4136 * waveOutGetPosition [MMSYSTEM.412]
4138 UINT16 WINAPI waveOutGetPosition16(HWAVEOUT16 hWaveOut, LPMMTIME16 lpTime,
4141 LPWAVEOPENDESC lpDesc;
4142 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveOut, lpTime, uSize);
4143 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4144 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4145 return wodMessage(lpDesc->uDeviceID, WODM_GETPOS, lpDesc->dwInstance,
4146 (DWORD)lpTime, (DWORD)uSize);
4149 #define WAVEOUT_SHORTCUT_1(xx,XX,atype) \
4150 UINT WINAPI waveOut##xx(HWAVEOUT hWaveOut, atype x) \
4152 return waveOut##xx##16(hWaveOut,x); \
4154 UINT16 WINAPI waveOut##xx##16(HWAVEOUT16 hWaveOut, atype x) \
4156 LPWAVEOPENDESC lpDesc; \
4157 TRACE(mmsys, "(%04X, %08lx);\n", hWaveOut, (DWORD)x); \
4158 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut); \
4159 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; \
4160 return wodMessage(lpDesc->uDeviceID, WODM_##XX, \
4161 lpDesc->dwInstance, (DWORD)x, 0L); \
4164 WAVEOUT_SHORTCUT_1(GetPitch,GETPITCH, DWORD*)
4165 WAVEOUT_SHORTCUT_1(SetPitch,SETPITCH, DWORD)
4166 WAVEOUT_SHORTCUT_1(GetPlaybackRate,GETPLAYBACKRATE, DWORD*)
4167 WAVEOUT_SHORTCUT_1(SetPlaybackRate,SETPLAYBACKRATE, DWORD)
4169 #define WAVEOUT_SHORTCUT_2(xx,XX,atype) \
4170 UINT WINAPI waveOut##xx(UINT devid, atype x) \
4172 return waveOut##xx##16(devid,x); \
4174 UINT16 WINAPI waveOut##xx##16(UINT16 devid, atype x) \
4176 TRACE(mmsys, "(%04X, %08lx);\n", devid, (DWORD)x); \
4177 return wodMessage(devid, WODM_##XX, 0L, (DWORD)x, 0L); \
4180 WAVEOUT_SHORTCUT_2(GetVolume,GETVOLUME, DWORD*)
4181 WAVEOUT_SHORTCUT_2(SetVolume,SETVOLUME, DWORD)
4183 /**************************************************************************
4184 * waveOutBreakLoop [MMSYSTEM.419]
4186 UINT WINAPI waveOutBreakLoop(HWAVEOUT hWaveOut)
4188 return waveOutBreakLoop16(hWaveOut);
4191 /**************************************************************************
4192 * waveOutBreakLoop [MMSYSTEM.419]
4194 UINT16 WINAPI waveOutBreakLoop16(HWAVEOUT16 hWaveOut)
4196 TRACE(mmsys, "(%04X)\n", hWaveOut);
4197 return MMSYSERR_INVALHANDLE;
4200 /**************************************************************************
4201 * waveOutGetID [MMSYSTEM.420]
4203 UINT WINAPI waveOutGetID(HWAVEOUT hWaveOut, UINT * lpuDeviceID)
4205 LPWAVEOPENDESC lpDesc;
4207 TRACE(mmsys, "(%04X, %p);\n", hWaveOut, lpuDeviceID);
4209 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4210 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4211 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
4212 *lpuDeviceID = lpDesc->uDeviceID;
4216 /**************************************************************************
4217 * waveOutGetID [MMSYSTEM.420]
4219 UINT16 WINAPI waveOutGetID16(HWAVEOUT16 hWaveOut, UINT16 * lpuDeviceID)
4221 LPWAVEOPENDESC lpDesc;
4223 TRACE(mmsys, "(%04X, %p);\n", hWaveOut, lpuDeviceID);
4225 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4226 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4227 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
4228 *lpuDeviceID = lpDesc->uDeviceID;
4232 /**************************************************************************
4233 * waveOutMessage [MMSYSTEM.421]
4235 DWORD WINAPI waveOutMessage(HWAVEOUT hWaveOut, UINT uMessage,
4236 DWORD dwParam1, DWORD dwParam2)
4238 LPWAVEOPENDESC lpDesc;
4240 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4241 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4243 case WODM_GETNUMDEVS:
4245 case WODM_GETVOLUME:
4247 case WODM_GETPLAYBACKRATE:
4248 case WODM_SETVOLUME:
4250 case WODM_SETPLAYBACKRATE:
4254 case WODM_UNPREPARE:
4257 /* no argument conversion needed */
4260 return waveOutWrite(hWaveOut, (LPWAVEHDR)dwParam1, dwParam2);
4261 case WODM_GETDEVCAPS:
4262 /* FIXME: UNICODE/ANSI? */
4263 return waveOutGetDevCapsA(hWaveOut, (LPWAVEOUTCAPSA)dwParam1, dwParam2);
4265 FIXME(mmsys,"can't handle WODM_OPEN, please report.\n");
4268 ERR(mmsys,"(0x%04x, 0x%04x,%08lx,%08lx): unhandled message\n",
4269 hWaveOut,uMessage, dwParam1, dwParam2);
4272 return wodMessage(lpDesc->uDeviceID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
4275 /**************************************************************************
4276 * waveOutMessage [MMSYSTEM.421]
4278 DWORD WINAPI waveOutMessage16(HWAVEOUT16 hWaveOut, UINT16 uMessage,
4279 DWORD dwParam1, DWORD dwParam2)
4281 LPWAVEOPENDESC lpDesc;
4283 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveOut);
4284 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4286 case WODM_GETNUMDEVS:
4287 case WODM_SETVOLUME:
4289 case WODM_SETPLAYBACKRATE:
4294 /* no argument conversion needed */
4297 return waveOutGetPosition16(hWaveOut, (LPMMTIME16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4298 case WODM_GETVOLUME:
4299 return waveOutGetVolume16(hWaveOut, (LPDWORD)PTR_SEG_TO_LIN(dwParam1));
4301 return waveOutGetPitch16(hWaveOut, (LPDWORD)PTR_SEG_TO_LIN(dwParam1));
4302 case WODM_GETPLAYBACKRATE:
4303 return waveOutGetPlaybackRate16(hWaveOut, (LPDWORD)PTR_SEG_TO_LIN(dwParam1));
4304 case WODM_GETDEVCAPS:
4305 return waveOutGetDevCaps16(hWaveOut, (LPWAVEOUTCAPS16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4307 return waveOutPrepareHeader16(hWaveOut, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4308 case WODM_UNPREPARE:
4309 return waveOutUnprepareHeader16(hWaveOut, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4311 return waveOutWrite16(hWaveOut, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4313 FIXME(mmsys,"can't handle WODM_OPEN, please report.\n");
4316 ERR(mmsys,"(0x%04x, 0x%04x,%08lx,%08lx): unhandled message\n",
4317 hWaveOut,uMessage, dwParam1, dwParam2);
4319 return wodMessage(lpDesc->uDeviceID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
4322 /**************************************************************************
4323 * waveInGetNumDevs [WINMM.151]
4325 UINT WINAPI waveInGetNumDevs()
4327 return waveInGetNumDevs16();
4330 /**************************************************************************
4331 * waveInGetNumDevs [MMSYSTEM.501]
4333 UINT16 WINAPI waveInGetNumDevs16()
4337 TRACE(mmsys, "waveInGetNumDevs\n");
4338 count += widMessage(0, WIDM_GETNUMDEVS, 0L, 0L, 0L);
4339 TRACE(mmsys, "waveInGetNumDevs return %u \n", count);
4343 /**************************************************************************
4344 * waveInGetDevCapsA [WINMM.147]
4346 UINT WINAPI waveInGetDevCapsW(UINT uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSize)
4349 UINT ret = waveInGetDevCaps16(uDeviceID, &wic16,uSize);
4351 lpCaps->wMid = wic16.wMid;
4352 lpCaps->wPid = wic16.wPid;
4353 lpCaps->vDriverVersion = wic16.vDriverVersion;
4354 lstrcpyAtoW(lpCaps->szPname, wic16.szPname);
4355 lpCaps->dwFormats = wic16.dwFormats;
4356 lpCaps->wChannels = wic16.wChannels;
4361 /**************************************************************************
4362 * waveInGetDevCapsA [WINMM.146]
4364 UINT WINAPI waveInGetDevCapsA(UINT uDeviceID, LPWAVEINCAPSA lpCaps, UINT uSize)
4367 UINT ret = waveInGetDevCaps16(uDeviceID, &wic16,uSize);
4369 lpCaps->wMid = wic16.wMid;
4370 lpCaps->wPid = wic16.wPid;
4371 lpCaps->vDriverVersion = wic16.vDriverVersion;
4372 strcpy(lpCaps->szPname, wic16.szPname);
4373 lpCaps->dwFormats = wic16.dwFormats;
4374 lpCaps->wChannels = wic16.wChannels;
4378 /**************************************************************************
4379 * waveInGetDevCaps [MMSYSTEM.502]
4381 UINT16 WINAPI waveInGetDevCaps16(UINT16 uDeviceID, LPWAVEINCAPS16 lpCaps, UINT16 uSize)
4383 TRACE(mmsys, "waveInGetDevCaps\n");
4385 return widMessage(uDeviceID, WIDM_GETDEVCAPS, 0L, (DWORD)lpCaps, uSize);
4388 /**************************************************************************
4389 * waveInGetErrorTextA [WINMM.148]
4391 UINT WINAPI waveInGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
4393 TRACE(mmsys, "waveInGetErrorText\n");
4394 return(waveGetErrorText(uError, lpText, uSize));
4397 /**************************************************************************
4398 * waveInGetErrorTextW [WINMM.149]
4400 UINT WINAPI waveInGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
4402 LPSTR txt = HeapAlloc(GetProcessHeap(), 0,uSize);
4403 UINT ret = waveGetErrorText(uError, txt, uSize);
4405 lstrcpyAtoW(lpText, txt);
4406 HeapFree(GetProcessHeap(), 0, txt);
4410 /**************************************************************************
4411 * waveInGetErrorText [MMSYSTEM.503]
4413 UINT16 WINAPI waveInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
4415 TRACE(mmsys, "waveInGetErrorText\n");
4416 return(waveGetErrorText(uError, lpText, uSize));
4419 /**************************************************************************
4420 * waveInOpen [WINMM.154]
4422 UINT WINAPI waveInOpen(HWAVEIN * lphWaveIn, UINT uDeviceID,
4423 const LPWAVEFORMAT lpFormat, DWORD dwCallback,
4424 DWORD dwInstance, DWORD dwFlags)
4427 UINT ret = waveInOpen16(&hwin16,uDeviceID, lpFormat, dwCallback, dwInstance,
4428 CALLBACK32CONV(dwFlags));
4429 if (lphWaveIn) *lphWaveIn = hwin16;
4433 /**************************************************************************
4434 * waveInOpen [MMSYSTEM.504]
4436 UINT16 WINAPI waveInOpen16(HWAVEIN16 * lphWaveIn, UINT16 uDeviceID,
4437 const LPWAVEFORMAT lpFormat, DWORD dwCallback,
4438 DWORD dwInstance, DWORD dwFlags)
4441 LPWAVEOPENDESC lpDesc;
4443 BOOL bMapperFlg = FALSE;
4445 TRACE(mmsys, "(%p, %d, %p, %08lX, %08lX, %08lX);\n",
4446 lphWaveIn, uDeviceID, lpFormat, dwCallback, dwInstance, dwFlags);
4447 if (dwFlags & WAVE_FORMAT_QUERY)
4448 TRACE(mmsys, "WAVE_FORMAT_QUERY requested !\n");
4449 if (uDeviceID == (UINT16)WAVE_MAPPER) {
4450 TRACE(mmsys, "WAVE_MAPPER mode requested !\n");
4454 if (lpFormat == NULL) return WAVERR_BADFORMAT;
4455 hWaveIn = USER_HEAP_ALLOC(sizeof(WAVEOPENDESC));
4456 if (lphWaveIn != NULL) *lphWaveIn = hWaveIn;
4457 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4458 if (lpDesc == NULL) return MMSYSERR_NOMEM;
4459 lpDesc->hWave = hWaveIn;
4460 lpDesc->lpFormat = lpFormat;
4461 lpDesc->dwCallBack = dwCallback;
4462 lpDesc->dwInstance = dwInstance;
4463 while (uDeviceID < MAXWAVEDRIVERS) {
4464 dwRet = widMessage(uDeviceID, WIDM_OPEN,
4465 lpDesc->dwInstance, (DWORD)lpDesc, 0L);
4466 if (dwRet == MMSYSERR_NOERROR) break;
4467 if (!bMapperFlg) break;
4469 TRACE(mmsys, "WAVE_MAPPER mode ! try next driver...\n");
4471 lpDesc->uDeviceID = uDeviceID;
4472 if (dwFlags & WAVE_FORMAT_QUERY) {
4473 TRACE(mmsys, "End of WAVE_FORMAT_QUERY !\n");
4474 dwRet = waveInClose16(hWaveIn);
4479 /**************************************************************************
4480 * waveInClose [WINMM.145]
4482 UINT WINAPI waveInClose(HWAVEIN hWaveIn)
4484 return waveInClose16(hWaveIn);
4487 /**************************************************************************
4488 * waveInClose [MMSYSTEM.505]
4490 UINT16 WINAPI waveInClose16(HWAVEIN16 hWaveIn)
4492 LPWAVEOPENDESC lpDesc;
4494 TRACE(mmsys, "(%04X)\n", hWaveIn);
4495 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4496 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4497 return widMessage(lpDesc->uDeviceID, WIDM_CLOSE, lpDesc->dwInstance, 0L, 0L);
4500 /**************************************************************************
4501 * waveInPrepareHeader [WINMM.155]
4503 UINT WINAPI waveInPrepareHeader(HWAVEIN hWaveIn,
4504 WAVEHDR * lpWaveInHdr, UINT uSize)
4506 LPWAVEOPENDESC lpDesc;
4508 TRACE(mmsys, "(%04X, %p, %u);\n",
4509 hWaveIn, lpWaveInHdr, uSize);
4510 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4511 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4512 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
4513 lpWaveInHdr = lpWaveInHdr;
4514 lpWaveInHdr->lpNext = NULL;
4515 lpWaveInHdr->dwBytesRecorded = 0;
4516 TRACE(mmsys, "lpData=%p size=%lu \n",
4517 lpWaveInHdr->lpData, lpWaveInHdr->dwBufferLength);
4518 return widMessage(lpDesc->uDeviceID, WIDM_PREPARE, lpDesc->dwInstance,
4519 (DWORD)lpWaveInHdr, uSize);
4522 /**************************************************************************
4523 * waveInPrepareHeader [MMSYSTEM.506]
4525 UINT16 WINAPI waveInPrepareHeader16(HWAVEIN16 hWaveIn,
4526 WAVEHDR * lpWaveInHdr, UINT16 uSize)
4528 LPWAVEOPENDESC lpDesc;
4529 LPBYTE saveddata = lpWaveInHdr->lpData;
4532 TRACE(mmsys, "(%04X, %p, %u);\n",
4533 hWaveIn, lpWaveInHdr, uSize);
4534 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4535 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4536 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
4537 lpWaveInHdr = lpWaveInHdr;
4538 lpWaveInHdr->lpNext = NULL;
4539 lpWaveInHdr->dwBytesRecorded = 0;
4541 TRACE(mmsys, "lpData=%p size=%lu \n",
4542 lpWaveInHdr->lpData, lpWaveInHdr->dwBufferLength);
4543 lpWaveInHdr->lpData = PTR_SEG_TO_LIN(lpWaveInHdr->lpData);
4544 ret = widMessage(lpDesc->uDeviceID, WIDM_PREPARE, lpDesc->dwInstance,
4545 (DWORD)lpWaveInHdr,uSize);
4546 lpWaveInHdr->lpData = saveddata;
4550 /**************************************************************************
4551 * waveInUnprepareHeader [WINMM.159]
4553 UINT WINAPI waveInUnprepareHeader(HWAVEIN hWaveIn,
4554 WAVEHDR * lpWaveInHdr, UINT uSize)
4556 LPWAVEOPENDESC lpDesc;
4558 TRACE(mmsys, "(%04X, %p, %u);\n",
4559 hWaveIn, lpWaveInHdr, uSize);
4560 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4561 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4562 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
4563 /*USER_HEAP_FREE(HIWORD((DWORD)lpWaveInHdr->lpData)); FIXME */
4564 lpWaveInHdr->lpData = NULL;
4565 lpWaveInHdr->lpNext = NULL;
4566 return widMessage(lpDesc->uDeviceID, WIDM_UNPREPARE, lpDesc->dwInstance,
4567 (DWORD)lpWaveInHdr, uSize);
4570 /**************************************************************************
4571 * waveInUnprepareHeader [MMSYSTEM.507]
4573 UINT16 WINAPI waveInUnprepareHeader16(HWAVEIN16 hWaveIn,
4574 WAVEHDR * lpWaveInHdr, UINT16 uSize)
4576 LPWAVEOPENDESC lpDesc;
4578 TRACE(mmsys, "(%04X, %p, %u);\n",
4579 hWaveIn, lpWaveInHdr, uSize);
4580 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4581 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4582 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
4583 /*USER_HEAP_FREE(HIWORD((DWORD)lpWaveInHdr->lpData)); FIXME */
4584 lpWaveInHdr->lpData = NULL;
4585 lpWaveInHdr->lpNext = NULL;
4586 return widMessage(lpDesc->uDeviceID, WIDM_UNPREPARE, lpDesc->dwInstance,
4587 (DWORD)lpWaveInHdr, uSize);
4590 /**************************************************************************
4591 * waveInAddBuffer [WINMM.144]
4593 UINT WINAPI waveInAddBuffer(HWAVEIN hWaveIn,
4594 WAVEHDR * lpWaveInHdr, UINT uSize)
4596 LPWAVEOPENDESC lpDesc;
4598 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
4599 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4600 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4601 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
4602 lpWaveInHdr->lpNext = NULL;
4603 lpWaveInHdr->dwBytesRecorded = 0;
4604 TRACE(mmsys, "lpData=%p size=%lu \n",
4605 lpWaveInHdr->lpData, lpWaveInHdr->dwBufferLength);
4606 return widMessage(lpDesc->uDeviceID, WIDM_ADDBUFFER, lpDesc->dwInstance,
4607 (DWORD)lpWaveInHdr, uSize);
4611 /**************************************************************************
4612 * waveInAddBuffer [MMSYSTEM.508]
4614 UINT16 WINAPI waveInAddBuffer16(HWAVEIN16 hWaveIn,
4615 WAVEHDR * lpWaveInHdr, UINT16 uSize)
4617 LPWAVEOPENDESC lpDesc;
4620 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
4621 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4622 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4623 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
4624 lpWaveInHdr->lpNext = NULL;
4625 lpWaveInHdr->dwBytesRecorded = 0;
4626 lpWaveInHdr->lpData = PTR_SEG_TO_LIN(lpWaveInHdr->lpData);
4627 TRACE(mmsys, "lpData=%p size=%lu \n",
4628 lpWaveInHdr->lpData, lpWaveInHdr->dwBufferLength);
4629 ret = widMessage(lpDesc->uDeviceID, WIDM_ADDBUFFER, lpDesc->dwInstance,
4630 (DWORD)lpWaveInHdr, uSize);
4631 /*lpWaveInHdr->lpData = saveddata;*/
4635 /**************************************************************************
4636 * waveInStart [WINMM.157]
4638 UINT WINAPI waveInStart(HWAVEIN hWaveIn)
4640 return waveInStart16(hWaveIn);
4643 /**************************************************************************
4644 * waveInStart [MMSYSTEM.509]
4646 UINT16 WINAPI waveInStart16(HWAVEIN16 hWaveIn)
4648 LPWAVEOPENDESC lpDesc;
4650 TRACE(mmsys, "(%04X)\n", hWaveIn);
4651 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4652 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4653 return widMessage(lpDesc->uDeviceID, WIDM_START, lpDesc->dwInstance, 0, 0);
4656 /**************************************************************************
4657 * waveInStop [WINMM.158]
4659 UINT WINAPI waveInStop(HWAVEIN hWaveIn)
4661 return waveInStop16(hWaveIn);
4664 /**************************************************************************
4665 * waveInStop [MMSYSTEM.510]
4667 UINT16 WINAPI waveInStop16(HWAVEIN16 hWaveIn)
4669 LPWAVEOPENDESC lpDesc;
4671 TRACE(mmsys, "(%04X)\n", hWaveIn);
4672 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4673 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4674 return widMessage(lpDesc->uDeviceID, WIDM_STOP, lpDesc->dwInstance, 0L, 0L);
4677 /**************************************************************************
4678 * waveInReset [WINMM.156]
4680 UINT WINAPI waveInReset(HWAVEIN hWaveIn)
4682 return waveInReset16(hWaveIn);
4685 /**************************************************************************
4686 * waveInReset [MMSYSTEM.511]
4688 UINT16 WINAPI waveInReset16(HWAVEIN16 hWaveIn)
4690 LPWAVEOPENDESC lpDesc;
4692 TRACE(mmsys, "(%04X)\n", hWaveIn);
4693 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4694 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4695 return widMessage(lpDesc->uDeviceID, WIDM_RESET, lpDesc->dwInstance, 0, 0);
4698 /**************************************************************************
4699 * waveInGetPosition [WINMM.152]
4701 UINT WINAPI waveInGetPosition(HWAVEIN hWaveIn, LPMMTIME lpTime,
4707 mmt16.wType = lpTime->wType;
4708 ret = waveInGetPosition16(hWaveIn, &mmt16,uSize);
4710 MMSYSTEM_MMTIME16to32(lpTime, &mmt16);
4714 /**************************************************************************
4715 * waveInGetPosition [MMSYSTEM.512]
4717 UINT16 WINAPI waveInGetPosition16(HWAVEIN16 hWaveIn, LPMMTIME16 lpTime,
4720 LPWAVEOPENDESC lpDesc;
4722 TRACE(mmsys, "(%04X, %p, %u);\n", hWaveIn, lpTime, uSize);
4723 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4724 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4725 return widMessage(lpDesc->uDeviceID, WIDM_GETPOS, lpDesc->dwInstance,
4726 (DWORD)lpTime, (DWORD)uSize);
4729 /**************************************************************************
4730 * waveInGetID [WINMM.150]
4732 UINT WINAPI waveInGetID(HWAVEIN hWaveIn, UINT * lpuDeviceID)
4734 LPWAVEOPENDESC lpDesc;
4736 TRACE(mmsys, "waveInGetID\n");
4737 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
4738 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4739 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4740 *lpuDeviceID = lpDesc->uDeviceID;
4744 /**************************************************************************
4745 * waveInGetID [MMSYSTEM.513]
4747 UINT16 WINAPI waveInGetID16(HWAVEIN16 hWaveIn, UINT16 * lpuDeviceID)
4749 LPWAVEOPENDESC lpDesc;
4751 TRACE(mmsys, "waveInGetID\n");
4752 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
4753 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4754 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4755 *lpuDeviceID = lpDesc->uDeviceID;
4759 /**************************************************************************
4760 * waveInMessage [WINMM.153]
4762 DWORD WINAPI waveInMessage(HWAVEIN hWaveIn, UINT uMessage,
4763 DWORD dwParam1, DWORD dwParam2)
4765 LPWAVEOPENDESC lpDesc;
4767 FIXME(mmsys, "(%04X, %04X, %08lX, %08lX)\n",
4768 hWaveIn, uMessage, dwParam1, dwParam2);
4769 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4770 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4773 FIXME(mmsys, "cannot handle WIDM_OPEN, please report.\n");
4775 case WIDM_GETNUMDEVS:
4782 case WIDM_UNPREPARE:
4783 case WIDM_ADDBUFFER:
4785 /* no argument conversion needed */
4787 case WIDM_GETDEVCAPS:
4788 /*FIXME: ANSI/UNICODE */
4789 return waveInGetDevCapsA(hWaveIn, (LPWAVEINCAPSA)dwParam1, dwParam2);
4791 ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
4792 hWaveIn,uMessage, dwParam1, dwParam2);
4795 return widMessage(lpDesc->uDeviceID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
4798 /**************************************************************************
4799 * waveInMessage [MMSYSTEM.514]
4801 DWORD WINAPI waveInMessage16(HWAVEIN16 hWaveIn, UINT16 uMessage,
4802 DWORD dwParam1, DWORD dwParam2)
4804 LPWAVEOPENDESC lpDesc;
4806 FIXME(mmsys, "(%04X, %04X, %08lX, %08lX)\n",
4807 hWaveIn, uMessage, dwParam1, dwParam2);
4808 lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hWaveIn);
4809 if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
4812 FIXME(mmsys,"cannot handle WIDM_OPEN, please report.\n");
4814 case WIDM_GETNUMDEVS:
4820 /* no argument conversion needed */
4822 case WIDM_GETDEVCAPS:
4823 return waveInGetDevCaps16(hWaveIn, (LPWAVEINCAPS16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4825 return waveInGetPosition16(hWaveIn, (LPMMTIME16)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4827 return waveInPrepareHeader16(hWaveIn, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4828 case WIDM_UNPREPARE:
4829 return waveInUnprepareHeader16(hWaveIn, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4830 case WIDM_ADDBUFFER:
4831 return waveInAddBuffer16(hWaveIn, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
4833 ERR(mmsys,"(%04x,%04x,%08lx,%08lx): unhandled message\n",
4834 hWaveIn,uMessage, dwParam1, dwParam2);
4837 return widMessage(lpDesc->uDeviceID, uMessage, lpDesc->dwInstance, dwParam1, dwParam2);
4840 /**************************************************************************
4841 * DrvOpen [MMSYSTEM.1100]
4843 HDRVR16 WINAPI DrvOpen(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
4845 TRACE(mmsys,"('%s','%s',%08lX);\n", lpDriverName, lpSectionName, lParam);
4847 return OpenDriver16(lpDriverName, lpSectionName, lParam);
4850 /**************************************************************************
4851 * DrvClose [MMSYSTEM.1101]
4853 LRESULT WINAPI DrvClose(HDRVR16 hDrvr, LPARAM lParam1, LPARAM lParam2)
4855 TRACE(mmsys, "(%04X, %08lX, %08lX);\n", hDrvr, lParam1, lParam2);
4857 return CloseDriver16(hDrvr, lParam1, lParam2);
4860 /**************************************************************************
4861 * DrvSendMessage [MMSYSTEM.1102]
4863 LRESULT WINAPI DrvSendMessage(HDRVR16 hDriver, WORD msg, LPARAM lParam1,
4866 /* DWORD dwDriverID = 0; */
4868 FIXME(mmsys, "(%04X, %04X, %08lX, %08lX);\n", hDriver, msg, lParam1, lParam2);
4869 return MMSYSERR_NOTENABLED;
4870 /* FIXME: wrong ... */
4871 /* should known the mapping between hDrv and wDevIDs */
4872 /* MCICDAUDIO_DriverProc16(dwDriverID, hDriver, msg, lParam1, lParam2); */
4875 /**************************************************************************
4876 * DrvGetModuleHandle [MMSYSTEM.1103]
4878 HANDLE16 WINAPI DrvGetModuleHandle16(HDRVR16 hDrvr)
4880 return GetDriverModuleHandle16(hDrvr);
4883 /**************************************************************************
4884 * DrvDefDriverProc [MMSYSTEM.1104]
4886 LRESULT WINAPI DrvDefDriverProc(DWORD dwDriverID, HDRVR16 hDriv, WORD wMsg,
4887 DWORD dwParam1, DWORD dwParam2)
4889 return DefDriverProc16(dwDriverID, hDriv, wMsg, dwParam1, dwParam2);
4892 /**************************************************************************
4893 * DefDriverProc32 [WINMM.5]
4895 LRESULT WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hdrvr,
4896 UINT Msg, LPARAM lParam1, LPARAM lParam2)
4912 /**************************************************************************
4913 * mmThreadCreate [MMSYSTEM.1120]
4915 LRESULT WINAPI mmThreadCreate16(LPVOID x1, LPWORD x2, DWORD x3, DWORD x4)
4917 FIXME(mmsys,"(%p,%p,%08lx,%08lx): stub!\n",x1,x2,x3,x4);
4922 /**************************************************************************
4923 * mmThreadGetTask [MMSYSTEM.1125]
4925 LRESULT WINAPI mmThreadGetTask16(WORD hnd)
4927 FIXME(mmsys,"(%04x): stub!\n", hnd);
4928 return GetCurrentTask();
4931 /**************************************************************************
4932 * mmThreadSignal [MMSYSTEM.1121]
4934 LRESULT WINAPI mmThreadSignal16(WORD hnd)
4936 FIXME(mmsys,"(%04x): stub!\n", hnd);
4940 /**************************************************************************
4941 * mmTaskCreate [MMSYSTEM.900]
4943 HINSTANCE16 WINAPI mmTaskCreate16(LPWORD lphnd,HINSTANCE16 *hMmTask, DWORD x2)
4945 DWORD showCmd = 0x40002;
4949 HINSTANCE16 ret, handle;
4951 TRACE(mmsys,"(%p,%p,%08lx);\n", lphnd, hMmTask,x2);
4952 cmdline = (LPSTR)HeapAlloc(GetProcessHeap(), 0, 0x0d);
4954 (DWORD)cmdline[1] = (DWORD)lphnd;
4955 (DWORD)cmdline[5] = x2;
4956 (DWORD)cmdline[9] = 0;
4958 sel1 = SELECTOR_AllocBlock(cmdline, 0x0d, SEGMENT_DATA, FALSE, FALSE);
4959 sel2 = SELECTOR_AllocBlock(&showCmd, sizeof(showCmd),
4960 SEGMENT_DATA, FALSE, FALSE);
4962 lp = (LOADPARAMS16 *)HeapAlloc(GetProcessHeap(), 0, sizeof(LOADPARAMS16));
4963 lp->hEnvironment = 0;
4964 lp->cmdLine = PTR_SEG_OFF_TO_SEGPTR(sel1, 0);
4965 lp->showCmd = PTR_SEG_OFF_TO_SEGPTR(sel2, 0);
4968 ret = LoadModule16("c:\\windows\\mmtask.tsk", lp);
4981 *(HINSTANCE16 *)PTR_SEG_TO_LIN(hMmTask) = handle;
4983 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel2, 0));
4984 UnMapLS(PTR_SEG_OFF_TO_SEGPTR(sel1, 0));
4986 HeapFree(GetProcessHeap(), 0, lp);
4987 HeapFree(GetProcessHeap(), 0, cmdline);
4992 /**************************************************************************
4993 * mmTaskSignal [MMSYSTEM.903]
4995 LRESULT WINAPI mmTaskSignal16(HTASK16 ht)
4997 TRACE(mmsys,"(%04x);\n", ht);
4998 return PostAppMessageA(ht, WM_USER, 0, 0);