diff options
| author | Julia D'Zmura <[email protected]> | 2023-02-02 15:53:08 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-02 15:53:08 -0800 |
| commit | 54a98a7e6af65ebc3a8ec92c7c09d94d0b44a6fd (patch) | |
| tree | 9a159a9b2dde990a70ae5b62760236314f165c41 | |
| parent | 520c37087776a198544ab9b721d802dd30864736 (diff) | |
Updates to make Sysvad and SimpleAudioSample Windows Drivers Compliant (#845)
Updating sysvad and simpleaudiosample drivers.
34 files changed, 611 insertions, 346 deletions
diff --git a/audio/simpleaudiosample/Source/Filters/Filters.vcxproj b/audio/simpleaudiosample/Source/Filters/Filters.vcxproj index 82fd07dc..1bc012e0 100644 --- a/audio/simpleaudiosample/Source/Filters/Filters.vcxproj +++ b/audio/simpleaudiosample/Source/Filters/Filters.vcxproj @@ -38,7 +38,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -46,7 +46,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -54,7 +54,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -62,7 +62,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -70,7 +70,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -78,7 +78,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> diff --git a/audio/simpleaudiosample/Source/Inc/Inc.vcxproj b/audio/simpleaudiosample/Source/Inc/Inc.vcxproj index ab768d84..14fce7b3 100644 --- a/audio/simpleaudiosample/Source/Inc/Inc.vcxproj +++ b/audio/simpleaudiosample/Source/Inc/Inc.vcxproj @@ -38,7 +38,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -46,7 +46,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -54,7 +54,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -62,7 +62,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -70,7 +70,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -78,7 +78,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> diff --git a/audio/simpleaudiosample/Source/Main/Main.vcxproj b/audio/simpleaudiosample/Source/Main/Main.vcxproj index a68d0242..be92b9d4 100644 --- a/audio/simpleaudiosample/Source/Main/Main.vcxproj +++ b/audio/simpleaudiosample/Source/Main/Main.vcxproj @@ -40,7 +40,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -48,7 +48,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -56,7 +56,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -64,7 +64,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -72,7 +72,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -80,7 +80,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> diff --git a/audio/simpleaudiosample/Source/Main/adapter.cpp b/audio/simpleaudiosample/Source/Main/adapter.cpp index 105f7fde..bbe23f26 100644 --- a/audio/simpleaudiosample/Source/Main/adapter.cpp +++ b/audio/simpleaudiosample/Source/Main/adapter.cpp @@ -45,10 +45,10 @@ _Dispatch_type_(IRP_MJ_PNP) DRIVER_DISPATCH PnpHandler; // -// Rendering streams are saved to a file by default. Use the registry value -// DoNotCreateDataFiles (DWORD) > 0 to override this default. +// Rendering streams are not saved to a file by default. Use the registry value +// DoNotCreateDataFiles (DWORD) = 0 to override this default. // -DWORD g_DoNotCreateDataFiles = 0; // default is off. +DWORD g_DoNotCreateDataFiles = 1; // default is off. DWORD g_DisableToneGenerator = 0; // default is to generate tones. UNICODE_STRING g_RegistryPath; // This is used to store the registry settings path for the driver @@ -192,7 +192,8 @@ Returns: { NTSTATUS ntStatus; - UNICODE_STRING parametersPath; + PDRIVER_OBJECT DriverObject; + HANDLE DriverKey; RTL_QUERY_REGISTRY_TABLE paramTable[] = { // QueryRoutine Flags Name EntryContext DefaultType DefaultData DefaultLength { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_TYPECHECK, L"DoNotCreateDataFiles", &g_DoNotCreateDataFiles, (REG_DWORD << RTL_QUERY_REGISTRY_TYPECHECK_SHIFT) | REG_DWORD, &g_DoNotCreateDataFiles, sizeof(ULONG)}, @@ -202,29 +203,27 @@ Returns: DPF(D_TERSE, ("[GetRegistrySettings]")); - PAGED_CODE(); - - RtlInitUnicodeString(¶metersPath, NULL); + PAGED_CODE(); + UNREFERENCED_PARAMETER(RegistryPath); - parametersPath.MaximumLength = - RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(WCHAR); + DriverObject = WdfDriverWdmGetDriverObject(WdfGetDriver()); + DriverKey = NULL; + ntStatus = IoOpenDriverRegistryKey(DriverObject, + DriverRegKeyParameters, + KEY_READ, + 0, + &DriverKey); - parametersPath.Buffer = (PWCH) ExAllocatePool2(POOL_FLAG_PAGED, parametersPath.MaximumLength, MINADAPTER_POOLTAG); - if (parametersPath.Buffer == NULL) + if (!NT_SUCCESS(ntStatus)) { - return STATUS_INSUFFICIENT_RESOURCES; + return ntStatus; } - RtlAppendUnicodeToString(¶metersPath, RegistryPath->Buffer); - RtlAppendUnicodeToString(¶metersPath, L"\\Parameters"); - - ntStatus = RtlQueryRegistryValues( - RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, - parametersPath.Buffer, - ¶mTable[0], - NULL, - NULL - ); + ntStatus = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE, + (PCWSTR) DriverKey, + ¶mTable[0], + NULL, + NULL); if (!NT_SUCCESS(ntStatus)) { @@ -240,10 +239,10 @@ Returns: DPF(D_VERBOSE, ("DoNotCreateDataFiles: %u", g_DoNotCreateDataFiles)); DPF(D_VERBOSE, ("DisableToneGenerator: %u", g_DisableToneGenerator)); - // - // Cleanup. - // - ExFreePool(parametersPath.Buffer); + if (DriverKey) + { + ZwClose(DriverKey); + } return STATUS_SUCCESS; } @@ -292,15 +291,6 @@ Return Value: ntStatus, DPF(D_ERROR, ("Registry path copy error 0x%x", ntStatus)), Done); - - // - // Get registry configuration. - // - ntStatus = GetRegistrySettings(RegistryPathName); - IF_FAILED_ACTION_JUMP( - ntStatus, - DPF(D_ERROR, ("Registry Configuration error 0x%x", ntStatus)), - Done); WDF_DRIVER_CONFIG_INIT(&config, WDF_NO_EVENT_CALLBACK); // @@ -324,6 +314,15 @@ Return Value: Done); // + // Get registry configuration. + // + ntStatus = GetRegistrySettings(RegistryPathName); + IF_FAILED_ACTION_JUMP( + ntStatus, + DPF(D_ERROR, ("Registry Configuration error 0x%x", ntStatus)), + Done); + + // // Tell the class driver to initialize the driver. // ntStatus = PcInitializeAdapterDriver(DriverObject, diff --git a/audio/simpleaudiosample/Source/Main/minwavertstream.cpp b/audio/simpleaudiosample/Source/Main/minwavertstream.cpp index 27289a0e..c189c939 100644 --- a/audio/simpleaudiosample/Source/Main/minwavertstream.cpp +++ b/audio/simpleaudiosample/Source/Main/minwavertstream.cpp @@ -108,8 +108,8 @@ NTSTATUS CMiniportWaveRTStream::ReadRegistrySettings() PAGED_CODE(); NTSTATUS ntStatus; - UNICODE_STRING parametersPath; - + PDRIVER_OBJECT DriverObject; + HANDLE DriverKey; RTL_QUERY_REGISTRY_TABLE paramTable[] = { // QueryRoutine Flags Name EntryContext DefaultType DefaultData DefaultLength { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_TYPECHECK, L"HostCaptureToneFrequency", &m_ulHostCaptureToneFrequency, (REG_DWORD << RTL_QUERY_REGISTRY_TYPECHECK_SHIFT) | REG_DWORD, &m_ulHostCaptureToneFrequency, sizeof(DWORD) }, @@ -119,30 +119,37 @@ NTSTATUS CMiniportWaveRTStream::ReadRegistrySettings() { NULL, 0, NULL, NULL, 0, NULL, 0 } }; - RtlInitUnicodeString(¶metersPath, NULL); - - // The sizeof(WCHAR) is added to the maximum length, for allowing a space for null termination of the string. - parametersPath.MaximumLength = - g_RegistryPath.Length + sizeof(L"\\Parameters") + sizeof(WCHAR); + DriverObject = WdfDriverWdmGetDriverObject(WdfGetDriver()); + DriverKey = NULL; + ntStatus = IoOpenDriverRegistryKey(DriverObject, + DriverRegKeyParameters, + KEY_READ, + 0, + &DriverKey); - parametersPath.Buffer = (PWCH)ExAllocatePool2(POOL_FLAG_PAGED, parametersPath.MaximumLength, MINWAVERT_POOLTAG); - if (parametersPath.Buffer == NULL) + if (!NT_SUCCESS(ntStatus)) { - return STATUS_INSUFFICIENT_RESOURCES; + return ntStatus; } - RtlAppendUnicodeToString(¶metersPath, g_RegistryPath.Buffer); - RtlAppendUnicodeToString(¶metersPath, L"\\Parameters"); + ntStatus = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE, + (PCWSTR) DriverKey, + ¶mTable[0], + NULL, + NULL); - ntStatus = RtlQueryRegistryValues( - RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, - parametersPath.Buffer, - ¶mTable[0], - NULL, - NULL - ); + if (!NT_SUCCESS(ntStatus)) + { + DPF(D_VERBOSE, ("RtlQueryRegistryValues failed, using default values, 0x%x", ntStatus)); + // + // Don't return error because we will operate with default values. + // + } - ExFreePool(parametersPath.Buffer); + if (DriverKey) + { + ZwClose(DriverKey); + } return ntStatus; } diff --git a/audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj b/audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj index 0a71bf42..710bf748 100644 --- a/audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj +++ b/audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj @@ -38,7 +38,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -46,7 +46,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -54,7 +54,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -62,7 +62,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -70,7 +70,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -78,7 +78,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> diff --git a/audio/simpleaudiosample/Source/Utilities/savedata.cpp b/audio/simpleaudiosample/Source/Utilities/savedata.cpp index 7b2a11e9..02c3f602 100644 --- a/audio/simpleaudiosample/Source/Utilities/savedata.cpp +++ b/audio/simpleaudiosample/Source/Utilities/savedata.cpp @@ -44,8 +44,9 @@ Abstract: #define DEFAULT_FRAME_SIZE PAGE_SIZE * 4 #define DEFAULT_BUFFER_SIZE DEFAULT_FRAME_SIZE * DEFAULT_FRAME_COUNT -#define DEFAULT_FILE_NAME L"\\DosDevices\\C:\\STREAM" -#define OSDATA_FILE_NAME L"\\DosDevices\\O:\\STREAM" +#define DEFAULT_FILE_FOLDER1 L"\\DriverData\\Audio_Samples" +#define DEFAULT_FILE_FOLDER2 L"\\DriverData\\Audio_Samples\\SimpleAudioSample" +#define DEFAULT_FILE_NAME L"\\DriverData\\Audio_Samples\\SimpleAudioSample\\STREAM" #define OFFLOAD_FILE_NAME L"OFFLOAD" #define HOST_FILE_NAME L"HOST" @@ -444,59 +445,86 @@ CSaveData::Initialize { PAGED_CODE(); - NTSTATUS ntStatus = STATUS_SUCCESS; - WCHAR szTemp[MAX_PATH]; - size_t cLen; - OBJECT_ATTRIBUTES objectAttributes; - UNICODE_STRING osDataVolumeString; - HANDLE osDataFileHandle = NULL; - IO_STATUS_BLOCK ioStatusBlock; + NTSTATUS ntStatus = STATUS_SUCCESS; + WCHAR szTemp[MAX_PATH]; + size_t cLen = 0; + IO_STATUS_BLOCK ioStatusBlock = {0}; + HANDLE fileHandle; + OBJECT_ATTRIBUTES objectAttributes; + UNICODE_STRING fileName; DPF_ENTER(("[CSaveData::Initialize]")); m_ulStreamId++; - // Probe if OSData volume exists. - // - RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_probe.txt", OSDATA_FILE_NAME); - RtlInitUnicodeString(&osDataVolumeString, szTemp); - InitializeObjectAttributes - ( - &objectAttributes, - &osDataVolumeString, - OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, - NULL, - NULL - ); + RtlInitUnicodeString(&fileName, DEFAULT_FILE_FOLDER1); + InitializeObjectAttributes( + &objectAttributes, + &fileName, + OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, + NULL, + NULL); - ntStatus = - ZwCreateFile - ( - &osDataFileHandle, - GENERIC_WRITE | SYNCHRONIZE, + // Create the folder. + ntStatus = ZwCreateFile( + &fileHandle, + 0, &objectAttributes, &ioStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0, - FILE_OVERWRITE_IF, - FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, + FILE_OPEN_IF, + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, - 0 - ); + 0); + + if (NT_SUCCESS(ntStatus)) + { + ZwClose(fileHandle); + fileHandle = NULL; + + RtlInitUnicodeString(&fileName, DEFAULT_FILE_FOLDER2); + InitializeObjectAttributes( + &objectAttributes, + &fileName, + OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + // Create the folder. + ntStatus = ZwCreateFile( + &fileHandle, + 0, + &objectAttributes, + &ioStatusBlock, + NULL, + FILE_ATTRIBUTE_NORMAL, + 0, + FILE_OPEN_IF, + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, + NULL, + 0); + + if (NT_SUCCESS(ntStatus)) + { + ZwClose(fileHandle); + fileHandle = NULL; + } + } + if (NT_SUCCESS(ntStatus)) { - ZwClose(osDataFileHandle); + // Allocate data file name. + // + RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_%s_%d.wav", DEFAULT_FILE_NAME, HOST_FILE_NAME, m_ulStreamId); + m_FileName.Length = 0; + ntStatus = RtlStringCchLengthW (szTemp, sizeof(szTemp)/sizeof(szTemp[0]), &cLen); } - // Allocate data file name. - // - RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_%s_%d.wav", NT_SUCCESS(ntStatus) ? OSDATA_FILE_NAME : DEFAULT_FILE_NAME, HOST_FILE_NAME, m_ulStreamId); - m_FileName.Length = 0; - ntStatus = RtlStringCchLengthW (szTemp, sizeof(szTemp)/sizeof(szTemp[0]), &cLen); if (NT_SUCCESS(ntStatus)) { - m_FileName.MaximumLength = (USHORT)((cLen * sizeof(WCHAR)) + sizeof(WCHAR));//convert to wchar and add room for NULL + m_FileName.MaximumLength = (USHORT)((cLen * sizeof(WCHAR)) + sizeof(WCHAR));//convert to wchar and add room for NULL m_FileName.Buffer = (PWSTR) ExAllocatePool2 ( @@ -574,7 +602,7 @@ CSaveData::Initialize ( &m_objectAttributes, &m_FileName, - OBJ_CASE_INSENSITIVE|OBJ_KERNEL_HANDLE, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL ); diff --git a/audio/sysvad/APO/AecApo/AecApo.h b/audio/sysvad/APO/AecApo/AecApo.h index a62b69ce..7c96314d 100644 --- a/audio/sysvad/APO/AecApo/AecApo.h +++ b/audio/sysvad/APO/AecApo/AecApo.h @@ -99,13 +99,8 @@ public: ) override; // IAudioSystemEffects3 - STDMETHODIMP GetControllableSystemEffectsList(_Outptr_result_buffer_maybenull_(*numEffects) AUDIO_SYSTEMEFFECT** effects, _Out_ UINT* numEffects, _In_opt_ HANDLE event) override - { - UNREFERENCED_PARAMETER(effects); - UNREFERENCED_PARAMETER(numEffects); - UNREFERENCED_PARAMETER(event); - return S_OK; - } + STDMETHOD(GetControllableSystemEffectsList)( + _Outptr_result_buffer_maybenull_(*numEffects) AUDIO_SYSTEMEFFECT** effects, _Out_ UINT* numEffects, _In_opt_ HANDLE event) override; STDMETHODIMP SetAudioSystemEffectState(GUID, AUDIO_SYSTEMEFFECT_STATE) override {return S_OK;} diff --git a/audio/sysvad/APO/AecApo/AecApo.vcxproj b/audio/sysvad/APO/AecApo/AecApo.vcxproj index f40ce919..3602ba64 100644 --- a/audio/sysvad/APO/AecApo/AecApo.vcxproj +++ b/audio/sysvad/APO/AecApo/AecApo.vcxproj @@ -39,7 +39,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -48,7 +48,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -57,7 +57,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -66,7 +66,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -75,7 +75,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -84,7 +84,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -350,4 +350,4 @@ <ClInclude Exclude="@(ClInclude)" Include="AecApo.h" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/audio/sysvad/APO/AecApo/AecApoMfx.cpp b/audio/sysvad/APO/AecApo/AecApoMfx.cpp index 21f2c20d..0c16f348 100644 --- a/audio/sysvad/APO/AecApo/AecApoMfx.cpp +++ b/audio/sysvad/APO/AecApo/AecApoMfx.cpp @@ -375,6 +375,39 @@ STDMETHODIMP CAecApoMFX::GetEffectsList(_Outptr_result_buffer_maybenull_(*pcEffe return S_OK; } +STDMETHODIMP CAecApoMFX::GetControllableSystemEffectsList(_Outptr_result_buffer_maybenull_(*numEffects) AUDIO_SYSTEMEFFECT** effects, _Out_ UINT* numEffects, _In_opt_ HANDLE event) +{ + UNREFERENCED_PARAMETER(event); + + RETURN_HR_IF_NULL(E_POINTER, effects); + RETURN_HR_IF_NULL(E_POINTER, numEffects); + + *effects = nullptr; + *numEffects = 0; + + if (m_audioSignalProcessingMode == AUDIO_SIGNALPROCESSINGMODE_COMMUNICATIONS) + { + // Return the list of effects implemented by this APO for COMMUNICATIONS processing mode + static const GUID effectsList[] = {AUDIO_EFFECT_TYPE_ACOUSTIC_ECHO_CANCELLATION}; + + wil::unique_cotaskmem_array_ptr<AUDIO_SYSTEMEFFECT> audioEffects( + static_cast<AUDIO_SYSTEMEFFECT*>(CoTaskMemAlloc(ARRAYSIZE(effectsList) * sizeof(AUDIO_SYSTEMEFFECT))), ARRAYSIZE(effectsList)); + RETURN_IF_NULL_ALLOC(audioEffects.get()); + + for (UINT i = 0; i < ARRAYSIZE(effectsList); i++) + { + audioEffects[i].id = effectsList[i]; + audioEffects[i].state = AUDIO_SYSTEMEFFECT_STATE_ON; + audioEffects[i].canSetState = FALSE; + } + + *numEffects = (UINT)audioEffects.size(); + *effects = audioEffects.release(); + } + + return S_OK; +} + HRESULT IsInputFormatSupportedForAec(IAudioMediaType* pMediaType, BOOL * pSupported) { ASSERT_NONREALTIME(); diff --git a/audio/sysvad/APO/DelayAPO/DelayAPO.vcxproj b/audio/sysvad/APO/DelayAPO/DelayAPO.vcxproj index ecdaf321..86f49395 100644 --- a/audio/sysvad/APO/DelayAPO/DelayAPO.vcxproj +++ b/audio/sysvad/APO/DelayAPO/DelayAPO.vcxproj @@ -39,7 +39,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -48,7 +48,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -57,7 +57,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -66,7 +66,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -75,7 +75,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -84,7 +84,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> diff --git a/audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp b/audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp index 8778b252..e7492131 100644 --- a/audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp +++ b/audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp @@ -430,7 +430,8 @@ HRESULT CDelayAPOMFX::Initialize(UINT32 cbDataSize, BYTE* pbyData) processingMode != AUDIO_SIGNALPROCESSINGMODE_COMMUNICATIONS && processingMode != AUDIO_SIGNALPROCESSINGMODE_SPEECH && processingMode != AUDIO_SIGNALPROCESSINGMODE_MEDIA && - processingMode != AUDIO_SIGNALPROCESSINGMODE_MOVIE), hr = E_INVALIDARG, Exit); + processingMode != AUDIO_SIGNALPROCESSINGMODE_MOVIE && + processingMode != AUDIO_SIGNALPROCESSINGMODE_NOTIFICATION), hr = E_INVALIDARG, Exit); m_AudioProcessingMode = processingMode; // diff --git a/audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp b/audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp index 81594bb7..c37abb7c 100644 --- a/audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp +++ b/audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp @@ -388,7 +388,8 @@ HRESULT CDelayAPOSFX::Initialize(UINT32 cbDataSize, BYTE* pbyData) processingMode != AUDIO_SIGNALPROCESSINGMODE_COMMUNICATIONS && processingMode != AUDIO_SIGNALPROCESSINGMODE_SPEECH && processingMode != AUDIO_SIGNALPROCESSINGMODE_MEDIA && - processingMode != AUDIO_SIGNALPROCESSINGMODE_MOVIE), hr = E_INVALIDARG, Exit); + processingMode != AUDIO_SIGNALPROCESSINGMODE_MOVIE && + processingMode != AUDIO_SIGNALPROCESSINGMODE_NOTIFICATION), hr = E_INVALIDARG, Exit); m_AudioProcessingMode = processingMode; // diff --git a/audio/sysvad/APO/KWSApo/KWSApo.vcxproj b/audio/sysvad/APO/KWSApo/KWSApo.vcxproj index b34e03d9..592686b4 100644 --- a/audio/sysvad/APO/KWSApo/KWSApo.vcxproj +++ b/audio/sysvad/APO/KWSApo/KWSApo.vcxproj @@ -39,7 +39,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -48,7 +48,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -57,7 +57,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -66,7 +66,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -75,7 +75,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -84,7 +84,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -352,4 +352,4 @@ <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/audio/sysvad/APO/SwapAPO/SwapAPO.h b/audio/sysvad/APO/SwapAPO/SwapAPO.h index aeb9d259..d169d9db 100644 --- a/audio/sysvad/APO/SwapAPO/SwapAPO.h +++ b/audio/sysvad/APO/SwapAPO/SwapAPO.h @@ -195,7 +195,8 @@ public: public: LONG m_fEnableSwapMFX; GUID m_AudioProcessingMode; - wil::com_ptr_nothrow<IMMDevice> m_device; + wil::com_ptr_nothrow<IMMDevice> m_deviceTopologyMMDevice; + wil::com_ptr_nothrow<IMMDevice> m_audioEndpoint; CComPtr<IPropertyStore> m_spAPOSystemEffectsProperties; CComPtr<IMMDeviceEnumerator> m_spEnumerator; static const CRegAPOProperties<1> sm_RegProperties; // registration properties @@ -315,7 +316,8 @@ public: LONG m_fEnableSwapSFX; LONG m_fEnableDelaySFX; GUID m_AudioProcessingMode; - wil::com_ptr_nothrow<IMMDevice> m_device; + wil::com_ptr_nothrow<IMMDevice> m_deviceTopologyMMDevice; + wil::com_ptr_nothrow<IMMDevice> m_audioEndpoint; CComPtr<IPropertyStore> m_spAPOSystemEffectsProperties; CComPtr<IMMDeviceEnumerator> m_spEnumerator; static const CRegAPOProperties<1> sm_RegProperties; // registration properties diff --git a/audio/sysvad/APO/SwapAPO/SwapAPO.vcxproj b/audio/sysvad/APO/SwapAPO/SwapAPO.vcxproj index 2a26307e..8ceee8ea 100644 --- a/audio/sysvad/APO/SwapAPO/SwapAPO.vcxproj +++ b/audio/sysvad/APO/SwapAPO/SwapAPO.vcxproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?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|ARM64"> @@ -39,7 +39,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -48,7 +48,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -57,7 +57,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -66,7 +66,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -75,7 +75,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -84,7 +84,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <EmbedManifest>false</EmbedManifest> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> @@ -427,4 +427,4 @@ <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/audio/sysvad/APO/SwapAPO/swapapomfx.cpp b/audio/sysvad/APO/SwapAPO/swapapomfx.cpp index 7a772a07..b05b1568 100644 --- a/audio/sysvad/APO/SwapAPO/swapapomfx.cpp +++ b/audio/sysvad/APO/SwapAPO/swapapomfx.cpp @@ -458,10 +458,38 @@ HRESULT CSwapAPOMFX::Initialize(UINT32 cbDataSize, BYTE* pbyData) // that need to run at a real-time priority. The work queue ID is used with the Rtwq APIs. hr = apoRtQueueService->GetRealTimeWorkQueue(&m_queueId); IF_FAILED_JUMP(hr, Exit); - + // Windows should pass a valid collection. ATLASSERT(papoSysFxInit3->pDeviceCollection != nullptr); IF_TRUE_ACTION_JUMP(papoSysFxInit3->pDeviceCollection == nullptr, hr = E_INVALIDARG, Exit); + + // Use IMMDevice to activate IAudioSystemEffectsPropertyStore that contains the default, user and + // volatile settings. + IMMDeviceCollection* deviceCollection = reinterpret_cast<APOInitSystemEffects3*>(pbyData)->pDeviceCollection; + UINT32 numDevices; + // Get the endpoint on which this APO has been created + // (It is the last device in the device collection) + hr = deviceCollection->GetCount(&numDevices); + IF_FAILED_JUMP(hr, Exit); + + hr = numDevices > 0 ? S_OK : E_UNEXPECTED; + IF_FAILED_JUMP(hr, Exit); + + hr = deviceCollection->Item(numDevices - 1, &m_audioEndpoint); + IF_FAILED_JUMP(hr, Exit); + + wil::unique_prop_variant activationParam; + hr = InitPropVariantFromCLSID(SWAP_APO_SFX_CONTEXT, &activationParam); + IF_FAILED_JUMP(hr, Exit); + + wil::com_ptr_nothrow<IAudioSystemEffectsPropertyStore> effectsPropertyStore; + hr = m_audioEndpoint->Activate(__uuidof(effectsPropertyStore), CLSCTX_ALL, &activationParam, effectsPropertyStore.put_void()); + IF_FAILED_JUMP(hr, Exit); + + // This is where an APO might want to open the volatile or default property stores as well + // Use STGM_READWRITE if IPropertyStore::SetValue is needed. + hr = effectsPropertyStore->OpenUserPropertyStore(STGM_READ, m_userStore.put()); + IF_FAILED_JUMP(hr, Exit); // Save the processing mode being initialized. processingMode = papoSysFxInit3->AudioProcessingMode; @@ -523,7 +551,8 @@ HRESULT CSwapAPOMFX::Initialize(UINT32 cbDataSize, BYTE* pbyData) processingMode != AUDIO_SIGNALPROCESSINGMODE_COMMUNICATIONS && processingMode != AUDIO_SIGNALPROCESSINGMODE_SPEECH && processingMode != AUDIO_SIGNALPROCESSINGMODE_MEDIA && - processingMode != AUDIO_SIGNALPROCESSINGMODE_MOVIE), hr = E_INVALIDARG, Exit); + processingMode != AUDIO_SIGNALPROCESSINGMODE_MOVIE && + processingMode != AUDIO_SIGNALPROCESSINGMODE_NOTIFICATION), hr = E_INVALIDARG, Exit); m_AudioProcessingMode = processingMode; // @@ -755,7 +784,7 @@ HRESULT CSwapAPOMFX::SetAudioSystemEffectState(GUID effectId, AUDIO_SYSTEMEFFECT if (oldState != effectInfo.state) { SetEvent(m_hEffectsChangedEvent); - m_apoLoggingService->ApoLog(APO_LOG_LEVEL_INFO, L"SetAudioSystemEffectState - effect: " GUID_FORMAT_STRING L", state: %i", effectInfo.id, effectInfo.state); + m_apoLoggingService->ApoLog(APO_LOG_LEVEL_INFO, L"CSwapAPOMFX::SetAudioSystemEffectState - effect: " GUID_FORMAT_STRING L", state: %i", effectInfo.id, effectInfo.state); } m_EffectsLock.Leave(); @@ -772,8 +801,6 @@ HRESULT CSwapAPOMFX::GetApoNotificationRegistrationInfo(_Out_writes_(*count) APO *apoNotifications = nullptr; *count = 0; - RETURN_HR_IF_NULL(E_FAIL, m_device); - // Let the OS know what notifications we are interested in by returning an array of // APO_NOTIFICATION_DESCRIPTORs. constexpr DWORD numDescriptors = 1; @@ -785,7 +812,7 @@ HRESULT CSwapAPOMFX::GetApoNotificationRegistrationInfo(_Out_writes_(*count) APO // Our APO wants to get notified when a endpoint property changes on the audio endpoint. apoNotificationDescriptors[0].type = APO_NOTIFICATION_TYPE_ENDPOINT_PROPERTY_CHANGE; - (void)m_device.query_to(&apoNotificationDescriptors[0].audioEndpointPropertyChange.device); + (void)m_audioEndpoint.query_to(&apoNotificationDescriptors[0].audioEndpointPropertyChange.device); *apoNotifications = apoNotificationDescriptors.release(); *count = numDescriptors; @@ -811,7 +838,7 @@ void CSwapAPOMFX::HandleNotification(APO_NOTIFICATION *apoNotification) {PKEY_Endpoint_Enable_Channel_Swap_MFX, &m_fEnableSwapMFX}, }; - m_apoLoggingService->ApoLog(APO_LOG_LEVEL_INFO, L"HandleNotification - pkey: " GUID_FORMAT_STRING L" %d", GUID_FORMAT_ARGS(apoNotification->audioEndpointPropertyChange.propertyKey.fmtid), apoNotification->audioEndpointPropertyChange.propertyKey.pid); + m_apoLoggingService->ApoLog(APO_LOG_LEVEL_INFO, L"CSwapAPOMFX::HandleNotification - pkey: " GUID_FORMAT_STRING L" %d", GUID_FORMAT_ARGS(apoNotification->audioEndpointPropertyChange.propertyKey.fmtid), apoNotification->audioEndpointPropertyChange.propertyKey.pid); for (int i = 0; i < ARRAYSIZE(controls); i++) { @@ -847,11 +874,11 @@ HRESULT CSwapAPOMFX::ProprietaryCommunicationWithDriver(IMMDeviceCollection *pDe } // Get the target IMMDevice - hr = pDeviceCollection->Item(nSoftwareIoDeviceInCollection, &m_device); + hr = pDeviceCollection->Item(nSoftwareIoDeviceInCollection, &m_deviceTopologyMMDevice); IF_FAILED_JUMP(hr, Exit); // Instantiate a device topology instance - hr = m_device->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, (void**)&spMyDeviceTopology); + hr = m_deviceTopologyMMDevice->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, (void**)&spMyDeviceTopology); IF_FAILED_JUMP(hr, Exit); // retrieve connect instance @@ -859,7 +886,7 @@ HRESULT CSwapAPOMFX::ProprietaryCommunicationWithDriver(IMMDeviceCollection *pDe IF_FAILED_JUMP(hr, Exit); // activate IKsControl on the IMMDevice - hr = m_device->Activate(__uuidof(IKsControl), CLSCTX_INPROC_SERVER, NULL, (void**)&spKsControl); + hr = m_deviceTopologyMMDevice->Activate(__uuidof(IKsControl), CLSCTX_INPROC_SERVER, NULL, (void**)&spKsControl); IF_FAILED_JUMP(hr, Exit); // get KS pin id diff --git a/audio/sysvad/APO/SwapAPO/swapaposfx.cpp b/audio/sysvad/APO/SwapAPO/swapaposfx.cpp index 8483d8df..ef418f75 100644 --- a/audio/sysvad/APO/SwapAPO/swapaposfx.cpp +++ b/audio/sysvad/APO/SwapAPO/swapaposfx.cpp @@ -297,48 +297,48 @@ HRESULT CSwapAPOSFX::Initialize(UINT32 cbDataSize, BYTE* pbyData) hr = papoSysFxInit3->pServiceProvider->QueryService(SID_AudioProcessingObjectLoggingService, IID_PPV_ARGS(&m_apoLoggingService)); IF_FAILED_JUMP(hr, Exit); - // SampleApo supports the new IAudioSystemEffects3 interface so it will receive APOInitSystemEffects3 + // SampleApo supports the new IAudioSystemEffects3 interface so it will receive APOInitSystemEffects3 // in pbyData if the audio driver has declared support for this. + // Windows should pass a valid collection. + ATLASSERT(papoSysFxInit3->pDeviceCollection != nullptr); + IF_TRUE_ACTION_JUMP(papoSysFxInit3->pDeviceCollection == nullptr, hr = E_INVALIDARG, Exit); + // Use IMMDevice to activate IAudioSystemEffectsPropertyStore that contains the default, user and // volatile settings. IMMDeviceCollection* deviceCollection = reinterpret_cast<APOInitSystemEffects3*>(pbyData)->pDeviceCollection; - if (deviceCollection != nullptr) - { - UINT32 numDevices; - wil::com_ptr_nothrow<IMMDevice> endpoint; + UINT32 numDevices; + // Get the endpoint on which this APO has been created + // (It is the last device in the device collection) + hr = deviceCollection->GetCount(&numDevices); + IF_FAILED_JUMP(hr, Exit); - // Get the endpoint on which this APO has been created - // (It is the last device in the device collection) - if (SUCCEEDED(deviceCollection->GetCount(&numDevices)) && numDevices > 0 && - SUCCEEDED(deviceCollection->Item(numDevices - 1, &endpoint))) - { - wil::unique_prop_variant activationParam; - hr = InitPropVariantFromCLSID(SWAP_APO_SFX_CONTEXT, &activationParam); - IF_FAILED_JUMP(hr, Exit); + hr = numDevices > 0 ? S_OK : E_UNEXPECTED; + IF_FAILED_JUMP(hr, Exit); - wil::com_ptr_nothrow<IAudioSystemEffectsPropertyStore> effectsPropertyStore; - hr = endpoint->Activate(__uuidof(effectsPropertyStore), CLSCTX_ALL, &activationParam, effectsPropertyStore.put_void()); - IF_FAILED_JUMP(hr, Exit); + hr = deviceCollection->Item(numDevices - 1, &m_audioEndpoint); + IF_FAILED_JUMP(hr, Exit); - // This is where an APO might want to open the volatile or default property stores as well - // Use STGM_READWRITE if IPropertyStore::SetValue is needed. - hr = effectsPropertyStore->OpenUserPropertyStore(STGM_READ, m_userStore.put()); - IF_FAILED_JUMP(hr, Exit); - } - } + wil::unique_prop_variant activationParam; + hr = InitPropVariantFromCLSID(SWAP_APO_SFX_CONTEXT, &activationParam); + IF_FAILED_JUMP(hr, Exit); - // Windows should pass a valid collection. - ATLASSERT(papoSysFxInit2->pDeviceCollection != nullptr); - IF_TRUE_ACTION_JUMP(papoSysFxInit3->pDeviceCollection == nullptr, hr = E_INVALIDARG, Exit); + wil::com_ptr_nothrow<IAudioSystemEffectsPropertyStore> effectsPropertyStore; + hr = m_audioEndpoint->Activate(__uuidof(effectsPropertyStore), CLSCTX_ALL, &activationParam, effectsPropertyStore.put_void()); + IF_FAILED_JUMP(hr, Exit); + + // This is where an APO might want to open the volatile or default property stores as well + // Use STGM_READWRITE if IPropertyStore::SetValue is needed. + hr = effectsPropertyStore->OpenUserPropertyStore(STGM_READ, m_userStore.put()); + IF_FAILED_JUMP(hr, Exit); // Get the IDeviceTopology and IConnector interfaces to communicate with this // APO's counterpart audio driver. This can be used for any proprietary // communication. - hr = papoSysFxInit3->pDeviceCollection->Item(papoSysFxInit3->nSoftwareIoDeviceInCollection, &m_device); + hr = papoSysFxInit3->pDeviceCollection->Item(papoSysFxInit3->nSoftwareIoDeviceInCollection, &m_deviceTopologyMMDevice); IF_FAILED_JUMP(hr, Exit); - hr = m_device->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, (void**)&spMyDeviceTopology); + hr = m_deviceTopologyMMDevice->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, (void**)&spMyDeviceTopology); IF_FAILED_JUMP(hr, Exit); hr = spMyDeviceTopology->GetConnector(papoSysFxInit3->nSoftwareIoConnectorIndex, &spMyConnector); @@ -365,10 +365,10 @@ HRESULT CSwapAPOSFX::Initialize(UINT32 cbDataSize, BYTE* pbyData) // Get the IDeviceTopology and IConnector interfaces to communicate with this // APO's counterpart audio driver. This can be used for any proprietary // communication. - hr = papoSysFxInit2->pDeviceCollection->Item(papoSysFxInit2->nSoftwareIoDeviceInCollection, &m_device); + hr = papoSysFxInit2->pDeviceCollection->Item(papoSysFxInit2->nSoftwareIoDeviceInCollection, &m_deviceTopologyMMDevice); IF_FAILED_JUMP(hr, Exit); - hr = m_device->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, (void**)&spMyDeviceTopology); + hr = m_deviceTopologyMMDevice->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, (void**)&spMyDeviceTopology); IF_FAILED_JUMP(hr, Exit); hr = spMyDeviceTopology->GetConnector(papoSysFxInit2->nSoftwareIoConnectorIndex, &spMyConnector); @@ -407,7 +407,8 @@ HRESULT CSwapAPOSFX::Initialize(UINT32 cbDataSize, BYTE* pbyData) processingMode != AUDIO_SIGNALPROCESSINGMODE_COMMUNICATIONS && processingMode != AUDIO_SIGNALPROCESSINGMODE_SPEECH && processingMode != AUDIO_SIGNALPROCESSINGMODE_MEDIA && - processingMode != AUDIO_SIGNALPROCESSINGMODE_MOVIE), hr = E_INVALIDARG, Exit); + processingMode != AUDIO_SIGNALPROCESSINGMODE_MOVIE && + processingMode != AUDIO_SIGNALPROCESSINGMODE_NOTIFICATION), hr = E_INVALIDARG, Exit); m_AudioProcessingMode = processingMode; // @@ -640,7 +641,7 @@ HRESULT CSwapAPOSFX::SetAudioSystemEffectState(GUID effectId, AUDIO_SYSTEMEFFECT if (oldState != effectInfo.state) { SetEvent(m_hEffectsChangedEvent); - m_apoLoggingService->ApoLog(APO_LOG_LEVEL_INFO, L"SetAudioSystemEffectState - effect: " GUID_FORMAT_STRING L", state: %i", effectInfo.id, effectInfo.state); + m_apoLoggingService->ApoLog(APO_LOG_LEVEL_INFO, L"CSwapAPOSFX::SetAudioSystemEffectState - effect: " GUID_FORMAT_STRING L", state: %i", effectInfo.id, effectInfo.state); } m_EffectsLock.Leave(); @@ -733,8 +734,6 @@ HRESULT CSwapAPOSFX::GetApoNotificationRegistrationInfo(_Out_writes_(*count) APO *apoNotifications = nullptr; *count = 0; - RETURN_HR_IF_NULL(E_FAIL, m_device); - // Let the OS know what notifications we are interested in by returning an array of // APO_NOTIFICATION_DESCRIPTORs. constexpr DWORD numDescriptors = 1; @@ -746,7 +745,7 @@ HRESULT CSwapAPOSFX::GetApoNotificationRegistrationInfo(_Out_writes_(*count) APO // Our APO wants to get notified when a endpoint property changes on the audio endpoint. apoNotificationDescriptors[0].type = APO_NOTIFICATION_TYPE_ENDPOINT_PROPERTY_CHANGE; - (void)m_device.query_to(&apoNotificationDescriptors[0].audioEndpointPropertyChange.device); + (void)m_audioEndpoint.query_to(&apoNotificationDescriptors[0].audioEndpointPropertyChange.device); *apoNotifications = apoNotificationDescriptors.release(); *count = numDescriptors; @@ -772,7 +771,7 @@ void CSwapAPOSFX::HandleNotification(APO_NOTIFICATION *apoNotification) {PKEY_Endpoint_Enable_Channel_Swap_SFX, &m_fEnableSwapSFX}, }; - m_apoLoggingService->ApoLog(APO_LOG_LEVEL_INFO, L"HandleNotification - pkey: " GUID_FORMAT_STRING L" %d", GUID_FORMAT_ARGS(apoNotification->audioEndpointPropertyChange.propertyKey.fmtid), apoNotification->audioEndpointPropertyChange.propertyKey.pid); + m_apoLoggingService->ApoLog(APO_LOG_LEVEL_INFO, L"CSwapAPOSFX::HandleNotification - pkey: " GUID_FORMAT_STRING L" %d", GUID_FORMAT_ARGS(apoNotification->audioEndpointPropertyChange.propertyKey.fmtid), apoNotification->audioEndpointPropertyChange.propertyKey.pid); for (int i = 0; i < ARRAYSIZE(controls); i++) { diff --git a/audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj b/audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj index 5b819cf3..4c59e3c1 100644 --- a/audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj +++ b/audio/sysvad/EndpointsCommon/EndpointsCommon.vcxproj @@ -38,7 +38,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -46,7 +46,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -54,7 +54,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -62,7 +62,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -70,7 +70,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -78,7 +78,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>StaticLibrary</ConfigurationType> diff --git a/audio/sysvad/EndpointsCommon/mintopo.cpp b/audio/sysvad/EndpointsCommon/mintopo.cpp index c1e4bc14..9fb2cc21 100644 --- a/audio/sysvad/EndpointsCommon/mintopo.cpp +++ b/audio/sysvad/EndpointsCommon/mintopo.cpp @@ -581,6 +581,100 @@ Return Value: //============================================================================= #pragma code_seg("PAGE") NTSTATUS +CMiniportTopology::PropertyHandlerJackDescription3 +( + _In_ PPCPROPERTY_REQUEST PropertyRequest, + _In_ ULONG cJackDescriptions, + _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION * JackDescriptions, + _In_ ULONG ConfigId +) +/*++ + +Routine Description: + + Handles ( KSPROPSETID_Jack, KSPROPERTY_JACK_DESCRIPTION3 ) + +Arguments: + + PropertyRequest - + cJackDescriptions - # of elements in the jack descriptions array. + JackDescriptions - Array of jack descriptions pointers. + ConfigId - Current endpoint config id + +Return Value: + + NT status code. + +--*/ +{ + PAGED_CODE(); + + ASSERT(PropertyRequest); + + DPF_ENTER(("[PropertyHandlerJackDescription3]")); + + NTSTATUS ntStatus = STATUS_INVALID_DEVICE_REQUEST; + ULONG nPinId = (ULONG)-1; + + if (PropertyRequest->InstanceSize >= sizeof(ULONG)) + { + nPinId = *(PULONG(PropertyRequest->Instance)); + + if ((nPinId < cJackDescriptions) && (JackDescriptions[nPinId] != NULL)) + { + if (PropertyRequest->Verb & KSPROPERTY_TYPE_BASICSUPPORT) + { + ntStatus = + PropertyHandler_BasicSupport + ( + PropertyRequest, + KSPROPERTY_TYPE_BASICSUPPORT | KSPROPERTY_TYPE_GET, + VT_ILLEGAL + ); + } + else + { + ULONG cbNeeded = sizeof(KSMULTIPLE_ITEM) + sizeof(KSJACK_DESCRIPTION3); + + if (PropertyRequest->ValueSize == 0) + { + PropertyRequest->ValueSize = cbNeeded; + ntStatus = STATUS_BUFFER_OVERFLOW; + } + else if (PropertyRequest->ValueSize < cbNeeded) + { + ntStatus = STATUS_BUFFER_TOO_SMALL; + } + else + { + if (PropertyRequest->Verb & KSPROPERTY_TYPE_GET) + { + PKSMULTIPLE_ITEM pMI = (PKSMULTIPLE_ITEM)PropertyRequest->Value; + PKSJACK_DESCRIPTION3 pDesc = (PKSJACK_DESCRIPTION3)(pMI+1); + + pMI->Size = cbNeeded; + pMI->Count = 1; + + RtlZeroMemory(pDesc, sizeof(KSJACK_DESCRIPTION3)); + + // + // hardware config id + // + pDesc->ConfigId = ConfigId; + + ntStatus = STATUS_SUCCESS; + } + } + } + } + } + + return ntStatus; +} + +//============================================================================= +#pragma code_seg("PAGE") +NTSTATUS CMiniportTopology::PropertyHandlerAudioResourceGroup ( _In_ PPCPROPERTY_REQUEST PropertyRequest diff --git a/audio/sysvad/EndpointsCommon/mintopo.h b/audio/sysvad/EndpointsCommon/mintopo.h index 596e13b1..f0bae44d 100644 --- a/audio/sysvad/EndpointsCommon/mintopo.h +++ b/audio/sysvad/EndpointsCommon/mintopo.h @@ -100,6 +100,14 @@ public: _In_ DWORD JackCapabilities ); + NTSTATUS PropertyHandlerJackDescription3 + ( + _In_ PPCPROPERTY_REQUEST PropertyRequest, + _In_ ULONG cJackDescriptions, + _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION *JackDescriptions, + _In_ ULONG ConfigId + ); + NTSTATUS PropertyHandlerAudioResourceGroup ( _In_ PPCPROPERTY_REQUEST PropertyRequest diff --git a/audio/sysvad/EndpointsCommon/minwavert.cpp b/audio/sysvad/EndpointsCommon/minwavert.cpp index bd81c110..c6b8e8c3 100644 --- a/audio/sysvad/EndpointsCommon/minwavert.cpp +++ b/audio/sysvad/EndpointsCommon/minwavert.cpp @@ -3452,7 +3452,8 @@ NTSTATUS CKeywordDetector::ReadKeywordTimestampRegistry() PAGED_CODE(); NTSTATUS ntStatus; - UNICODE_STRING parametersPath; + PDRIVER_OBJECT DriverObject; + HANDLE DriverKey; RTL_QUERY_REGISTRY_TABLE paramTable[] = { // QueryRoutine Flags Name EntryContext DefaultType DefaultData DefaultLength @@ -3461,30 +3462,37 @@ NTSTATUS CKeywordDetector::ReadKeywordTimestampRegistry() { NULL, 0, NULL, NULL, 0, NULL, 0 } }; - RtlInitUnicodeString(¶metersPath, NULL); + DriverObject = WdfDriverWdmGetDriverObject(WdfGetDriver()); + DriverKey = NULL; + ntStatus = IoOpenDriverRegistryKey(DriverObject, + DriverRegKeyParameters, + KEY_READ, + 0, + &DriverKey); - // The sizeof(WCHAR) is added to the maximum length, for allowing a space for null termination of the string. - parametersPath.MaximumLength = - g_RegistryPath.Length + sizeof(L"\\Parameters") + sizeof(WCHAR); - - parametersPath.Buffer = (PWCH)ExAllocatePool2(POOL_FLAG_PAGED, parametersPath.MaximumLength, MINWAVERT_POOLTAG); - if (parametersPath.Buffer == NULL) + if (!NT_SUCCESS(ntStatus)) { - return STATUS_INSUFFICIENT_RESOURCES; + return ntStatus; } - RtlAppendUnicodeToString(¶metersPath, g_RegistryPath.Buffer); - RtlAppendUnicodeToString(¶metersPath, L"\\Parameters"); + ntStatus = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE, + (PCWSTR) DriverKey, + ¶mTable[0], + NULL, + NULL); - ntStatus = RtlQueryRegistryValues( - RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, - parametersPath.Buffer, - ¶mTable[0], - NULL, - NULL - ); + if (!NT_SUCCESS(ntStatus)) + { + DPF(D_VERBOSE, ("RtlQueryRegistryValues failed, using default values, 0x%x", ntStatus)); + // + // Don't return error because we will operate with default values. + // + } - ExFreePool(parametersPath.Buffer); + if (DriverKey) + { + ZwClose(DriverKey); + } return ntStatus; } diff --git a/audio/sysvad/EndpointsCommon/minwavertstream.cpp b/audio/sysvad/EndpointsCommon/minwavertstream.cpp index 08467e05..adea0c82 100644 --- a/audio/sysvad/EndpointsCommon/minwavertstream.cpp +++ b/audio/sysvad/EndpointsCommon/minwavertstream.cpp @@ -121,7 +121,8 @@ NTSTATUS CMiniportWaveRTStream::ReadRegistrySettings() PAGED_CODE(); NTSTATUS ntStatus; - UNICODE_STRING parametersPath; + PDRIVER_OBJECT DriverObject; + HANDLE DriverKey; RTL_QUERY_REGISTRY_TABLE paramTable[] = { // QueryRoutine Flags Name EntryContext DefaultType DefaultData DefaultLength @@ -136,30 +137,37 @@ NTSTATUS CMiniportWaveRTStream::ReadRegistrySettings() { NULL, 0, NULL, NULL, 0, NULL, 0 } }; - RtlInitUnicodeString(¶metersPath, NULL); + DriverObject = WdfDriverWdmGetDriverObject(WdfGetDriver()); + DriverKey = NULL; + ntStatus = IoOpenDriverRegistryKey(DriverObject, + DriverRegKeyParameters, + KEY_READ, + 0, + &DriverKey); - // The sizeof(WCHAR) is added to the maximum length, for allowing a space for null termination of the string. - parametersPath.MaximumLength = - g_RegistryPath.Length + sizeof(L"\\Parameters") + sizeof(WCHAR); - - parametersPath.Buffer = (PWCH)ExAllocatePool2(POOL_FLAG_PAGED, parametersPath.MaximumLength, MINWAVERT_POOLTAG); - if (parametersPath.Buffer == NULL) + if (!NT_SUCCESS(ntStatus)) { - return STATUS_INSUFFICIENT_RESOURCES; + return ntStatus; } - RtlAppendUnicodeToString(¶metersPath, g_RegistryPath.Buffer); - RtlAppendUnicodeToString(¶metersPath, L"\\Parameters"); + ntStatus = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE, + (PCWSTR) DriverKey, + ¶mTable[0], + NULL, + NULL); - ntStatus = RtlQueryRegistryValues( - RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, - parametersPath.Buffer, - ¶mTable[0], - NULL, - NULL - ); + if (!NT_SUCCESS(ntStatus)) + { + DPF(D_VERBOSE, ("RtlQueryRegistryValues failed, using default values, 0x%x", ntStatus)); + // + // Don't return error because we will operate with default values. + // + } - ExFreePool(parametersPath.Buffer); + if (DriverKey) + { + ZwClose(DriverKey); + } return ntStatus; } diff --git a/audio/sysvad/EndpointsCommon/speakertopo.cpp b/audio/sysvad/EndpointsCommon/speakertopo.cpp index fba72036..002b1174 100644 --- a/audio/sysvad/EndpointsCommon/speakertopo.cpp +++ b/audio/sysvad/EndpointsCommon/speakertopo.cpp @@ -75,6 +75,15 @@ Return Value: 0 // jack capabilities ); } + else if (PropertyRequest->PropertyItem->Id == KSPROPERTY_JACK_DESCRIPTION3) + { + ntStatus = pMiniport->PropertyHandlerJackDescription3( + PropertyRequest, + ARRAYSIZE(SpeakerJackDescriptions), + SpeakerJackDescriptions, + 42 // jack config id + ); + } } else if (IsEqualGUIDAligned(*PropertyRequest->PropertyItem->Set, KSPROPSETID_AudioResourceManagement)) { diff --git a/audio/sysvad/EndpointsCommon/speakertoptable.h b/audio/sysvad/EndpointsCommon/speakertoptable.h index 3d31d7a4..ea3890f7 100644 --- a/audio/sysvad/EndpointsCommon/speakertoptable.h +++ b/audio/sysvad/EndpointsCommon/speakertoptable.h @@ -142,6 +142,13 @@ PCPROPERTY_ITEM PropertiesSpeakerTopoFilter[] = PropertyHandler_SpeakerTopoFilter }, { + &KSPROPSETID_Jack, + KSPROPERTY_JACK_DESCRIPTION3, + KSPROPERTY_TYPE_GET | + KSPROPERTY_TYPE_BASICSUPPORT, + PropertyHandler_SpeakerTopoFilter + }, + { &KSPROPSETID_AudioResourceManagement, KSPROPERTY_AUDIORESOURCEMANAGEMENT_RESOURCEGROUP, KSPROPERTY_TYPE_SET, diff --git a/audio/sysvad/KeywordDetectorAdapter/KeywordDetectorContosoAdapter.vcxproj b/audio/sysvad/KeywordDetectorAdapter/KeywordDetectorContosoAdapter.vcxproj index d1675201..7151399e 100644 --- a/audio/sysvad/KeywordDetectorAdapter/KeywordDetectorContosoAdapter.vcxproj +++ b/audio/sysvad/KeywordDetectorAdapter/KeywordDetectorContosoAdapter.vcxproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?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|ARM64"> @@ -39,7 +39,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -47,7 +47,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -55,7 +55,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -63,7 +63,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -71,7 +71,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -79,7 +79,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> diff --git a/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx b/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx Binary files differindex 28069e1c..34b8401a 100644 --- a/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx +++ b/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx diff --git a/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inx b/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inx Binary files differindex 70cd79b8..4afba224 100644 --- a/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inx +++ b/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inx diff --git a/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj b/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj index 6e4e4c44..fe70dacf 100644 --- a/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj +++ b/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj @@ -40,7 +40,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -48,7 +48,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -56,7 +56,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -64,7 +64,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -72,7 +72,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -80,7 +80,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Windows Driver</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> diff --git a/audio/sysvad/TabletAudioSample/tabletaudiosample.inx b/audio/sysvad/TabletAudioSample/tabletaudiosample.inx Binary files differdeleted file mode 100644 index 29c74cfb..00000000 --- a/audio/sysvad/TabletAudioSample/tabletaudiosample.inx +++ /dev/null diff --git a/audio/sysvad/adapter.cpp b/audio/sysvad/adapter.cpp index ef48e5f4..0f44c593 100644 --- a/audio/sysvad/adapter.cpp +++ b/audio/sysvad/adapter.cpp @@ -246,10 +246,10 @@ _Dispatch_type_(IRP_MJ_PNP) DRIVER_DISPATCH PnpHandler; // -// Rendering streams are saved to a file by default. Use the registry value -// DoNotCreateDataFiles (DWORD) > 0 to override this default. +// Rendering streams are not saved to a file by default. Use the registry value +// DoNotCreateDataFiles (DWORD) = 0 to override this default. // -DWORD g_DoNotCreateDataFiles = 0; // default is off. +DWORD g_DoNotCreateDataFiles = 1; // default is off. DWORD g_DisableToneGenerator = 0; // default is to generate tones. UNICODE_STRING g_RegistryPath; // This is used to store the registry settings path for the driver @@ -425,7 +425,8 @@ Returns: { NTSTATUS ntStatus; - UNICODE_STRING parametersPath; + PDRIVER_OBJECT DriverObject; + HANDLE DriverKey; RTL_QUERY_REGISTRY_TABLE paramTable[] = { // QueryRoutine Flags Name EntryContext DefaultType DefaultData DefaultLength { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_TYPECHECK, L"DoNotCreateDataFiles", &g_DoNotCreateDataFiles, (REG_DWORD << RTL_QUERY_REGISTRY_TYPECHECK_SHIFT) | REG_DWORD, &g_DoNotCreateDataFiles, sizeof(ULONG)}, @@ -441,29 +442,27 @@ Returns: DPF(D_TERSE, ("[GetRegistrySettings]")); - PAGED_CODE(); - - RtlInitUnicodeString(¶metersPath, NULL); + PAGED_CODE(); + UNREFERENCED_PARAMETER(RegistryPath); - parametersPath.MaximumLength = - RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(WCHAR); + DriverObject = WdfDriverWdmGetDriverObject(WdfGetDriver()); + DriverKey = NULL; + ntStatus = IoOpenDriverRegistryKey(DriverObject, + DriverRegKeyParameters, + KEY_READ, + 0, + &DriverKey); - parametersPath.Buffer = (PWCH) ExAllocatePool2(POOL_FLAG_PAGED, parametersPath.MaximumLength, MINADAPTER_POOLTAG); - if (parametersPath.Buffer == NULL) + if (!NT_SUCCESS(ntStatus)) { - return STATUS_INSUFFICIENT_RESOURCES; + return ntStatus; } - RtlAppendUnicodeToString(¶metersPath, RegistryPath->Buffer); - RtlAppendUnicodeToString(¶metersPath, L"\\Parameters"); - - ntStatus = RtlQueryRegistryValues( - RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, - parametersPath.Buffer, - ¶mTable[0], - NULL, - NULL - ); + ntStatus = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE, + (PCWSTR) DriverKey, + ¶mTable[0], + NULL, + NULL); if (!NT_SUCCESS(ntStatus)) { @@ -485,10 +484,10 @@ Returns: DPF(D_VERBOSE, ("DisableUsbSideband: %u", g_DisableUsbSideband)); #endif // SYSVAD_USB_SIDEBAND - // - // Cleanup. - // - ExFreePool(parametersPath.Buffer); + if (DriverKey) + { + ZwClose(DriverKey); + } return STATUS_SUCCESS; } @@ -537,15 +536,6 @@ Return Value: ntStatus, DPF(D_ERROR, ("Registry path copy error 0x%x", ntStatus)), Done); - - // - // Get registry configuration. - // - ntStatus = GetRegistrySettings(RegistryPathName); - IF_FAILED_ACTION_JUMP( - ntStatus, - DPF(D_ERROR, ("Registry Configuration error 0x%x", ntStatus)), - Done); WDF_DRIVER_CONFIG_INIT(&config, WDF_NO_EVENT_CALLBACK); // @@ -569,6 +559,15 @@ Return Value: Done); // + // Get registry configuration. + // + ntStatus = GetRegistrySettings(RegistryPathName); + IF_FAILED_ACTION_JUMP( + ntStatus, + DPF(D_ERROR, ("Registry Configuration error 0x%x", ntStatus)), + Done); + + // // Tell the class driver to initialize the driver. // ntStatus = PcInitializeAdapterDriver(DriverObject, diff --git a/audio/sysvad/common.cpp b/audio/sysvad/common.cpp index 9bc3e644..1334411e 100644 --- a/audio/sysvad/common.cpp +++ b/audio/sysvad/common.cpp @@ -50,7 +50,6 @@ Abstract: // CSaveData statics //----------------------------------------------------------------------------- -PSAVEWORKER_PARAM CSaveData::m_pWorkItems = NULL; PDEVICE_OBJECT CSaveData::m_pDeviceObject = NULL; //============================================================================= // Classes @@ -642,8 +641,6 @@ Return Value: delete m_pHW; m_pHW = NULL; } - - CSaveData::DestroyWorkItems(); SAFE_RELEASE(m_pPortClsEtwHelper); SAFE_RELEASE(m_pServiceGroupWave); @@ -841,8 +838,6 @@ Return Value: // Initialize SaveData class. // CSaveData::SetDeviceObject(DeviceObject); //device object is needed by CSaveData - ntStatus = CSaveData::InitializeWorkItems(DeviceObject); - IF_FAILED_JUMP(ntStatus, Done); Done: return ntStatus; diff --git a/audio/sysvad/savedata.cpp b/audio/sysvad/savedata.cpp index cb5f5cfc..39789f3b 100644 --- a/audio/sysvad/savedata.cpp +++ b/audio/sysvad/savedata.cpp @@ -47,12 +47,13 @@ Abstract: #define DEFAULT_FRAME_SIZE PAGE_SIZE * 4 #define DEFAULT_BUFFER_SIZE DEFAULT_FRAME_SIZE * DEFAULT_FRAME_COUNT -#define DEFAULT_FILE_NAME L"\\DosDevices\\C:\\STREAM" -#define OSDATA_FILE_NAME L"\\DosDevices\\O:\\STREAM" +#define DEFAULT_FILE_FOLDER1 L"\\DriverData\\Audio_Samples" +#define DEFAULT_FILE_FOLDER2 L"\\DriverData\\Audio_Samples\\Sysvad" +#define DEFAULT_FILE_NAME L"\\DriverData\\Audio_Samples\\Sysvad\\STREAM" #define OFFLOAD_FILE_NAME L"OFFLOAD" #define HOST_FILE_NAME L"HOST" -#define MAX_WORKER_ITEM_COUNT 15 +#define MAX_WORKER_ITEM_COUNT 8 //============================================================================= // Statics @@ -91,6 +92,7 @@ CSaveData::CSaveData() m_DataHeader.dwData = DATA_TAG; m_DataHeader.dwDataLength = 0; + RtlZeroMemory(&m_FileName, sizeof(m_FileName)); RtlZeroMemory(&m_objectAttributes, sizeof(m_objectAttributes)); } // CSaveData @@ -101,6 +103,12 @@ CSaveData::~CSaveData() DPF_ENTER(("[CSaveData::~CSaveData]")); + // + // All write activity is done at this point (see acquire->stop stream transition). + // Safe to call even if the Initialize function failed. + // + DestroyWorkItems(); + // Update the wave header in data file with real file size. // if(m_pFilePtr) @@ -415,6 +423,7 @@ CSaveData::GetNewWorkItem { LARGE_INTEGER timeOut = { 0 }; NTSTATUS ntStatus; + PSAVEWORKER_PARAM saveWorker = NULL; for (int i = 0; i < MAX_WORKER_ITEM_COUNT; i++) { @@ -430,13 +439,16 @@ CSaveData::GetNewWorkItem if (STATUS_SUCCESS == ntStatus) { if (m_pWorkItems[i].WorkItem) - return &(m_pWorkItems[i]); - else - return NULL; + { + saveWorker = &(m_pWorkItems[i]); + KeResetEvent(&saveWorker->EventDone); + break; + } } } - return NULL; + + return saveWorker; } // GetNewWorkItem #pragma code_seg("PAGE") @@ -449,13 +461,13 @@ CSaveData::Initialize { PAGED_CODE(); - NTSTATUS ntStatus = STATUS_SUCCESS; - WCHAR szTemp[MAX_PATH]; - size_t cLen; - OBJECT_ATTRIBUTES objectAttributes; - UNICODE_STRING osDataVolumeString; - HANDLE osDataFileHandle = NULL; - IO_STATUS_BLOCK ioStatusBlock; + NTSTATUS ntStatus = STATUS_SUCCESS; + WCHAR szTemp[MAX_PATH]; + size_t cLen = 0; + IO_STATUS_BLOCK ioStatusBlock = {0}; + HANDLE fileHandle; + OBJECT_ATTRIBUTES objectAttributes; + UNICODE_STRING fileName; DPF_ENTER(("[CSaveData::Initialize]")); @@ -468,47 +480,74 @@ CSaveData::Initialize m_ulStreamId++; } - // Probe if OSData volume exists. - // - RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_probe.txt", OSDATA_FILE_NAME); - RtlInitUnicodeString(&osDataVolumeString, szTemp); - InitializeObjectAttributes - ( - &objectAttributes, - &osDataVolumeString, - OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, - NULL, - NULL - ); + RtlInitUnicodeString(&fileName, DEFAULT_FILE_FOLDER1); + InitializeObjectAttributes( + &objectAttributes, + &fileName, + OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, + NULL, + NULL); - ntStatus = - ZwCreateFile - ( - &osDataFileHandle, - GENERIC_WRITE | SYNCHRONIZE, + // Create the folder. + ntStatus = ZwCreateFile( + &fileHandle, + 0, &objectAttributes, &ioStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0, - FILE_OVERWRITE_IF, - FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, + FILE_OPEN_IF, + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, - 0 - ); + 0); + + if (NT_SUCCESS(ntStatus)) + { + ZwClose(fileHandle); + fileHandle = NULL; + + RtlInitUnicodeString(&fileName, DEFAULT_FILE_FOLDER2); + InitializeObjectAttributes( + &objectAttributes, + &fileName, + OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + // Create the folder. + ntStatus = ZwCreateFile( + &fileHandle, + 0, + &objectAttributes, + &ioStatusBlock, + NULL, + FILE_ATTRIBUTE_NORMAL, + 0, + FILE_OPEN_IF, + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, + NULL, + 0); + + if (NT_SUCCESS(ntStatus)) + { + ZwClose(fileHandle); + fileHandle = NULL; + } + } + if (NT_SUCCESS(ntStatus)) { - ZwClose(osDataFileHandle); + // Allocate data file name. + // + RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_%s_%d.wav", DEFAULT_FILE_NAME, _bOffloaded ? OFFLOAD_FILE_NAME : HOST_FILE_NAME, _bOffloaded ? m_ulOffloadStreamId : m_ulStreamId); + m_FileName.Length = 0; + ntStatus = RtlStringCchLengthW (szTemp, sizeof(szTemp)/sizeof(szTemp[0]), &cLen); } - // Allocate data file name. - // - RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_%s_%d.wav", NT_SUCCESS(ntStatus) ? OSDATA_FILE_NAME : DEFAULT_FILE_NAME, _bOffloaded ? OFFLOAD_FILE_NAME : HOST_FILE_NAME, _bOffloaded ? m_ulOffloadStreamId : m_ulStreamId); - m_FileName.Length = 0; - ntStatus = RtlStringCchLengthW (szTemp, sizeof(szTemp)/sizeof(szTemp[0]), &cLen); if (NT_SUCCESS(ntStatus)) { - m_FileName.MaximumLength = (USHORT)((cLen * sizeof(WCHAR)) + sizeof(WCHAR));//convert to wchar and add room for NULL + m_FileName.MaximumLength = (USHORT)((cLen * sizeof(WCHAR)) + sizeof(WCHAR));//convert to wchar and add room for NULL m_FileName.Buffer = (PWSTR) ExAllocatePool2 ( @@ -572,6 +611,13 @@ CSaveData::Initialize // KeInitializeMutex( &m_FileSync, 1 ) ; + // Allocate work-items. + // + if (NT_SUCCESS(ntStatus)) + { + ntStatus = InitializeWorkItems(m_pDeviceObject); + } + // Open the data file. // if (NT_SUCCESS(ntStatus)) @@ -586,7 +632,7 @@ CSaveData::Initialize ( &m_objectAttributes, &m_FileName, - OBJ_CASE_INSENSITIVE|OBJ_KERNEL_HANDLE, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL ); @@ -896,7 +942,6 @@ CSaveData::SaveFrame pParam->ulFrameNo = ulFrameNo; pParam->ulDataSize = ulDataSize; pParam->pData = m_pDataBuffer + ulFrameNo * m_ulFrameSize; - KeResetEvent(&pParam->EventDone); IoQueueWorkItem(pParam->WorkItem, SaveFrameWorkerCallback, CriticalWorkQueue, (PVOID)pParam); } diff --git a/audio/sysvad/savedata.h b/audio/sysvad/savedata.h index a1525bda..94221025 100644 --- a/audio/sysvad/savedata.h +++ b/audio/sysvad/savedata.h @@ -98,7 +98,7 @@ protected: static PDEVICE_OBJECT m_pDeviceObject; static ULONG m_ulStreamId; static ULONG m_ulOffloadStreamId; - static PSAVEWORKER_PARAM m_pWorkItems; + PSAVEWORKER_PARAM m_pWorkItems; BOOL m_fWriteDisabled; @@ -108,11 +108,11 @@ public: CSaveData(); ~CSaveData(); - static NTSTATUS InitializeWorkItems + NTSTATUS InitializeWorkItems ( _In_ PDEVICE_OBJECT DeviceObject ); - static void DestroyWorkItems + void DestroyWorkItems ( void ); @@ -120,7 +120,7 @@ public: ( _In_ BOOL fDisable ); - static PSAVEWORKER_PARAM GetNewWorkItem + PSAVEWORKER_PARAM GetNewWorkItem ( void ); |
