Windows updates
authorChris Tallon <chris@vomp.tv>
Sat, 25 Nov 2006 17:58:07 +0000 (17:58 +0000)
committerChris Tallon <chris@vomp.tv>
Sat, 25 Nov 2006 17:58:07 +0000 (17:58 +0000)
audiowin.cc
dssourcefilter.cc
dssourcepin.cc
videowin.cc
videowin.h

index 3e04813c2f135e2240611f1c69192121b73e0400..d13127ecd87722b1bb5e87bdc0e150b8b6ae598e 100644 (file)
@@ -168,6 +168,7 @@ UINT AudioWin::DeliverMediaPacket(MediaPacket packet,
 \r
   /*First Check, if we have an audio sample*/\r
   VideoWin *vw=(VideoWin*)Video::getInstance();\r
+  if (!vw->isdsinited()) return 0;\r
   if (vw->InIframemode()) {\r
                samplepos=0;\r
                MILLISLEEP(10);\r
@@ -253,7 +254,6 @@ UINT AudioWin::DeliverMediaPacket(MediaPacket packet,
       ms->SetTime(NULL,NULL);\r
       ms->SetMediaTime(NULL, NULL);\r
     ms->SetPreroll(FALSE);\r
-     MessageBox(0,"here I'm","Hallo",0);\r
     //  ms->SetSyncPoint(TRUE);\r
     }\r
   }\r
@@ -286,3 +286,4 @@ int AudioWin::test()
 #endif\r
 \r
 \r
+\r
index 8689b8c844d381ff97805d87dabc2754885c489c..ff77a0c884a8bb0031901fbb7b4d136e822f572b 100644 (file)
@@ -1,43 +1,43 @@
-/*
-    Copyright 2004-2006 Marten Richter
-
-    This file is part of VOMP.
-
-    VOMP is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    VOMP is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-#include "dssourcefilter.h"
-
-#define AUDIOPIN_NAME L"Audio"
-#define VIDEOPIN_NAME L"Video"
-
-class DsSFEnumPins: public IEnumPins {
-public:
-       DsSFEnumPins(DsSourcePin* audio,DsSourcePin* video,DsSourceFilter *filt,ULONG pos=0);
-       virtual ~DsSFEnumPins();
+/*\r
+    Copyright 2004-2006 Marten Richter\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+#include "dssourcefilter.h"\r
+\r
+#define AUDIOPIN_NAME L"Audio"\r
+#define VIDEOPIN_NAME L"Video"\r
+\r
+class DsSFEnumPins: public IEnumPins {\r
+public:\r
+       DsSFEnumPins(DsSourcePin* audio,DsSourcePin* video,DsSourceFilter *filt,ULONG pos=0);\r
+       virtual ~DsSFEnumPins();\r
        virtual HRESULT STDMETHODCALLTYPE Next(ULONG numpin,IPin **pins,ULONG *fetched);\r
        virtual HRESULT STDMETHODCALLTYPE Skip(ULONG numpin);\r
        virtual HRESULT STDMETHODCALLTYPE Reset();\r
        virtual HRESULT STDMETHODCALLTYPE Clone(IEnumPins **enuma);\r
-       virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id,void ** object);
+       virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id,void ** object);\r
        virtual ULONG STDMETHODCALLTYPE AddRef();\r
     virtual ULONG STDMETHODCALLTYPE Release();\r
 protected:\r
        DsSourcePin* audiopin;\r
        DsSourcePin* videopin;\r
        DsSourceFilter *filter;\r
-       ULONG curpos;
+       ULONG curpos;\r
        volatile long refs;\r
 };\r
 \r
@@ -47,11 +47,14 @@ DsSFEnumPins::DsSFEnumPins(DsSourcePin* audio,DsSourcePin* video,DsSourceFilter
        curpos=pos;\r
        filter=filt;\r
        filt->AddRef();\r
+       refs=0;\r
+       \r
 }\r
 \r
-DsSFEnumPins::~DsSFEnumPins(){
-       filter->Release();
-}
+DsSFEnumPins::~DsSFEnumPins(){\r
+       filter->Release();\r
+       \r
+}\r
 \r
 HRESULT STDMETHODCALLTYPE DsSFEnumPins::Next(ULONG numpin,IPin **pins,ULONG *fetched) {\r
        int i;\r
@@ -87,19 +90,19 @@ HRESULT STDMETHODCALLTYPE DsSFEnumPins::Clone(IEnumPins **enuma){
        return S_OK;\r
 }\r
 \r
-HRESULT STDMETHODCALLTYPE  DsSFEnumPins::QueryInterface(REFIID id,void ** object){
-       if (object==NULL) return E_POINTER;
-       if (id==IID_IUnknown ||id == IID_IEnumPins) {
-               *object=(IUnknown*)this;
-               ((IUnknown*)object)->AddRef();
-               return NOERROR;
-       } else {
-               *object=NULL;
-               return E_NOINTERFACE;
-       }
-}
-
-
+HRESULT STDMETHODCALLTYPE  DsSFEnumPins::QueryInterface(REFIID id,void ** object){\r
+       if (object==NULL) return E_POINTER;\r
+       if (id==IID_IUnknown ||id == IID_IEnumPins) {\r
+               *object=(IUnknown*)this;\r
+               ((IUnknown*)object)->AddRef();\r
+               return NOERROR;\r
+       } else {\r
+               *object=NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+}\r
+\r
+\r
 \r
 ULONG STDMETHODCALLTYPE DsSFEnumPins::AddRef(){\r
        InterlockedIncrement(&refs);\r
@@ -123,63 +126,63 @@ ULONG STDMETHODCALLTYPE DsSFEnumPins::Release(){
 \r
 \r
 \r
-
-
-
-
-DsSourceFilter::DsSourceFilter()
-{
-       //add audio pin
-       HRESULT res;
-       audiopin=new DsSourcePin(this,&res,L"Vomp Audio Out",true);
-       videopin=new DsSourcePin(this,&res,L"Vomp Video Out",false);
-       filtergraph=NULL;
-       clock=NULL;
-       mystate=State_Stopped;
-       laststart=0;
-       refs=0;
-       InitializeCriticalSection(&filterlock);
-
-}
-
-DsSourceFilter::~DsSourceFilter()
-{
-       if (audiopin) delete audiopin;
-       if (videopin) delete videopin;
-       if (clock) {
-               clock->Release();
-               clock=NULL;
-       }
-       DeleteCriticalSection(&filterlock);
-       
-}
-
-HRESULT STDMETHODCALLTYPE  DsSourceFilter::GetClassID(CLSID *clsid){
-       if (clsid==NULL) return E_POINTER;
-       *clsid=_uuidof(this);
-       return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE DsSourceFilter::QueryInterface(REFIID id,void ** object){
-       if (object==NULL) return E_POINTER;
-       if (id==IID_IUnknown) {
-               *object=(IUnknown*)this;
-               ((IUnknown*)object)->AddRef();
-               return NOERROR;
-       } else if (id==IID_IBaseFilter) {
-               *object=(IBaseFilter*)this;
-               ((IBaseFilter*)object)->AddRef();
-               return NOERROR;
-       } else if (id==IID_IMediaFilter) {
-               *object=(IMediaFilter*)this;
-               ((IMediaFilter*)object)->AddRef();
-               return NOERROR;
-       }else {
-               *object=NULL;
-               return E_NOINTERFACE;
-       }
-}
-
+\r
+\r
+\r
+\r
+DsSourceFilter::DsSourceFilter()\r
+{\r
+       //add audio pin\r
+       HRESULT res;\r
+       audiopin=new DsSourcePin(this,&res,L"Vomp Audio Out",true);\r
+       videopin=new DsSourcePin(this,&res,L"Vomp Video Out",false);\r
+       filtergraph=NULL;\r
+       clock=NULL;\r
+       mystate=State_Stopped;\r
+       laststart=0;\r
+       refs=0;\r
+       InitializeCriticalSection(&filterlock);\r
+\r
+}\r
+\r
+DsSourceFilter::~DsSourceFilter()\r
+{\r
+       if (audiopin) delete audiopin;\r
+       if (videopin) delete videopin;\r
+       if (clock) {\r
+               clock->Release();\r
+               clock=NULL;\r
+       }\r
+       DeleteCriticalSection(&filterlock);\r
+       \r
+}\r
+\r
+HRESULT STDMETHODCALLTYPE  DsSourceFilter::GetClassID(CLSID *clsid){\r
+       if (clsid==NULL) return E_POINTER;\r
+       *clsid=_uuidof(this);\r
+       return S_OK;\r
+}\r
+\r
+HRESULT STDMETHODCALLTYPE DsSourceFilter::QueryInterface(REFIID id,void ** object){\r
+       if (object==NULL) return E_POINTER;\r
+       if (id==IID_IUnknown) {\r
+               *object=(IUnknown*)this;\r
+               AddRef();\r
+               return NOERROR;\r
+       } else if (id==IID_IBaseFilter) {\r
+               *object=(IBaseFilter*)this;\r
+               AddRef();\r
+               return NOERROR;\r
+       } else if (id==IID_IMediaFilter) {\r
+               *object=(IMediaFilter*)this;\r
+               AddRef();\r
+               return NOERROR;\r
+       }else {\r
+               *object=NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+}\r
+\r
 ULONG STDMETHODCALLTYPE DsSourceFilter::AddRef(){\r
        InterlockedIncrement(&refs);\r
        long tempref=refs;\r
@@ -190,38 +193,42 @@ ULONG STDMETHODCALLTYPE DsSourceFilter::Release(){
        long tempref=InterlockedDecrement(&refs);\r
        \r
        if (tempref==0) {\r
-               //refs++;\r
+               refs++;\r
                delete this;\r
                return NULL;\r
        } else {\r
                if (tempref>1) return tempref;\r
                else return 1;\r
        }\r
-}
-
-/*IBaseFilter*/
-HRESULT STDMETHODCALLTYPE DsSourceFilter::EnumPins(IEnumPins **enumar){
-       if (enumar==NULL) return E_POINTER;
-       *enumar=new DsSFEnumPins(audiopin,videopin, this);
-       (*enumar)->AddRef();
-       return S_OK;
-}
-
+}\r
+\r
+/*IBaseFilter*/\r
+HRESULT STDMETHODCALLTYPE DsSourceFilter::EnumPins(IEnumPins **enumar){\r
+       if (enumar==NULL) return E_POINTER;\r
+       *enumar=new DsSFEnumPins(audiopin,videopin, this);\r
+       (*enumar)->AddRef();\r
+       return S_OK;\r
+}\r
+\r
 HRESULT STDMETHODCALLTYPE DsSourceFilter::FindPin(LPCWSTR iden,IPin **pin){\r
        if (pin==NULL) return E_POINTER;\r
+       EnterCriticalSection(&filterlock);\r
 \r
        if (wcscmp(AUDIOPIN_NAME,iden)==NULL) {\r
                *pin=(IPin*)audiopin;\r
                (*pin)->AddRef();\r
+               LeaveCriticalSection(&filterlock);\r
                return S_OK;\r
        }\r
        if (wcscmp(VIDEOPIN_NAME,iden)==NULL) {\r
                *pin=(IPin*)videopin;\r
                (*pin)->AddRef();\r
+               LeaveCriticalSection(&filterlock);\r
                return S_OK;\r
        }\r
 \r
        *pin=NULL;\r
+       LeaveCriticalSection(&filterlock);\r
     return VFW_E_NOT_FOUND;\r
 }\r
 HRESULT STDMETHODCALLTYPE DsSourceFilter::QueryFilterInfo(FILTER_INFO *info){\r
@@ -236,7 +243,7 @@ HRESULT STDMETHODCALLTYPE DsSourceFilter::JoinFilterGraph(IFilterGraph *graph,LP
        //Should we lock\r
        EnterCriticalSection(&filterlock);\r
        filtergraph=graph;\r
-       filtergraph->AddRef();\r
+       //filtergraph->AddRef();\r
        //We ignore the name\r
        LeaveCriticalSection(&filterlock);\r
        \r
@@ -245,17 +252,20 @@ HRESULT STDMETHODCALLTYPE DsSourceFilter::JoinFilterGraph(IFilterGraph *graph,LP
 HRESULT STDMETHODCALLTYPE DsSourceFilter::QueryVendorInfo(LPWSTR *vendinf) {\r
        return E_NOTIMPL;\r
 }\r
-
-
-/*IMediaFilter*/
+\r
+\r
+/*IMediaFilter*/\r
 HRESULT STDMETHODCALLTYPE DsSourceFilter::GetState(DWORD timeout,FILTER_STATE *state){\r
        if (state==NULL) return E_POINTER;\r
+       EnterCriticalSection(&filterlock);\r
        *state=mystate;\r
+       LeaveCriticalSection(&filterlock);\r
        return S_OK;\r
 }\r
 \r
 HRESULT STDMETHODCALLTYPE DsSourceFilter::SetSyncSource(IReferenceClock *uhr){\r
        EnterCriticalSection(&filterlock);\r
+       //MessageBox(0,"Sets ync","",0);\r
        if (clock!=NULL) {\r
                clock->Release();\r
        }\r
@@ -330,7 +340,10 @@ HRESULT STDMETHODCALLTYPE DsSourceFilter::Run(REFERENCE_TIME start){
 \r
        if (mystate==State_Stopped) {\r
                HRESULT phres=Pause();\r
-               if (phres!=S_OK) return phres;\r
+               if (phres!=S_OK){\r
+                       LeaveCriticalSection(&filterlock);\r
+                       return phres;\r
+               }\r
        }\r
        \r
        laststart=start;\r
@@ -358,65 +371,66 @@ HRESULT STDMETHODCALLTYPE DsSourceFilter::Run(REFERENCE_TIME start){
 \r
        return S_OK;\r
 }\r
-
-
-
-int DsSourceFilter::GetPinCount()
-{
-       return 2; //audio and video
-}
-
-
-
-int DsSourceFilter::getCurrentAudioMediaSample(IMediaSample** ms)
-{
-       if (!audiopin || !IsActive()) {
-               return 0;
-       }
-       if (audiopin->getCurrentMediaSample(ms)!=S_OK) {
-               return 0;
-       }
-       return 1;
-}
-
-int DsSourceFilter::getCurrentVideoMediaSample(IMediaSample** ms)
-{
-       if (!videopin || !IsActive()) {
-               return 0;
-       }
-       if (videopin->getCurrentMediaSample(ms)!=S_OK) {
-               return 0;
-       }
-       return 1;
-}
-
-int DsSourceFilter::DeliverAudioMediaSample(IMediaSample* ms)
-{
-       if (!audiopin || !IsActive()) {
-               ms->Release();
-               return 0;
-       }
-       if (audiopin->deliver(ms)!=S_OK) {
-               ms->Release();
-               return 0;
-       }
-       ms->Release();
-       return 1;
-
-}
-
-int DsSourceFilter::DeliverVideoMediaSample(IMediaSample* ms)
-{
-       if (!videopin || !IsActive()) {
-               ms->Release();
-               return 0;
-       }
-       if (videopin->deliver(ms)!=S_OK) {
-               ms->Release();
-               return 0;
-       }
-       ms->Release();
-       return 1;
-
-}
+\r
+\r
+\r
+int DsSourceFilter::GetPinCount()\r
+{\r
+       return 2; //audio and video\r
+}\r
+\r
+\r
+\r
+int DsSourceFilter::getCurrentAudioMediaSample(IMediaSample** ms)\r
+{\r
+       if (!audiopin  || !IsActive()) {\r
+               return 0;\r
+       }\r
+       if (audiopin->getCurrentMediaSample(ms)!=S_OK) {\r
+               return 0;\r
+       }\r
+       return 1;\r
+}\r
+\r
+int DsSourceFilter::getCurrentVideoMediaSample(IMediaSample** ms)\r
+{\r
+       if (!videopin || !IsActive()) {\r
+               return 0;\r
+       }\r
+       if (videopin->getCurrentMediaSample(ms)!=S_OK) {\r
+               return 0;\r
+       }\r
+       return 1;\r
+}\r
+\r
+int DsSourceFilter::DeliverAudioMediaSample(IMediaSample* ms)\r
+{\r
+       if (!audiopin || !IsActive()) {\r
+               ms->Release();\r
+               return 0;\r
+       }\r
+       if (audiopin->deliver(ms)!=S_OK) {\r
+               ms->Release();\r
+               return 0;\r
+       }\r
+       ms->Release();\r
+       return 1;\r
+\r
+}\r
+\r
+int DsSourceFilter::DeliverVideoMediaSample(IMediaSample* ms)\r
+{\r
+       if (!videopin || !IsActive()) {\r
+               ms->Release();\r
+               return 0;\r
+       }\r
+       if (videopin->deliver(ms)!=S_OK) {\r
+               ms->Release();\r
+               return 0;\r
+       }\r
+       ms->Release();\r
+       return 1;\r
+\r
+}\r
+\r
 \r
index 88319a465b8af8278d42b3be6bbebbd6fbc2d451..63812a16a29238521a7eca88294a7a8ddded6f78 100644 (file)
@@ -144,6 +144,7 @@ DsSourcePin::DsSourcePin(DsSourceFilter *pFilter,
 DsSourcePin::~DsSourcePin()\r
 {\r
        \r
+       \r
 \r
 }\r
 \r
@@ -185,12 +186,14 @@ HRESULT STDMETHODCALLTYPE DsSourcePin::Connect(IPin *pinempf,const AM_MEDIA_TYPE
 \r
        if (mtype!=NULL) {\r
                if (CheckMediaType(mtype)==S_OK){\r
+                       pinempf->AddRef();\r
                        if (pinempf->ReceiveConnection((IPin*)this,mtype)==S_OK) {\r
                                CopyMType(&medtype,mtype);\r
                                LeaveCriticalSection(&m_pFilter->filterlock);\r
                        } else {\r
                                LeaveCriticalSection(&m_pFilter->filterlock);\r
                                CoTaskMemFree(mtype->pbFormat);\r
+                               pinempf->Release();\r
                                return VFW_E_TYPE_NOT_ACCEPTED;\r
                        }\r
 \r
@@ -207,10 +210,11 @@ HRESULT STDMETHODCALLTYPE DsSourcePin::Connect(IPin *pinempf,const AM_MEDIA_TYPE
                AM_MEDIA_TYPE  * emtype;\r
                emtype=&emtype_np;\r
                ULONG fetched=0;\r
+               pinempf->AddRef();\r
                while (emt->Next(1,&emtype,&fetched)==S_OK) {\r
                        if (CheckMediaType(emtype)==S_OK){\r
                                if (pinempf->ReceiveConnection((IPin*)this,emtype)==S_OK) {\r
-                                       \r
+                                       connected=pinempf;\r
                                        CopyMType(&medtype,emtype);\r
                                        CoTaskMemFree(emtype->pbFormat);\r
                                        gotmt=true;\r
@@ -238,6 +242,7 @@ HRESULT STDMETHODCALLTYPE DsSourcePin::Connect(IPin *pinempf,const AM_MEDIA_TYPE
                        }\r
                        emt->Release();\r
                        if (gotmt==false) {\r
+                               pinempf->Release();\r
                                LeaveCriticalSection(&m_pFilter->filterlock);\r
                                return VFW_E_NO_ACCEPTABLE_TYPES;\r
                        }\r
@@ -246,8 +251,10 @@ HRESULT STDMETHODCALLTYPE DsSourcePin::Connect(IPin *pinempf,const AM_MEDIA_TYPE
 \r
        if (pinempf->QueryInterface(IID_IMemInputPin,(void**)&connectedinput)!=S_OK) {\r
                LeaveCriticalSection(&m_pFilter->filterlock);\r
-               connectedinput->Release();\r
-               connectedinput=NULL;\r
+               connected->Release();\r
+               connected=NULL;\r
+       /*      connectedinput->Release();\r
+               connectedinput=NULL;*/\r
                return VFW_E_NO_TRANSPORT;\r
        }\r
        ALLOCATOR_PROPERTIES eigenall;\r
@@ -277,6 +284,10 @@ HRESULT STDMETHODCALLTYPE DsSourcePin::Connect(IPin *pinempf,const AM_MEDIA_TYPE
        }\r
        if (allocator!=NULL) allocator->Release();\r
        allocator=NULL;\r
+       connected->Release();\r
+       connected=NULL;\r
+       connectedinput->Release();\r
+       connectedinput=NULL;\r
        LeaveCriticalSection(&m_pFilter->filterlock);\r
        return VFW_E_NO_TRANSPORT;\r
        \r
@@ -312,7 +323,7 @@ HRESULT STDMETHODCALLTYPE DsSourcePin::ReceiveConnection(IPin *connect,
         if (pin==NULL) return E_POINTER;\r
         IPin* pinn=connected;\r
         *pin=pinn;\r
-        if (connected!=NULL) {\r
+        if (pinn!=NULL) {\r
                 pinn->AddRef();\r
                 return S_OK;\r
         } else {\r
@@ -333,6 +344,7 @@ HRESULT STDMETHODCALLTYPE DsSourcePin::ReceiveConnection(IPin *connect,
         if (info==NULL) return E_POINTER;\r
         info->dir=PINDIR_OUTPUT;\r
         info->pFilter=(IBaseFilter*)m_pFilter;\r
+        if (m_pFilter) m_pFilter->AddRef();\r
         if (isaudiopin) wcscpy(info->achName,L"Audio");\r
         else wcscpy(info->achName,L"Video");\r
         return S_OK;\r
index ad0390f6a3294e2299d4d6f9b151874ccb10f6b1..50e19d03d3290f4aa5de2b40a7bcd71bd7feef39 100644 (file)
@@ -31,6 +31,7 @@ void AdjustWindow();
 \r
 VideoWin::VideoWin()\r
 {\r
+  dsinited=false;\r
   dsgraphbuilder=NULL;\r
   dsmediacontrol=NULL;\r
   dsvmrrenderer=NULL;\r
@@ -227,7 +228,6 @@ int VideoWin::dsplay()
    firstsynched=false;\r
    sourcefilter=new DsSourceFilter(); //Creating our Source filter for pushing Data\r
    // to DirectShow\r
-   sourcefilter->AddRef();\r
    if (hres=dsgraphbuilder->AddFilter(sourcefilter,L"Vomp Win Source Filter")!=S_OK) {\r
    Log::getInstance()->log("VideoWin", Log::WARN , "Failed adding Vomp Source Filter!");\r
         ReleaseMutex(filtermutex);\r
@@ -313,6 +313,8 @@ int VideoWin::dsplay()
 \r
    dsgraphbuilder->QueryInterface(IID_IMediaControl,(void **) &dsmediacontrol);\r
    dsgraphbuilder->QueryInterface(IID_IBasicAudio,(void **) &dsbasicaudio);    \r
+   dsinited=true;\r
+   MILLISLEEP(100);\r
 \r
    hresdeb=dsmediacontrol->Run();\r
    iframemode=false;//exit iframe mode\r
@@ -341,7 +343,6 @@ int VideoWin::EnterIframePlayback()
    //firstsynched=false;\r
    sourcefilter=new DsSourceFilter(); //Creating our Source filter for pushing Data\r
    // to DirectShow\r
-   sourcefilter->AddRef();\r
    if (hres=dsgraphbuilder->AddFilter(sourcefilter,L"Vomp Win Source Filter")!=S_OK) {\r
    Log::getInstance()->log("VideoWin", Log::WARN , "Failed adding Vomp Source Filter!");\r
      ReleaseMutex(filtermutex);  \r
@@ -415,6 +416,8 @@ int VideoWin::EnterIframePlayback()
 \r
    dsgraphbuilder->QueryInterface(IID_IMediaControl,(void **) &dsmediacontrol);\r
    dsgraphbuilder->QueryInterface(IID_IBasicAudio,(void **) &dsbasicaudio);    \r
+  dsinited=true;\r
+  \r
 \r
    dsmediacontrol->Run();\r
    ReleaseMutex(filtermutex);\r
@@ -554,6 +557,7 @@ ULLONG VideoWin::frameNumberToTimecode(ULONG framenumber)
 void VideoWin::CleanupDS()\r
 {\r
   WaitForSingleObject(filtermutex,INFINITE);\r
+  dsinited=false;\r
   if (dsmediacontrol)dsmediacontrol->Stop();\r
   if (cur_audio_media_sample) {\r
     cur_audio_media_sample->Release();\r
@@ -601,9 +605,9 @@ void VideoWin::CleanupDS()
 #ifdef DS_DEBUG\r
     RemoveFromRot(graphidentifier);\r
 #endif\r
-    dsgraphbuilder->Release();\r
+       dsgraphbuilder->Release();\r
     dsgraphbuilder=NULL;\r
-       sourcefilter->Release();\r
+       \r
     sourcefilter=NULL; //The Graph Builder destroys our SourceFilter\r
   }\r
   ReleaseMutex(filtermutex);\r
@@ -631,6 +635,7 @@ UINT VideoWin::DeliverMediaPacket(MediaPacket packet,
      UINT *samplepos)\r
 {\r
   /*First Check, if we have an audio sample*/\r
+       if (!isdsinited()) return 0;\r
 #ifdef DO_VIDEO\r
        if (!videoon) {\r
          *samplepos+=packet.length;\r
@@ -887,7 +892,7 @@ void VideoWin::displayIFrame(const UCHAR* buffer, UINT length)
 {\r
        if (!iframemode) EnterIframePlayback();\r
 \r
-\r
+       if (!isdsinited()) return ;\r
 #ifdef DO_VIDEO\r
   IMediaSample* ms=NULL;\r
   REFERENCE_TIME reftime1=0;\r
@@ -981,3 +986,4 @@ int VideoWin::test2()
 #endif\r
 \r
 \r
+\r
index 7b9dd4b1858fe7209c240d32724cef1aeaabf427..2b0050cf6afce1598607fb8feaca5f4f3b648eeb 100644 (file)
@@ -107,6 +107,7 @@ class VideoWin : public Video
   unsigned int getPosx() {return videoposx;};\r
   unsigned int getPosy() {return videoposy;};\r
   bool isVideoOn() {return videoon;};\r
+  bool isdsinited() {return dsinited;};\r
 \r
 #ifdef DEV\r
     int test();\r
@@ -136,7 +137,7 @@ private:
   long long startoffset;\r
   long long lastrefvideotime;\r
   long long lastrefaudiotime;\r
-\r
+  bool dsinited;\r
   bool firstsynched;\r
   bool audioon;\r
   bool videoon;\r
@@ -154,3 +155,4 @@ private:
 #endif\r
 \r
 \r
+\r