1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

CoreMidi: Respect input protocol request

This commit is contained in:
reuk 2025-09-24 12:14:12 +01:00
parent 69d0e8da1e
commit fa1b4b07ef
No known key found for this signature in database

View file

@ -1762,7 +1762,8 @@ struct CoreMidiHelpers
} }
static std::shared_ptr<ConnectionToSrc> make (std::shared_ptr<SharedEndpointsImplNative> cachedEndpoints, static std::shared_ptr<ConnectionToSrc> make (std::shared_ptr<SharedEndpointsImplNative> cachedEndpoints,
ump::EndpointId id) ump::EndpointId id,
ump::PacketProtocol protocol)
{ {
const auto endpoint = cachedEndpoints->getNativeEndpointForId (ump::IOKind::src, id); const auto endpoint = cachedEndpoints->getNativeEndpointForId (ump::IOKind::src, id);
@ -1780,7 +1781,7 @@ struct CoreMidiHelpers
auto receiver = rawToUniquePtr (new ConnectionToSrc (cachedEndpoints)); auto receiver = rawToUniquePtr (new ConnectionToSrc (cachedEndpoints));
MIDIPortRef port; MIDIPortRef port;
const auto error = CreatorFunctionsToUse::createInputPort (ump::PacketProtocol::MIDI_2_0, const auto error = CreatorFunctionsToUse::createInputPort (protocol,
cachedEndpoints->getClient(), cachedEndpoints->getClient(),
cfName.object, cfName.object,
&receiver->receiver, &receiver->receiver,
@ -2361,7 +2362,7 @@ struct CoreMidiHelpers
ump::PacketProtocol p, ump::PacketProtocol p,
ump::Consumer& c) override ump::Consumer& c) override
{ {
if (auto src = findOrMakeSrc (id)) if (auto src = findOrMakeSrc (id, p))
return rawToUniquePtr (new InputImplNative { src, id, l, p, c }); return rawToUniquePtr (new InputImplNative { src, id, l, p, c });
return {}; return {};
@ -2396,7 +2397,8 @@ struct CoreMidiHelpers
if (connection != nullptr) if (connection != nullptr)
{ {
connectionsSrc[connection->getId()] = connection->getSrc(); connectionsSrc[{ connection->getId(), ump::PacketProtocol::MIDI_1_0 }] = connection->getSrc();
connectionsSrc[{ connection->getId(), ump::PacketProtocol::MIDI_2_0 }] = connection->getSrc();
connectionsDst[connection->getId()] = connection->getDst(); connectionsDst[connection->getId()] = connection->getDst();
} }
@ -2415,7 +2417,7 @@ struct CoreMidiHelpers
return {}; return {};
auto result = LegacyVirtualEndpointImplNative::make (connection, id); auto result = LegacyVirtualEndpointImplNative::make (connection, id);
connectionsSrc[result->getId()] = connection; connectionsSrc[{ result->getId(), ump::PacketProtocol::MIDI_1_0 }] = connection;
return result; return result;
} }
@ -2440,14 +2442,14 @@ struct CoreMidiHelpers
SessionImplNative (std::shared_ptr<SharedEndpointsImplNative> c, const String& n) SessionImplNative (std::shared_ptr<SharedEndpointsImplNative> c, const String& n)
: cachedEndpoints (c), name (n) {} : cachedEndpoints (c), name (n) {}
std::shared_ptr<ConnectionToSrc> findOrMakeSrc (const ump::EndpointId& id) std::shared_ptr<ConnectionToSrc> findOrMakeSrc (const ump::EndpointId& id, ump::PacketProtocol protocol)
{ {
auto& weak = connectionsSrc[id]; auto& weak = connectionsSrc[{ id, protocol }];
if (auto strong = weak.lock()) if (auto strong = weak.lock())
return strong; return strong;
const auto strong = ConnectionToSrc::make (cachedEndpoints, id); const auto strong = ConnectionToSrc::make (cachedEndpoints, id, protocol);
weak = strong; weak = strong;
return strong; return strong;
} }
@ -2464,7 +2466,16 @@ struct CoreMidiHelpers
return strong; return strong;
} }
std::map<ump::EndpointId, std::weak_ptr<ConnectionToSrc>> connectionsSrc; struct SrcKey
{
ump::EndpointId id;
ump::PacketProtocol protocol;
auto tie() const { return std::tie (id, protocol); }
auto operator< (const SrcKey& other) const { return tie() < other.tie(); }
};
std::map<SrcKey, std::weak_ptr<ConnectionToSrc>> connectionsSrc;
std::map<ump::EndpointId, std::weak_ptr<ConnectionToDst>> connectionsDst; std::map<ump::EndpointId, std::weak_ptr<ConnectionToDst>> connectionsDst;
std::shared_ptr<SharedEndpointsImplNative> cachedEndpoints; std::shared_ptr<SharedEndpointsImplNative> cachedEndpoints;