Skip to content

Commit

Permalink
Naming fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Psychlist1972 committed Feb 17, 2025
1 parent 593ce15 commit 5eadd89
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/api/Inc/midi_naming.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,28 @@ namespace WindowsMidiServicesInternal::Midi1PortNaming
}


// this is the fallback
// this is the fallback. This needs better calculation to better support block name

std::wstring name;

if (!transportSuppliedEndpointName.empty() && blockName != transportSuppliedEndpointName)
if (!transportSuppliedEndpointName.empty())
{
name = internal::TrimmedWStringCopy(transportSuppliedEndpointName + L" " + blockName);
if (auto pos = blockName.find(transportSuppliedEndpointName); pos != std::wstring::npos)
{
name = internal::TrimmedWStringCopy(transportSuppliedEndpointName + L" " + internal::TrimmedWStringCopy(blockName.substr(pos + transportSuppliedEndpointName.length())));
}
else
{
name = internal::TrimmedWStringCopy(transportSuppliedEndpointName + L" " + blockName);
}
}
else
else if (!blockName.empty())
{
name = transportSuppliedEndpointName;
name = blockName;
}
else if (!parentDeviceName.empty())
{
name = parentDeviceName;
}

return truncateToWinMMLimit ? name.substr(0, MAXPNAMELEN - 1) : name;
Expand Down

0 comments on commit 5eadd89

Please sign in to comment.