vendredi 24 juin 2016

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.

Aucun commentaire:

Enregistrer un commentaire