ReactOS 0.4.15-dev-8131-g4988de4
midimap.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winuser.h>
#include <mmddk.h>
#include <winreg.h>
#include <wine/unicode.h>
#include <wine/debug.h>
Include dependency graph for midimap.c:

Go to the source code of this file.

Classes

struct  tagMIDIOUTPORT
 
struct  tagMIDIMAPDATA
 

Typedefs

typedef struct tagMIDIOUTPORT MIDIOUTPORT
 
typedef struct tagMIDIMAPDATA MIDIMAPDATA
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msacm)
 
static BOOL MIDIMAP_IsBadData (MIDIMAPDATA *mm)
 
static BOOL MIDIMAP_FindPort (const WCHAR *name, unsigned *dev)
 
static BOOL MIDIMAP_LoadSettingsDefault (MIDIMAPDATA *mom, const WCHAR *port)
 
static BOOL MIDIMAP_LoadSettingsScheme (MIDIMAPDATA *mom, const WCHAR *scheme)
 
static BOOL MIDIMAP_LoadSettings (MIDIMAPDATA *mom)
 
static DWORD modOpen (DWORD_PTR *lpdwUser, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
 
static DWORD modClose (MIDIMAPDATA *mom)
 
static DWORD modLongData (MIDIMAPDATA *mom, LPMIDIHDR lpMidiHdr, DWORD_PTR dwParam2)
 
static DWORD modData (MIDIMAPDATA *mom, DWORD_PTR dwParam)
 
static DWORD modPrepare (MIDIMAPDATA *mom, LPMIDIHDR lpMidiHdr, DWORD_PTR dwParam2)
 
static DWORD modUnprepare (MIDIMAPDATA *mom, LPMIDIHDR lpMidiHdr, DWORD_PTR dwParam2)
 
static DWORD modGetDevCaps (UINT wDevID, MIDIMAPDATA *mom, LPMIDIOUTCAPSW lpMidiCaps, DWORD_PTR size)
 
static DWORD modReset (MIDIMAPDATA *mom)
 
DWORD WINAPI MIDIMAP_modMessage (UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
 
static LRESULT MIDIMAP_drvOpen (LPSTR str)
 
static LRESULT MIDIMAP_drvClose (DWORD_PTR dwDevID)
 
LRESULT CALLBACK MIDIMAP_DriverProc (DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, LPARAM dwParam1, LPARAM dwParam2)
 

Variables

static MIDIOUTPORTmidiOutPorts
 
static unsigned numMidiOutPorts
 

Typedef Documentation

◆ MIDIMAPDATA

◆ MIDIOUTPORT

Function Documentation

◆ MIDIMAP_DriverProc()

LRESULT CALLBACK MIDIMAP_DriverProc ( DWORD_PTR  dwDevID,
HDRVR  hDriv,
UINT  wMsg,
LPARAM  dwParam1,
LPARAM  dwParam2 
)

Definition at line 558 of file midimap.c.

560{
561/* EPP TRACE("(%08lX, %04X, %08lX, %08lX, %08lX)\n", */
562/* EPP dwDevID, hDriv, wMsg, dwParam1, dwParam2); */
563
564 switch (wMsg)
565 {
566 case DRV_LOAD: return 1;
567 case DRV_FREE: return 1;
568 case DRV_OPEN: return MIDIMAP_drvOpen((LPSTR)dwParam1);
569 case DRV_CLOSE: return MIDIMAP_drvClose(dwDevID);
570 case DRV_ENABLE: return 1;
571 case DRV_DISABLE: return 1;
572 case DRV_QUERYCONFIGURE: return 1;
573 case DRV_CONFIGURE: MessageBoxA(0, "MIDIMAP MultiMedia Driver !", "OSS Driver", MB_OK); return 1;
574 case DRV_INSTALL: return DRVCNF_RESTART;
575 case DRV_REMOVE: return DRVCNF_RESTART;
576 default:
577 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
578 }
579}
LRESULT WINAPI DefDriverProc(DWORD_PTR dwDriverIdentifier, HDRVR hDrv, UINT Msg, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:554
#define DRV_LOAD(x)
static LRESULT MIDIMAP_drvClose(DWORD_PTR dwDevID)
Definition: midimap.c:544
static LRESULT MIDIMAP_drvOpen(LPSTR str)
Definition: midimap.c:509
#define DRV_CLOSE
Definition: mmsystem.h:122
#define DRV_QUERYCONFIGURE
Definition: mmsystem.h:126
#define DRVCNF_RESTART
Definition: mmsystem.h:135
#define DRV_REMOVE
Definition: mmsystem.h:128
#define DRV_ENABLE
Definition: mmsystem.h:120
#define DRV_CONFIGURE
Definition: mmsystem.h:125
#define DRV_OPEN
Definition: mmsystem.h:121
#define DRV_INSTALL
Definition: mmsystem.h:127
#define DRV_FREE
Definition: mmsystem.h:124
#define DRV_DISABLE
Definition: mmsystem.h:123
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:790
char * LPSTR
Definition: xmlstorage.h:182

◆ MIDIMAP_drvClose()

static LRESULT MIDIMAP_drvClose ( DWORD_PTR  dwDevID)
static

Definition at line 544 of file midimap.c.

545{
546 if (midiOutPorts)
547 {
550 return 1;
551 }
552 return 0;
553}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
static MIDIOUTPORT * midiOutPorts
Definition: midimap.c:99

Referenced by MIDIMAP_DriverProc().

◆ MIDIMAP_drvOpen()

static LRESULT MIDIMAP_drvOpen ( LPSTR  str)
static

Definition at line 509 of file midimap.c.

510{
511 MIDIOUTCAPSW moc;
512 unsigned dev, i;
513
514 if (midiOutPorts)
515 return 0;
516
519 numMidiOutPorts * sizeof(MIDIOUTPORT));
520 for (dev = 0; dev < numMidiOutPorts; dev++)
521 {
522 if (midiOutGetDevCapsW(dev, &moc, sizeof(moc)) == 0L)
523 {
529 for (i = 0; i < 16; i++)
530 midiOutPorts[dev].aChn[i] = i;
531 }
532 else
533 {
534 midiOutPorts[dev].loaded = -1;
535 }
536 }
537
538 return 1;
539}
#define HeapAlloc
Definition: compat.h:733
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static unsigned numMidiOutPorts
Definition: midimap.c:100
#define L(x)
Definition: ntvdm.h:50
#define strcpyW(d, s)
Definition: unicode.h:35
Definition: name.c:39
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1126
HMIDIOUT hMidi
Definition: midimap.c:87
unsigned short uDevID
Definition: midimap.c:88
LPBYTE lpbPatch
Definition: midimap.c:89
UINT WINAPI midiOutGetNumDevs(void)
Definition: winmm.c:806
UINT WINAPI midiOutGetDevCapsW(UINT_PTR uDeviceID, LPMIDIOUTCAPSW lpCaps, UINT uSize)
Definition: winmm.c:814

Referenced by MIDIMAP_DriverProc().

◆ MIDIMAP_FindPort()

static BOOL MIDIMAP_FindPort ( const WCHAR name,
unsigned dev 
)
static

Definition at line 110 of file midimap.c.

111{
112 for (*dev = 0; *dev < numMidiOutPorts; (*dev)++)
113 {
115 if (strcmpW(midiOutPorts[*dev].name, name) == 0)
116 return TRUE;
117 }
118 /* try the form #nnn */
119 if (*name == '#' && isdigit(name[1]))
120 {
121 const WCHAR* ptr = name + 1;
122 *dev = 0;
123 do
124 {
125 *dev = *dev * 10 + *ptr - '0';
126 } while (isdigit(*++ptr));
127 if (*dev < numMidiOutPorts)
128 return TRUE;
129 }
130 return FALSE;
131}
#define isdigit(c)
Definition: acclib.h:68
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wine_dbgstr_w
Definition: kernel32.h:34
static PVOID ptr
Definition: dispmode.c:27
#define strcmpW(s1, s2)
Definition: unicode.h:44
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by MIDIMAP_LoadSettingsDefault(), and MIDIMAP_LoadSettingsScheme().

◆ MIDIMAP_IsBadData()

static BOOL MIDIMAP_IsBadData ( MIDIMAPDATA mm)
static

Definition at line 102 of file midimap.c.

103{
104 if (!IsBadReadPtr(mm, sizeof(MIDIMAPDATA)) && mm->self == mm)
105 return FALSE;
106 TRACE("Bad midimap data (%p)\n", mm);
107 return TRUE;
108}
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:805
struct tagMIDIMAPDATA * self
Definition: midimap.c:95

Referenced by modClose(), modData(), modLongData(), modPrepare(), modReset(), and modUnprepare().

◆ MIDIMAP_LoadSettings()

static BOOL MIDIMAP_LoadSettings ( MIDIMAPDATA mom)
static

Definition at line 203 of file midimap.c.

204{
205 HKEY hUserKey, hKey;
206 DWORD err;
207 BOOL ret;
208
209 err = RegOpenCurrentUser(KEY_READ, &hUserKey);
210 if (err == ERROR_SUCCESS)
211 {
212 err = RegOpenKeyW(hUserKey,
213 L"Software\\Microsoft\\Windows\\CurrentVersion\\Multimedia\\MIDIMap",
214 &hKey);
215 RegCloseKey(hUserKey);
216 }
217
218 if (err != ERROR_SUCCESS)
219 {
221 }
222 else
223 {
224 DWORD type, size, out;
225 WCHAR buffer[256];
226
227 ret = 2;
228 size = sizeof(out);
229 if (!RegQueryValueExA(hKey, "UseScheme", 0, &type, (void*)&out, &size) && out)
230 {
231 static const WCHAR cs[] = {'C','u','r','r','e','n','t','S','c','h','e','m','e',0};
232 size = sizeof(buffer);
233 if (!RegQueryValueExW(hKey, cs, 0, &type, (void*)buffer, &size))
234 {
237 }
238 else
239 {
240 ERR("Wrong registry: UseScheme is active, but no CurrentScheme found\n");
241 }
242 }
243 if (ret == 2)
244 {
245 static const WCHAR ci[] = {'C','u','r','r','e','n','t','I','n','s','t','r','u','m','e','n','t',0};
246 size = sizeof(buffer);
247 if (!RegQueryValueExW(hKey, ci, 0, &type, (void*)buffer, &size) && *buffer)
248 {
250 }
251 else if (!RegQueryValueExW(hKey, L"szPname", 0, &type, (void*)buffer, &size) && *buffer)
252 {
253 /* Windows XP and higher setting */
255 }
256 else
257 {
259 }
260 }
261 }
263
264 if (ret && TRACE_ON(msacm))
265 {
266 unsigned i;
267
268 for (i = 0; i < 16; i++)
269 {
270 TRACE("chnMap[%2d] => %d\n",
271 i, mom->ChannelMap[i] ? mom->ChannelMap[i]->uDevID : -1);
272 }
273 }
274 return ret;
275}
#define ERR(fmt,...)
Definition: debug.h:113
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3209
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define TRACE_ON(x)
Definition: compat.h:75
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
#define cs
Definition: i386-dis.c:442
static BOOL MIDIMAP_LoadSettingsScheme(MIDIMAPDATA *mom, const WCHAR *scheme)
Definition: midimap.c:152
static BOOL MIDIMAP_LoadSettingsDefault(MIDIMAPDATA *mom, const WCHAR *port)
Definition: midimap.c:133
#define KEY_READ
Definition: nt_native.h:1023
#define err(...)
static FILE * out
Definition: regtests2xml.c:44
MIDIOUTPORT * ChannelMap[16]
Definition: midimap.c:96
int ret

Referenced by modOpen().

◆ MIDIMAP_LoadSettingsDefault()

static BOOL MIDIMAP_LoadSettingsDefault ( MIDIMAPDATA mom,
const WCHAR port 
)
static

Definition at line 133 of file midimap.c.

134{
135 unsigned i, dev = 0;
136
137 if (port != NULL && !MIDIMAP_FindPort(port, &dev))
138 {
139 ERR("Registry glitch: couldn't find midi out (%s)\n", wine_dbgstr_w(port));
140 dev = 0;
141 }
142
143 /* this is necessary when no midi out ports are present */
144 if (dev >= numMidiOutPorts)
145 return FALSE;
146 /* sets default */
147 for (i = 0; i < 16; i++) mom->ChannelMap[i] = &midiOutPorts[dev];
148
149 return TRUE;
150}
USHORT port
Definition: uri.c:228
static BOOL MIDIMAP_FindPort(const WCHAR *name, unsigned *dev)
Definition: midimap.c:110

Referenced by MIDIMAP_LoadSettings().

◆ MIDIMAP_LoadSettingsScheme()

static BOOL MIDIMAP_LoadSettingsScheme ( MIDIMAPDATA mom,
const WCHAR scheme 
)
static

Definition at line 152 of file midimap.c.

153{
154 HKEY hSchemesKey, hKey, hPortKey;
155 unsigned i, idx, dev;
156 WCHAR buffer[256], port[256];
158
159 for (i = 0; i < 16; i++) mom->ChannelMap[i] = NULL;
160
162 "System\\CurrentControlSet\\Control\\MediaProperties\\PrivateProperties\\Midi\\Schemes",
163 &hSchemesKey))
164 {
165 return FALSE;
166 }
167 if (RegOpenKeyW(hSchemesKey, scheme, &hKey))
168 {
169 RegCloseKey(hSchemesKey);
170 return FALSE;
171 }
172
173 for (idx = 0; !RegEnumKeyW(hKey, idx, buffer, sizeof(buffer)); idx++)
174 {
175 if (RegOpenKeyW(hKey, buffer, &hPortKey)) continue;
176
177 size = sizeof(port);
178 if (RegQueryValueExW(hPortKey, NULL, 0, &type, (void*)port, &size)) continue;
179
180 if (!MIDIMAP_FindPort(port, &dev)) continue;
181
182 size = sizeof(mask);
183 if (RegQueryValueExA(hPortKey, "Channels", 0, &type, (void*)&mask, &size))
184 continue;
185
186 for (i = 0; i < 16; i++)
187 {
188 if (mask & (1 << i))
189 {
190 if (mom->ChannelMap[i])
191 ERR("Quirks in registry, channel %u is mapped twice\n", i);
192 mom->ChannelMap[i] = &midiOutPorts[dev];
193 }
194 }
195 }
196
197 RegCloseKey(hSchemesKey);
199
200 return TRUE;
201}
unsigned int idx
Definition: utils.c:41
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
GLenum GLint GLuint mask
Definition: glext.h:6028
if(dx< 0)
Definition: linetemp.h:194
DWORD scheme
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by MIDIMAP_LoadSettings().

◆ MIDIMAP_modMessage()

DWORD WINAPI MIDIMAP_modMessage ( UINT  wDevID,
UINT  wMsg,
DWORD_PTR  dwUser,
DWORD_PTR  dwParam1,
DWORD_PTR  dwParam2 
)

Definition at line 468 of file midimap.c.

470{
471 TRACE("(%u, %04X, %08lX, %08lX, %08lX);\n",
472 wDevID, wMsg, dwUser, dwParam1, dwParam2);
473
474 switch (wMsg)
475 {
476 case DRVM_INIT:
477 case DRVM_EXIT:
478 case DRVM_ENABLE:
479 case DRVM_DISABLE:
480 /* FIXME: Pretend this is supported */
481 return 0;
482
483 case MODM_OPEN: return modOpen((DWORD_PTR *)dwUser, (LPMIDIOPENDESC)dwParam1, dwParam2);
484 case MODM_CLOSE: return modClose ((MIDIMAPDATA*)dwUser);
485
486 case MODM_DATA: return modData ((MIDIMAPDATA*)dwUser, dwParam1);
487 case MODM_LONGDATA: return modLongData ((MIDIMAPDATA*)dwUser, (LPMIDIHDR)dwParam1, dwParam2);
488 case MODM_PREPARE: return modPrepare ((MIDIMAPDATA*)dwUser, (LPMIDIHDR)dwParam1, dwParam2);
489 case MODM_UNPREPARE: return modUnprepare ((MIDIMAPDATA*)dwUser, (LPMIDIHDR)dwParam1, dwParam2);
490 case MODM_RESET: return modReset ((MIDIMAPDATA*)dwUser);
491
492 case MODM_GETDEVCAPS: return modGetDevCaps (wDevID, (MIDIMAPDATA*)dwUser, (LPMIDIOUTCAPSW)dwParam1,dwParam2);
493 case MODM_GETNUMDEVS: return 1;
496 default:
497 FIXME("unknown message %d!\n", wMsg);
498 }
500}
#define FIXME(fmt,...)
Definition: debug.h:114
#define MODM_GETDEVCAPS
Definition: mmddk.h:155
#define DRVM_INIT
Definition: mmddk.h:56
#define MODM_PREPARE
Definition: mmddk.h:158
#define DRVM_DISABLE
Definition: mmddk.h:58
#define MODM_RESET
Definition: mmddk.h:162
#define MODM_GETNUMDEVS
Definition: mmddk.h:154
#define MODM_DATA
Definition: mmddk.h:160
#define MODM_GETVOLUME
Definition: mmddk.h:163
#define DRVM_ENABLE
Definition: mmddk.h:59
#define MODM_OPEN
Definition: mmddk.h:156
#define MODM_SETVOLUME
Definition: mmddk.h:164
#define MODM_UNPREPARE
Definition: mmddk.h:159
#define DRVM_EXIT
Definition: mmddk.h:57
#define MODM_LONGDATA
Definition: mmddk.h:161
#define MODM_CLOSE
Definition: mmddk.h:157
static DWORD modClose(MIDIMAPDATA *mom)
Definition: midimap.c:296
static DWORD modPrepare(MIDIMAPDATA *mom, LPMIDIHDR lpMidiHdr, DWORD_PTR dwParam2)
Definition: midimap.c:410
static DWORD modLongData(MIDIMAPDATA *mom, LPMIDIHDR lpMidiHdr, DWORD_PTR dwParam2)
Definition: midimap.c:323
static DWORD modUnprepare(MIDIMAPDATA *mom, LPMIDIHDR lpMidiHdr, DWORD_PTR dwParam2)
Definition: midimap.c:420
static DWORD modData(MIDIMAPDATA *mom, DWORD_PTR dwParam)
Definition: midimap.c:347
static DWORD modOpen(DWORD_PTR *lpdwUser, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
Definition: midimap.c:277
static DWORD modGetDevCaps(UINT wDevID, MIDIMAPDATA *mom, LPMIDIOUTCAPSW lpMidiCaps, DWORD_PTR size)
Definition: midimap.c:430
static DWORD modReset(MIDIMAPDATA *mom)
Definition: midimap.c:446
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
uint32_t DWORD_PTR
Definition: typedefs.h:65

◆ modClose()

static DWORD modClose ( MIDIMAPDATA mom)
static

Definition at line 296 of file midimap.c.

297{
298 UINT i;
300
301 if (MIDIMAP_IsBadData(mom)) return MMSYSERR_ERROR;
302
303 for (i = 0; i < 16; i++)
304 {
305 DWORD t;
306 if (mom->ChannelMap[i] && mom->ChannelMap[i]->loaded > 0)
307 {
308 t = midiOutClose(mom->ChannelMap[i]->hMidi);
309 if (t == MMSYSERR_NOERROR)
310 {
311 mom->ChannelMap[i]->loaded = 0;
312 mom->ChannelMap[i]->hMidi = 0;
313 }
314 else if (ret == MMSYSERR_NOERROR)
315 ret = t;
316 }
317 }
318 if (ret == MMSYSERR_NOERROR)
319 HeapFree(GetProcessHeap(), 0, mom);
320 return ret;
321}
GLdouble GLdouble t
Definition: gl.h:2047
static BOOL MIDIMAP_IsBadData(MIDIMAPDATA *mm)
Definition: midimap.c:102
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI midiOutClose(HMIDIOUT hMidiOut)
Definition: winmm.c:978

Referenced by MIDIMAP_modMessage().

◆ modData()

static DWORD modData ( MIDIMAPDATA mom,
DWORD_PTR  dwParam 
)
static

Definition at line 347 of file midimap.c.

348{
349 BYTE lb = LOBYTE(LOWORD(dwParam));
350 WORD chn = lb & 0x0F;
352
353 if (MIDIMAP_IsBadData(mom))
354 return MMSYSERR_ERROR;
355
356 if (!mom->ChannelMap[chn]) return MMSYSERR_NOERROR;
357
358 switch (lb & 0xF0)
359 {
360 case 0x80:
361 case 0x90:
362 case 0xA0:
363 case 0xB0:
364 case 0xC0:
365 case 0xD0:
366 case 0xE0:
367 if (mom->ChannelMap[chn]->loaded == 0)
368 {
369 if (midiOutOpen(&mom->ChannelMap[chn]->hMidi, mom->ChannelMap[chn]->uDevID,
371 mom->ChannelMap[chn]->loaded = 1;
372 else
373 mom->ChannelMap[chn]->loaded = -1;
374 /* FIXME: should load here the IDF midi data... and allow channel and
375 * patch mappings
376 */
377 }
378 if (mom->ChannelMap[chn]->loaded > 0)
379 {
380 /* change channel */
381 dwParam &= ~0x0F;
382 dwParam |= mom->ChannelMap[chn]->aChn[chn];
383
384 if ((LOBYTE(LOWORD(dwParam)) & 0xF0) == 0xC0 /* program change */ &&
385 mom->ChannelMap[chn]->lpbPatch)
386 {
387 BYTE patch = HIBYTE(LOWORD(dwParam));
388
389 /* change patch */
390 dwParam &= ~0x0000FF00;
391 dwParam |= mom->ChannelMap[chn]->lpbPatch[patch];
392 }
393 ret = midiOutShortMsg(mom->ChannelMap[chn]->hMidi, dwParam);
394 }
395 break;
396 case 0xF0:
397 for (chn = 0; chn < 16; chn++)
398 {
399 if (mom->ChannelMap[chn]->loaded > 0)
400 ret = midiOutShortMsg(mom->ChannelMap[chn]->hMidi, dwParam);
401 }
402 break;
403 default:
404 FIXME("ooch %lx\n", dwParam);
405 }
406
407 return ret;
408}
unsigned short WORD
Definition: ntddk_ex.h:93
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
#define CALLBACK_NULL
Definition: mmsystem.h:147
#define LOWORD(l)
Definition: pedump.c:82
unsigned int aChn[16]
Definition: midimap.c:90
UINT WINAPI midiOutShortMsg(HMIDIOUT hMidiOut, DWORD dwMsg)
Definition: winmm.c:1039
MMRESULT WINAPI midiOutOpen(LPHMIDIOUT lphMidiOut, UINT uDeviceID, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags)
Definition: winmm.c:939
unsigned char BYTE
Definition: xxhash.c:193

Referenced by MIDIMAP_modMessage().

◆ modGetDevCaps()

static DWORD modGetDevCaps ( UINT  wDevID,
MIDIMAPDATA mom,
LPMIDIOUTCAPSW  lpMidiCaps,
DWORD_PTR  size 
)
static

Definition at line 430 of file midimap.c.

431{
432 static const WCHAR name[] = {'W','i','n','e',' ','m','i','d','i',' ','m','a','p','p','e','r',0};
433 lpMidiCaps->wMid = 0x00FF;
434 lpMidiCaps->wPid = 0x0001;
435 lpMidiCaps->vDriverVersion = 0x0100;
436 lstrcpyW(lpMidiCaps->szPname, name);
437 lpMidiCaps->wTechnology = MOD_MAPPER;
438 lpMidiCaps->wVoices = 0;
439 lpMidiCaps->wNotes = 0;
440 lpMidiCaps->wChannelMask = 0xFFFF;
441 lpMidiCaps->dwSupport = 0L;
442
443 return MMSYSERR_NOERROR;
444}
#define lstrcpyW
Definition: compat.h:749
#define MOD_MAPPER
Definition: mmsystem.h:263
MMVERSION vDriverVersion
Definition: mmsystem.h:1125

Referenced by MIDIMAP_modMessage().

◆ modLongData()

static DWORD modLongData ( MIDIMAPDATA mom,
LPMIDIHDR  lpMidiHdr,
DWORD_PTR  dwParam2 
)
static

Definition at line 323 of file midimap.c.

324{
325 WORD chn;
327 MIDIHDR mh;
328
329 if (MIDIMAP_IsBadData(mom))
330 return MMSYSERR_ERROR;
331
332 mh = *lpMidiHdr;
333 for (chn = 0; chn < 16; chn++)
334 {
335 if (mom->ChannelMap[chn] && mom->ChannelMap[chn]->loaded > 0)
336 {
337 mh.dwFlags = 0;
338 midiOutPrepareHeader(mom->ChannelMap[chn]->hMidi, &mh, sizeof(mh));
339 ret = midiOutLongMsg(mom->ChannelMap[chn]->hMidi, &mh, sizeof(mh));
340 midiOutUnprepareHeader(mom->ChannelMap[chn]->hMidi, &mh, sizeof(mh));
341 if (ret != MMSYSERR_NOERROR) break;
342 }
343 }
344 return ret;
345}
DWORD dwFlags
Definition: mmsystem.h:1155
UINT WINAPI midiOutLongMsg(HMIDIOUT hMidiOut, MIDIHDR *lpMidiOutHdr, UINT uSize)
Definition: winmm.c:1054
UINT WINAPI midiOutUnprepareHeader(HMIDIOUT hMidiOut, MIDIHDR *lpMidiOutHdr, UINT uSize)
Definition: winmm.c:1016
UINT WINAPI midiOutPrepareHeader(HMIDIOUT hMidiOut, MIDIHDR *lpMidiOutHdr, UINT uSize)
Definition: winmm.c:997

Referenced by MIDIMAP_modMessage().

◆ modOpen()

static DWORD modOpen ( DWORD_PTR lpdwUser,
LPMIDIOPENDESC  lpDesc,
DWORD  dwFlags 
)
static

Definition at line 277 of file midimap.c.

278{
279 MIDIMAPDATA* mom = HeapAlloc(GetProcessHeap(), 0, sizeof(MIDIMAPDATA));
280
281 TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags);
282
283 if (!mom) return MMSYSERR_NOMEM;
284
285 if (MIDIMAP_LoadSettings(mom))
286 {
287 *lpdwUser = (DWORD_PTR)mom;
288 mom->self = mom;
289
290 return MMSYSERR_NOERROR;
291 }
292 HeapFree(GetProcessHeap(), 0, mom);
294}
static BOOL MIDIMAP_LoadSettings(MIDIMAPDATA *mom)
Definition: midimap.c:203
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define MIDIERR_INVALIDSETUP
Definition: mmsystem.h:236
#define DWORD_PTR
Definition: treelist.c:76
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by MIDIMAP_modMessage().

◆ modPrepare()

static DWORD modPrepare ( MIDIMAPDATA mom,
LPMIDIHDR  lpMidiHdr,
DWORD_PTR  dwParam2 
)
static

Definition at line 410 of file midimap.c.

411{
412 if (MIDIMAP_IsBadData(mom)) return MMSYSERR_ERROR;
413 if (lpMidiHdr->dwFlags & (MHDR_ISSTRM|MHDR_PREPARED))
414 return MMSYSERR_INVALPARAM;
415
416 lpMidiHdr->dwFlags |= MHDR_PREPARED;
417 return MMSYSERR_NOERROR;
418}
#define MHDR_PREPARED
Definition: mmsystem.h:269
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define MHDR_ISSTRM
Definition: mmsystem.h:271

Referenced by MIDIMAP_modMessage().

◆ modReset()

static DWORD modReset ( MIDIMAPDATA mom)
static

Definition at line 446 of file midimap.c.

447{
448 WORD chn;
450
451 if (MIDIMAP_IsBadData(mom))
452 return MMSYSERR_ERROR;
453
454 for (chn = 0; chn < 16; chn++)
455 {
456 if (mom->ChannelMap[chn] && mom->ChannelMap[chn]->loaded > 0)
457 {
458 ret = midiOutReset(mom->ChannelMap[chn]->hMidi);
459 if (ret != MMSYSERR_NOERROR) break;
460 }
461 }
462 return ret;
463}
UINT WINAPI midiOutReset(HMIDIOUT hMidiOut)
Definition: winmm.c:1070

Referenced by MIDIMAP_modMessage().

◆ modUnprepare()

static DWORD modUnprepare ( MIDIMAPDATA mom,
LPMIDIHDR  lpMidiHdr,
DWORD_PTR  dwParam2 
)
static

Definition at line 420 of file midimap.c.

421{
422 if (MIDIMAP_IsBadData(mom)) return MMSYSERR_ERROR;
423 if ((lpMidiHdr->dwFlags & MHDR_ISSTRM) || !(lpMidiHdr->dwFlags & MHDR_PREPARED))
424 return MMSYSERR_INVALPARAM;
425
426 lpMidiHdr->dwFlags &= ~MHDR_PREPARED;
427 return MMSYSERR_NOERROR;
428}

Referenced by MIDIMAP_modMessage().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msacm  )

Variable Documentation

◆ midiOutPorts

◆ numMidiOutPorts

unsigned numMidiOutPorts
static

Definition at line 100 of file midimap.c.

Referenced by MIDIMAP_drvOpen(), MIDIMAP_FindPort(), and MIDIMAP_LoadSettingsDefault().