diff options
| author | Adonais Romero González <[email protected]> | 2019-02-12 16:25:07 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-02-12 16:25:07 -0800 |
| commit | 638243cd4283cbe4cc2c3cad460c361ceb01cad8 (patch) | |
| tree | f480cd1d2505b74beb41d2fb992bf7bc56c6b7b0 | |
| parent | 39d39e7485faddf601d51c897863ff2f876e391e (diff) | |
| parent | 2d1a3f431eb203f3ae7225a48cfbb7c584acb016 (diff) | |
Merge pull request #345 from saredd/master
Updating Samples to RS5 versions. Setting DriverTargetPlatform to Universal to enable API Validator
| -rw-r--r-- | avstream/avscamera/Package/package.VcxProj | 4 | ||||
| -rw-r--r-- | avstream/avscamera/mft0/AvsCameraMft0.vcxproj | 8 | ||||
| -rw-r--r-- | avstream/avscamera/mft0/AvsCameraMft0.vcxproj.Filters | 42 | ||||
| -rw-r--r-- | avstream/avscamera/sys/CameraProfile.h | 2 | ||||
| -rw-r--r-- | avstream/avscamera/sys/Capture.cpp | 23 | ||||
| -rw-r--r-- | avstream/avscamera/sys/Capture.h | 6 | ||||
| -rw-r--r-- | avstream/avscamera/sys/Common.h | 5 | ||||
| -rw-r--r-- | avstream/avscamera/sys/Device.cpp | 95 | ||||
| -rw-r--r-- | avstream/avscamera/sys/Device.h | 18 | ||||
| -rw-r--r-- | avstream/avscamera/sys/Sensor.h | 1 | ||||
| -rw-r--r-- | avstream/avscamera/sys/SensorSimulation.cpp | 53 | ||||
| -rw-r--r-- | avstream/avscamera/sys/SensorSimulation.h | 8 | ||||
| -rw-r--r-- | avstream/avscamera/sys/formats.cpp | 28 | ||||
| -rw-r--r-- | avstream/avscamera/sys/hwsim.cpp | 51 | ||||
| -rw-r--r-- | avstream/avscamera/sys/hwsim.h | 12 |
15 files changed, 266 insertions, 90 deletions
diff --git a/avstream/avscamera/Package/package.VcxProj b/avstream/avscamera/Package/package.VcxProj index 92690b1a..5b8aa6ef 100644 --- a/avstream/avscamera/Package/package.VcxProj +++ b/avstream/avscamera/Package/package.VcxProj @@ -42,18 +42,22 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>true</UseDebugLibraries> + <DriverTargetPlatform>Universal</DriverTargetPlatform> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>false</UseDebugLibraries> + <DriverTargetPlatform>Universal</DriverTargetPlatform> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>true</UseDebugLibraries> + <DriverTargetPlatform>Universal</DriverTargetPlatform> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>false</UseDebugLibraries> + <DriverTargetPlatform>Universal</DriverTargetPlatform> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/avstream/avscamera/mft0/AvsCameraMft0.vcxproj b/avstream/avscamera/mft0/AvsCameraMft0.vcxproj index 3e071c71..518a324f 100644 --- a/avstream/avscamera/mft0/AvsCameraMft0.vcxproj +++ b/avstream/avscamera/mft0/AvsCameraMft0.vcxproj @@ -31,7 +31,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Desktop</DriverTargetPlatform> + <DriverTargetPlatform>Universal</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -39,7 +39,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Desktop</DriverTargetPlatform> + <DriverTargetPlatform>Universal</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -47,7 +47,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Desktop</DriverTargetPlatform> + <DriverTargetPlatform>Universal</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -55,7 +55,7 @@ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Desktop</DriverTargetPlatform> + <DriverTargetPlatform>Universal</DriverTargetPlatform> <DriverType /> <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> <ConfigurationType>DynamicLibrary</ConfigurationType> diff --git a/avstream/avscamera/mft0/AvsCameraMft0.vcxproj.Filters b/avstream/avscamera/mft0/AvsCameraMft0.vcxproj.Filters deleted file mode 100644 index ec3124e3..00000000 --- a/avstream/avscamera/mft0/AvsCameraMft0.vcxproj.Filters +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Source Files"> - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions> - <UniqueIdentifier>{5293FBF9-AB37-479B-86A2-4DE6B858B90A}</UniqueIdentifier> - </Filter> - <Filter Include="Header Files"> - <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> - <UniqueIdentifier>{BB11CFC9-BD19-4353-9E5F-42D5BA1A0CB3}</UniqueIdentifier> - </Filter> - <Filter Include="Resource Files"> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions> - <UniqueIdentifier>{49D3ED6A-39BD-49AC-96B4-4C1645E71934}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClCompile Include="Debug\\Mft0_i.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="dllmain.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="Mft0Impl.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="stdafxsrc.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <Midl Include="Mft0.idl"> - <Filter>Source Files</Filter> - </Midl> - <None Include="MFT0.def"> - <Filter>Source Files</Filter> - </None> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="AvsCameraMft0.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/avstream/avscamera/sys/CameraProfile.h b/avstream/avscamera/sys/CameraProfile.h index 1a2aca8a..fd2f1fe4 100644 --- a/avstream/avscamera/sys/CameraProfile.h +++ b/avstream/avscamera/sys/CameraProfile.h @@ -28,7 +28,7 @@ public: public: CExtendedProfile( ULONGLONG flags=0, ULONG result=STATUS_SUCCESS ) - : CExtendedProfile( flags, result ) + : CExtendedHeader( flags, result ) { Size = sizeof(*this); m_Profile.ProfileId = KSCAMERAPROFILE_Legacy; diff --git a/avstream/avscamera/sys/Capture.cpp b/avstream/avscamera/sys/Capture.cpp index 77bd618c..e5d43ddd 100644 --- a/avstream/avscamera/sys/Capture.cpp +++ b/avstream/avscamera/sys/Capture.cpp @@ -2262,14 +2262,11 @@ UpdateAllocatorFraming() m_Pin->Descriptor->AllocatorFraming ); - Framing->FramingItem[0].Frames = m_DesiredFrames; - Framing->FramingItem[0].PhysicalRange.MinFrameSize = m_VideoInfoHeader->bmiHeader.biSizeImage; - Framing->FramingItem[0].PhysicalRange.MaxFrameSize = m_VideoInfoHeader->bmiHeader.biSizeImage; - Framing->FramingItem [0].FramingRange.Range.MinFrameSize = m_VideoInfoHeader->bmiHeader.biSizeImage; - Framing->FramingItem [0].FramingRange.Range.MaxFrameSize = m_VideoInfoHeader->bmiHeader.biSizeImage; + SetFramingSizes(Framing); - Framing->FramingItem [0].PhysicalRange.Stepping = 0; - Framing->FramingItem [0].FramingRange.Range.Stepping = 0; + Framing->FramingItem[0].Frames = m_DesiredFrames; + Framing->FramingItem[0].PhysicalRange.Stepping = 0; + Framing->FramingItem[0].FramingRange.Range.Stepping = 0; DBG_TRACE( "Advertising Frame requirement: %d", m_DesiredFrames ); DBG_TRACE("Image size estimate of: %d bytes", m_VideoInfoHeader->bmiHeader.biSizeImage ); @@ -2280,3 +2277,15 @@ UpdateAllocatorFraming() return Status; } +void +CCapturePin:: +SetFramingSizes( + PKSALLOCATOR_FRAMING_EX Framing +) +{ + Framing->FramingItem[0].PhysicalRange.MinFrameSize = m_VideoInfoHeader->bmiHeader.biSizeImage; + Framing->FramingItem[0].PhysicalRange.MaxFrameSize = m_VideoInfoHeader->bmiHeader.biSizeImage; + Framing->FramingItem[0].FramingRange.Range.MinFrameSize = m_VideoInfoHeader->bmiHeader.biSizeImage; + Framing->FramingItem[0].FramingRange.Range.MaxFrameSize = m_VideoInfoHeader->bmiHeader.biSizeImage; +} + diff --git a/avstream/avscamera/sys/Capture.h b/avstream/avscamera/sys/Capture.h index 0a065d24..21c9796a 100644 --- a/avstream/avscamera/sys/Capture.h +++ b/avstream/avscamera/sys/Capture.h @@ -188,6 +188,12 @@ protected: NTSTATUS Initialize(); + virtual + void + SetFramingSizes( + PKSALLOCATOR_FRAMING_EX Framing + ); + public: // // CCapturePin(): diff --git a/avstream/avscamera/sys/Common.h b/avstream/avscamera/sys/Common.h index 5c83f2fc..fdcb1c48 100644 --- a/avstream/avscamera/sys/Common.h +++ b/avstream/avscamera/sys/Common.h @@ -27,6 +27,7 @@ #include <stdlib.h> #include <wdm.h> +#include <wdmguid.h> #include <windef.h> #include <unknown.h> #include <ks.h> @@ -190,8 +191,8 @@ void __cdecl operator delete[] // The number of ranges supported on the capture pin. // #define IMAGE_CAPTURE_PIN_DATA_RANGE_COUNT 2 -#define VIDEO_CAPTURE_PIN_DATA_RANGE_COUNT 30 -#define VIDEO_PREVIEW_PIN_DATA_RANGE_COUNT 15 +#define VIDEO_CAPTURE_PIN_DATA_RANGE_COUNT 32 +#define VIDEO_PREVIEW_PIN_DATA_RANGE_COUNT 16 // // CAPTURE_FILTER_CATEGORIES_COUNT: diff --git a/avstream/avscamera/sys/Device.cpp b/avstream/avscamera/sys/Device.cpp index 943b2f2b..99bc60ce 100644 --- a/avstream/avscamera/sys/Device.cpp +++ b/avstream/avscamera/sys/Device.cpp @@ -100,6 +100,98 @@ GetFilterIndex(PKSFILTER Filter) NTSTATUS CCaptureDevice:: +IrpSynchronousCompletion( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID pKevent + ) +{ + if (Irp->PendingReturned) + { + NT_ASSERT(pKevent); + KeSetEvent((PRKEVENT)pKevent, 0, FALSE); + } + + return STATUS_MORE_PROCESSING_REQUIRED; +} + +_Must_inspect_result_ +NTSTATUS +CCaptureDevice:: +QueryForInterface( + _In_ PDEVICE_OBJECT TopOfStack, + _In_ const GUID* InterfaceType, + _Out_ PINTERFACE Interface, + _In_ USHORT Size, + _In_ USHORT Version, + _In_opt_ PVOID InterfaceSpecificData + ) +{ + PAGED_CODE(); + + PIRP pIrp; + NTSTATUS status; + + if (TopOfStack == nullptr) + { + return STATUS_INVALID_PARAMETER; + } + + pIrp = IoAllocateIrp(TopOfStack->StackSize, FALSE); + + if (pIrp != NULL) + { + PIO_STACK_LOCATION stack; + KEVENT event; + + KeInitializeEvent(&event, NotificationEvent, FALSE); + + IoSetCompletionRoutine(pIrp, + IrpSynchronousCompletion, + &event, + TRUE, + TRUE, + TRUE); + + pIrp->IoStatus.Status = STATUS_NOT_SUPPORTED; + + stack = IoGetNextIrpStackLocation(pIrp); + + stack->MajorFunction = IRP_MJ_PNP; + stack->MinorFunction = IRP_MN_QUERY_INTERFACE; + + stack->Parameters.QueryInterface.Interface = Interface; + stack->Parameters.QueryInterface.InterfaceSpecificData = InterfaceSpecificData; + stack->Parameters.QueryInterface.Size = Size; + stack->Parameters.QueryInterface.Version = Version; + stack->Parameters.QueryInterface.InterfaceType = InterfaceType; + + status = IoCallDriver(TopOfStack, pIrp); + + if (status == STATUS_PENDING) + { + KeWaitForSingleObject( + &event, + Executive, + KernelMode, + FALSE, // Not alertable + NULL + ); + + status = pIrp->IoStatus.Status; + } + + IoFreeIrp(pIrp); + } + else { + status = STATUS_INSUFFICIENT_RESOURCES; + } + + return status; +} + +NTSTATUS +CCaptureDevice:: Prepare() { PAGED_CODE(); @@ -111,6 +203,8 @@ Prepare() return Status; } + PKSDEVICE Device = m_Device; + // // Add the item to the object bag if we were successful. // Whenever the device goes away, the bag is cleaned up and @@ -120,7 +214,6 @@ Prepare() // the device mutex before doing this. For Windows XP, this is // not required, but it is still safe. // - PKSDEVICE Device = m_Device; LockDevice Lock(Device); Status = KsAddItemToObjectBag ( diff --git a/avstream/avscamera/sys/Device.h b/avstream/avscamera/sys/Device.h index 6a3133d6..95debada 100644 --- a/avstream/avscamera/sys/Device.h +++ b/avstream/avscamera/sys/Device.h @@ -106,6 +106,7 @@ protected: // This is a seperate helper function to allow the derived DispatchCreate // implementation to be as simple as is feasible. // + virtual NTSTATUS Prepare(); @@ -392,11 +393,18 @@ public: PDEVICE_OBJECT GetDeviceObject(); - PKSDEVICE - GetKsDevice() - { - return m_Device; - } + static IO_COMPLETION_ROUTINE CCaptureDevice::IrpSynchronousCompletion; + + virtual + NTSTATUS + QueryForInterface( + _In_ PDEVICE_OBJECT TopOfStack, + _In_ const GUID* InterfaceType, + _Out_ PINTERFACE Interface, + _In_ USHORT Size, + _In_ USHORT Version, + _In_opt_ PVOID InterfaceSpecificData + ); ULONG GetFilterIndex(PKSFILTER Filter); diff --git a/avstream/avscamera/sys/Sensor.h b/avstream/avscamera/sys/Sensor.h index 34997908..327b860a 100644 --- a/avstream/avscamera/sys/Sensor.h +++ b/avstream/avscamera/sys/Sensor.h @@ -446,6 +446,7 @@ public: // stop issuing. When this call returns, the "fake" hardware has // stopped accessing all s/g buffers, etc... // + virtual NTSTATUS Stop ( _In_ PKSPIN diff --git a/avstream/avscamera/sys/SensorSimulation.cpp b/avstream/avscamera/sys/SensorSimulation.cpp index 95824ca5..6ecd9007 100644 --- a/avstream/avscamera/sys/SensorSimulation.cpp +++ b/avstream/avscamera/sys/SensorSimulation.cpp @@ -495,6 +495,38 @@ Return Value: NTSTATUS CSensorSimulation:: +CreateHardwareSimulation( + _In_ LONG pinID, + _In_ const KSPIN_DESCRIPTOR_EX *pinDescriptors, + _Out_ CHardwareSimulation** pSim +) +{ + PAGED_CODE(); + // Video pin type + if (IsEqualGUID(*pinDescriptors[pinID].PinDescriptor.Category, PIN_CATEGORY_CAPTURE)) + { + *pSim = new (NonPagedPoolNx, 'ediV') CVideoHardwareSimulation(this, pinID); + m_VideoMask |= 1 << pinID; + } + else if (IsEqualGUID(*pinDescriptors[pinID].PinDescriptor.Category, PIN_CATEGORY_PREVIEW)) + { + *pSim = new (NonPagedPoolNx, 'verP') CPreviewHardwareSimulation(this, pinID); + m_PreviewMask |= 1 << pinID; // must set to enable photo confirmation... + } + else if (IsEqualGUID(*pinDescriptors[pinID].PinDescriptor.Category, PINNAME_IMAGE)) + { + *pSim = new (NonPagedPoolNx, 'litS') CImageHardwareSimulation(this, pinID); + m_StillMask |= 1 << pinID; + } + else { + return STATUS_NOT_FOUND; + } + + return STATUS_SUCCESS; +} + +NTSTATUS +CSensorSimulation:: Initialize() /*++ @@ -531,26 +563,11 @@ Return Value: { const KSPIN_DESCRIPTOR_EX *PinDescriptors = m_Descriptors->PinDescriptors; CHardwareSimulation *pSim=nullptr; - NT_ASSERT( m_Descriptors->PinDescriptorSize == sizeof( *PinDescriptors ) ); - // Video pin type - if( IsEqualGUID( *PinDescriptors[PinIndex].PinDescriptor.Category, PIN_CATEGORY_CAPTURE ) ) - { - pSim = new (NonPagedPoolNx, 'ediV') CVideoHardwareSimulation( this, PinIndex ); - m_VideoMask |= 1<<PinIndex; - } - else if( IsEqualGUID( *PinDescriptors[PinIndex].PinDescriptor.Category, PIN_CATEGORY_PREVIEW ) ) - { - pSim = new (NonPagedPoolNx, 'verP') CPreviewHardwareSimulation( this, PinIndex ); - m_PreviewMask |= 1<<PinIndex; // must set to enable photo confirmation... - } - else if( IsEqualGUID( *PinDescriptors[PinIndex].PinDescriptor.Category, PINNAME_IMAGE ) ) - { - pSim = new (NonPagedPoolNx, 'litS') CImageHardwareSimulation( this, PinIndex ); - m_StillMask |= 1<<PinIndex; - } - else + NTSTATUS localStatus = CreateHardwareSimulation(PinIndex, PinDescriptors, &pSim); + + if (localStatus == STATUS_NOT_FOUND) { // We don't know this pin type, so skip it. m_HardwareSimulation[PinIndex] = nullptr; diff --git a/avstream/avscamera/sys/SensorSimulation.h b/avstream/avscamera/sys/SensorSimulation.h index 7fb30825..a2dd1fe7 100644 --- a/avstream/avscamera/sys/SensorSimulation.h +++ b/avstream/avscamera/sys/SensorSimulation.h @@ -138,6 +138,14 @@ protected: NTSTATUS ProgramDefaults(); + virtual + NTSTATUS + CreateHardwareSimulation( + _In_ LONG pinID, + _In_ const KSPIN_DESCRIPTOR_EX *pinDescriptors, + _Out_ CHardwareSimulation** pSim + ); + public: // // This simulation is based solely on the Descriptors. Yours might diff --git a/avstream/avscamera/sys/formats.cpp b/avstream/avscamera/sys/formats.cpp index 0c03d4ab..d521c4c5 100644 --- a/avstream/avscamera/sys/formats.cpp +++ b/avstream/avscamera/sys/formats.cpp @@ -25,6 +25,14 @@ #pragma code_seg("PAGE") #endif // ALLOC_PRAGMA +// Define 720p resolution. +#define D720P_W 1280 +#define D720P_H 720 + +// Add 20% for overscan. +#define D720P_W_OS (1280+(1280/5)) +#define D720P_H_OS (720+(720/5)) + /************************************************************************** @@ -311,6 +319,23 @@ DEFINE_DATARANGE_VIDEO( 32, KS_BI_RGB) +DEFINE_DATARANGE_VIDEO( + FormatNV12_720p, + STATICGUIDOF(KSDATAFORMAT_SUBTYPE_NV12), + D720P_W, D720P_H, + 30, + 1, + 12, + FOURCC_NV12) + +DEFINE_DATARANGE_VIDEO( + FormatNV12_720pOverscan, + STATICGUIDOF(KSDATAFORMAT_SUBTYPE_NV12), + D720P_W_OS, D720P_H_OS, + 30, + 1, + 12, + FOURCC_NV12) // // CapturePinDataRanges: @@ -366,6 +391,8 @@ VideoCapturePinDataRanges [VIDEO_CAPTURE_PIN_DATA_RANGE_COUNT] = (PKSDATARANGE) &FormatRGB32Bpp_CaptureVGA_120fpsOverscan, (PKSDATARANGE) &FormatRGB32Bpp_CaptureQVGA, (PKSDATARANGE) &FormatRGB32Bpp_CaptureQVGAOverscan, + (PKSDATARANGE) &FormatNV12_720p, + (PKSDATARANGE) &FormatNV12_720pOverscan }; const @@ -387,4 +414,5 @@ VideoPreviewPinDataRanges[VIDEO_PREVIEW_PIN_DATA_RANGE_COUNT] = (PKSDATARANGE) &FormatRGB32Bpp_CaptureVGA_90fps, (PKSDATARANGE) &FormatRGB32Bpp_CaptureVGA_120fps, (PKSDATARANGE) &FormatRGB32Bpp_CaptureQVGA, + (PKSDATARANGE) &FormatNV12_720p }; diff --git a/avstream/avscamera/sys/hwsim.cpp b/avstream/avscamera/sys/hwsim.cpp index 2db48d30..5322cff3 100644 --- a/avstream/avscamera/sys/hwsim.cpp +++ b/avstream/avscamera/sys/hwsim.cpp @@ -792,6 +792,35 @@ EmitMetadata( } } +bool +CHardwareSimulation:: +CheckForAvailableBuffer() +{ + return true; +} + +NTSTATUS +CHardwareSimulation:: +CommitImageData(PSCATTER_GATHER_ENTRY sGEntry, ULONG stride) +{ + // Have the synthesizer output a frame to the buffer. + ULONG CommitBufferSize = sGEntry->ByteCount; + PUCHAR CommitBufferAddress = sGEntry->Virtual; + + ULONG BytesCopied = m_Synthesizer->DoCommit(CommitBufferAddress, CommitBufferSize, stride); + NT_ASSERT(BytesCopied); + DBG_TRACE("BytesCopied = %d", BytesCopied); + + return STATUS_SUCCESS; +} + +NTSTATUS +CHardwareSimulation:: +ValidateBuffer(PSCATTER_GATHER_ENTRY sGEntry) +{ + return STATUS_SUCCESS; +} + void CHardwareSimulation:: EmitFaceMetadata( @@ -1004,18 +1033,17 @@ Return Value: m_PinID, m_ImageSize, m_ScatterGatherMappingsQueued, m_ScatterGatherBytesQueued); NTSTATUS ntStatus = STATUS_SUCCESS; - ULONG BufferRemaining = m_ImageSize; // - // If there isn't a frame buffer queued, we justskip the frame and consider + // If there isn't a frame buffer queued, we just skip the frame and consider // it starvation. // while (BufferRemaining && !IsListEmpty(&m_ScatterGatherMappings) && - m_ScatterGatherBytesQueued >= BufferRemaining) + (!CheckForAvailableBuffer() || m_ScatterGatherBytesQueued >= BufferRemaining)) { - LIST_ENTRY *listEntry = RemoveHeadList (&m_ScatterGatherMappings); + LIST_ENTRY *listEntry = RemoveHeadList(&m_ScatterGatherMappings); m_ScatterGatherMappingsQueued--; PSCATTER_GATHER_ENTRY SGEntry = @@ -1050,10 +1078,13 @@ Return Value: Stride = (ULONG) ABS(FrameInfo->lSurfacePitch); } - // Have the synthesizer output a frame to the buffer. - ULONG BytesCopied = m_Synthesizer->DoCommit( SGEntry->Virtual, SGEntry->ByteCount, Stride ); - NT_ASSERT( BytesCopied ); - DBG_TRACE( "BytesCopied = %d", BytesCopied ); + ntStatus = ValidateBuffer(SGEntry); + if (!NT_SUCCESS(ntStatus)) + { + break; + } + + ntStatus = CommitImageData(SGEntry, Stride); //Adding time stamp if(m_PhotoConfirmationEntry.isRequired()) @@ -1091,9 +1122,9 @@ Return Value: } // Report an error if we used the last buffer. - if (BufferRemaining) + if (NT_SUCCESS(ntStatus) && BufferRemaining) { - //DBG_TRACE("BufferRemaining=%u", BufferRemaining); + DBG_TRACE("BufferRemaining=%u", BufferRemaining); ntStatus = STATUS_INSUFFICIENT_RESOURCES; } diff --git a/avstream/avscamera/sys/hwsim.h b/avstream/avscamera/sys/hwsim.h index 0a866eea..b326702f 100644 --- a/avstream/avscamera/sys/hwsim.h +++ b/avstream/avscamera/sys/hwsim.h @@ -145,6 +145,18 @@ protected: _Inout_ PKSSTREAM_HEADER pStreamHeader ); + virtual + bool + CheckForAvailableBuffer(); + + virtual + NTSTATUS + CommitImageData(PSCATTER_GATHER_ENTRY sGEntry, ULONG stride); + + virtual + NTSTATUS + ValidateBuffer(PSCATTER_GATHER_ENTRY sGEntry); + // Helper function to generate random face metadata. void EmitFaceMetadata( |
