简体   繁体   中英

Force 3rd party DirectShow filter to use custom allocator

Reason to use custom allocator in 3rd party filter:

I have a NUMA system, and having filters allocating memory on the wrong NUMA node results in performance issue and dropping images received from camera.

My current approach:

I'll wrote a function that iterates all filters and ask them if their input pin has an allocator. Then i ask this allocator for my special allocator interface and finally if the interface is not found i create new custom allocator and apply the same properties as the previous allocator had. Then i call NotifyAllocator on the input pin to notify it about the new allocator.

I tried to call this function at different times in graph building; currently after IMediaControl::Pause and right before IMediaControl::Run but my custom allocator is not used by any 3rd party filter. The samples reside on the wrong NUMA node.

Additionally i also keep track of the threads created during the IMediaControl::Pause call and change their thread affinity to the correct CPU so normally these DirectShow filters should have the right NUMA node as they should allocate on the NUMA node of their running CPU.

You cannot override allocators with NotifyAllocator . Output pin makes a decision on the allocator to use, stores a pointer internally and notifies input pin. You cannot replace the allocator externally, at least not at the state when pins are connected.

Some filters rely on their own allocators and are simply unable to work with other. There is no generic solution for allocator replacement, specific filters might be tricked by the fact that output pin might have no specific requirements for the allocator and asks peer input pin to provide a suitable instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM