From 5eadd891d9fcdf14e0822539c9e467f83e40bc92 Mon Sep 17 00:00:00 2001 From: Pete Brown Date: Mon, 17 Feb 2025 04:44:34 -0500 Subject: [PATCH] Naming fixes --- src/api/Inc/midi_naming.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/api/Inc/midi_naming.h b/src/api/Inc/midi_naming.h index 98b24af3..6f37d1d5 100644 --- a/src/api/Inc/midi_naming.h +++ b/src/api/Inc/midi_naming.h @@ -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;