Skip to content

Commit

Permalink
Merge pull request #484 from microsoft/pete-dev
Browse files Browse the repository at this point in the history
DP9 NAMM Preview 1 for Network MIDI 2.0
  • Loading branch information
Psychlist1972 authored Jan 12, 2025
2 parents 183ffcc + 22c9009 commit f33b267
Show file tree
Hide file tree
Showing 53 changed files with 2,692 additions and 624 deletions.
2 changes: 1 addition & 1 deletion build/staging/version/BundleInfo.wxi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Include>
<?define SetupVersionName="Developer Preview 9 Arm64" ?>
<?define SetupVersionNumber="1.0.2-preview-9.250106-1428" ?>
<?define SetupVersionNumber="1.0.2-preview-9.250112-1659" ?>
</Include>
6 changes: 3 additions & 3 deletions build/staging/version/WindowsMidiServicesVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ public static class MidiBuildInformation
{
public const string Source = "GitHub Preview";
public const string Name = "Developer Preview 9";
public const string BuildFullVersion = "1.0.2-preview-9.250106-1428";
public const string BuildFullVersion = "1.0.2-preview-9.250112-1659";
public const string VersionMajor = "1";
public const string VersionMinor = "0";
public const string VersionRevision = "2";
public const string VersionDateNumber = "250106";
public const string VersionTimeNumber = "1428";
public const string VersionDateNumber = "250112";
public const string VersionTimeNumber = "1659";
}
}

6 changes: 3 additions & 3 deletions build/staging/version/WindowsMidiServicesVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#define WINDOWS_MIDI_SERVICES_BUILD_SOURCE L"GitHub Preview"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_NAME L"Developer Preview 9"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_FULL L"1.0.2-preview-9.250106-1428"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_FULL L"1.0.2-preview-9.250112-1659"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_MAJOR L"1"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_MINOR L"0"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_REVISION L"2"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_DATE_NUMBER L"250106"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_TIME_NUMBER L"1428"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_DATE_NUMBER L"250112"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_TIME_NUMBER L"1659"

#endif

37 changes: 3 additions & 34 deletions diagnostics/trace-logging/MidiServices.wprp
Original file line number Diff line number Diff line change
@@ -1,41 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<WindowsPerformanceRecorder Version="1.0" Author="Microsoft Corporation" Copyright="Microsoft Corporation" Company="Microsoft Corporation">
<Profiles>
<SystemCollector Id="SystemCollector" Name="System Collector">
<BufferSize Value="256" />
<Buffers Value="3" PercentageOfTotalMemory="true" MaximumBufferSpace="256" />
</SystemCollector>

<EventCollector Id="EventCollector_MidiSrvSimple" Name="Windows MIDI Services Events">
<BufferSize Value="256" />
<Buffers Value="64" />
</EventCollector>
<SystemProvider Id="SystemProvider">
<Keywords>
<Keyword Value="CpuConfig" />
<Keyword Value="CSwitch" />
<Keyword Value="DiskIO" />
<Keyword Value="DPC" />
<Keyword Value="HardFaults" />
<Keyword Value="Interrupt" />
<Keyword Value="KernelQueue" />
<Keyword Value="Loader" />
<Keyword Value="Power" />
<Keyword Value="ProcessThread" />
<Keyword Value="ReadyThread" />
<Keyword Value="SampledProfile" />
<Keyword Value="WDFDPC" />
<Keyword Value="WDFInterrupt" />
</Keywords>
<Stacks>
<Stack Value="CSwitch" />
<Stack Value="ProcessCreate" />
<Stack Value="ProcessDelete" />
<Stack Value="ReadyThread" />
<Stack Value="SampledProfile" />
<Stack Value="ThreadCreate" />
<Stack Value="ThreadDelete" />
</Stacks>
</SystemProvider>


<EventProvider Id="EventProvider_MidiSrv" Stack="true" ProcessExeFilter="Midisrv.exe" Name="*Microsoft.Windows.Midi2.MidiSrv"/>
<EventProvider Id="EventProvider_MidiSrvTransport" Name="*Microsoft.Windows.Midi2.MidiSrvTransport"/>
Expand Down Expand Up @@ -65,9 +36,7 @@

<Profile Id="MidiSrv.Verbose.File" Name="MidiSrv" DetailLevel="Verbose" Description="Windows MIDI Services trace profile" LoggingMode="File">
<Collectors>
<SystemCollectorId Value="SystemCollector">
<SystemProviderId Value="SystemProvider" />
</SystemCollectorId>

<EventCollectorId Value="EventCollector_MidiSrvSimple">
<EventProviders>
<EventProviderId Value="EventProvider_MidiSrv"/>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/basics/client-basics-cpp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250106-1428</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250112-1659</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>false</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/basics/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250106-1428" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250112-1659" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250106-1428</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250112-1659</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/loopback-endpoints/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250106-1428" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250112-1659" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion samples/cpp-winrt/send-speed/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250106-1428" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250112-1659" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion samples/cpp-winrt/send-speed/send-speed-cpp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250106-1428</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250112-1659</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/simple-app-to-app-midi/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250106-1428" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250112-1659" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250106-1428</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250112-1659</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/static-enum-endpoints/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250106-1428" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250112-1659" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250106-1428</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250112-1659</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/watch-endpoints/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250106-1428" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.2-preview-9.250112-1659" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250106-1428</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.2-preview-9.250112-1659</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
32 changes: 16 additions & 16 deletions src/api/Service/Exe/MidiDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2259,20 +2259,20 @@ CMidiDeviceManager::UseFallbackMidi1PortDefinition(
additionalProperties.Append(winrt::to_hstring(STRING_PKEY_MIDI_FunctionBlocksAreStatic));
auto deviceInfo = DeviceInformation::CreateFromIdAsync(umpDeviceInterfaceId, additionalProperties, winrt::Windows::Devices::Enumeration::DeviceInformationKind::DeviceInterface).get();

auto prop = deviceInfo.Properties().Lookup(winrt::to_hstring(STRING_PKEY_MIDI_FunctionBlocksAreStatic));
if (prop)
{
auto functionBlocksAreStatic = winrt::unbox_value<winrt::Windows::Foundation::IReferenceArray<bool>>(prop);
if (functionBlocksAreStatic)
{
TraceLoggingWrite(
MidiSrvTelemetryProvider::Provider(),
MIDI_TRACE_EVENT_INFO,
TraceLoggingString(__FUNCTION__, MIDI_TRACE_EVENT_LOCATION_FIELD),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingPointer(this, "this"),
TraceLoggingWideString(L"Using static function blocks", MIDI_TRACE_EVENT_MESSAGE_FIELD)
);
//auto prop = deviceInfo.Properties().Lookup(winrt::to_hstring(STRING_PKEY_MIDI_FunctionBlocksAreStatic));
//if (prop)
//{
//auto functionBlocksAreStatic = winrt::unbox_value<winrt::Windows::Foundation::IReferenceArray<bool>>(prop);
//if (functionBlocksAreStatic)
//{
// TraceLoggingWrite(
// MidiSrvTelemetryProvider::Provider(),
// MIDI_TRACE_EVENT_INFO,
// TraceLoggingString(__FUNCTION__, MIDI_TRACE_EVENT_LOCATION_FIELD),
// TraceLoggingLevel(WINEVENT_LEVEL_INFO),
// TraceLoggingPointer(this, "this"),
// TraceLoggingWideString(L"Using static function blocks", MIDI_TRACE_EVENT_MESSAGE_FIELD)
// );

for (UINT flow = 0; flow < 2; flow++)
{
Expand All @@ -2284,8 +2284,8 @@ CMidiDeviceManager::UseFallbackMidi1PortDefinition(
portInfo[flow][groupIndex].InterfaceId = umpDeviceInterfaceId;
}
}
}
}
//}
//}

return S_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ CMidi2NetworkMidiBiDi::Initialize(
// look up the endpointDeviceInterfaceId in our list of endpoints, and connect to it

m_connection = TransportState::Current().GetSessionConnection(m_endpointDeviceInterfaceId);
RETURN_HR_IF_NULL(E_INVALIDARG, m_connection);

m_connection->SetMidiCallback(this);
if (auto conn = m_connection.lock())
{
RETURN_IF_FAILED(conn->ConnectMidiCallback(this));
}
else
{
RETURN_IF_FAILED(E_INVALIDARG);
}


return S_OK;
}
Expand All @@ -62,15 +69,16 @@ CMidi2NetworkMidiBiDi::Shutdown()
TraceLoggingWideString(L"Enter", MIDI_TRACE_EVENT_MESSAGE_FIELD)
);

m_callback = nullptr;
m_context = 0;
// TODO: This causes the service to crash when the remote network endpoint disconnects. Need to look into this further.

if (m_connection)
if (auto ptr = m_connection.lock())
{
m_connection->RemoveMidiCallback();
ptr->DisconnectMidiCallback();
m_connection.reset();
}


m_callback = nullptr;
m_context = 0;

return S_OK;
}
Expand All @@ -88,9 +96,10 @@ CMidi2NetworkMidiBiDi::SendMidiMessage(
RETURN_HR_IF_NULL(E_INVALIDARG, message);
RETURN_HR_IF(E_INVALIDARG, size < sizeof(uint32_t));

RETURN_HR_IF_NULL(E_UNEXPECTED, m_connection);

RETURN_IF_FAILED(m_connection->SendMidiMessagesToNetwork(message, size));
if (auto conn = m_connection.lock())
{
RETURN_IF_FAILED(conn->SendMidiMessagesToNetwork(message, size));
}

return S_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class CMidi2NetworkMidiBiDi :
STDMETHOD(Shutdown)();

private:
IMidiCallback* m_callback{ nullptr };
wil::com_ptr_nothrow<IMidiCallback> m_callback{ nullptr };
LONGLONG m_context{ 0 };

std::wstring m_endpointDeviceInterfaceId{ };

std::shared_ptr<MidiNetworkConnection> m_connection{ nullptr };
std::weak_ptr<MidiNetworkConnection> m_connection;
};


Loading

0 comments on commit f33b267

Please sign in to comment.