 DirectShowFilters/TsWriter/bin/Debug/vc100.pdb     | Bin 1290240 -> 1298432 bytes
 DirectShowFilters/TsWriter/bin/Release/TsWriter.ax | Bin 262144 -> 268288 bytes
 DirectShowFilters/TsWriter/source/TsWriter.cpp     |  62 ++++++++++++++-------
 DirectShowFilters/TsWriter/source/TsWriter.h       |  10 ++--
 4 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/DirectShowFilters/TsWriter/bin/Debug/vc100.pdb b/DirectShowFilters/TsWriter/bin/Debug/vc100.pdb
index 4b1ca49..3510f38 100644
Binary files a/DirectShowFilters/TsWriter/bin/Debug/vc100.pdb and b/DirectShowFilters/TsWriter/bin/Debug/vc100.pdb differ
diff --git a/DirectShowFilters/TsWriter/bin/Release/TsWriter.ax b/DirectShowFilters/TsWriter/bin/Release/TsWriter.ax
index b6faf97..3e872cb 100644
Binary files a/DirectShowFilters/TsWriter/bin/Release/TsWriter.ax and b/DirectShowFilters/TsWriter/bin/Release/TsWriter.ax differ
diff --git a/DirectShowFilters/TsWriter/source/TsWriter.cpp b/DirectShowFilters/TsWriter/source/TsWriter.cpp
index 711123a..4b42a46 100644
--- a/DirectShowFilters/TsWriter/source/TsWriter.cpp
+++ b/DirectShowFilters/TsWriter/source/TsWriter.cpp
@@ -229,13 +229,12 @@ STDMETHODIMP CMpTsFilter::Run(REFERENCE_TIME tStart)
 //
 //  Definition of CMpTsFilterPin
 //
-CMpTsFilterPin::CMpTsFilterPin(CMpTs *pDump,LPUNKNOWN pUnk,CBaseFilter *pFilter,CCritSec *pLock,CCritSec *pReceiveLock,HRESULT *phr) 
+CMpTsFilterPin::CMpTsFilterPin(CMpTs *pDump,LPUNKNOWN pUnk,CBaseFilter *pFilter,CCritSec *pLock,HRESULT *phr) 
 :CRenderedInputPin(NAME("CMpTsFilterPin"),
                   pFilter,                   // Filter
                   pLock,                     // Locking
                   phr,                       // Return code
                   L"Input"),                 // Pin name
-    m_pReceiveLock(pReceiveLock),
     m_pWriterFilter(pDump)
 {
 	LogDebug("CMpTsFilterPin:ctor");
@@ -327,9 +326,7 @@ void CMpTsFilterPin::OnTsPacket(byte* tsPacket)
 
 STDMETHODIMP CMpTsFilterPin::EndOfStream(void)
 {
-    CAutoLock lock(m_pReceiveLock);
-    return CRenderedInputPin::EndOfStream();
-
+	return CRenderedInputPin::EndOfStream();
 }
 
 void CMpTsFilterPin::Reset()
@@ -364,7 +361,7 @@ CMpTs::CMpTs(LPUNKNOWN pUnk, HRESULT *phr)
   LogDebug("--------------- BUG-3782 fix v2 -------------------");
 		
 	b_dumpRawPakets=false;
-  m_pFilter = new CMpTsFilter(this, GetOwner(), &m_Lock, phr);
+  m_pFilter = new CMpTsFilter(this, GetOwner(), &m_filterLock, phr);
   if (m_pFilter == NULL) 
   {
     if (phr)
@@ -372,7 +369,7 @@ CMpTs::CMpTs(LPUNKNOWN pUnk, HRESULT *phr)
     return;
   }
 
-  m_pPin = new CMpTsFilterPin(this,GetOwner(),m_pFilter,&m_Lock,&m_ReceiveLock,phr);
+  m_pPin = new CMpTsFilterPin(this,GetOwner(),m_pFilter,&m_filterLock,phr);
   if (m_pPin == NULL) 
   {
     if (phr)
@@ -396,12 +393,7 @@ CMpTs::~CMpTs()
 	delete m_pEpgScanner;
 	delete m_pChannelLinkageScanner;
 	delete m_rawPaketWriter;
-  CAutoLock lock(&m_Lock);
-  for (int i=0; i < (int)m_vecChannels.size();++i)
-  {
-    delete m_vecChannels[i];
-  }
-  m_vecChannels.clear();
+  DeleteAllChannels();
 }
 
 //
@@ -432,7 +424,6 @@ CUnknown * WINAPI CMpTs::CreateInstance(LPUNKNOWN punk, HRESULT *phr)
 STDMETHODIMP CMpTs::NonDelegatingQueryInterface(REFIID riid, void ** ppv)
 {
   CheckPointer(ppv,E_POINTER);
-  CAutoLock lock(&m_Lock);
 
   // Do we have this interface
 	if (riid == IID_ITSChannelScan)
@@ -503,7 +494,7 @@ void CMpTs::AnalyzeTsPacket(byte* tsPacket)
 {
 	try
 	{
-    CAutoLock lock(&m_Lock);
+    CAutoLock lock(&m_channelLock);
     for (int i=0; i < (int)m_vecChannels.size();++i)
     {
       m_vecChannels[i]->OnTsPacket(tsPacket);
@@ -521,7 +512,7 @@ void CMpTs::AnalyzeTsPacket(byte* tsPacket)
 
 STDMETHODIMP CMpTs::AddChannel( int* handle)
 {
-  CAutoLock lock(&m_Lock);
+  CAutoLock lock(&m_channelLock);
 	HRESULT hr;
   CTsChannel* channel = new CTsChannel(GetOwner(), &hr,m_id); 
 	*handle=m_id;
@@ -532,7 +523,7 @@ STDMETHODIMP CMpTs::AddChannel( int* handle)
 
 STDMETHODIMP CMpTs::DeleteChannel( int handle)
 {
-  CAutoLock lock(&m_Lock);
+  CAutoLock lock(&m_channelLock);
 	try
 	{
 		ivecChannels it = m_vecChannels.begin();
@@ -560,7 +551,6 @@ STDMETHODIMP CMpTs::DeleteChannel( int handle)
 
 CTsChannel* CMpTs::GetTsChannel(int handle)
 {
-  CAutoLock lock(&m_Lock);
 	ivecChannels it = m_vecChannels.begin();
 	while (it != m_vecChannels.end())
 	{
@@ -575,7 +565,7 @@ CTsChannel* CMpTs::GetTsChannel(int handle)
 
 STDMETHODIMP CMpTs::DeleteAllChannels()
 {
-  CAutoLock lock(&m_Lock);
+  CAutoLock lock(&m_channelLock);
   LogDebug("--delete all channels");
   for (int i=0; i < (int)m_vecChannels.size();++i)
   {
@@ -588,6 +578,7 @@ STDMETHODIMP CMpTs::DeleteAllChannels()
 
 STDMETHODIMP CMpTs::AnalyzerSetVideoPid(int handle, int videoPid)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pVideoAnalyzer->SetVideoPid(  videoPid);
@@ -595,6 +586,7 @@ STDMETHODIMP CMpTs::AnalyzerSetVideoPid(int handle, int videoPid)
 
 STDMETHODIMP CMpTs::AnalyzerGetVideoPid(int handle,  int* videoPid)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pVideoAnalyzer->GetVideoPid(  videoPid);
@@ -602,6 +594,7 @@ STDMETHODIMP CMpTs::AnalyzerGetVideoPid(int handle,  int* videoPid)
 
 STDMETHODIMP CMpTs::AnalyzerSetAudioPid(int handle,  int audioPid)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pVideoAnalyzer->SetAudioPid(  audioPid);
@@ -609,6 +602,7 @@ STDMETHODIMP CMpTs::AnalyzerSetAudioPid(int handle,  int audioPid)
 
 STDMETHODIMP CMpTs::AnalyzerGetAudioPid(int handle,  int* audioPid)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pVideoAnalyzer->GetAudioPid(  audioPid);
@@ -616,6 +610,7 @@ STDMETHODIMP CMpTs::AnalyzerGetAudioPid(int handle,  int* audioPid)
 
 STDMETHODIMP CMpTs::AnalyzerIsVideoEncrypted(int handle,  int* yesNo)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pVideoAnalyzer->IsVideoEncrypted(  yesNo);
@@ -623,6 +618,7 @@ STDMETHODIMP CMpTs::AnalyzerIsVideoEncrypted(int handle,  int* yesNo)
 
 STDMETHODIMP CMpTs::AnalyzerIsAudioEncrypted(int handle,  int* yesNo)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pVideoAnalyzer->IsAudioEncrypted(  yesNo);
@@ -630,6 +626,7 @@ STDMETHODIMP CMpTs::AnalyzerIsAudioEncrypted(int handle,  int* yesNo)
 
 STDMETHODIMP CMpTs::AnalyzerReset(int handle )
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pVideoAnalyzer->Reset(  );
@@ -637,6 +634,7 @@ STDMETHODIMP CMpTs::AnalyzerReset(int handle )
 
 STDMETHODIMP CMpTs::PmtSetPmtPid(int handle,int pmtPid, long serviceId)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pPmtGrabber->SetPmtPid(pmtPid,serviceId  );
@@ -644,6 +642,7 @@ STDMETHODIMP CMpTs::PmtSetPmtPid(int handle,int pmtPid, long serviceId)
 
 STDMETHODIMP CMpTs::PmtSetCallBack(int handle,IPMTCallback* callback)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pPmtGrabber->SetCallBack(callback);
@@ -651,6 +650,7 @@ STDMETHODIMP CMpTs::PmtSetCallBack(int handle,IPMTCallback* callback)
 
 STDMETHODIMP CMpTs::PmtGetPMTData (int handle,BYTE *pmtData)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pPmtGrabber->GetPMTData (pmtData);
@@ -658,6 +658,7 @@ STDMETHODIMP CMpTs::PmtGetPMTData (int handle,BYTE *pmtData)
 
 STDMETHODIMP CMpTs::RecordSetRecordingFileNameW( int handle, wchar_t* pwszFileName)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
   pChannel->m_pRecorder->SetFileNameW(pwszFileName);
@@ -666,6 +667,7 @@ STDMETHODIMP CMpTs::RecordSetRecordingFileNameW( int handle, wchar_t* pwszFileNa
 
 STDMETHODIMP CMpTs::RecordStartRecord( int handle)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	if (pChannel->m_pRecorder->Start())
@@ -676,6 +678,7 @@ STDMETHODIMP CMpTs::RecordStartRecord( int handle)
 
 STDMETHODIMP CMpTs::RecordStopRecord( int handle)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	pChannel->m_pRecorder->Stop(  );
@@ -684,6 +687,7 @@ STDMETHODIMP CMpTs::RecordStopRecord( int handle)
 
 STDMETHODIMP CMpTs::RecordSetPmtPid(int handle,int mtPid, int serviceId,byte* pmtData,int pmtLength )
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	pChannel->m_pRecorder->SetPmtPid( mtPid, serviceId,pmtData,pmtLength );
@@ -692,6 +696,7 @@ STDMETHODIMP CMpTs::RecordSetPmtPid(int handle,int mtPid, int serviceId,byte* pm
 
 STDMETHODIMP CMpTs::TimeShiftSetTimeShiftingFileNameW( int handle, wchar_t* pwszFileName)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 
@@ -711,6 +716,7 @@ STDMETHODIMP CMpTs::TimeShiftSetTimeShiftingFileNameW( int handle, wchar_t* pwsz
 }
 STDMETHODIMP CMpTs::TimeShiftStart( int handle )
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
   if (b_dumpRawPakets)
@@ -726,6 +732,7 @@ STDMETHODIMP CMpTs::TimeShiftStart( int handle )
 
 STDMETHODIMP CMpTs::TimeShiftStop( int handle )
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
   if (b_dumpRawPakets)
@@ -739,6 +746,7 @@ STDMETHODIMP CMpTs::TimeShiftStop( int handle )
 
 STDMETHODIMP CMpTs:: TimeShiftReset( int handle )
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
   if (b_dumpRawPakets)
@@ -753,6 +761,7 @@ STDMETHODIMP CMpTs:: TimeShiftReset( int handle )
 
 STDMETHODIMP CMpTs:: TimeShiftGetBufferSize( int handle, long * size) 
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	pChannel->m_pTimeShifting->GetBufferSize( size);
@@ -761,6 +770,7 @@ STDMETHODIMP CMpTs:: TimeShiftGetBufferSize( int handle, long * size)
 
 STDMETHODIMP CMpTs:: TimeShiftSetPmtPid( int handle, int pmtPid, int serviceId,byte* pmtData,int pmtLength) 
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	pChannel->m_pTimeShifting->SetPmtPid( pmtPid,serviceId,pmtData,pmtLength);
@@ -769,6 +779,7 @@ STDMETHODIMP CMpTs:: TimeShiftSetPmtPid( int handle, int pmtPid, int serviceId,b
 
 STDMETHODIMP CMpTs:: TimeShiftPause( int handle, BYTE onOff) 
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	pChannel->m_pTimeShifting->Pause( onOff);
@@ -777,6 +788,7 @@ STDMETHODIMP CMpTs:: TimeShiftPause( int handle, BYTE onOff)
 
 STDMETHODIMP CMpTs::TimeShiftSetParams(int handle, int minFiles, int maxFiles, ULONG chunkSize) 
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
   pChannel->m_pTimeShifting->SetMinTSFiles(minFiles);
@@ -788,6 +800,7 @@ STDMETHODIMP CMpTs::TimeShiftSetParams(int handle, int minFiles, int maxFiles, U
 
 STDMETHODIMP CMpTs::TimeShiftGetCurrentFilePosition(int handle,__int64 * position,long * bufferId)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	pChannel->m_pTimeShifting->GetTimeShiftPosition(position,bufferId);
@@ -796,6 +809,7 @@ STDMETHODIMP CMpTs::TimeShiftGetCurrentFilePosition(int handle,__int64 * positio
 
 STDMETHODIMP CMpTs::SetVideoAudioObserver(int handle, IVideoAudioObserver* callback)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_FALSE;
   pChannel->m_pTimeShifting->SetVideoAudioObserver(callback);
@@ -804,6 +818,7 @@ STDMETHODIMP CMpTs::SetVideoAudioObserver(int handle, IVideoAudioObserver* callb
 
 STDMETHODIMP CMpTs::RecordSetVideoAudioObserver(int handle, IVideoAudioObserver* callback)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_FALSE;
   pChannel->m_pRecorder->SetVideoAudioObserver(callback);
@@ -812,6 +827,7 @@ STDMETHODIMP CMpTs::RecordSetVideoAudioObserver(int handle, IVideoAudioObserver*
 
 STDMETHODIMP CMpTs::TTxStart( int handle)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pTeletextGrabber->Start( );
@@ -819,6 +835,7 @@ STDMETHODIMP CMpTs::TTxStart( int handle)
 
 STDMETHODIMP CMpTs::TTxStop( int handle )
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pTeletextGrabber->Stop( );
@@ -826,6 +843,7 @@ STDMETHODIMP CMpTs::TTxStop( int handle )
 
 STDMETHODIMP CMpTs::TTxSetTeletextPid( int handle,int teletextPid)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pTeletextGrabber->SetTeletextPid(teletextPid );
@@ -833,6 +851,7 @@ STDMETHODIMP CMpTs::TTxSetTeletextPid( int handle,int teletextPid)
 
 STDMETHODIMP CMpTs::TTxSetCallBack( int handle,ITeletextCallBack* callback)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pTeletextGrabber->SetCallBack(callback );
@@ -840,6 +859,7 @@ STDMETHODIMP CMpTs::TTxSetCallBack( int handle,ITeletextCallBack* callback)
 
 STDMETHODIMP CMpTs::CaSetCallBack(int handle,ICACallback* callback)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pCaGrabber->SetCallBack(callback );
@@ -847,6 +867,7 @@ STDMETHODIMP CMpTs::CaSetCallBack(int handle,ICACallback* callback)
 
 STDMETHODIMP CMpTs::CaGetCaData(int handle,BYTE *caData)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pCaGrabber->GetCaData(caData );
@@ -854,6 +875,7 @@ STDMETHODIMP CMpTs::CaGetCaData(int handle,BYTE *caData)
 
 STDMETHODIMP CMpTs::CaReset(int handle)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	return pChannel->m_pCaGrabber->Reset( );
@@ -862,6 +884,7 @@ STDMETHODIMP CMpTs::CaReset(int handle)
 STDMETHODIMP CMpTs::GetStreamQualityCounters(int handle, int* totalTsBytes, int* totalRecordingBytes, 
       int* TsDiscontinuity, int* recordingDiscontinuity)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_FALSE;
 
@@ -886,6 +909,7 @@ STDMETHODIMP CMpTs::GetStreamQualityCounters(int handle, int* totalTsBytes, int*
 
 STDMETHODIMP CMpTs::TimeShiftSetChannelType(int handle, int channelType)
 {
+  CAutoLock lock(&m_channelLock);
   CTsChannel* pChannel=GetTsChannel(handle);
   if (pChannel==NULL) return S_OK;
 	pChannel->m_pRecorder->SetChannelType(channelType);
diff --git a/DirectShowFilters/TsWriter/source/TsWriter.h b/DirectShowFilters/TsWriter/source/TsWriter.h
index b8fe9a0..6117eb0 100644
--- a/DirectShowFilters/TsWriter/source/TsWriter.h
+++ b/DirectShowFilters/TsWriter/source/TsWriter.h
@@ -121,10 +121,10 @@ public:
 class CMpTsFilterPin : public CRenderedInputPin,public CPacketSync
 {
     CMpTs*	const	m_pWriterFilter;   // Main renderer object
-    CCritSec*		const	m_pReceiveLock;    // Sample critical section
+
 public:
 
-    CMpTsFilterPin(CMpTs *pDump,LPUNKNOWN pUnk,CBaseFilter *pFilter,CCritSec *pLock,CCritSec *pReceiveLock,HRESULT *phr);
+    CMpTsFilterPin(CMpTs *pDump,LPUNKNOWN pUnk,CBaseFilter *pFilter,CCritSec *pLock,HRESULT *phr);
 
     // Do something with this media sample
     STDMETHODIMP Receive(IMediaSample *pSample);
@@ -138,7 +138,6 @@ public:
     HRESULT		CheckMediaType(const CMediaType *);
     // Break connection
     HRESULT		BreakConnect();
-		BOOL			IsReceiving();
 		void			Reset();
     // Track NewSegment
     STDMETHODIMP NewSegment(REFERENCE_TIME tStart,REFERENCE_TIME tStop,double dRate);
@@ -161,8 +160,8 @@ class CMpTs : public CUnknown, public ITSFilter
     friend class CMpTsFilterPin;
     CMpTsFilter*	m_pFilter;       // Methods for filter interfaces
     CMpTsFilterPin*	m_pPin;          // A simple rendered input pin
-    CCritSec 		m_Lock;                // Main renderer critical section
-    CCritSec 		m_ReceiveLock;         // Sublock for received samples
+    CCritSec 		m_filterLock;          // Main renderer critical section
+
 public:
     DECLARE_IUNKNOWN
 
@@ -228,6 +227,7 @@ private:
 		bool b_dumpRawPakets;
 		CChannelLinkageScanner* m_pChannelLinkageScanner;
 		vector<CTsChannel*> m_vecChannels;
+		CCritSec m_channelLock;         // Lock for protecting access to m_vecChannels.
     typedef vector<CTsChannel*>::iterator ivecChannels;
 		int m_id;
 };
