diff options
| author | Daniel Rugerio <[email protected]> | 2019-06-28 16:08:54 -0700 |
|---|---|---|
| committer | Adonais Romero González <[email protected]> | 2019-06-28 16:08:54 -0700 |
| commit | 8ffcdad009e4d410f92fabc4e322a76a0be3a69d (patch) | |
| tree | 378b2d98a4210c61e2bc34f5b8959e87e4be5c6c /audio/sysvad/EndpointsCommon | |
| parent | 75b2290f2a4ece68739d07135d352cdfec3a9e89 (diff) | |
Update audio samples (#387)
* Update SysVAD public sample.
* Add WaveTest public sample.
Diffstat (limited to 'audio/sysvad/EndpointsCommon')
| -rw-r--r-- | audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj | 70 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/MiniportAudioEngineNode.cpp | 4 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/MiniportStreamAudioEngineNode.cpp | 5 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/NewDelete.h | 5 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/bthhfpmictopo.cpp | 2 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/micarraywavtable.h | 115 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/mintopo.cpp | 12 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/mintopo.h | 11 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/minwavert.cpp | 574 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/minwavert.h | 54 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/minwavertstream.cpp | 21 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/sources | 48 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/speakerhptoptable.h | 2 |
13 files changed, 727 insertions, 196 deletions
diff --git a/audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj b/audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj index 7fda3a23..b4d1c802 100644 --- a/audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj +++ b/audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj @@ -1,10 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|ARM"> - <Configuration>Debug</Configuration> - <Platform>ARM</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Debug|ARM64"> <Configuration>Debug</Configuration> <Platform>ARM64</Platform> @@ -13,10 +9,6 @@ <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> - <ProjectConfiguration Include="Release|ARM"> - <Configuration>Release</Configuration> - <Platform>ARM</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Release|ARM64"> <Configuration>Release</Configuration> <Platform>ARM64</Platform> @@ -83,14 +75,6 @@ <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>StaticLibrary</ConfigurationType> - </PropertyGroup> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> @@ -99,14 +83,6 @@ <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>StaticLibrary</ConfigurationType> - </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> <OutDir>$(IntDir)</OutDir> @@ -126,15 +102,9 @@ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> <ItemGroup Label="WrappedTaskItems" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetName>EndpointsCommon</TargetName> @@ -151,15 +121,9 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetName>EndpointsCommon</TargetName> </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> - <TargetName>EndpointsCommon</TargetName> - </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetName>EndpointsCommon</TargetName> </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> - <TargetName>EndpointsCommon</TargetName> - </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ResourceCompile> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);..</AdditionalIncludeDirectories> @@ -245,23 +209,6 @@ <PreprocessorDefinitions>%(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS;SYSVAD_USB_SIDEBAND</PreprocessorDefinitions> </Midl> </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> - <ResourceCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);..</AdditionalIncludeDirectories> - <PreprocessorDefinitions>%(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS;SYSVAD_USB_SIDEBAND</PreprocessorDefinitions> - </ResourceCompile> - <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;.</AdditionalIncludeDirectories> - <PreprocessorDefinitions>%(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS;SYSVAD_USB_SIDEBAND;_NEW_DELETE_OPERATORS_</PreprocessorDefinitions> - <ExceptionHandling> - </ExceptionHandling> - <DisableSpecificWarnings>4595;%(DisableSpecificWarnings)</DisableSpecificWarnings> - </ClCompile> - <Midl> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);..</AdditionalIncludeDirectories> - <PreprocessorDefinitions>%(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS;SYSVAD_USB_SIDEBAND</PreprocessorDefinitions> - </Midl> - </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ResourceCompile> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);..</AdditionalIncludeDirectories> @@ -279,23 +226,6 @@ <PreprocessorDefinitions>%(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS;SYSVAD_USB_SIDEBAND</PreprocessorDefinitions> </Midl> </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> - <ResourceCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);..</AdditionalIncludeDirectories> - <PreprocessorDefinitions>%(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS;SYSVAD_USB_SIDEBAND</PreprocessorDefinitions> - </ResourceCompile> - <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;.</AdditionalIncludeDirectories> - <PreprocessorDefinitions>%(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS;SYSVAD_USB_SIDEBAND;_NEW_DELETE_OPERATORS_</PreprocessorDefinitions> - <ExceptionHandling> - </ExceptionHandling> - <DisableSpecificWarnings>4595;%(DisableSpecificWarnings)</DisableSpecificWarnings> - </ClCompile> - <Midl> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);..</AdditionalIncludeDirectories> - <PreprocessorDefinitions>%(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS;SYSVAD_USB_SIDEBAND</PreprocessorDefinitions> - </Midl> - </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="AudioModuleHelper.cpp" /> <ClCompile Include="bthhfpmictopo.cpp" /> diff --git a/audio/sysvad/EndpointsCommon/MiniportAudioEngineNode.cpp b/audio/sysvad/EndpointsCommon/MiniportAudioEngineNode.cpp index c3a77d1f..5f45d15a 100644 --- a/audio/sysvad/EndpointsCommon/MiniportAudioEngineNode.cpp +++ b/audio/sysvad/EndpointsCommon/MiniportAudioEngineNode.cpp @@ -851,10 +851,10 @@ NTSTATUS CMiniportWaveRT::GetVolumeSteppings(_Out_writes_bytes_(_ui32DataSize) P //============================================================================= // The volume control should be implemented as follows: // -// #1 If the Sideband device supports volume control, then the audio driver should +// #1 If the USB headset supports volume control, then the audio driver should // pipe the volume change requests through the Sideband Interface // -// #2 If the Sideband device does not implement a hardware volume, and the codec +// #2 If the USB headset does not implement a hardware volume, and the codec // (or DSP) has a hardware volume, the audio driver should handle the volume // control on the codec (or DSP). // diff --git a/audio/sysvad/EndpointsCommon/MiniportStreamAudioEngineNode.cpp b/audio/sysvad/EndpointsCommon/MiniportStreamAudioEngineNode.cpp index 1b0f13f1..49f4cec8 100644 --- a/audio/sysvad/EndpointsCommon/MiniportStreamAudioEngineNode.cpp +++ b/audio/sysvad/EndpointsCommon/MiniportStreamAudioEngineNode.cpp @@ -860,12 +860,11 @@ NTSTATUS CMiniportWaveRTStream::SetCurrentWritePositionInternal(_In_ ULONG _ulC //linear and presentation positions #pragma code_seg() -NTSTATUS CMiniportWaveRTStream::GetPositions -( +NTSTATUS CMiniportWaveRTStream::GetPositions( _Out_opt_ ULONGLONG * _pullLinearBufferPosition, _Out_opt_ ULONGLONG * _pullPresentationPosition, _Out_opt_ LARGE_INTEGER * _pliQPCTime -) + ) { DPF_ENTER(("[CMiniportWaveRTStream::GetPositions]")); diff --git a/audio/sysvad/EndpointsCommon/NewDelete.h b/audio/sysvad/EndpointsCommon/NewDelete.h index 288634d4..1b5d5e61 100644 --- a/audio/sysvad/EndpointsCommon/NewDelete.h +++ b/audio/sysvad/EndpointsCommon/NewDelete.h @@ -10,10 +10,6 @@ Abstract: Declaration of placement new and delete operators. -//@@BEGIN_DDKSPLIT -Revision History: - -//@@END_DDKSPLIT --*/ #pragma once @@ -114,3 +110,4 @@ void __cdecl operator delete[] ); #endif//_NEW_DELETE_OPERATORS_ + diff --git a/audio/sysvad/EndpointsCommon/bthhfpmictopo.cpp b/audio/sysvad/EndpointsCommon/bthhfpmictopo.cpp index 01eb156b..bcaaca94 100644 --- a/audio/sysvad/EndpointsCommon/bthhfpmictopo.cpp +++ b/audio/sysvad/EndpointsCommon/bthhfpmictopo.cpp @@ -275,3 +275,5 @@ PropertyHandler_BthHfpMicTopoFilterEvent #pragma code_seg() #endif // SYSVAD_BTH_BYPASS + + diff --git a/audio/sysvad/EndpointsCommon/micarraywavtable.h b/audio/sysvad/EndpointsCommon/micarraywavtable.h index 0db6e6a0..55309092 100644 --- a/audio/sysvad/EndpointsCommon/micarraywavtable.h +++ b/audio/sysvad/EndpointsCommon/micarraywavtable.h @@ -711,6 +711,14 @@ DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorArmed); DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorArmed); DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorMatchResult); +DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorSupportedPatterns2); +DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorPatterns2); +DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorArmed2); +DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorArmed2); +DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorReset2); +DECLARE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorStreamingSupport2); + + static SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = { @@ -725,7 +733,9 @@ SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = 0, NULL, NULL, - NULL + NULL, + NULL, + 0 }, { { @@ -738,7 +748,9 @@ SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = 0, NULL, NULL, - NULL + NULL, + NULL, + 0 }, { { @@ -751,7 +763,9 @@ SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = 0, NULL, NULL, - NULL + NULL, + NULL, + 0 }, { { @@ -764,7 +778,9 @@ SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = 0, NULL, NULL, - NULL + NULL, + NULL, + 0 }, { { @@ -777,7 +793,9 @@ SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = sizeof(CONTOSO_SUPPORTEDPATTERNSVALUE), CMiniportWaveRT_Get_SoundDetectorSupportedPatterns, NULL, - NULL + NULL, + NULL, + 0 }, { { @@ -790,7 +808,9 @@ SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = (sizeof(KSMULTIPLE_ITEM) + sizeof(CONTOSO_KEYWORDCONFIGURATION)), NULL, CMiniportWaveRT_Set_SoundDetectorPatterns, - NULL + NULL, + NULL, + 0 }, { { @@ -803,7 +823,9 @@ SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = sizeof(BOOL), CMiniportWaveRT_Get_SoundDetectorArmed, CMiniportWaveRT_Set_SoundDetectorArmed, - NULL + NULL, + NULL, + 0 }, { { @@ -816,7 +838,84 @@ SYSVADPROPERTY_ITEM PropertiesMicArrayWaveFilter[] = sizeof(CONTOSO_KEYWORDDETECTIONRESULT), CMiniportWaveRT_Get_SoundDetectorMatchResult, NULL, - NULL + NULL, + NULL, + 0 + }, + { + { + &KSPROPSETID_SoundDetector2, + KSPROPERTY_SOUNDDETECTOR_SUPPORTEDPATTERNS, + KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, + SysvadPropertyDispatch, + }, + sizeof(KSSOUNDDETECTORPROPERTY) - sizeof(KSPROPERTY), + sizeof(CONTOSO_SUPPORTEDPATTERNSVALUE), + CMiniportWaveRT_Get_SoundDetectorSupportedPatterns2, + NULL, + NULL, + NULL, + 0 + }, + { + { + &KSPROPSETID_SoundDetector2, + KSPROPERTY_SOUNDDETECTOR_PATTERNS, + KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_BASICSUPPORT, + SysvadPropertyDispatch, + }, + sizeof(KSSOUNDDETECTORPROPERTY) - sizeof(KSPROPERTY), + (sizeof(KSMULTIPLE_ITEM) + sizeof(CONTOSO_KEYWORDCONFIGURATION)), + NULL, + CMiniportWaveRT_Set_SoundDetectorPatterns2, + NULL, + NULL, + 0 + }, + { + { + &KSPROPSETID_SoundDetector2, + KSPROPERTY_SOUNDDETECTOR_ARMED, + KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_BASICSUPPORT, + SysvadPropertyDispatch, + }, + sizeof(KSSOUNDDETECTORPROPERTY) - sizeof(KSPROPERTY), + sizeof(BOOL), + CMiniportWaveRT_Get_SoundDetectorArmed2, + CMiniportWaveRT_Set_SoundDetectorArmed2, + NULL, + NULL, + 0 + }, + { + { + &KSPROPSETID_SoundDetector2, + KSPROPERTY_SOUNDDETECTOR_RESET, + KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_BASICSUPPORT, + SysvadPropertyDispatch, + }, + sizeof(KSSOUNDDETECTORPROPERTY) - sizeof(KSPROPERTY), + sizeof(BOOL), + NULL, + CMiniportWaveRT_Set_SoundDetectorReset2, + NULL, + NULL, + 0 + }, + { + { + &KSPROPSETID_SoundDetector2, + KSPROPERTY_SOUNDDETECTOR_STREAMINGSUPPORT, + KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, + SysvadPropertyDispatch, + }, + sizeof(KSSOUNDDETECTORPROPERTY) - sizeof(KSPROPERTY), + sizeof(BOOL), + CMiniportWaveRT_Get_SoundDetectorStreamingSupport2, + NULL, + NULL, + NULL, + 0 }, }; diff --git a/audio/sysvad/EndpointsCommon/mintopo.cpp b/audio/sysvad/EndpointsCommon/mintopo.cpp index 128fa15c..28ddf419 100644 --- a/audio/sysvad/EndpointsCommon/mintopo.cpp +++ b/audio/sysvad/EndpointsCommon/mintopo.cpp @@ -110,13 +110,13 @@ Return Value: DPF_ENTER(("[CMiniportTopology::~CMiniportTopology]")); -#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) +#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) || defined (SYSVAD_A2DP_SIDEBAND) if (IsSidebandDevice()) { ASSERT(m_pSidebandDevice != NULL); // - // Register with BthHfpDevice or UsbHsDevice to get notification events. + // Register with BthHfpDevice, A2dpHpDevice or UsbHsDevice to get notification events. // if(IsSidebandDevice()) { @@ -127,7 +127,7 @@ Return Value: SAFE_RELEASE(m_pSidebandDevice); // ISidebandDeviceCommon } -#endif // defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) +#endif // defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) || defined(SYSVAD_A2DP_SIDEBAND) } // ~CMiniportTopology @@ -281,7 +281,7 @@ Return Value: DPF(D_ERROR, ("Init: CMiniportTopologySYSVAD::Init failed, 0x%x", ntStatus)), Done); -#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) +#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) || defined(SYSVAD_A2DP_SIDEBAND) if (IsSidebandDevice()) { PSIDEBANDDEVICECOMMON sidebandDevice = NULL; @@ -306,7 +306,7 @@ Return Value: } else { - ASSERT(m_DeviceType == eBthHfpSpeakerDevice || m_DeviceType == eUsbHsSpeakerDevice); + ASSERT(m_DeviceType == eBthHfpSpeakerDevice || m_DeviceType == eUsbHsSpeakerDevice || m_DeviceType == eA2dpHpSpeakerDevice); sidebandDevice->SetVolumeHandler( m_DeviceType, @@ -319,7 +319,7 @@ Return Value: PCMiniportTopology(this)); // context. } } -#endif // defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) +#endif // defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) || defined(SYSVAD_A2DP_SIDEBAND) Done: return ntStatus; diff --git a/audio/sysvad/EndpointsCommon/mintopo.h b/audio/sysvad/EndpointsCommon/mintopo.h index 7f573237..4aa3d2de 100644 --- a/audio/sysvad/EndpointsCommon/mintopo.h +++ b/audio/sysvad/EndpointsCommon/mintopo.h @@ -92,7 +92,8 @@ public: return (m_DeviceType == eBthHfpMicDevice || m_DeviceType == eBthHfpSpeakerDevice || m_DeviceType == eUsbHsMicDevice || - m_DeviceType == eUsbHsSpeakerDevice ) ? TRUE : FALSE; + m_DeviceType == eUsbHsSpeakerDevice || + m_DeviceType == eA2dpHpSpeakerDevice) ? TRUE : FALSE; } // Returns a weak ref to the Bluetooth HFP device. @@ -164,6 +165,14 @@ public: _In_ PPCPROPERTY_REQUEST PropertyRequest); friend NTSTATUS PropertyHandler_UsbHsMicMute( _In_ PPCPROPERTY_REQUEST PropertyRequest); + friend NTSTATUS PropertyHandler_A2dpHpJackContainerId( + _In_ PPCPROPERTY_REQUEST PropertyRequest, + _In_ ULONG cJackDescriptions, + _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION * JackDescriptions); + friend NTSTATUS PropertyHandler_A2dpHpVolumeLevel_BasicSupport( + _In_ PPCPROPERTY_REQUEST PropertyRequest); + friend NTSTATUS PropertyHandler_A2dpHpMute_BasicSupport( + _In_ PPCPROPERTY_REQUEST PropertyRequest); }; typedef CMiniportTopology *PCMiniportTopology; diff --git a/audio/sysvad/EndpointsCommon/minwavert.cpp b/audio/sysvad/EndpointsCommon/minwavert.cpp index 1ad029f7..4cabc7c4 100644 --- a/audio/sysvad/EndpointsCommon/minwavert.cpp +++ b/audio/sysvad/EndpointsCommon/minwavert.cpp @@ -1214,6 +1214,8 @@ BOOL CMiniportWaveRT::IsKeywordDetectorPin(ULONG nPinId) return (pinType == KeywordCapturePin); } + +//============================================================================= #pragma code_seg("PAGE") NTSTATUS CMiniportWaveRT::StreamCreated @@ -1739,7 +1741,24 @@ CMiniportWaveRT::PropertyHandlerProposedFormat ntStatus = STATUS_SUCCESS; } } + else #endif // defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND) + if (IsKeywordDetectorPin(kspPin->PinId)) + { + KSDATAFORMAT_WAVEFORMATEXTENSIBLE *propFormat = (KSDATAFORMAT_WAVEFORMATEXTENSIBLE *)PropertyRequest->Value; + ULONG numModes = 0; + MODE_AND_DEFAULT_FORMAT *modeInfo = NULL; + + numModes = GetPinSupportedDeviceModes(kspPin->PinId, &modeInfo); + if (numModes == 0 || modeInfo->DefaultFormat == NULL) + { + return STATUS_NOT_SUPPORTED; + } + + RtlCopyMemory(propFormat, modeInfo->DefaultFormat, modeInfo->DefaultFormat->FormatSize); + PropertyRequest->ValueSize = modeInfo->DefaultFormat->FormatSize; + ntStatus = STATUS_SUCCESS; + } } else if (PropertyRequest->Verb & KSPROPERTY_TYPE_SET) { @@ -1815,6 +1834,49 @@ Arguments: } //============================================================================= +#pragma code_seg() +VOID +CMiniportWaveRT::SendPNPNotification( + _In_ const GUID * NotificationId, + _In_ PVOID NotificationBuffer, + _In_ USHORT NotificationBufferCb + ) +{ + NTSTATUS status = STATUS_SUCCESS; + PPCNOTIFICATION_BUFFER buffer = NULL; + + PAGED_CODE(); + + DPF_ENTER(("[SendPNPNotification]")); + + // Allocate a notification buffer. + status = m_pPortClsNotifications->AllocNotificationBuffer(PagedPool, + NotificationBufferCb, + &buffer); + if (!NT_SUCCESS(status)) + { + goto exit; + } + + // Notification buffer is only guaranteed to be LONG aligned, + // it is received as ULONGLONG aligned on the receiving end. + RtlCopyMemory(buffer, NotificationBuffer, NotificationBufferCb); + + // + // Generate notification (async). + // + m_pPortClsNotifications->SendNotification(NotificationId, buffer); + +exit: + if (buffer != NULL) + { + // Free notification buffer. + m_pPortClsNotifications->FreeNotificationBuffer(buffer); + buffer = NULL; + } +} + +//============================================================================= #pragma code_seg("PAGE") NTSTATUS CMiniportWaveRT::PropertyHandlerAudioEffectsDiscoveryEffectsList @@ -2675,7 +2737,7 @@ DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorPatterns) // No items so clear the configuration. if (itemsHeader->Count == 0) { - m_KeywordDetector.ResetDetector(); + m_KeywordDetector.ResetDetector(CONTOSO_KEYWORD1); return STATUS_SUCCESS; } @@ -2722,9 +2784,7 @@ DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorPatterns) pattern = (CONTOSO_KEYWORDCONFIGURATION*)(patternHeader); // Program the hardware. - m_KeywordDetector.DownloadDetectorData(pattern->ContosoDetectorConfigurationData); - - return STATUS_SUCCESS; + return m_KeywordDetector.DownloadDetectorData(CONTOSO_KEYWORD1, pattern->ContosoDetectorConfigurationData); } DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorArmed) @@ -2736,9 +2796,8 @@ DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorArmed) NT_ASSERT(PropertyRequest->ValueSize >= sizeof(BOOL)); RtlZeroMemory(PropertyRequest->Value, PropertyRequest->ValueSize); - *(BOOL*)PropertyRequest->Value = m_KeywordDetector.GetArmed(); - return STATUS_SUCCESS; + return m_KeywordDetector.GetArmed(CONTOSO_KEYWORD1, (BOOL*)PropertyRequest->Value); } DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorArmed) @@ -2754,7 +2813,7 @@ DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorArmed) armed = ((*(BOOL*)PropertyRequest->Value) != 0); - ntStatus = m_KeywordDetector.SetArmed(armed); + ntStatus = m_KeywordDetector.SetArmed(CONTOSO_KEYWORD1, armed); if (NT_SUCCESS(ntStatus) && armed) { @@ -2762,7 +2821,7 @@ DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorArmed) // it is armed, but later, find a better way to demonstrate this from // within CKeywordDetector. m_pPortEvents->GenerateEventList(const_cast<GUID*>(&KSEVENTSETID_SoundDetector), KSEVENT_SOUNDDETECTOR_MATCHDETECTED, FALSE, 0, FALSE, 0); - m_KeywordDetector.SetArmed(FALSE); + m_KeywordDetector.SetArmed(CONTOSO_KEYWORD1, FALSE); } return ntStatus; @@ -2785,15 +2844,297 @@ DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorMatchResult) value->Header.Size = sizeof(CONTOSO_KEYWORDDETECTIONRESULT); value->Header.PatternType = CONTOSO_KEYWORDCONFIGURATION_IDENTIFIER; - value->ContosoDetectorResultData = m_KeywordDetector.GetDetectorData(); value->KeywordStartTimestamp = m_KeywordDetector.GetStartTimestamp(); value->KeywordStopTimestamp = m_KeywordDetector.GetStopTimestamp(); PropertyRequest->ValueSize = sizeof(*value); - + + return m_KeywordDetector.GetDetectorData(CONTOSO_KEYWORD1, &(value->ContosoDetectorResultData)); +} + +DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorSupportedPatterns2) +{ + CONTOSO_SUPPORTEDPATTERNSVALUE *value; + PKSSOUNDDETECTORPROPERTY propertyInstance = NULL; + + PAGED_CODE(); + + NT_ASSERT(PropertyRequest->ValueSize >= sizeof(*value)); + + if (PropertyRequest->InstanceSize < (sizeof(KSSOUNDDETECTORPROPERTY) - RTL_SIZEOF_THROUGH_FIELD(KSSOUNDDETECTORPROPERTY, Property))) + { + return STATUS_INVALID_PARAMETER; + } + + propertyInstance = CONTAINING_RECORD(PropertyRequest->Instance, KSSOUNDDETECTORPROPERTY, EventId); + + // There is currently only support for 1 OEM DLL, and that CLSID is returned when + // the EventID is GUID_NULL. + if (propertyInstance->EventId != GUID_NULL) + { + return STATUS_INVALID_PARAMETER; + } + + // Does this filter support a sound detector? + if ((m_DeviceFlags & ENDPOINT_SOUNDDETECTOR_SUPPORTED) == 0) + { + return STATUS_NOT_SUPPORTED; + } + + value = (CONTOSO_SUPPORTEDPATTERNSVALUE*)PropertyRequest->Value; + + RtlZeroMemory(value, sizeof(*value)); + + value->MultipleItem.Size = sizeof(*value); + value->MultipleItem.Count = 1; + value->PatternType[0] = CONTOSO_KEYWORDCONFIGURATION_IDENTIFIER2; + + PropertyRequest->ValueSize = sizeof(*value); + return STATUS_SUCCESS; } +DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorPatterns2) +{ + KSMULTIPLE_ITEM *itemsHeader; + PKSSOUNDDETECTORPROPERTY propertyInstance = NULL; + SOUNDDETECTOR_PATTERNHEADER *patternHeader; + CONTOSO_KEYWORDCONFIGURATION *pattern; + ULONG cbRemaining; // Tracks bytes remaining in property value + + PAGED_CODE(); + + if (PropertyRequest->InstanceSize < (sizeof(KSSOUNDDETECTORPROPERTY) - RTL_SIZEOF_THROUGH_FIELD(KSSOUNDDETECTORPROPERTY, Property))) + { + return STATUS_INVALID_PARAMETER; + } + + propertyInstance = CONTAINING_RECORD(PropertyRequest->Instance, KSSOUNDDETECTORPROPERTY, EventId); + + cbRemaining = PropertyRequest->ValueSize; + + // The SYSVADPROPERTY_ITEM for this property ensures the value size is at + // least sizeof KSMULTIPLE_ITEM. + if (cbRemaining < sizeof(KSMULTIPLE_ITEM)) + { + return STATUS_INVALID_PARAMETER; + } + + itemsHeader = (KSMULTIPLE_ITEM*)PropertyRequest->Value; + + // Verify property value is large enough to include the items + if (itemsHeader->Size > cbRemaining) + { + PropertyRequest->ValueSize = 0; + return STATUS_INVALID_PARAMETER; + } + + // No items so clear the configuration. + if (itemsHeader->Count == 0) + { + m_KeywordDetector.ResetDetector(propertyInstance->EventId); + return STATUS_SUCCESS; + } + + // This sample supports only 1 pattern type. + if (itemsHeader->Count > 1) + { + PropertyRequest->ValueSize = 0; + return STATUS_NOT_SUPPORTED; + } + + // Bytes remaining after the items header + cbRemaining = itemsHeader->Size - sizeof(*itemsHeader); + + // Verify the property value is large enough to include the pattern header. + if (cbRemaining < sizeof(SOUNDDETECTOR_PATTERNHEADER)) + { + PropertyRequest->ValueSize = 0; + return STATUS_INVALID_PARAMETER; + } + + patternHeader = (SOUNDDETECTOR_PATTERNHEADER*)(itemsHeader + 1); + + // Verify the pattern type is supported. + if (patternHeader->PatternType != CONTOSO_KEYWORDCONFIGURATION_IDENTIFIER2) + { + PropertyRequest->ValueSize = 0; + return STATUS_NOT_SUPPORTED; + } + + // Verify the property value is large enough for the pattern. + if (cbRemaining < patternHeader->Size) + { + PropertyRequest->ValueSize = 0; + return STATUS_INVALID_PARAMETER; + } + + // Verify the pattern is large enough. + if (patternHeader->Size != sizeof(CONTOSO_KEYWORDCONFIGURATION)) + { + PropertyRequest->ValueSize = 0; + return STATUS_INVALID_PARAMETER; + } + + pattern = (CONTOSO_KEYWORDCONFIGURATION*)(patternHeader); + + return m_KeywordDetector.DownloadDetectorData(propertyInstance->EventId, pattern->ContosoDetectorConfigurationData); +} + +DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorArmed2) +{ + PKSSOUNDDETECTORPROPERTY propertyInstance = NULL; + + PAGED_CODE(); + + if (PropertyRequest->InstanceSize < (sizeof(KSSOUNDDETECTORPROPERTY) - RTL_SIZEOF_THROUGH_FIELD(KSSOUNDDETECTORPROPERTY, Property))) + { + return STATUS_INVALID_PARAMETER; + } + + propertyInstance = CONTAINING_RECORD(PropertyRequest->Instance, KSSOUNDDETECTORPROPERTY, EventId); + + // The SYSVADPROPERTY_ITEM for this property ensures the value size is at + // least sizeof BOOL. + NT_ASSERT(PropertyRequest->ValueSize >= sizeof(BOOL)); + + RtlZeroMemory(PropertyRequest->Value, PropertyRequest->ValueSize); + return m_KeywordDetector.GetArmed(propertyInstance->EventId, (BOOL*)PropertyRequest->Value); +} + +DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorArmed2) +{ + NTSTATUS ntStatus; + BOOL armed; + PKSSOUNDDETECTORPROPERTY propertyInstance = NULL; + + PAGED_CODE(); + + if (PropertyRequest->InstanceSize < (sizeof(KSSOUNDDETECTORPROPERTY) - RTL_SIZEOF_THROUGH_FIELD(KSSOUNDDETECTORPROPERTY, Property))) + { + return STATUS_INVALID_PARAMETER; + } + + propertyInstance = CONTAINING_RECORD(PropertyRequest->Instance, KSSOUNDDETECTORPROPERTY, EventId); + + // The SYSVADPROPERTY_ITEM for this property ensures the value size is at + // least sizeof BOOL. + NT_ASSERT(PropertyRequest->ValueSize >= sizeof(BOOL)); + + armed = ((*(BOOL*)PropertyRequest->Value) != 0); + + ntStatus = m_KeywordDetector.SetArmed(propertyInstance->EventId, armed); + + // THIS BLOCK IS FOR SYSVAD TESTING ONLY AND WILL NEED TO BE REMOVED + if (NT_SUCCESS(ntStatus) && armed && + (propertyInstance->EventId == CONTOSO_KEYWORD1 || + propertyInstance->EventId == CONTOSO_KEYWORD2)) + { + CONTOSO_KEYWORDDETECTIONRESULT value = {0}; + + m_KeywordDetector.NotifyDetection(); + + value.EventId = propertyInstance->EventId; + value.Header.Size = sizeof(CONTOSO_KEYWORDDETECTIONRESULT); + value.Header.PatternType = CONTOSO_KEYWORDCONFIGURATION_IDENTIFIER2; + value.KeywordStartTimestamp = m_KeywordDetector.GetStartTimestamp(); + value.KeywordStopTimestamp = m_KeywordDetector.GetStopTimestamp(); + m_KeywordDetector.GetDetectorData(propertyInstance->EventId, &(value.ContosoDetectorResultData)); + + SendPNPNotification(&KSNOTIFICATIONID_SoundDetector, &value, sizeof(value)); + } + + return ntStatus; +} + +DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Set_SoundDetectorReset2) +{ + NTSTATUS ntStatus = STATUS_SUCCESS; + BOOL reset; + PKSSOUNDDETECTORPROPERTY propertyInstance = NULL; + + PAGED_CODE(); + + if (PropertyRequest->InstanceSize < (sizeof(KSSOUNDDETECTORPROPERTY) - RTL_SIZEOF_THROUGH_FIELD(KSSOUNDDETECTORPROPERTY, Property))) + { + return STATUS_INVALID_PARAMETER; + } + + propertyInstance = CONTAINING_RECORD(PropertyRequest->Instance, KSSOUNDDETECTORPROPERTY, EventId); + + // The SYSVADPROPERTY_ITEM for this property ensures the value size is at + // least sizeof BOOL. + NT_ASSERT(PropertyRequest->ValueSize >= sizeof(BOOL)); + + reset = ((*(BOOL*)PropertyRequest->Value) != 0); + + if (reset) + { + ntStatus = m_KeywordDetector.ResetDetector(propertyInstance->EventId); + } + + return ntStatus; +} + +DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_SoundDetectorStreamingSupport2) +{ + PKSSOUNDDETECTORPROPERTY propertyInstance = NULL; + + PAGED_CODE(); + + if (PropertyRequest->InstanceSize < (sizeof(KSSOUNDDETECTORPROPERTY) - RTL_SIZEOF_THROUGH_FIELD(KSSOUNDDETECTORPROPERTY, Property))) + { + return STATUS_INVALID_PARAMETER; + } + + propertyInstance = CONTAINING_RECORD(PropertyRequest->Instance, KSSOUNDDETECTORPROPERTY, EventId); + + // The SYSVADPROPERTY_ITEM for this property ensures the value size is at + // least sizeof BOOL. + NT_ASSERT(PropertyRequest->ValueSize >= sizeof(BOOL)); + + RtlZeroMemory(PropertyRequest->Value, PropertyRequest->ValueSize); + return m_KeywordDetector.GetStreamingSupport(propertyInstance->EventId, (BOOL*)PropertyRequest->Value); +} + +DEFINE_CLASSPROPERTYHANDLER(CMiniportWaveRT, Get_InterleavedFormatInformation) +{ + PAGED_CODE(); + + PKSP_PIN propertyInstance = NULL; + + // being a SYSVADPROPERTY, the property item is a SYSVADPROPERTY_ITEM, which contains + // some context information from the endpoint + SYSVADPROPERTY_ITEM* item = (SYSVADPROPERTY_ITEM*)PropertyRequest->PropertyItem; + + // retrieve the pin information, so we can validate that this was called on the keyword pin + if (PropertyRequest->InstanceSize < (sizeof(KSP_PIN) - RTL_SIZEOF_THROUGH_FIELD(KSP_PIN, Property))) + { + return STATUS_INVALID_PARAMETER; + } + + propertyInstance = CONTAINING_RECORD(PropertyRequest->Instance, KSP_PIN, PinId); + + // Only Keyword burst pins may support interleaving loopback and microphone audio + if (!IsKeywordDetectorPin(propertyInstance->PinId)) + { + return STATUS_INVALID_PARAMETER; + } + + // If the context data provided for this endpoint is invalid, or if it is larger than the amount + // of data requested, then we have an invalid parameter + if (NULL == item->ContextData || item->ContextDataSize > PropertyRequest->ValueSize) + { + return STATUS_INVALID_PARAMETER; + } + + // copy the context data (which is interleaving information), into the output. + RtlCopyMemory(PropertyRequest->Value, item->ContextData , item->ContextDataSize); + + return STATUS_SUCCESS; +} + + #pragma code_seg() NTSTATUS CMiniportWaveRT_EventHandler_SoundDetectorMatchDetected ( @@ -3101,10 +3442,13 @@ exit: #pragma code_seg("PAGE") CKeywordDetector::CKeywordDetector() : + m_streamRunning(FALSE), m_qpcStartCapture(0), m_nLastQueuedPacket(-1), - m_SoundDetectorArmed(FALSE), - m_SoundDetectorData(0), + m_SoundDetectorArmed1(FALSE), + m_SoundDetectorArmed2(FALSE), + m_SoundDetectorData1(0), + m_SoundDetectorData2(0), m_ullKeywordStartTimestamp(0), m_ullKeywordStopTimestamp(0) { @@ -3165,29 +3509,96 @@ NTSTATUS CKeywordDetector::ReadKeywordTimestampRegistry() #pragma code_seg("PAGE") _IRQL_requires_max_(PASSIVE_LEVEL) -VOID CKeywordDetector::ResetDetector() +NTSTATUS CKeywordDetector::ResetDetector(_In_ GUID eventId) { PAGED_CODE(); - m_SoundDetectorData = 0; + if (eventId == CONTOSO_KEYWORD1) + { + m_SoundDetectorData1 = 0; + m_SoundDetectorArmed1 = FALSE; + } + else if(eventId == CONTOSO_KEYWORD2) + { + m_SoundDetectorData2 = 0; + m_SoundDetectorArmed2 = FALSE; + } + else if(eventId == GUID_NULL) + { + // When DownloadDetectorData is called to set the pattern for multiple keywords + // at once, all keyword detectors must be reset. Also used during keyword detector + // initialization and cleanup to restore it back to initial state and power down. + m_SoundDetectorData1 = 0; + m_SoundDetectorArmed1 = FALSE; + m_SoundDetectorData2 = 0; + m_SoundDetectorArmed2 = FALSE; + } + else + { + return STATUS_INVALID_PARAMETER; + } + + return STATUS_SUCCESS; } #pragma code_seg("PAGE") _IRQL_requires_max_(PASSIVE_LEVEL) -VOID CKeywordDetector::DownloadDetectorData(_In_ LONGLONG Data) +NTSTATUS CKeywordDetector::DownloadDetectorData(_In_ GUID eventId, _In_ LONGLONG Data) { PAGED_CODE(); - m_SoundDetectorData = Data; + // reset the detector for this event Id + ResetDetector(eventId); + + // In this example, the driver supports detection data + // set with a single call for both detectors, or each + // detector set individually. + if (eventId == CONTOSO_KEYWORD1) + { + m_SoundDetectorData1 = Data; + } + else if(eventId == CONTOSO_KEYWORD2) + { + m_SoundDetectorData2 = Data; + } + else if(eventId == GUID_NULL) + { + // in this simplified example "Data" is set on both detectors, + // however in a real system "Data" could be a data structure which + // contains different values for each detector. + m_SoundDetectorData1 = m_SoundDetectorData2 = Data; + } + else + { + return STATUS_INVALID_PARAMETER; + } + + return STATUS_SUCCESS; } +// The following function is only applicable to single keyword detection systems, +// and assumes keyword detector #1. #pragma code_seg("PAGE") _IRQL_requires_max_(PASSIVE_LEVEL) -LONGLONG CKeywordDetector::GetDetectorData() +NTSTATUS CKeywordDetector::GetDetectorData(_In_ GUID eventId, _Out_ LONGLONG *Data) { PAGED_CODE(); - return m_SoundDetectorData; + if (eventId == CONTOSO_KEYWORD1) + { + *Data = m_SoundDetectorData1; + } + else if(eventId == CONTOSO_KEYWORD2) + { + *Data = m_SoundDetectorData2; + } + else + { + return STATUS_INVALID_PARAMETER; + } + + + return STATUS_SUCCESS; } #pragma code_seg("PAGE") @@ -3228,30 +3639,85 @@ VOID CKeywordDetector::ResetFifo() #pragma code_seg("PAGE") _IRQL_requires_max_(PASSIVE_LEVEL) -NTSTATUS CKeywordDetector::SetArmed(_In_ BOOL Arm) +NTSTATUS CKeywordDetector::SetArmed(_In_ GUID eventId, _In_ BOOL Arm) { PAGED_CODE(); - BOOL previousArming = m_SoundDetectorArmed; + BOOL previousArming = FALSE; NTSTATUS ntStatus = STATUS_SUCCESS; - m_SoundDetectorArmed = Arm; + // the previous state is "armed" if either detector is armed. + // this reflects the fact that both detectors are sharing the + // same stream. + previousArming = m_SoundDetectorArmed1 || m_SoundDetectorArmed2; + + if (eventId == CONTOSO_KEYWORD1) + { + m_SoundDetectorArmed1 = Arm; + } + else if(eventId == CONTOSO_KEYWORD2) + { + m_SoundDetectorArmed2 = Arm; + } + else + { + return STATUS_INVALID_PARAMETER; + } if (Arm && !previousArming && m_qpcStartCapture == 0) { - ntStatus = ReadKeywordTimestampRegistry(); StartBufferingStream(); } + else if (!Arm && previousArming && !m_streamRunning) + { + // if it's not actively streaming and everything has been disarmed, + // then stop buffering. + ResetFifo(); + } + return ntStatus; } #pragma code_seg("PAGE") _IRQL_requires_max_(PASSIVE_LEVEL) -BOOL CKeywordDetector::GetArmed() +NTSTATUS CKeywordDetector::GetArmed(_In_ GUID eventId, _Out_ BOOL *Arm) { PAGED_CODE(); + NTSTATUS ntStatus = STATUS_SUCCESS; - return m_SoundDetectorArmed; + if (eventId == CONTOSO_KEYWORD1) + { + *Arm = m_SoundDetectorArmed1; + } + else if(eventId == CONTOSO_KEYWORD2) + { + *Arm = m_SoundDetectorArmed2; + } + else + { + return STATUS_INVALID_PARAMETER; + } + + return ntStatus; +} + +#pragma code_seg("PAGE") +_IRQL_requires_max_(PASSIVE_LEVEL) +NTSTATUS CKeywordDetector::GetStreamingSupport(_In_ GUID eventId, _Out_ BOOL *Support) +{ + PAGED_CODE(); + NTSTATUS ntStatus = STATUS_SUCCESS; + + if (eventId == GUID_NULL) + { + *Support = TRUE; + } + else + { + return STATUS_INVALID_PARAMETER; + } + + return ntStatus; } #pragma code_seg("PAGE") @@ -3264,6 +3730,8 @@ VOID CKeywordDetector::Run() { StartBufferingStream(); } + + m_streamRunning = TRUE; } #pragma code_seg("PAGE") @@ -3273,6 +3741,7 @@ VOID CKeywordDetector::Stop() PAGED_CODE(); ResetFifo(); + m_streamRunning = FALSE; } #pragma code_seg("PAGE") @@ -3289,6 +3758,63 @@ VOID CKeywordDetector::StartBufferingStream() qpc = KeQueryPerformanceCounter(&qpcFrequency); m_qpcStartCapture = qpc.QuadPart; + m_qpcFrequency = qpcFrequency.QuadPart; + + return; +} + +#pragma code_seg("PAGE") +_IRQL_requires_max_(PASSIVE_LEVEL) +VOID CKeywordDetector::NotifyDetection() +{ + PAGED_CODE(); + + // A detection will only happen if armed and the + // stream is already running. If there isn't a client + // running, then set the stream start time to align + // with this detection. + if (!m_streamRunning) + { + StartBufferingStream(); + + // The following code is for testing purposes only. + // m_qpcFrequency is defined to be the number of ticks in 1 second. + // Use the stream start time (the current time retrieved in StartBufferStream) to + // mark when the keyword ended, and the start time minus 1 second worth of ticks + // to mark when the keyword started. Also, adjust the stream start time to align + // to this new keyword start time, so that the simulated stream contains the full keyword. + + m_ullKeywordStopTimestamp = m_qpcStartCapture; // stop time is the current time + m_qpcStartCapture = m_qpcStartCapture - m_qpcFrequency; // buffer start time is 1 second ago + m_ullKeywordStartTimestamp = m_qpcStartCapture; // buffer start time = keyword start time + + } + else + { + // The following code is for testing purposes only. + // If the stream is running, we cannot modify qpcStartCapture to be in + // the past, so instead make the keyword start & stop times fit within the + // time period that the keyword has been running. If it has been running + // for more than 1 second, then set the keyword start time to be 1 second back + // into the stream, as though we just figured out there was a keyword there. + // If it has been running less than one second, then the keyword size ends + // up being however long the stream has been running. + + LARGE_INTEGER qpc; + qpc = KeQueryPerformanceCounter(NULL); + + m_ullKeywordStopTimestamp = qpc.QuadPart; // stop time is the current time + + if (m_qpcStartCapture < (qpc.QuadPart - m_qpcFrequency)) + { + m_ullKeywordStartTimestamp = (qpc.QuadPart - m_qpcFrequency); + } + else + { + m_ullKeywordStartTimestamp = m_qpcStartCapture; + } + + } return; } diff --git a/audio/sysvad/EndpointsCommon/minwavert.h b/audio/sysvad/EndpointsCommon/minwavert.h index 21c92542..00534650 100644 --- a/audio/sysvad/EndpointsCommon/minwavert.h +++ b/audio/sysvad/EndpointsCommon/minwavert.h @@ -40,13 +40,13 @@ public: CKeywordDetector(); _IRQL_requires_max_(PASSIVE_LEVEL) - VOID ResetDetector(); + NTSTATUS ResetDetector(_In_ GUID eventId); _IRQL_requires_max_(PASSIVE_LEVEL) - VOID DownloadDetectorData(_In_ LONGLONG Data); + NTSTATUS DownloadDetectorData(_In_ GUID eventId, _In_ LONGLONG Data); _IRQL_requires_max_(PASSIVE_LEVEL) - LONGLONG GetDetectorData(); + NTSTATUS GetDetectorData(_In_ GUID eventId, _Out_ LONGLONG *Data); _IRQL_requires_max_(PASSIVE_LEVEL) ULONGLONG GetStartTimestamp(); @@ -55,10 +55,16 @@ public: ULONGLONG GetStopTimestamp(); _IRQL_requires_max_(PASSIVE_LEVEL) - NTSTATUS SetArmed(_In_ BOOL Arm); + NTSTATUS SetArmed(_In_ GUID eventId, _In_ BOOL Arm); _IRQL_requires_max_(PASSIVE_LEVEL) - BOOL GetArmed(); + VOID NotifyDetection(); + + _IRQL_requires_max_(PASSIVE_LEVEL) + NTSTATUS GetArmed(_In_ GUID eventId, _Out_ BOOL *Arm); + + _IRQL_requires_max_(PASSIVE_LEVEL) + NTSTATUS GetStreamingSupport(_In_ GUID eventId, _Out_ BOOL *Support); _IRQL_requires_max_(PASSIVE_LEVEL) VOID Run(); @@ -95,10 +101,15 @@ private: UINT16 Samples[SamplesPerPacket]; } PACKET_ENTRY; - BOOL m_SoundDetectorArmed; - LONGLONG m_SoundDetectorData; + BOOL m_streamRunning; + + BOOL m_SoundDetectorArmed1; + BOOL m_SoundDetectorArmed2; + LONGLONG m_SoundDetectorData1; + LONGLONG m_SoundDetectorData2; LONGLONG m_qpcStartCapture; + LONGLONG m_qpcFrequency; LONGLONG m_nLastQueuedPacket; ULONGLONG m_ullKeywordStartTimestamp; @@ -181,7 +192,17 @@ public: DECLARE_PROPERTYHANDLER(Get_SoundDetectorArmed); DECLARE_PROPERTYHANDLER(Set_SoundDetectorArmed); DECLARE_PROPERTYHANDLER(Get_SoundDetectorMatchResult); - + + DECLARE_PROPERTYHANDLER(Get_SoundDetectorSupportedPatterns2); + DECLARE_PROPERTYHANDLER(Set_SoundDetectorPatterns2); + DECLARE_PROPERTYHANDLER(Get_SoundDetectorArmed2); + DECLARE_PROPERTYHANDLER(Set_SoundDetectorArmed2); + DECLARE_PROPERTYHANDLER(Set_SoundDetectorReset2); + DECLARE_PROPERTYHANDLER(Get_SoundDetectorStreamingSupport2); + + DECLARE_PROPERTYHANDLER(Get_InterleavedFormatInformation); + + NTSTATUS EventHandler_PinCapsChange ( _In_ PPCEVENT_REQUEST EventRequest @@ -250,6 +271,12 @@ protected: _In_ ULONG NodeId ); + VOID SendPNPNotification( + _In_ const GUID * NotificationId, + _In_ PVOID NotificationBuffer, + _In_ USHORT NotificationBufferCb + ); + public: DECLARE_STD_UNKNOWN(); @@ -319,13 +346,13 @@ public: else { // - // >= comparison here because capture bridge pin comes first in the enumeration + // capture bridge pin comes first in the enumeration // - if (m_FilterDesc.PinCount >= KSPIN_WAVEIN_HOST) + if (m_FilterDesc.PinCount > KSPIN_WAVEIN_HOST) { m_ulMaxSystemStreams = m_FilterDesc.Pins[KSPIN_WAVEIN_HOST].MaxFilterInstanceCount; } - if (m_FilterDesc.PinCount >= KSPIN_WAVEIN_KEYWORD) + if (m_FilterDesc.PinCount > KSPIN_WAVEIN_KEYWORD) { m_ulMaxKeywordDetectorStreams = m_FilterDesc.Pins[KSPIN_WAVEIN_KEYWORD].MaxFilterInstanceCount; } @@ -534,6 +561,7 @@ protected: m_DeviceType == eSpdifRenderDevice || m_DeviceType == eBthHfpSpeakerDevice || m_DeviceType == eUsbHsSpeakerDevice || + m_DeviceType == eA2dpHpSpeakerDevice || m_DeviceType == eHandsetSpeakerDevice) ? TRUE : FALSE; } @@ -595,7 +623,6 @@ protected: return KSPIN_WAVE_RENDER_SINK_OFFLOAD; } -#pragma code_seg() ULONG GetAudioModuleDescriptorListCount() @@ -666,7 +693,8 @@ public: return (m_DeviceType == eBthHfpMicDevice || m_DeviceType == eBthHfpSpeakerDevice || m_DeviceType == eUsbHsMicDevice || - m_DeviceType == eUsbHsSpeakerDevice ) ? TRUE : FALSE; + m_DeviceType == eUsbHsSpeakerDevice || + m_DeviceType == eA2dpHpSpeakerDevice ) ? TRUE : FALSE; } // Returns a weak ref to the Bluetooth HFP device. diff --git a/audio/sysvad/EndpointsCommon/minwavertstream.cpp b/audio/sysvad/EndpointsCommon/minwavertstream.cpp index 9ea47c56..93ecdcf3 100644 --- a/audio/sysvad/EndpointsCommon/minwavertstream.cpp +++ b/audio/sysvad/EndpointsCommon/minwavertstream.cpp @@ -889,8 +889,7 @@ Done: // // Return value // -// Returns STATUS_OPERATION_IN_PROGRESS if no new packets are available and -// the next packet is in progress. +// Returns STATUS_DEVICE_NOT_READY if no new packets are available. // // IRQL - PASSIVE_LEVEL // @@ -900,6 +899,7 @@ Done: // // ISSUE-2014/10/4 Will this work correctly across pause/play? #pragma code_seg() +_IRQL_requires_max_(PASSIVE_LEVEL) NTSTATUS CMiniportWaveRTStream::GetReadPacket ( _Out_ ULONG *PacketNumber, @@ -993,24 +993,11 @@ NTSTATUS CMiniportWaveRTStream::GetReadPacket // Update the last packet read by the OS m_ulLastOsReadPacket = availablePacketNumber; -#if 0 - // For test, embed packet number and timestamp into first two LONGLONGs of the packet - LONG packetIndex = availablePacketNumber % m_ulNotificationsPerBuffer; - SIZE_T packetSize = m_ulDmaBufferSize / m_ulNotificationsPerBuffer; - BYTE *packetDataAsBytes = m_pDmaBuffer + (packetIndex * packetSize); - LONGLONG *packetDataAsLonglongs = (LONGLONG*)packetDataAsBytes; - for (int i = 0; i < packetSize / sizeof(LONGLONG); i++) - { - packetDataAsLonglongs[i] = i; - } - packetDataAsLonglongs[0] = availablePacketNumber; - packetDataAsLonglongs[1] = timeOfAvailablePacketInQpc; -#endif - return STATUS_SUCCESS; } #pragma code_seg() +_IRQL_requires_max_(PASSIVE_LEVEL) NTSTATUS CMiniportWaveRTStream::SetWritePacket ( _In_ ULONG PacketNumber, @@ -1103,6 +1090,7 @@ NTSTATUS CMiniportWaveRTStream::SetWritePacket //============================================================================= #pragma code_seg() +_IRQL_requires_max_(PASSIVE_LEVEL) NTSTATUS CMiniportWaveRTStream::GetOutputStreamPresentationPosition ( _Out_ KSAUDIO_PRESENTATION_POSITION *pPresentationPosition @@ -1121,6 +1109,7 @@ NTSTATUS CMiniportWaveRTStream::GetOutputStreamPresentationPosition //============================================================================= #pragma code_seg() +_IRQL_requires_max_(PASSIVE_LEVEL) NTSTATUS CMiniportWaveRTStream::GetPacketCount ( _Out_ ULONG *pPacketCount diff --git a/audio/sysvad/EndpointsCommon/sources b/audio/sysvad/EndpointsCommon/sources deleted file mode 100644 index 4ac1b852..00000000 --- a/audio/sysvad/EndpointsCommon/sources +++ /dev/null @@ -1,48 +0,0 @@ - -# Copyright (c) Microsoft Corporation. All rights reserved. - - -TARGETNAME=EndpointsCommon -TARGETTYPE=LIBRARY -KM_LIBRARY=1 - -INCLUDES= \ - $(DDK_INC_PATH); \ - .. - - -C_DEFINES = $(C_DEFINES) -D_USE_WAVERT_ -DSYSVAD_BTH_BYPASS -DSYSVAD_USB_SIDEBAND -#C_DEFINES = $(C_DEFINES) -D_USE_WAVERT_ - -DDK_TARGET_PLATFORM=Universal - -# -# Indicate to the WDK that this sample only supports Win10[+] -# -MINIMUM_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINTHRESHOLD) - -# -# Audio driver is a KMDF miniport. -# -KMDF_VERSION_MAJOR=1 - - -SOURCES=$(SOURCES) \ - AudioModuleHelper.cpp \ - bthhfptopo.cpp \ - bthhfpmictopo.cpp \ - bthhfpspeakertopo.cpp \ - bthhfpminwavert.cpp \ - micarraytopo.cpp \ - MiniportAudioEngineNode.cpp \ - MiniportStreamAudioEngineNode.cpp \ - mintopo.cpp \ - minwavert.cpp \ - minwavertstream.cpp \ - speakertopo.cpp \ - speakerhptopo.cpp \ - usbhstopo.cpp \ - usbhsmictopo.cpp \ - usbhsspeakertopo.cpp \ - usbhsminwavert.cpp \ - diff --git a/audio/sysvad/EndpointsCommon/speakerhptoptable.h b/audio/sysvad/EndpointsCommon/speakerhptoptable.h index dece62fa..3a851dce 100644 --- a/audio/sysvad/EndpointsCommon/speakerhptoptable.h +++ b/audio/sysvad/EndpointsCommon/speakerhptoptable.h @@ -15,7 +15,7 @@ Abstract: #ifndef _SYSVAD_SPEAKERHPTOPTABLE_H_ #define _SYSVAD_SPEAKERHPTOPTABLE_H_ -#include "mintopo.h" +#include <mintopo.h> //============================================================================= static |
