Skip to content

Commit

Permalink
Merge pull request #384 from microsoft/midi2merge
Browse files Browse the repository at this point in the history
Midi2merge
  • Loading branch information
Psychlist1972 authored Aug 5, 2024
2 parents 6b1eaa6 + d69266c commit 0132f02
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
36 changes: 19 additions & 17 deletions src/api/Client/WinMM/winmmdrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ struct MIDICLIENT
LPMIDIHDR buffers[16] {0};
};

struct MIDICLIENT g_InClients[32];
struct MIDICLIENT g_OutClients[32];
#define MAX_CLIENTS 32

struct MIDICLIENT g_InClients[MAX_CLIENTS];
struct MIDICLIENT g_OutClients[MAX_CLIENTS];

void Callback(struct MIDICLIENT* client, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2)
{
Expand Down Expand Up @@ -94,9 +96,9 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
case MIDM_OPEN:
{
UINT freeIndex = 0;
for (freeIndex = 0; g_InClients[freeIndex].used && freeIndex < 32; freeIndex++);
for (freeIndex = 0;freeIndex < MAX_CLIENTS && g_InClients[freeIndex].used; freeIndex++);

if (freeIndex < 32 &&
if (freeIndex < MAX_CLIENTS &&
dwParam1 >= sizeof(MIDIOPENDESC))
{
g_InClients[freeIndex].used = TRUE;
Expand All @@ -118,7 +120,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand All @@ -141,7 +143,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
if (nullptr != header &&
dwParam2 >= sizeof(MIDIHDR))
{
for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand Down Expand Up @@ -169,7 +171,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand All @@ -185,7 +187,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand All @@ -201,7 +203,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand Down Expand Up @@ -252,9 +254,9 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
case MODM_OPEN:
{
UINT freeIndex = 0;
for (freeIndex = 0; g_OutClients[freeIndex].used && freeIndex < 32; freeIndex++);
for (freeIndex = 0;freeIndex < MAX_CLIENTS && g_OutClients[freeIndex].used; freeIndex++);

if (freeIndex < 32 &&
if (freeIndex < MAX_CLIENTS &&
dwParam1 >= sizeof(MIDIOPENDESC))
{
g_OutClients[freeIndex].used = TRUE;
Expand All @@ -276,7 +278,7 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_OutClients[index].used &&
g_OutClients[index].user == dwUser)
Expand All @@ -299,13 +301,13 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
if (nullptr != header &&
dwParam2 >= sizeof(MIDIHDR))
{
for (UINT outIndex = 0; outIndex < 32; outIndex++)
for (UINT outIndex = 0; outIndex < MAX_CLIENTS; outIndex++)
{
if (g_OutClients[outIndex].used && g_OutClients[outIndex].user == dwUser)
{
mmResult = MMSYSERR_NOERROR;

for (UINT inIndex = 0; inIndex < 32; inIndex++)
for (UINT inIndex = 0; inIndex < MAX_CLIENTS; inIndex++)
{
if (g_InClients[inIndex].used &&
g_OutClients[outIndex].device == g_InClients[inIndex].device)
Expand Down Expand Up @@ -334,13 +336,13 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT outIndex = 0; outIndex < 32; outIndex++)
for (UINT outIndex = 0; outIndex < MAX_CLIENTS; outIndex++)
{
if (g_OutClients[outIndex].used && g_OutClients[outIndex].user == dwUser)
{
mmResult = MMSYSERR_NOERROR;

for (UINT inIndex = 0; inIndex < 32; inIndex++)
for (UINT inIndex = 0; inIndex < MAX_CLIENTS; inIndex++)
{
if (g_InClients[inIndex].used &&
g_OutClients[outIndex].device == g_InClients[inIndex].device)
Expand All @@ -362,7 +364,7 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_OutClients[index].used && g_OutClients[index].user == dwUser)
{
Expand Down
4 changes: 2 additions & 2 deletions src/api/Inc/MidiKSCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ InstantiateMidiPin(

BOOL
IsAutogeneratedPinName(
_In_ const WCHAR* FilterName,
_In_z_ const WCHAR* FilterName,
_In_ ULONG PinId,
_In_ const WCHAR* NameToCheck
_In_z_ const WCHAR* NameToCheck
);

1 change: 0 additions & 1 deletion src/api/Libs/MidiKsCommon/MidiKsCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ InstantiateMidiPin(
return S_OK;
}

_Use_decl_annotations_
BOOL
IsAutogeneratedPinName(
const WCHAR* FilterName,
Expand Down
2 changes: 1 addition & 1 deletion src/api/Service/Exe/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace json = ::winrt::Windows::Data::Json;
#include "Midi2BS2UMPTransform.h"
#include "Midi2UMP2BSTransform.h"
#include "Midi2SchedulerTransform.h"
#include "Midi2EndpointMetadataListenerTransform.h"
//#include "Midi2EndpointMetadataListenerTransform.h"
#include "Midi2UmpProtocolDownscalerTransform.h"

// MidiSrv internal classes
Expand Down

0 comments on commit 0132f02

Please sign in to comment.