Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6848289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:51:00+00:00 2026-05-27T00:51:00+00:00

When we create a directshow filter and register it, static variables/functions are shared in

  • 0

When we create a directshow filter and register it, static variables/functions are shared in multiple instances of the same filter. I believe this also applies to other ActiveX controls. For instance if I try to use something like;

static int counter = 0;

void someFunction() {
    counter++;
    // trace result here
}

If I start another instance of the same filter, second instance doesn’t start from 0 but where first instance counter left. And then they start to increase the same counter asynchronously.

My question is, is there any smart way to block sharing between static variables for DirectShow filters? It may sound silly but if we register the same filter with different GUID (by recompiling the same project with a different GUID and file output), static variables are not shared anymore because they are two different filters, right? So, is there any way I can simulate this using the same filter but keeping the statics?

What am I trying to do is to use a library with many static usage in it. Getting rid of all the static variables/functions is very hard. the library i’m trying to use uses old standards like Ansi C and doesn’t have a real object oriented design. So, encapsulation is not very easy. Most of the functions are in the global space, not in classes. Please keep that in mind. If I leave the statics as they are, single instance of the filter works fine but other instances start getting messed up because of shared (static) variables.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:51:00+00:00Added an answer on May 27, 2026 at 12:51 am

    It is not actually specific to DirectShow, the question is a typical one: should I use static variables in multiple instances of my class.

    Smart answer: if you don’t want to use static variables – don’t. Every instance of your filter is a separate instance of a class. Use it’s member variables and don’t use globals.

    What am I trying to do is to use a library with many static usage in
    it. Getting rid of all the static variables/functions is very hard.

    Put all your statics into one big class, e.g. “state” and have a separate instance of this “state” per filter. This is really preferred way.

    Another solution is to move all statics into child DLL and load it out-of-process, so that each instance is hosted by a separate process. While technically this sovles your problem directly – that is, in a child process all statics remain static and in the same time each owner filter owns a separate copy, the knowledge required to implement out-of-process DLL and interprocess communication basically assumes you can manage to successfully implement the first “state” solution mentioned in the previous paragraph.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I create a simple video effect filter for DirectShow or DMO? What
Some background: I am attempting to create a DirectShow source filter based on the
I am attempting to create a DirectShow source filter based on the pushsource example
I am attempting to create a DirectShow source filter based on the pushsource example
I have a DirectShow filter created with Delphi Pro 6 and the DSPACK direct
create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
I have a custom DirectShow filter created by extending the ezrgb24 filter from the
I have a problem with connecting to remote graph from DirectShow Filter Graph Editor.
I want to create a project using DirectShow. Which license does DirectShow have? Can
I have a DirectShow filter written in Delphi 6 using the DSPACK component library.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.