Search code examples
c++windowswinapivisual-c++directshow

graph builder is not released and render is in the background


I had some problems in my app I made an app that can detect the available webcams and render them we can shift from one webcam to another at any time but the problems is when i switch the new render is shown as main stream and the old chosen webcam is shown in the background

Here is an image that shows the prob:

enter image description here

what i have done is releasing the graphbuilder and reinit again with the new filter it works but i'm not satisfied with this logic

MessageBox(NULL,"this is the reload","",NULL);
if(this->videoFilter){  this->videoFilter->Release();   this->videoFilter=NULL; }
if(this->mediaEvent){   this->mediaEvent->Release(); this->mediaEvent=NULL;     }
if(this->videoWindow){  this->videoWindow->Release(); this->videoFilter=NULL;   }
if(this->mediaControl){ this->mediaControl->Release(); this->mediaControl=NULL; }
    // and reallocate them 

Solution

  • You didn't remove the filters from the graph. Releasing them is not removing.