@@ -52,8 +52,10 @@ struct MIDICLIENT
52
52
LPMIDIHDR buffers[16 ] {0 };
53
53
};
54
54
55
- struct MIDICLIENT g_InClients[32 ];
56
- struct MIDICLIENT g_OutClients[32 ];
55
+ #define MAX_CLIENTS 32
56
+
57
+ struct MIDICLIENT g_InClients[MAX_CLIENTS];
58
+ struct MIDICLIENT g_OutClients[MAX_CLIENTS];
57
59
58
60
void Callback (struct MIDICLIENT * client, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2)
59
61
{
@@ -94,9 +96,9 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
94
96
case MIDM_OPEN:
95
97
{
96
98
UINT freeIndex = 0 ;
97
- for (freeIndex = 0 ; g_InClients[freeIndex].used && freeIndex < 32 ; freeIndex++);
99
+ for (freeIndex = 0 ;freeIndex < MAX_CLIENTS && g_InClients[freeIndex].used ; freeIndex++);
98
100
99
- if (freeIndex < 32 &&
101
+ if (freeIndex < MAX_CLIENTS &&
100
102
dwParam1 >= sizeof (MIDIOPENDESC))
101
103
{
102
104
g_InClients[freeIndex].used = TRUE ;
@@ -118,7 +120,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
118
120
{
119
121
mmResult = MMSYSERR_ERROR;
120
122
121
- for (UINT index = 0 ; index < 32 ; index++)
123
+ for (UINT index = 0 ; index < MAX_CLIENTS ; index++)
122
124
{
123
125
if (g_InClients[index].used && g_InClients[index].user == dwUser)
124
126
{
@@ -141,7 +143,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
141
143
if (nullptr != header &&
142
144
dwParam2 >= sizeof (MIDIHDR))
143
145
{
144
- for (UINT index = 0 ; index < 32 ; index++)
146
+ for (UINT index = 0 ; index < MAX_CLIENTS ; index++)
145
147
{
146
148
if (g_InClients[index].used && g_InClients[index].user == dwUser)
147
149
{
@@ -169,7 +171,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
169
171
{
170
172
mmResult = MMSYSERR_ERROR;
171
173
172
- for (UINT index = 0 ; index < 32 ; index++)
174
+ for (UINT index = 0 ; index < MAX_CLIENTS ; index++)
173
175
{
174
176
if (g_InClients[index].used && g_InClients[index].user == dwUser)
175
177
{
@@ -185,7 +187,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
185
187
{
186
188
mmResult = MMSYSERR_ERROR;
187
189
188
- for (UINT index = 0 ; index < 32 ; index++)
190
+ for (UINT index = 0 ; index < MAX_CLIENTS ; index++)
189
191
{
190
192
if (g_InClients[index].used && g_InClients[index].user == dwUser)
191
193
{
@@ -201,7 +203,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
201
203
{
202
204
mmResult = MMSYSERR_ERROR;
203
205
204
- for (UINT index = 0 ; index < 32 ; index++)
206
+ for (UINT index = 0 ; index < MAX_CLIENTS ; index++)
205
207
{
206
208
if (g_InClients[index].used && g_InClients[index].user == dwUser)
207
209
{
@@ -252,9 +254,9 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
252
254
case MODM_OPEN:
253
255
{
254
256
UINT freeIndex = 0 ;
255
- for (freeIndex = 0 ; g_OutClients[freeIndex].used && freeIndex < 32 ; freeIndex++);
257
+ for (freeIndex = 0 ;freeIndex < MAX_CLIENTS && g_OutClients[freeIndex].used ; freeIndex++);
256
258
257
- if (freeIndex < 32 &&
259
+ if (freeIndex < MAX_CLIENTS &&
258
260
dwParam1 >= sizeof (MIDIOPENDESC))
259
261
{
260
262
g_OutClients[freeIndex].used = TRUE ;
@@ -276,7 +278,7 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
276
278
{
277
279
mmResult = MMSYSERR_ERROR;
278
280
279
- for (UINT index = 0 ; index < 32 ; index++)
281
+ for (UINT index = 0 ; index < MAX_CLIENTS ; index++)
280
282
{
281
283
if (g_OutClients[index].used &&
282
284
g_OutClients[index].user == dwUser)
@@ -299,13 +301,13 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
299
301
if (nullptr != header &&
300
302
dwParam2 >= sizeof (MIDIHDR))
301
303
{
302
- for (UINT outIndex = 0 ; outIndex < 32 ; outIndex++)
304
+ for (UINT outIndex = 0 ; outIndex < MAX_CLIENTS ; outIndex++)
303
305
{
304
306
if (g_OutClients[outIndex].used && g_OutClients[outIndex].user == dwUser)
305
307
{
306
308
mmResult = MMSYSERR_NOERROR;
307
309
308
- for (UINT inIndex = 0 ; inIndex < 32 ; inIndex++)
310
+ for (UINT inIndex = 0 ; inIndex < MAX_CLIENTS ; inIndex++)
309
311
{
310
312
if (g_InClients[inIndex].used &&
311
313
g_OutClients[outIndex].device == g_InClients[inIndex].device )
@@ -334,13 +336,13 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
334
336
{
335
337
mmResult = MMSYSERR_ERROR;
336
338
337
- for (UINT outIndex = 0 ; outIndex < 32 ; outIndex++)
339
+ for (UINT outIndex = 0 ; outIndex < MAX_CLIENTS ; outIndex++)
338
340
{
339
341
if (g_OutClients[outIndex].used && g_OutClients[outIndex].user == dwUser)
340
342
{
341
343
mmResult = MMSYSERR_NOERROR;
342
344
343
- for (UINT inIndex = 0 ; inIndex < 32 ; inIndex++)
345
+ for (UINT inIndex = 0 ; inIndex < MAX_CLIENTS ; inIndex++)
344
346
{
345
347
if (g_InClients[inIndex].used &&
346
348
g_OutClients[outIndex].device == g_InClients[inIndex].device )
@@ -362,7 +364,7 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
362
364
{
363
365
mmResult = MMSYSERR_ERROR;
364
366
365
- for (UINT index = 0 ; index < 32 ; index++)
367
+ for (UINT index = 0 ; index < MAX_CLIENTS ; index++)
366
368
{
367
369
if (g_OutClients[index].used && g_OutClients[index].user == dwUser)
368
370
{
0 commit comments