Skip to content

Commit

Permalink
Merge pull request #405 from microsoft/GroupIndexAppVerifier
Browse files Browse the repository at this point in the history
Merge in OS changes for group indexes and application verifier fixes
  • Loading branch information
Psychlist1972 authored Oct 2, 2024
2 parents 7fe08ba + 550434a commit abe9449
Show file tree
Hide file tree
Showing 67 changed files with 970 additions and 370 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand All @@ -170,6 +171,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand All @@ -188,6 +190,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand Down Expand Up @@ -225,6 +228,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand All @@ -242,6 +246,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand Down Expand Up @@ -269,6 +274,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,7 @@ CMidi2DiagnosticsEndpointManager::Cleanup()
TraceLoggingPointer(this, "this")
);

m_MidiDeviceManager.reset();

return S_OK;
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ CMidi2DiagnosticsMidiConfigurationManager::Cleanup()
TraceLoggingPointer(this, "this")
);

m_MidiDeviceManager.reset();

return S_OK;
}
7 changes: 4 additions & 3 deletions src/api/Abstraction/DiagnosticsAbstraction/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ DllMain(
_Use_decl_annotations_
STDAPI
DllCanUnloadNow(void)
{
return _AtlModule.DllCanUnloadNow();
}
{
auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
return module.Terminate() ? _AtlModule.DllCanUnloadNow() : S_FALSE;
}

_Use_decl_annotations_
STDAPI
Expand Down
6 changes: 6 additions & 0 deletions src/api/Abstraction/KSAbstraction/Midi2.KSAbstraction.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ksuser.lib;avrt.lib;midixproc.lib;midiks.lib;midikscommon.lib;midiksenum.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
Expand All @@ -162,6 +163,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ksuser.lib;avrt.lib;midixproc.lib;midiks.lib;midikscommon.lib;midiksenum.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
Expand All @@ -182,6 +184,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ksuser.lib;avrt.lib;midixproc.lib;midiks.lib;midikscommon.lib;midiksenum.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
Expand All @@ -202,6 +205,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ksuser.lib;avrt.lib;midixproc.lib;midiks.lib;midikscommon.lib;midiksenum.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
Expand All @@ -226,6 +230,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -241,6 +246,7 @@
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<Optimization>MaxSpeed</Optimization>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Midl>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)\idl</AdditionalIncludeDirectories>
Expand Down
24 changes: 20 additions & 4 deletions src/api/Abstraction/KSAbstraction/Midi2.KSMidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,33 @@ CMidi2KSMidi::Initialize(
{
prop = deviceInfo.Properties().Lookup(winrt::to_hstring(STRING_DEVPKEY_KsMidiPort_InPinId));
RETURN_HR_IF_NULL(E_INVALIDARG, prop);
inPinId = outPinId = winrt::unbox_value<uint32_t>(prop);
inPinId = winrt::unbox_value<uint32_t>(prop);

prop = deviceInfo.Properties().Lookup(winrt::to_hstring(STRING_DEVPKEY_KsMidiPort_OutPinId));
RETURN_HR_IF_NULL(E_INVALIDARG, prop);
outPinId = outPinId = winrt::unbox_value<uint32_t>(prop);
outPinId = winrt::unbox_value<uint32_t>(prop);
}
else
{
// first check for the legacy pin id, if that's not present then look for the newer in/out
// pin id's that is on bidi endpoints, which can be activated separately in and out.
prop = deviceInfo.Properties().Lookup(winrt::to_hstring(STRING_DEVPKEY_KsMidiPort_KsPinId));
RETURN_HR_IF_NULL(E_INVALIDARG, prop);
inPinId = outPinId = winrt::unbox_value<uint32_t>(prop);
if (prop)
{
inPinId = outPinId = winrt::unbox_value<uint32_t>(prop);
}
else if (Flow == MidiFlowIn)
{
prop = deviceInfo.Properties().Lookup(winrt::to_hstring(STRING_DEVPKEY_KsMidiPort_InPinId));
RETURN_HR_IF_NULL(E_INVALIDARG, prop);
inPinId = winrt::unbox_value<uint32_t>(prop);
}
else
{
prop = deviceInfo.Properties().Lookup(winrt::to_hstring(STRING_DEVPKEY_KsMidiPort_OutPinId));
RETURN_HR_IF_NULL(E_INVALIDARG, prop);
outPinId = winrt::unbox_value<uint32_t>(prop);
}
}

if (Flow == MidiFlowIn || Flow == MidiFlowBidirectional)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ CMidi2KSMidiConfigurationManager::Cleanup()
TraceLoggingPointer(this, "this")
);

AbstractionState::Current().Cleanup();

m_MidiServiceConfigurationManagerInterface.reset();
m_MidiDeviceManager.reset();

return S_OK;
}
Original file line number Diff line number Diff line change
Expand Up @@ -906,14 +906,20 @@ CMidi2KSMidiEndpointManager::Cleanup()
TraceLoggingPointer(this, "this")
);

m_EnumerationCompleted.wait();
AbstractionState::Current().Cleanup();

m_AvailableMidiPins.clear();

m_Watcher.Stop();
m_EnumerationCompleted.wait();
m_EnumerationCompleted.wait(500);
m_DeviceAdded.revoke();
m_DeviceRemoved.revoke();
m_DeviceUpdated.revoke();
m_DeviceStopped.revoke();
m_DeviceEnumerationCompleted.revoke();

m_MidiDeviceManager.reset();
m_MidiProtocolManager.reset();

return S_OK;
}
3 changes: 2 additions & 1 deletion src/api/Abstraction/KSAbstraction/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ _Use_decl_annotations_
STDAPI
DllCanUnloadNow(void)
{
return _AtlModule.DllCanUnloadNow();
auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
return module.Terminate() ? _AtlModule.DllCanUnloadNow() : S_FALSE;
}

_Use_decl_annotations_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ksuser.lib;avrt.lib;midixproc.lib;midiks.lib;midikscommon.lib;midiksenum.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
Expand All @@ -162,6 +163,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ksuser.lib;avrt.lib;midixproc.lib;midiks.lib;midikscommon.lib;midiksenum.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
Expand All @@ -182,6 +184,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ksuser.lib;avrt.lib;midixproc.lib;midiks.lib;midikscommon.lib;midiksenum.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
Expand All @@ -202,6 +205,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ksuser.lib;avrt.lib;midixproc.lib;midiks.lib;midikscommon.lib;midiksenum.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
Expand All @@ -226,6 +230,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -241,6 +246,7 @@
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<Optimization>MaxSpeed</Optimization>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Midl>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)\idl</AdditionalIncludeDirectories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,16 @@ CMidi2KSAggregateMidi::Cleanup()
TraceLoggingWideString(L"Enter", MIDI_TRACE_EVENT_MESSAGE_FIELD)
);

for (auto it = m_midiInDeviceGroupMap.begin(); it != m_midiInDeviceGroupMap.end(); it++)
for (auto it = m_midiInDeviceGroupMap.begin(); it != m_midiInDeviceGroupMap.end();)
{
LOG_IF_FAILED(it->second->Cleanup());
m_midiInDeviceGroupMap.erase(it);
it = m_midiInDeviceGroupMap.erase(it);
}

for (auto it = m_midiOutDeviceGroupMap.begin(); it != m_midiOutDeviceGroupMap.end(); it++)
for (auto it = m_midiOutDeviceGroupMap.begin(); it != m_midiOutDeviceGroupMap.end();)
{
LOG_IF_FAILED(it->second->Cleanup());
m_midiOutDeviceGroupMap.erase(it);
it = m_midiOutDeviceGroupMap.erase(it);
}

return S_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,11 @@ CMidi2KSAggregateMidiConfigurationManager::Cleanup()
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingPointer(this, "this")
);

AbstractionState::Current().Cleanup();

m_MidiServiceConfigurationManagerInterface.reset();
m_MidiDeviceManager.reset();

return S_OK;
}
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,6 @@ CMidi2KSAggregateMidiEndpointManager::OnDeviceAdded(

// std::vector<std::unique_ptr<MIDI_PIN_INFO>> newMidiPins;


// TODO: There can be a race condition here between this abstraction and the KS abstraction. They really need
// to be combined.


// instantiate the interface
RETURN_IF_FAILED(FilterInstantiate(endpointDefinition.FilterDeviceId.c_str(), &hFilter));
RETURN_IF_FAILED(PinPropertySimple(hFilter.get(), 0, KSPROPSETID_Pin, KSPROPERTY_PIN_CTYPES, &cPins, sizeof(cPins)));
Expand Down Expand Up @@ -664,14 +659,18 @@ CMidi2KSAggregateMidiEndpointManager::Cleanup()
TraceLoggingPointer(this, "this")
);

m_EnumerationCompleted.wait();
AbstractionState::Current().Cleanup();

m_Watcher.Stop();
m_EnumerationCompleted.wait();
m_EnumerationCompleted.wait(500);
m_DeviceAdded.revoke();
m_DeviceRemoved.revoke();
m_DeviceUpdated.revoke();
m_DeviceStopped.revoke();
m_DeviceEnumerationCompleted.revoke();

m_MidiDeviceManager.reset();
m_MidiProtocolManager.reset();

return S_OK;
}
7 changes: 4 additions & 3 deletions src/api/Abstraction/KSAggregateAbstraction/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ DllMain(
_Use_decl_annotations_
STDAPI
DllCanUnloadNow(void)
{
return _AtlModule.DllCanUnloadNow();
}
{
auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
return module.Terminate() ? _AtlModule.DllCanUnloadNow() : S_FALSE;
}

_Use_decl_annotations_
STDAPI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand All @@ -163,6 +164,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand All @@ -181,6 +183,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand Down Expand Up @@ -218,6 +221,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand All @@ -235,6 +239,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand Down Expand Up @@ -262,6 +267,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<DisableSpecificWarnings>4324</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;avrt.lib;$(CoreLibraryDependencies);</AdditionalDependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,9 @@ CMidi2LoopbackMidiConfigurationManager::Cleanup()
TraceLoggingPointer(this, "this")
);

AbstractionState::Current().Cleanup();


m_MidiDeviceManager.reset();

return S_OK;
}
Expand Down
Loading

0 comments on commit abe9449

Please sign in to comment.