diff options
| author | Wei Mao <[email protected]> | 2017-08-16 14:55:19 -0700 |
|---|---|---|
| committer | Wei Mao <[email protected]> | 2017-08-16 14:55:19 -0700 |
| commit | 3ea77dce79b649dd75c43d6cf22378667e8124c2 (patch) | |
| tree | 72c479a81729542d54dea091abef747d5e453c57 | |
| parent | 562f9f003d163470eaab98517f0770dc328f292b (diff) | |
Build avshws sample with RS2 WDK
| -rw-r--r-- | avstream/avshws/avshws.h | 125 | ||||
| -rw-r--r-- | avstream/avshws/device.cpp | 185 |
2 files changed, 184 insertions, 126 deletions
diff --git a/avstream/avshws/avshws.h b/avstream/avshws/avshws.h index 70f220f3..a6b3d8bc 100644 --- a/avstream/avshws/avshws.h +++ b/avstream/avshws/avshws.h @@ -10,7 +10,7 @@ Abstract: - AVStream Simulated Hardware Sample header file. This is the + AVStream Simulated Hardware Sample header file. This is the main header. History: @@ -43,6 +43,14 @@ extern "C" { #include <unknown.h> #include <ks.h> #include <ksmedia.h> + +// Note: Since VS2015 Update 2 overloaded operator new and operator delete may not +// be declared inline (Level 1 (/W1) on-by-default, warning C4595). +// See https://msdn.microsoft.com/en-us/library/mt656697.aspx +// +// To mitigate this issue, add "#define _NEW_DELETE_OPERATORS_" before "#include <kcom.h>" +// and implement non-inline operator new and operator delete locally. +#define _NEW_DELETE_OPERATORS_ #include <kcom.h> /************************************************* @@ -76,7 +84,7 @@ const DebugLevel = DEBUGLVL_TERSE; #define ABS(x) ((x) < 0 ? (-(x)) : (x)) -#ifndef mmioFOURCC +#ifndef mmioFOURCC #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \ ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \ ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) ) @@ -137,12 +145,12 @@ CaptureFilterCategories [CAPTURE_FILTER_CATEGORIES_COUNT]; // // capture.cpp externs: // -extern +extern const KSALLOCATOR_FRAMING_EX CapturePinAllocatorFraming; -extern +extern const KSPIN_DISPATCH CapturePinDispatch; @@ -210,103 +218,38 @@ public: }; - /************************************************* Global Functions *************************************************/ -/*++ - -Routine Description: - - Array delete() operator. - -Arguments: - - pVoid - - The memory to free. - -Return Value: - - None - ---*/ -inline -void -__cdecl -operator delete[]( - PVOID pVoid -) -{ - if (pVoid) - { - ExFreePool(pVoid); - } -} - -/*++ - -Routine Description: - - Sized delete() operator. - -Arguments: - - pVoid - - The memory to free. - - size - - The size of the memory to free. - -Return Value: - - None - ---*/ -inline void __cdecl operator delete +void __cdecl operator delete[] ( - void *pVoid, - size_t /*size*/ -) -{ - if (pVoid) - { - ExFreePool(pVoid); - } -} - -/*++ + PVOID pVoid +); -Routine Description: - - Sized delete[]() operator. - -Arguments: - - pVoid - - The memory to free. - - size - - The size of the memory to free. - -Return Value: +void __cdecl operator delete +( + void *pVoid, + size_t /*size*/ +); - None +void __cdecl operator delete[] +( + void *pVoid, + size_t /*size*/ +); ---*/ -inline void __cdecl operator delete[] +PVOID operator new ( - void *pVoid, - size_t /*size*/ -) -{ - if (pVoid) - { - ExFreePool(pVoid); - } -} + size_t iSize, + _When_((poolType & NonPagedPoolMustSucceed) != 0, + __drv_reportError("Must succeed pool allocations are forbidden. " + "Allocation failures cause a system crash")) + POOL_TYPE poolType, + ULONG tag +); /************************************************* @@ -320,4 +263,4 @@ inline void __cdecl operator delete[] #include "filter.h" #include "capture.h" #include <uuids.h> -#endif //_avshws_h_
\ No newline at end of file +#endif //_avshws_h_ diff --git a/avstream/avshws/device.cpp b/avstream/avshws/device.cpp index 75b06cd5..2f54aca4 100644 --- a/avstream/avshws/device.cpp +++ b/avstream/avshws/device.cpp @@ -161,7 +161,7 @@ Return Value: // // By PnP, it's possible to receive multiple starts without an intervening // stop (to reevaluate resources, for example). Thus, we only perform - // creations of the simulation on the initial start and ignore any + // creations of the simulation on the initial start and ignore any // subsequent start. Hardware drivers with resources should evaluate // resources and make changes on 2nd start. // @@ -173,7 +173,7 @@ Return Value: // If we couldn't create the hardware simulation, fail. // Status = STATUS_INSUFFICIENT_RESOURCES; - + } else { Status = KsAddItemToObjectBag ( m_Device -> Bag, @@ -197,15 +197,15 @@ Return Value: // // Set up DMA... // - // Ordinarilly, we'd be using InterfaceBuffer or - // InterfaceTypeUndefined if !NT_SUCCESS (IfStatus) as the - // InterfaceType below; however, for the purposes of this sample, + // Ordinarilly, we'd be using InterfaceBuffer or + // InterfaceTypeUndefined if !NT_SUCCESS (IfStatus) as the + // InterfaceType below; however, for the purposes of this sample, // we lie and say we're on the PCI Bus. Otherwise, we're using map // registers on x86 32 bit physical to 32 bit logical and this isn't // what I want to show in this sample. // // - // NTSTATUS IfStatus = + // NTSTATUS IfStatus = IoGetDeviceProperty ( m_Device -> PhysicalDeviceObject, @@ -216,7 +216,7 @@ Return Value: ); // - // Initialize our fake device description. We claim to be a + // Initialize our fake device description. We claim to be a // bus-mastering 32-bit scatter/gather capable piece of hardware. // DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION; @@ -229,7 +229,7 @@ Return Value: DeviceDescription.Dma32BitAddresses = TRUE; DeviceDescription.AutoInitialize = FALSE; DeviceDescription.MaximumLength = (ULONG) -1; - + // // Get a DMA adapter object from the system. // @@ -238,21 +238,21 @@ Return Value: &DeviceDescription, &m_NumberOfMapRegisters ); - + if (!m_DmaAdapterObject) { Status = STATUS_UNSUCCESSFUL; } - + } - + if (NT_SUCCESS (Status)) { // - // Initialize our DMA adapter object with AVStream. This is + // Initialize our DMA adapter object with AVStream. This is // **ONLY** necessary **IF** you are doing DMA directly into // capture buffers as this sample does. For this, // KSPIN_FLAG_GENERATE_MAPPINGS must be specified on a queue. // - + // // The (1 << 20) below is the maximum size of a single s/g mapping // that this hardware can handle. Note that I have pulled this @@ -264,11 +264,11 @@ Return Value: (1 << 20), sizeof (KSMAPPING) ); - + } #endif } - + return Status; } @@ -306,7 +306,7 @@ Return Value: // // Return the DMA adapter back to the system. // - m_DmaAdapterObject -> DmaOperations -> + m_DmaAdapterObject -> DmaOperations -> PutDmaAdapter (m_DmaAdapterObject); m_DmaAdapterObject = NULL; @@ -328,7 +328,7 @@ AcquireHardwareResources ( Routine Description: - Acquire hardware resources for the capture hardware. If the + Acquire hardware resources for the capture hardware. If the resources are already acquired, this will return an error. The hardware configuration must be passed as a VideoInfoHeader. @@ -376,44 +376,44 @@ Return Value: delete m_ImageSynth; m_ImageSynth = NULL; } - + // // Create the necessary type of image synthesizer. // if (m_VideoInfoHeader -> bmiHeader.biBitCount == 24 && m_VideoInfoHeader -> bmiHeader.biCompression == KS_BI_RGB) { - + // // If we're RGB24, create a new RGB24 synth. RGB24 surfaces // can be in either orientation. The origin is lower left if // height < 0. Otherwise, it's upper left. // - m_ImageSynth = new (NonPagedPoolNx, 'RysI') + m_ImageSynth = new (NonPagedPoolNx, 'RysI') CRGB24Synthesizer ( m_VideoInfoHeader -> bmiHeader.biHeight >= 0 ); - + } else if (m_VideoInfoHeader -> bmiHeader.biBitCount == 16 && (m_VideoInfoHeader -> bmiHeader.biCompression == FOURCC_YUY2)) { - + // // If we're UYVY, create the YUV synth. // m_ImageSynth = new(NonPagedPoolNx, 'YysI') CYUVSynthesizer; - + } else // // We don't synthesize anything but RGB 24 and UYVY. // Status = STATUS_INVALID_PARAMETER; - + if (NT_SUCCESS (Status) && !m_ImageSynth) { - + Status = STATUS_INSUFFICIENT_RESOURCES; - - } + + } if (NT_SUCCESS (Status)) { // @@ -428,7 +428,7 @@ Return Value: // ReleaseHardwareResources (); } - + } else { // @@ -660,9 +660,9 @@ Return Value: PAGED_CODE(); - - return + + return m_HardwareSimulation -> ProgramScatterGatherMappings ( Clone, Buffer, @@ -749,7 +749,7 @@ Return Value: // of hardware registers (ReadNumberOfMappingsCompleted) which would likely // be done in the ISR. // - ULONG NumMappingsCompleted = + ULONG NumMappingsCompleted = m_HardwareSimulation -> ReadNumberOfMappingsCompleted (); // @@ -774,7 +774,7 @@ Return Value: // CaptureFilterDescriptor: // // The filter descriptor for the capture device. -DEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) { +DEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) { &CaptureFilterDescriptor }; @@ -810,8 +810,8 @@ CaptureDeviceDispatch = { // This is the device descriptor for the capture device. It points to the // dispatch table and contains a list of filter descriptors that describe // filter-types that this device supports. Note that the filter-descriptors -// can be created dynamically and the factories created via -// KsCreateFilterFactory as well. +// can be created dynamically and the factories created via +// KsCreateFilterFactory as well. // const KSDEVICE_DESCRIPTOR @@ -865,7 +865,7 @@ Return Value: // at add & start. Everything is done based on the descriptors passed // here. // - return + return KsInitializeDriver ( DriverObject, RegistryPath, @@ -873,3 +873,118 @@ Return Value: ); } + +/************************************************* + + Global Functions + +*************************************************/ + +/*++ + +Routine Description: + + Array delete() operator. + +Arguments: + + pVoid - + The memory to free. + +Return Value: + + None + +--*/ +void +__cdecl +operator delete[]( + PVOID pVoid +) +{ + if (pVoid) + { + ExFreePool(pVoid); + } +} + +/*++ + +Routine Description: + + Sized delete() operator. + +Arguments: + + pVoid - + The memory to free. + + size - + The size of the memory to free. + +Return Value: + + None + +--*/ +void __cdecl operator delete +( + void *pVoid, + size_t /*size*/ +) +{ + if (pVoid) + { + ExFreePool(pVoid); + } +} + +/*++ + +Routine Description: + + Sized delete[]() operator. + +Arguments: + + pVoid - + The memory to free. + + size - + The size of the memory to free. + +Return Value: + + None + +--*/ +void __cdecl operator delete[] +( + void *pVoid, + size_t /*size*/ +) +{ + if (pVoid) + { + ExFreePool(pVoid); + } +} + +PVOID operator new +( + size_t iSize, + _When_((poolType & NonPagedPoolMustSucceed) != 0, + __drv_reportError("Must succeed pool allocations are forbidden. " + "Allocation failures cause a system crash")) + POOL_TYPE poolType, + ULONG tag +) +{ + PVOID result = ExAllocatePoolWithTag(poolType,iSize,tag); + + if (result) { + RtlZeroMemory(result,iSize); + } + + return result; +} |
