baseclasses: Move from unfree to 3rdparty

Update it to the version found at
https://github.com/Microsoft/Windows-classic-samples , which is in an
MIT licensed repo, and add the LICENSE file (edited to remove the SIL
Open Font LICENSE part since that doesn't apply).

Some modifications have been made to reduce the diff/stop git
complaining (not including any file that wasn't in the previous version
and removing the related header includes in streams.h, and fixing some
but not all of the whitespace issues).
This commit is contained in:
Jonathan Li 2018-04-28 17:52:15 +01:00
parent b84b2808f4
commit ab9bdb009b
61 changed files with 2160 additions and 2599 deletions

21
3rdparty/baseclasses/LICENSE vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Microsoft Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -3,14 +3,14 @@
// //
// Desc: DirectShow base classes - implements CRenderedInputPin class. // Desc: DirectShow base classes - implements CRenderedInputPin class.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" // DirectShow base class definitions #include <streams.h> // DirectShow base class definitions
#include <mmsystem.h> // Needed for definition of timeGetTime #include <mmsystem.h> // Needed for definition of timeGetTime
#include <limits.h> // Standard data type limit definitions #include <limits.h> // Standard data type limit definitions
#include "measure.h" // Used for time critical log functions #include <measure.h> // Used for time critical log functions
#include "amextra.h" #include "amextra.h"
@ -18,22 +18,22 @@
// Implements CRenderedInputPin class // Implements CRenderedInputPin class
CRenderedInputPin::CRenderedInputPin(TCHAR *pObjectName, CRenderedInputPin::CRenderedInputPin(__in_opt LPCTSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName) : __in_opt LPCWSTR pName) :
CBaseInputPin(pObjectName, pFilter, pLock, phr, pName), CBaseInputPin(pObjectName, pFilter, pLock, phr, pName),
m_bAtEndOfStream(FALSE), m_bAtEndOfStream(FALSE),
m_bCompleteNotified(FALSE) m_bCompleteNotified(FALSE)
{ {
} }
#ifdef UNICODE #ifdef UNICODE
CRenderedInputPin::CRenderedInputPin(CHAR *pObjectName, CRenderedInputPin::CRenderedInputPin(__in_opt LPCSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName) : __in_opt LPCWSTR pName) :
CBaseInputPin(pObjectName, pFilter, pLock, phr, pName), CBaseInputPin(pObjectName, pFilter, pLock, phr, pName),
m_bAtEndOfStream(FALSE), m_bAtEndOfStream(FALSE),
m_bCompleteNotified(FALSE) m_bCompleteNotified(FALSE)

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -22,17 +22,17 @@ class CRenderedInputPin : public CBaseInputPin
{ {
public: public:
CRenderedInputPin(TCHAR *pObjectName, CRenderedInputPin(__in_opt LPCTSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#ifdef UNICODE #ifdef UNICODE
CRenderedInputPin(CHAR *pObjectName, CRenderedInputPin(__in_opt LPCSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#endif #endif
// Override methods to track end of stream state // Override methods to track end of stream state

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - efines class hierarchy for streams // Desc: DirectShow base classes - efines class hierarchy for streams
// architecture. // architecture.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -73,9 +73,9 @@ protected:
public: public:
CBaseMediaFilter( CBaseMediaFilter(
const TCHAR *pName, __in_opt LPCTSTR pName,
LPUNKNOWN pUnk, __inout_opt LPUNKNOWN pUnk,
CCritSec *pLock, __in CCritSec *pLock,
REFCLSID clsid); REFCLSID clsid);
virtual ~CBaseMediaFilter(); virtual ~CBaseMediaFilter();
@ -83,21 +83,21 @@ public:
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to say what interfaces we support where // override this to say what interfaces we support where
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);
// //
// --- IPersist method --- // --- IPersist method ---
// //
STDMETHODIMP GetClassID(CLSID *pClsID); STDMETHODIMP GetClassID(__out CLSID *pClsID);
// --- IMediaFilter methods --- // --- IMediaFilter methods ---
STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State); STDMETHODIMP GetState(DWORD dwMSecs, __out FILTER_STATE *State);
STDMETHODIMP SetSyncSource(IReferenceClock *pClock); STDMETHODIMP SetSyncSource(__inout_opt IReferenceClock *pClock);
STDMETHODIMP GetSyncSource(IReferenceClock **pClock); STDMETHODIMP GetSyncSource(__deref_out_opt IReferenceClock **pClock);
// default implementation of Stop and Pause just record the // default implementation of Stop and Pause just record the
// state. Override to activate or de-activate your filter. // state. Override to activate or de-activate your filter.
@ -168,37 +168,37 @@ protected:
public: public:
CBaseFilter( CBaseFilter(
const TCHAR *pName, // Object description __in_opt LPCTSTR pName, // Object description
LPUNKNOWN pUnk, // IUnknown of delegating object __inout_opt LPUNKNOWN pUnk, // IUnknown of delegating object
CCritSec *pLock, // Object who maintains lock __in CCritSec *pLock, // Object who maintains lock
REFCLSID clsid); // The clsid to be used to serialize this filter REFCLSID clsid); // The clsid to be used to serialize this filter
CBaseFilter( CBaseFilter(
TCHAR *pName, // Object description __in_opt LPCTSTR pName, // Object description
LPUNKNOWN pUnk, // IUnknown of delegating object __in_opt LPUNKNOWN pUnk, // IUnknown of delegating object
CCritSec *pLock, // Object who maintains lock __in CCritSec *pLock, // Object who maintains lock
REFCLSID clsid, // The clsid to be used to serialize this filter REFCLSID clsid, // The clsid to be used to serialize this filter
HRESULT *phr); // General OLE return code __inout HRESULT *phr); // General OLE return code
#ifdef UNICODE #ifdef UNICODE
CBaseFilter( CBaseFilter(
const CHAR *pName, // Object description __in_opt LPCSTR pName, // Object description
LPUNKNOWN pUnk, // IUnknown of delegating object __in_opt LPUNKNOWN pUnk, // IUnknown of delegating object
CCritSec *pLock, // Object who maintains lock __in CCritSec *pLock, // Object who maintains lock
REFCLSID clsid); // The clsid to be used to serialize this filter REFCLSID clsid); // The clsid to be used to serialize this filter
CBaseFilter( CBaseFilter(
CHAR *pName, // Object description __in_opt LPCSTR pName, // Object description
LPUNKNOWN pUnk, // IUnknown of delegating object __in_opt LPUNKNOWN pUnk, // IUnknown of delegating object
CCritSec *pLock, // Object who maintains lock __in CCritSec *pLock, // Object who maintains lock
REFCLSID clsid, // The clsid to be used to serialize this filter REFCLSID clsid, // The clsid to be used to serialize this filter
HRESULT *phr); // General OLE return code __inout HRESULT *phr); // General OLE return code
#endif #endif
~CBaseFilter(); ~CBaseFilter();
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to say what interfaces we support where // override this to say what interfaces we support where
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);
#ifdef DEBUG #ifdef DEBUG
STDMETHODIMP_(ULONG) NonDelegatingRelease(); STDMETHODIMP_(ULONG) NonDelegatingRelease();
#endif #endif
@ -207,15 +207,15 @@ public:
// --- IPersist method --- // --- IPersist method ---
// //
STDMETHODIMP GetClassID(CLSID *pClsID); STDMETHODIMP GetClassID(__out CLSID *pClsID);
// --- IMediaFilter methods --- // --- IMediaFilter methods ---
STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State); STDMETHODIMP GetState(DWORD dwMSecs, __out FILTER_STATE *State);
STDMETHODIMP SetSyncSource(IReferenceClock *pClock); STDMETHODIMP SetSyncSource(__in_opt IReferenceClock *pClock);
STDMETHODIMP GetSyncSource(IReferenceClock **pClock); STDMETHODIMP GetSyncSource(__deref_out_opt IReferenceClock **pClock);
// override Stop and Pause so we can activate the pins. // override Stop and Pause so we can activate the pins.
@ -253,27 +253,27 @@ public:
// pin enumerator // pin enumerator
STDMETHODIMP EnumPins( STDMETHODIMP EnumPins(
IEnumPins ** ppEnum); __deref_out IEnumPins ** ppEnum);
// default behaviour of FindPin assumes pin ids are their names // default behaviour of FindPin assumes pin ids are their names
STDMETHODIMP FindPin( STDMETHODIMP FindPin(
LPCWSTR Id, LPCWSTR Id,
IPin ** ppPin __deref_out IPin ** ppPin
); );
STDMETHODIMP QueryFilterInfo( STDMETHODIMP QueryFilterInfo(
FILTER_INFO * pInfo); __out FILTER_INFO * pInfo);
STDMETHODIMP JoinFilterGraph( STDMETHODIMP JoinFilterGraph(
IFilterGraph * pGraph, __inout_opt IFilterGraph * pGraph,
LPCWSTR pName); __in_opt LPCWSTR pName);
// return a Vendor information string. Optional - may return E_NOTIMPL. // return a Vendor information string. Optional - may return E_NOTIMPL.
// memory returned should be freed using CoTaskMemFree // memory returned should be freed using CoTaskMemFree
// default implementation returns E_NOTIMPL // default implementation returns E_NOTIMPL
STDMETHODIMP QueryVendorInfo( STDMETHODIMP QueryVendorInfo(
LPWSTR* pVendorInfo __deref_out LPWSTR* pVendorInfo
); );
// --- helper methods --- // --- helper methods ---
@ -287,7 +287,7 @@ public:
LONG_PTR EventParam2); LONG_PTR EventParam2);
// return the filter graph we belong to // return the filter graph we belong to
IFilterGraph *GetFilterGraph() { __out_opt IFilterGraph *GetFilterGraph() {
return m_pGraph; return m_pGraph;
} }
@ -295,7 +295,7 @@ public:
// pPin is the pin to reconnect // pPin is the pin to reconnect
// pmt is the type to reconnect with - can be NULL // pmt is the type to reconnect with - can be NULL
// Calls ReconnectEx on the filter graph // Calls ReconnectEx on the filter graph
HRESULT ReconnectPin(IPin *pPin, AM_MEDIA_TYPE const *pmt); HRESULT ReconnectPin(IPin *pPin, __in_opt AM_MEDIA_TYPE const *pmt);
// find out the current pin version (used by enumerators) // find out the current pin version (used by enumerators)
virtual LONG GetPinVersion(); virtual LONG GetPinVersion();
@ -314,7 +314,7 @@ public:
// --- setup helper methods --- // --- setup helper methods ---
// (override to return filters setup data) // (override to return filters setup data)
virtual LPAMOVIESETUP_FILTER GetSetupData(){ return NULL; } virtual __out_opt LPAMOVIESETUP_FILTER GetSetupData(){ return NULL; }
}; };
@ -376,8 +376,8 @@ protected:
// try all the media types in this enumerator - for each that // try all the media types in this enumerator - for each that
// we accept, try to connect using ReceiveConnection. // we accept, try to connect using ReceiveConnection.
HRESULT TryMediaTypes( HRESULT TryMediaTypes(
IPin *pReceivePin, // connect to this pin IPin *pReceivePin, // connect to this pin
const CMediaType *pmt, // proposed type from Connect __in_opt const CMediaType *pmt, // proposed type from Connect
IEnumMediaTypes *pEnum); // try this enumerator IEnumMediaTypes *pEnum); // try this enumerator
// establish a connection with a suitable mediatype. Needs to // establish a connection with a suitable mediatype. Needs to
@ -386,31 +386,31 @@ protected:
// enumerator until we find one that works. // enumerator until we find one that works.
HRESULT AgreeMediaType( HRESULT AgreeMediaType(
IPin *pReceivePin, // connect to this pin IPin *pReceivePin, // connect to this pin
const CMediaType *pmt); // proposed type from Connect const CMediaType *pmt); // proposed type from Connect
public: public:
CBasePin( CBasePin(
TCHAR *pObjectName, // Object description __in_opt LPCTSTR pObjectName, // Object description
CBaseFilter *pFilter, // Owning filter who knows about pins __in CBaseFilter *pFilter, // Owning filter who knows about pins
CCritSec *pLock, // Object who implements the lock __in CCritSec *pLock, // Object who implements the lock
HRESULT *phr, // General OLE return code __inout HRESULT *phr, // General OLE return code
LPCWSTR pName, // Pin name for us __in_opt LPCWSTR pName, // Pin name for us
PIN_DIRECTION dir); // Either PINDIR_INPUT or PINDIR_OUTPUT PIN_DIRECTION dir); // Either PINDIR_INPUT or PINDIR_OUTPUT
#ifdef UNICODE #ifdef UNICODE
CBasePin( CBasePin(
CHAR *pObjectName, // Object description __in_opt LPCSTR pObjectName, // Object description
CBaseFilter *pFilter, // Owning filter who knows about pins __in CBaseFilter *pFilter, // Owning filter who knows about pins
CCritSec *pLock, // Object who implements the lock __in CCritSec *pLock, // Object who implements the lock
HRESULT *phr, // General OLE return code __inout HRESULT *phr, // General OLE return code
LPCWSTR pName, // Pin name for us __in_opt LPCWSTR pName, // Pin name for us
PIN_DIRECTION dir); // Either PINDIR_INPUT or PINDIR_OUTPUT PIN_DIRECTION dir); // Either PINDIR_INPUT or PINDIR_OUTPUT
#endif #endif
virtual ~CBasePin(); virtual ~CBasePin();
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);
STDMETHODIMP_(ULONG) NonDelegatingRelease(); STDMETHODIMP_(ULONG) NonDelegatingRelease();
STDMETHODIMP_(ULONG) NonDelegatingAddRef(); STDMETHODIMP_(ULONG) NonDelegatingAddRef();
@ -421,7 +421,7 @@ public:
// (subtype or format type may be GUID_NULL). // (subtype or format type may be GUID_NULL).
STDMETHODIMP Connect( STDMETHODIMP Connect(
IPin * pReceivePin, IPin * pReceivePin,
const AM_MEDIA_TYPE *pmt // optional media type __in_opt const AM_MEDIA_TYPE *pmt // optional media type
); );
// (passive) accept a connection from another pin // (passive) accept a connection from another pin
@ -432,20 +432,20 @@ public:
STDMETHODIMP Disconnect(); STDMETHODIMP Disconnect();
STDMETHODIMP ConnectedTo(IPin **pPin); STDMETHODIMP ConnectedTo(__deref_out IPin **pPin);
STDMETHODIMP ConnectionMediaType(AM_MEDIA_TYPE *pmt); STDMETHODIMP ConnectionMediaType(__out AM_MEDIA_TYPE *pmt);
STDMETHODIMP QueryPinInfo( STDMETHODIMP QueryPinInfo(
PIN_INFO * pInfo __out PIN_INFO * pInfo
); );
STDMETHODIMP QueryDirection( STDMETHODIMP QueryDirection(
PIN_DIRECTION * pPinDir __out PIN_DIRECTION * pPinDir
); );
STDMETHODIMP QueryId( STDMETHODIMP QueryId(
LPWSTR * Id __deref_out LPWSTR * Id
); );
// does the pin support this media type // does the pin support this media type
@ -455,7 +455,7 @@ public:
// return an enumerator for this pins preferred media types // return an enumerator for this pins preferred media types
STDMETHODIMP EnumMediaTypes( STDMETHODIMP EnumMediaTypes(
IEnumMediaTypes **ppEnum __deref_out IEnumMediaTypes **ppEnum
); );
// return an array of IPin* - the pins that this pin internally connects to // return an array of IPin* - the pins that this pin internally connects to
@ -466,9 +466,9 @@ public:
// all visible output pins and vice versa. // all visible output pins and vice versa.
// apPin can be NULL if nPin==0 (not otherwise). // apPin can be NULL if nPin==0 (not otherwise).
STDMETHODIMP QueryInternalConnections( STDMETHODIMP QueryInternalConnections(
IPin* *apPin, // array of IPin* __out_ecount_part(*nPin,*nPin) IPin* *apPin, // array of IPin*
ULONG *nPin // on input, the number of slots __inout ULONG *nPin // on input, the number of slots
// on output the number of pins // on output the number of pins
) { return E_NOTIMPL; } ) { return E_NOTIMPL; }
// Called when no more data will be sent // Called when no more data will be sent
@ -534,7 +534,7 @@ public:
virtual HRESULT CompleteConnect(IPin *pReceivePin); virtual HRESULT CompleteConnect(IPin *pReceivePin);
// returns the preferred formats for a pin // returns the preferred formats for a pin
virtual HRESULT GetMediaType(int iPosition,CMediaType *pMediaType); virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType);
// access to NewSegment values // access to NewSegment values
REFERENCE_TIME CurrentStopTime() { REFERENCE_TIME CurrentStopTime() {
@ -616,26 +616,26 @@ class CEnumPins : public IEnumPins // The interface we support
public: public:
CEnumPins( CEnumPins(
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CEnumPins *pEnumPins); __in_opt CEnumPins *pEnumPins);
virtual ~CEnumPins(); virtual ~CEnumPins();
// IUnknown // IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void **ppv); STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);
STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release(); STDMETHODIMP_(ULONG) Release();
// IEnumPins // IEnumPins
STDMETHODIMP Next( STDMETHODIMP Next(
ULONG cPins, // place this many pins... ULONG cPins, // place this many pins...
IPin ** ppPins, // ...in this array of IPin* __out_ecount(cPins) IPin ** ppPins, // ...in this array of IPin*
ULONG * pcFetched // actual count passed returned here __out_opt ULONG * pcFetched // actual count passed returned here
); );
STDMETHODIMP Skip(ULONG cPins); STDMETHODIMP Skip(ULONG cPins);
STDMETHODIMP Reset(); STDMETHODIMP Reset();
STDMETHODIMP Clone(IEnumPins **ppEnum); STDMETHODIMP Clone(__deref_out IEnumPins **ppEnum);
}; };
@ -672,26 +672,26 @@ class CEnumMediaTypes : public IEnumMediaTypes // The interface we support
public: public:
CEnumMediaTypes( CEnumMediaTypes(
CBasePin *pPin, __in CBasePin *pPin,
CEnumMediaTypes *pEnumMediaTypes); __in_opt CEnumMediaTypes *pEnumMediaTypes);
virtual ~CEnumMediaTypes(); virtual ~CEnumMediaTypes();
// IUnknown // IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void **ppv); STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);
STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release(); STDMETHODIMP_(ULONG) Release();
// IEnumMediaTypes // IEnumMediaTypes
STDMETHODIMP Next( STDMETHODIMP Next(
ULONG cMediaTypes, // place this many pins... ULONG cMediaTypes, // place this many pins...
AM_MEDIA_TYPE ** ppMediaTypes, // ...in this array __out_ecount(cMediaTypes) AM_MEDIA_TYPE ** ppMediaTypes, // ...in this array
ULONG * pcFetched // actual count passed __out_opt ULONG * pcFetched // actual count passed
); );
STDMETHODIMP Skip(ULONG cMediaTypes); STDMETHODIMP Skip(ULONG cMediaTypes);
STDMETHODIMP Reset(); STDMETHODIMP Reset();
STDMETHODIMP Clone(IEnumMediaTypes **ppEnum); STDMETHODIMP Clone(__deref_out IEnumMediaTypes **ppEnum);
}; };
@ -721,25 +721,25 @@ protected:
public: public:
CBaseOutputPin( CBaseOutputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#ifdef UNICODE #ifdef UNICODE
CBaseOutputPin( CBaseOutputPin(
CHAR *pObjectName, __in_opt LPCSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#endif #endif
// override CompleteConnect() so we can negotiate an allocator // override CompleteConnect() so we can negotiate an allocator
virtual HRESULT CompleteConnect(IPin *pReceivePin); virtual HRESULT CompleteConnect(IPin *pReceivePin);
// negotiate the allocator and its buffer size/count and other properties // negotiate the allocator and its buffer size/count and other properties
// Calls DecideBufferSize to set properties // Calls DecideBufferSize to set properties
virtual HRESULT DecideAllocator(IMemInputPin * pPin, IMemAllocator ** pAlloc); virtual HRESULT DecideAllocator(IMemInputPin * pPin, __deref_out IMemAllocator ** pAlloc);
// override this to set the buffer size and count. Return an error // override this to set the buffer size and count. Return an error
// if the size/count is not to your liking. // if the size/count is not to your liking.
@ -748,13 +748,13 @@ public:
// no preference on these. // no preference on these.
virtual HRESULT DecideBufferSize( virtual HRESULT DecideBufferSize(
IMemAllocator * pAlloc, IMemAllocator * pAlloc,
ALLOCATOR_PROPERTIES * ppropInputRequest __inout ALLOCATOR_PROPERTIES * ppropInputRequest
) PURE; ) PURE;
// returns an empty sample buffer from the allocator // returns an empty sample buffer from the allocator
virtual HRESULT GetDeliveryBuffer(IMediaSample ** ppSample, virtual HRESULT GetDeliveryBuffer(__deref_out IMediaSample ** ppSample,
REFERENCE_TIME * pStartTime, __in_opt REFERENCE_TIME * pStartTime,
REFERENCE_TIME * pEndTime, __in_opt REFERENCE_TIME * pEndTime,
DWORD dwFlags); DWORD dwFlags);
// deliver a filled-in sample to the connected input pin // deliver a filled-in sample to the connected input pin
@ -764,7 +764,7 @@ public:
virtual HRESULT Deliver(IMediaSample *); virtual HRESULT Deliver(IMediaSample *);
// override this to control the connection // override this to control the connection
virtual HRESULT InitAllocator(IMemAllocator **ppAlloc); virtual HRESULT InitAllocator(__deref_out IMemAllocator **ppAlloc);
HRESULT CheckConnect(IPin *pPin); HRESULT CheckConnect(IPin *pPin);
HRESULT BreakConnect(); HRESULT BreakConnect();
@ -839,29 +839,29 @@ protected:
public: public:
CBaseInputPin( CBaseInputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#ifdef UNICODE #ifdef UNICODE
CBaseInputPin( CBaseInputPin(
CHAR *pObjectName, __in_opt LPCSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#endif #endif
virtual ~CBaseInputPin(); virtual ~CBaseInputPin();
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
// return the allocator interface that this input pin // return the allocator interface that this input pin
// would like the output pin to use // would like the output pin to use
STDMETHODIMP GetAllocator(IMemAllocator ** ppAllocator); STDMETHODIMP GetAllocator(__deref_out IMemAllocator ** ppAllocator);
// tell the input pin which allocator the output pin is actually // tell the input pin which allocator the output pin is actually
// going to use. // going to use.
@ -874,9 +874,9 @@ public:
// do something with these media samples // do something with these media samples
STDMETHODIMP ReceiveMultiple ( STDMETHODIMP ReceiveMultiple (
IMediaSample **pSamples, __in_ecount(nSamples) IMediaSample **pSamples,
long nSamples, long nSamples,
long *nSamplesProcessed); __out long *nSamplesProcessed);
// See if Receive() blocks // See if Receive() blocks
STDMETHODIMP ReceiveCanBlock(); STDMETHODIMP ReceiveCanBlock();
@ -898,7 +898,7 @@ public:
// default implementation returns E_NOTIMPL. Override if you have // default implementation returns E_NOTIMPL. Override if you have
// specific alignment or prefix needs, but could use an upstream // specific alignment or prefix needs, but could use an upstream
// allocator // allocator
STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES*pProps); STDMETHODIMP GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES*pProps);
// Release the pin's allocator. // Release the pin's allocator.
HRESULT BreakConnect(); HRESULT BreakConnect();
@ -952,25 +952,25 @@ class CDynamicOutputPin : public CBaseOutputPin,
public: public:
#ifdef UNICODE #ifdef UNICODE
CDynamicOutputPin( CDynamicOutputPin(
CHAR *pObjectName, __in_opt LPCSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#endif #endif
CDynamicOutputPin( CDynamicOutputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CBaseFilter *pFilter, __in CBaseFilter *pFilter,
CCritSec *pLock, __in CCritSec *pLock,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
~CDynamicOutputPin(); ~CDynamicOutputPin();
// IUnknown Methods // IUnknown Methods
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
// IPin Methods // IPin Methods
STDMETHODIMP Disconnect(void); STDMETHODIMP Disconnect(void);
@ -1083,14 +1083,14 @@ private:
class CAutoUsingOutputPin class CAutoUsingOutputPin
{ {
public: public:
CAutoUsingOutputPin( CDynamicOutputPin* pOutputPin, HRESULT* phr ); CAutoUsingOutputPin( __in CDynamicOutputPin* pOutputPin, __inout HRESULT* phr );
~CAutoUsingOutputPin(); ~CAutoUsingOutputPin();
private: private:
CDynamicOutputPin* m_pOutputPin; CDynamicOutputPin* m_pOutputPin;
}; };
inline CAutoUsingOutputPin::CAutoUsingOutputPin( CDynamicOutputPin* pOutputPin, HRESULT* phr ) : inline CAutoUsingOutputPin::CAutoUsingOutputPin( __in CDynamicOutputPin* pOutputPin, __inout HRESULT* phr ) :
m_pOutputPin(NULL) m_pOutputPin(NULL)
{ {
// The caller should always pass in valid pointers. // The caller should always pass in valid pointers.
@ -1213,7 +1213,7 @@ protected:
into the top word into the top word
*/ */
DWORD m_dwTypeSpecificFlags; /* Media type specific flags */ DWORD m_dwTypeSpecificFlags; /* Media type specific flags */
LPBYTE m_pBuffer; /* Pointer to the complete buffer */ __field_ecount_opt(m_cbBuffer) LPBYTE m_pBuffer; /* Pointer to the complete buffer */
LONG m_lActual; /* Length of data in this sample */ LONG m_lActual; /* Length of data in this sample */
LONG m_cbBuffer; /* Size of the buffer */ LONG m_cbBuffer; /* Size of the buffer */
CBaseAllocator *m_pAllocator; /* The allocator who owns us */ CBaseAllocator *m_pAllocator; /* The allocator who owns us */
@ -1231,17 +1231,17 @@ public:
public: public:
CMediaSample( CMediaSample(
TCHAR *pName, __in_opt LPCTSTR pName,
CBaseAllocator *pAllocator, __in_opt CBaseAllocator *pAllocator,
HRESULT *phr, __inout_opt HRESULT *phr,
LPBYTE pBuffer = NULL, __in_bcount_opt(length) LPBYTE pBuffer = NULL,
LONG length = 0); LONG length = 0);
#ifdef UNICODE #ifdef UNICODE
CMediaSample( CMediaSample(
CHAR *pName, __in_opt LPCSTR pName,
CBaseAllocator *pAllocator, __in_opt CBaseAllocator *pAllocator,
HRESULT *phr, __inout_opt HRESULT *phr,
LPBYTE pBuffer = NULL, __in_bcount_opt(length) LPBYTE pBuffer = NULL,
LONG length = 0); LONG length = 0);
#endif #endif
@ -1249,7 +1249,7 @@ public:
/* Note the media sample does not delegate to its owner */ /* Note the media sample does not delegate to its owner */
STDMETHODIMP QueryInterface(REFIID riid, void **ppv); STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);
STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release(); STDMETHODIMP_(ULONG) Release();
@ -1257,23 +1257,23 @@ public:
// want variable sized pointers or pointers into already-read data. // want variable sized pointers or pointers into already-read data.
// This is only available through a CMediaSample* not an IMediaSample* // This is only available through a CMediaSample* not an IMediaSample*
// and so cannot be changed by clients. // and so cannot be changed by clients.
HRESULT SetPointer(BYTE * ptr, LONG cBytes); HRESULT SetPointer(__in_bcount(cBytes) BYTE * ptr, LONG cBytes);
// Get me a read/write pointer to this buffer's memory. // Get me a read/write pointer to this buffer's memory.
STDMETHODIMP GetPointer(BYTE ** ppBuffer); STDMETHODIMP GetPointer(__deref_out BYTE ** ppBuffer);
STDMETHODIMP_(LONG) GetSize(void); STDMETHODIMP_(LONG) GetSize(void);
// get the stream time at which this sample should start and finish. // get the stream time at which this sample should start and finish.
STDMETHODIMP GetTime( STDMETHODIMP GetTime(
REFERENCE_TIME * pTimeStart, // put time here __out REFERENCE_TIME * pTimeStart, // put time here
REFERENCE_TIME * pTimeEnd __out REFERENCE_TIME * pTimeEnd
); );
// Set the stream time at which this sample should start and finish. // Set the stream time at which this sample should start and finish.
STDMETHODIMP SetTime( STDMETHODIMP SetTime(
REFERENCE_TIME * pTimeStart, // put time here __in_opt REFERENCE_TIME * pTimeStart, // put time here
REFERENCE_TIME * pTimeEnd __in_opt REFERENCE_TIME * pTimeEnd
); );
STDMETHODIMP IsSyncPoint(void); STDMETHODIMP IsSyncPoint(void);
STDMETHODIMP SetSyncPoint(BOOL bIsSyncPoint); STDMETHODIMP SetSyncPoint(BOOL bIsSyncPoint);
@ -1285,8 +1285,8 @@ public:
// these allow for limited format changes in band // these allow for limited format changes in band
STDMETHODIMP GetMediaType(AM_MEDIA_TYPE **ppMediaType); STDMETHODIMP GetMediaType(__deref_out AM_MEDIA_TYPE **ppMediaType);
STDMETHODIMP SetMediaType(AM_MEDIA_TYPE *pMediaType); STDMETHODIMP SetMediaType(__in_opt AM_MEDIA_TYPE *pMediaType);
// returns S_OK if there is a discontinuity in the data (this same is // returns S_OK if there is a discontinuity in the data (this same is
// not a continuation of the previous stream of data // not a continuation of the previous stream of data
@ -1298,25 +1298,25 @@ public:
// get the media times for this sample // get the media times for this sample
STDMETHODIMP GetMediaTime( STDMETHODIMP GetMediaTime(
LONGLONG * pTimeStart, __out LONGLONG * pTimeStart,
LONGLONG * pTimeEnd __out LONGLONG * pTimeEnd
); );
// Set the media times for this sample // Set the media times for this sample
STDMETHODIMP SetMediaTime( STDMETHODIMP SetMediaTime(
LONGLONG * pTimeStart, __in_opt LONGLONG * pTimeStart,
LONGLONG * pTimeEnd __in_opt LONGLONG * pTimeEnd
); );
// Set and get properties (IMediaSample2) // Set and get properties (IMediaSample2)
STDMETHODIMP GetProperties( STDMETHODIMP GetProperties(
DWORD cbProperties, DWORD cbProperties,
BYTE * pbProperties __out_bcount(cbProperties) BYTE * pbProperties
); );
STDMETHODIMP SetProperties( STDMETHODIMP SetProperties(
DWORD cbProperties, DWORD cbProperties,
const BYTE * pbProperties __in_bcount(cbProperties) const BYTE * pbProperties
); );
}; };
@ -1344,7 +1344,7 @@ class AM_NOVTABLE CBaseAllocator : public CUnknown,// A non delegating IUnknown
friend class CSampleList; friend class CSampleList;
/* Trick to get at protected member in CMediaSample */ /* Trick to get at protected member in CMediaSample */
static CMediaSample * &NextSample(CMediaSample *pSample) static CMediaSample * &NextSample(__in CMediaSample *pSample)
{ {
return pSample->m_pNext; return pSample->m_pNext;
}; };
@ -1361,9 +1361,9 @@ class AM_NOVTABLE CBaseAllocator : public CUnknown,// A non delegating IUnknown
}; };
#endif #endif
CMediaSample *Head() const { return m_List; }; CMediaSample *Head() const { return m_List; };
CMediaSample *Next(CMediaSample *pSample) const { return CBaseAllocator::NextSample(pSample); }; CMediaSample *Next(__in CMediaSample *pSample) const { return CBaseAllocator::NextSample(pSample); };
int GetCount() const { return m_nOnList; }; int GetCount() const { return m_nOnList; };
void Add(CMediaSample *pSample) void Add(__inout CMediaSample *pSample)
{ {
ASSERT(pSample != NULL); ASSERT(pSample != NULL);
CBaseAllocator::NextSample(pSample) = m_List; CBaseAllocator::NextSample(pSample) = m_List;
@ -1379,7 +1379,7 @@ class AM_NOVTABLE CBaseAllocator : public CUnknown,// A non delegating IUnknown
} }
return pSample; return pSample;
}; };
void Remove(CMediaSample *pSample); void Remove(__inout CMediaSample *pSample);
public: public:
CMediaSample *m_List; CMediaSample *m_List;
@ -1455,11 +1455,11 @@ protected:
public: public:
CBaseAllocator( CBaseAllocator(
TCHAR *, LPUNKNOWN, HRESULT *, __in_opt LPCTSTR , __inout_opt LPUNKNOWN, __inout HRESULT *,
BOOL bEvent = TRUE, BOOL fEnableReleaseCallback = FALSE); BOOL bEvent = TRUE, BOOL fEnableReleaseCallback = FALSE);
#ifdef UNICODE #ifdef UNICODE
CBaseAllocator( CBaseAllocator(
CHAR *, LPUNKNOWN, HRESULT *, __in_opt LPCSTR , __inout_opt LPUNKNOWN, __inout HRESULT *,
BOOL bEvent = TRUE, BOOL fEnableReleaseCallback = FALSE); BOOL bEvent = TRUE, BOOL fEnableReleaseCallback = FALSE);
#endif #endif
virtual ~CBaseAllocator(); virtual ~CBaseAllocator();
@ -1467,15 +1467,15 @@ public:
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
STDMETHODIMP SetProperties( STDMETHODIMP SetProperties(
ALLOCATOR_PROPERTIES* pRequest, __in ALLOCATOR_PROPERTIES* pRequest,
ALLOCATOR_PROPERTIES* pActual); __out ALLOCATOR_PROPERTIES* pActual);
// return the properties actually being used on this allocator // return the properties actually being used on this allocator
STDMETHODIMP GetProperties( STDMETHODIMP GetProperties(
ALLOCATOR_PROPERTIES* pProps); __out ALLOCATOR_PROPERTIES* pProps);
// override Commit to allocate memory. We handle the GetBuffer // override Commit to allocate memory. We handle the GetBuffer
//state changes //state changes
@ -1494,9 +1494,9 @@ public:
// bPrevFramesSkipped is not used (used only by the video renderer's // bPrevFramesSkipped is not used (used only by the video renderer's
// allocator where it affects quality management in direct draw). // allocator where it affects quality management in direct draw).
STDMETHODIMP GetBuffer(IMediaSample **ppBuffer, STDMETHODIMP GetBuffer(__deref_out IMediaSample **ppBuffer,
REFERENCE_TIME * pStartTime, __in_opt REFERENCE_TIME * pStartTime,
REFERENCE_TIME * pEndTime, __in_opt REFERENCE_TIME * pEndTime,
DWORD dwFlags); DWORD dwFlags);
// final release of a CMediaSample will call this // final release of a CMediaSample will call this
@ -1505,7 +1505,7 @@ public:
STDMETHODIMP SetNotify(IMemAllocatorNotifyCallbackTemp *pNotify); STDMETHODIMP SetNotify(IMemAllocatorNotifyCallbackTemp *pNotify);
STDMETHODIMP GetFreeCount(LONG *plBuffersFree); STDMETHODIMP GetFreeCount(__out LONG *plBuffersFree);
// Notify that a sample is available // Notify that a sample is available
void NotifySample(); void NotifySample();
@ -1532,7 +1532,7 @@ public:
//===================================================================== //=====================================================================
// Make me one from quartz.dll // Make me one from quartz.dll
STDAPI CreateMemoryAllocator(IMemAllocator **ppAllocator); STDAPI CreateMemoryAllocator(__deref_out IMemAllocator **ppAllocator);
class CMemAllocator : public CBaseAllocator class CMemAllocator : public CBaseAllocator
{ {
@ -1554,15 +1554,15 @@ protected:
public: public:
/* This goes in the factory template table to create new instances */ /* This goes in the factory template table to create new instances */
static CUnknown *CreateInstance(LPUNKNOWN, HRESULT *); static CUnknown *CreateInstance(__inout_opt LPUNKNOWN, __inout HRESULT *);
STDMETHODIMP SetProperties( STDMETHODIMP SetProperties(
ALLOCATOR_PROPERTIES* pRequest, __in ALLOCATOR_PROPERTIES* pRequest,
ALLOCATOR_PROPERTIES* pActual); __out ALLOCATOR_PROPERTIES* pActual);
CMemAllocator(TCHAR *, LPUNKNOWN, HRESULT *); CMemAllocator(__in_opt LPCTSTR , __inout_opt LPUNKNOWN, __inout HRESULT *);
#ifdef UNICODE #ifdef UNICODE
CMemAllocator(CHAR *, LPUNKNOWN, HRESULT *); CMemAllocator(__in_opt LPCSTR , __inout_opt LPUNKNOWN, __inout HRESULT *);
#endif #endif
~CMemAllocator(); ~CMemAllocator();
}; };

View File

@ -4,11 +4,11 @@
// Desc: DirectShow base classes - implements helper functions for // Desc: DirectShow base classes - implements helper functions for
// bitmap formats. // bitmap formats.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include <limits.h> #include <limits.h>
// These are bit field masks for true colour devices // These are bit field masks for true colour devices

View File

@ -56,7 +56,6 @@
<ClInclude Include="combase.h" /> <ClInclude Include="combase.h" />
<ClInclude Include="ctlutil.h" /> <ClInclude Include="ctlutil.h" />
<ClInclude Include="ddmm.h" /> <ClInclude Include="ddmm.h" />
<ClInclude Include="dsschedule.h" />
<ClInclude Include="fourcc.h" /> <ClInclude Include="fourcc.h" />
<ClInclude Include="measure.h" /> <ClInclude Include="measure.h" />
<ClInclude Include="msgthrd.h" /> <ClInclude Include="msgthrd.h" />
@ -109,10 +108,6 @@
<ClCompile Include="wxlist.cpp" /> <ClCompile Include="wxlist.cpp" />
<ClCompile Include="wxutil.cpp" /> <ClCompile Include="wxutil.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="activex.rcv" />
<None Include="activex.ver" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" /> <ImportGroup Label="ExtensionTargets" />
</Project> </Project>

View File

@ -36,9 +36,6 @@
<ClInclude Include="fourcc.h"> <ClInclude Include="fourcc.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="dsschedule.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="msgthrd.h"> <ClInclude Include="msgthrd.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -174,12 +171,4 @@
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="activex.ver">
<Filter>Resource Files</Filter>
</None>
<None Include="activex.rcv">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes - efines a non-MFC generic cache class. // Desc: DirectShow base classes - efines a non-MFC generic cache class.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -54,11 +54,11 @@ private:
public: public:
CCache(TCHAR *pName,INT iItems); CCache(__in_opt LPCTSTR pName,INT iItems);
virtual ~CCache(); virtual ~CCache();
/* Add an item to the cache */ /* Add an item to the cache */
CBaseObject *AddToCache(CBaseObject *pObject); CBaseObject *AddToCache(__in CBaseObject *pObject);
/* Remove an item from the cache */ /* Remove an item from the cache */
CBaseObject *RemoveFromCache(); CBaseObject *RemoveFromCache();

View File

@ -4,11 +4,11 @@
// Desc: DirectShow base classes - implements class hierarchy for creating // Desc: DirectShow base classes - implements class hierarchy for creating
// COM objects. // COM objects.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#pragma warning( disable : 4514 ) // Disable warnings re unused inline functions #pragma warning( disable : 4514 ) // Disable warnings re unused inline functions
@ -19,7 +19,7 @@ LONG CBaseObject::m_cObjects = 0;
/* Constructor */ /* Constructor */
CBaseObject::CBaseObject(const TCHAR *pName) CBaseObject::CBaseObject(__in_opt LPCTSTR pName)
{ {
/* Increment the number of active objects */ /* Increment the number of active objects */
InterlockedIncrement(&m_cObjects); InterlockedIncrement(&m_cObjects);
@ -85,7 +85,7 @@ HINSTANCE LoadOLEAut32()
// We know we use "this" in the initialization list, we also know we don't modify *phr. // We know we use "this" in the initialization list, we also know we don't modify *phr.
#pragma warning( disable : 4355 4100 ) #pragma warning( disable : 4355 4100 )
CUnknown::CUnknown(const TCHAR *pName, LPUNKNOWN pUnk) CUnknown::CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk)
: CBaseObject(pName) : CBaseObject(pName)
/* Start the object with a reference count of zero - when the */ /* Start the object with a reference count of zero - when the */
/* object is queried for it's first interface this may be */ /* object is queried for it's first interface this may be */
@ -107,7 +107,7 @@ CUnknown::CUnknown(const TCHAR *pName, LPUNKNOWN pUnk)
// This does the same as above except it has a useless HRESULT argument // This does the same as above except it has a useless HRESULT argument
// use the previous constructor, this is just left for compatibility... // use the previous constructor, this is just left for compatibility...
CUnknown::CUnknown(TCHAR *pName, LPUNKNOWN pUnk,HRESULT *phr) : CUnknown::CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr) :
CBaseObject(pName), CBaseObject(pName),
m_cRef(0), m_cRef(0),
m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) ) m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) )
@ -115,12 +115,12 @@ CUnknown::CUnknown(TCHAR *pName, LPUNKNOWN pUnk,HRESULT *phr) :
} }
#ifdef UNICODE #ifdef UNICODE
CUnknown::CUnknown(const CHAR *pName, LPUNKNOWN pUnk) CUnknown::CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk)
: CBaseObject(pName), m_cRef(0), : CBaseObject(pName), m_cRef(0),
m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) ) m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) )
{ } { }
CUnknown::CUnknown(CHAR *pName, LPUNKNOWN pUnk,HRESULT *phr) : CUnknown::CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr) :
CBaseObject(pName), m_cRef(0), CBaseObject(pName), m_cRef(0),
m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) ) m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) )
{ } { }
@ -132,7 +132,7 @@ CUnknown::CUnknown(CHAR *pName, LPUNKNOWN pUnk,HRESULT *phr) :
/* QueryInterface */ /* QueryInterface */
STDMETHODIMP CUnknown::NonDelegatingQueryInterface(REFIID riid, void ** ppv) STDMETHODIMP CUnknown::NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv)
{ {
CheckPointer(ppv,E_POINTER); CheckPointer(ppv,E_POINTER);
ValidateReadWritePtr(ppv,sizeof(PVOID)); ValidateReadWritePtr(ppv,sizeof(PVOID));
@ -200,7 +200,9 @@ STDMETHODIMP_(ULONG) CUnknown::NonDelegatingRelease()
delete this; delete this;
return ULONG(0); return ULONG(0);
} else { } else {
return ourmax(ULONG(m_cRef), 1ul); // Don't touch m_cRef again even in this leg as the object
// may have just been released on another thread too
return ourmax(ULONG(lRef), 1ul);
} }
} }
@ -208,7 +210,7 @@ STDMETHODIMP_(ULONG) CUnknown::NonDelegatingRelease()
/* Return an interface pointer to a requesting client /* Return an interface pointer to a requesting client
performing a thread safe AddRef as necessary */ performing a thread safe AddRef as necessary */
STDAPI GetInterface(LPUNKNOWN pUnk, void **ppv) STDAPI GetInterface(LPUNKNOWN pUnk, __out void **ppv)
{ {
CheckPointer(ppv, E_POINTER); CheckPointer(ppv, E_POINTER);
*ppv = pUnk; *ppv = pUnk;
@ -240,16 +242,23 @@ BOOL WINAPI IsEqualObject(IUnknown *pFirst, IUnknown *pSecond)
/* See if the IUnknown pointers match */ /* See if the IUnknown pointers match */
hr = pFirst->QueryInterface(IID_IUnknown,(void **) &pUnknown1); hr = pFirst->QueryInterface(IID_IUnknown,(void **) &pUnknown1);
ASSERT(SUCCEEDED(hr)); if (FAILED(hr)) {
return FALSE;
}
ASSERT(pUnknown1); ASSERT(pUnknown1);
hr = pSecond->QueryInterface(IID_IUnknown,(void **) &pUnknown2); /* Release the extra interface we hold */
ASSERT(SUCCEEDED(hr));
ASSERT(pUnknown2);
/* Release the extra interfaces we hold */
pUnknown1->Release(); pUnknown1->Release();
hr = pSecond->QueryInterface(IID_IUnknown,(void **) &pUnknown2);
if (FAILED(hr)) {
return FALSE;
}
ASSERT(pUnknown2);
/* Release the extra interface we hold */
pUnknown2->Release(); pUnknown2->Release();
return (pUnknown1 == pUnknown2); return (pUnknown1 == pUnknown2);
} }

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines a class hierarchy for creating // Desc: DirectShow base classes - defines a class hierarchy for creating
// COM objects. // COM objects.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -179,9 +179,9 @@ public:
/* These increment and decrement the number of active objects */ /* These increment and decrement the number of active objects */
CBaseObject(const TCHAR *pName); CBaseObject(__in_opt LPCTSTR pName);
#ifdef UNICODE #ifdef UNICODE
CBaseObject(const char *pName); CBaseObject(__in_opt LPCSTR pName);
#endif #endif
~CBaseObject(); ~CBaseObject();
@ -208,15 +208,15 @@ protected: /* So we can override NonDelegatingRelease() */
public: public:
CUnknown(const TCHAR *pName, LPUNKNOWN pUnk); CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk);
virtual ~CUnknown() {}; virtual ~CUnknown() {};
// This is redundant, just use the other constructor // This is redundant, just use the other constructor
// as we never touch the HRESULT in this anyway // as we never touch the HRESULT in this anyway
CUnknown(TCHAR *pName, LPUNKNOWN pUnk,HRESULT *phr); CUnknown(__in_opt LPCTSTR Name, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr);
#ifdef UNICODE #ifdef UNICODE
CUnknown(const char *pName, LPUNKNOWN pUnk); CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk);
CUnknown(char *pName, LPUNKNOWN pUnk,HRESULT *phr); CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk,__inout_opt HRESULT *phr);
#endif #endif
/* Return the owner of this object */ /* Return the owner of this object */
@ -232,33 +232,19 @@ public:
/* Non delegating unknown implementation */ /* Non delegating unknown implementation */
STDMETHODIMP NonDelegatingQueryInterface(REFIID, void **); STDMETHODIMP NonDelegatingQueryInterface(REFIID, __deref_out void **);
STDMETHODIMP_(ULONG) NonDelegatingAddRef(); STDMETHODIMP_(ULONG) NonDelegatingAddRef();
STDMETHODIMP_(ULONG) NonDelegatingRelease(); STDMETHODIMP_(ULONG) NonDelegatingRelease();
}; };
#if (_MSC_VER <= 1200)
#pragma warning(disable:4211)
/* The standard InterlockedXXX functions won't take volatiles */
static inline LONG WINAPI InterlockedIncrement( volatile LONG * plong )
{ return InterlockedIncrement( const_cast<LONG*>( plong ) ); }
static inline LONG WINAPI InterlockedDecrement( volatile LONG * plong )
{ return InterlockedDecrement( const_cast<LONG*>( plong ) ); }
#pragma warning(default:4211)
#endif
/* Return an interface pointer to a requesting client /* Return an interface pointer to a requesting client
performing a thread safe AddRef as necessary */ performing a thread safe AddRef as necessary */
STDAPI GetInterface(LPUNKNOWN pUnk, void **ppv); STDAPI GetInterface(LPUNKNOWN pUnk, __out void **ppv);
/* A function that can create a new COM object */ /* A function that can create a new COM object */
typedef CUnknown *(CALLBACK *LPFNNewCOMObject)(LPUNKNOWN pUnkOuter, HRESULT *phr); typedef CUnknown *(CALLBACK *LPFNNewCOMObject)(__in_opt LPUNKNOWN pUnkOuter, __inout_opt HRESULT *phr);
/* A function (can be NULL) which is called from the DLL entrypoint /* A function (can be NULL) which is called from the DLL entrypoint
routine for each factory template: routine for each factory template:
@ -285,7 +271,7 @@ public:
return (IsEqualCLSID(*m_ClsID,rclsid)); return (IsEqualCLSID(*m_ClsID,rclsid));
}; };
CUnknown *CreateInstance(LPUNKNOWN pUnk, HRESULT *phr) const { CUnknown *CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr) const {
CheckPointer(phr,NULL); CheckPointer(phr,NULL);
return m_lpfnNew(pUnk, phr); return m_lpfnNew(pUnk, phr);
}; };
@ -297,7 +283,7 @@ public:
class supports (the default implementation only supports IUnknown) */ class supports (the default implementation only supports IUnknown) */
#define DECLARE_IUNKNOWN \ #define DECLARE_IUNKNOWN \
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { \ STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv) { \
return GetOwner()->QueryInterface(riid,ppv); \ return GetOwner()->QueryInterface(riid,ppv); \
}; \ }; \
STDMETHODIMP_(ULONG) AddRef() { \ STDMETHODIMP_(ULONG) AddRef() { \

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -33,20 +33,20 @@ public:
~CBaseDispatch(); ~CBaseDispatch();
/* IDispatch methods */ /* IDispatch methods */
STDMETHODIMP GetTypeInfoCount(UINT * pctinfo); STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo( STDMETHODIMP GetTypeInfo(
REFIID riid, REFIID riid,
UINT itinfo, UINT itinfo,
LCID lcid, LCID lcid,
ITypeInfo ** pptinfo); __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames( STDMETHODIMP GetIDsOfNames(
REFIID riid, REFIID riid,
OLECHAR ** rgszNames, __in_ecount(cNames) LPOLESTR * rgszNames,
UINT cNames, UINT cNames,
LCID lcid, LCID lcid,
DISPID * rgdispid); __out_ecount(cNames) DISPID * rgdispid);
}; };
@ -63,32 +63,32 @@ public:
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
/* IDispatch methods */ /* IDispatch methods */
STDMETHODIMP GetTypeInfoCount(UINT * pctinfo); STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo( STDMETHODIMP GetTypeInfo(
UINT itinfo, UINT itinfo,
LCID lcid, LCID lcid,
ITypeInfo ** pptinfo); __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames( STDMETHODIMP GetIDsOfNames(
REFIID riid, REFIID riid,
OLECHAR ** rgszNames, __in_ecount(cNames) LPOLESTR * rgszNames,
UINT cNames, UINT cNames,
LCID lcid, LCID lcid,
DISPID * rgdispid); __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke( STDMETHODIMP Invoke(
DISPID dispidMember, DISPID dispidMember,
REFIID riid, REFIID riid,
LCID lcid, LCID lcid,
WORD wFlags, WORD wFlags,
DISPPARAMS * pdispparams, __in DISPPARAMS * pdispparams,
VARIANT * pvarResult, __out_opt VARIANT * pvarResult,
EXCEPINFO * pexcepinfo, __out_opt EXCEPINFO * pexcepinfo,
UINT * puArgErr); __out_opt UINT * puArgErr);
}; };
@ -100,37 +100,37 @@ class AM_NOVTABLE CMediaEvent :
public: public:
CMediaEvent(const TCHAR *, LPUNKNOWN); CMediaEvent(__in_opt LPCTSTR, __in_opt LPUNKNOWN);
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
/* IDispatch methods */ /* IDispatch methods */
STDMETHODIMP GetTypeInfoCount(UINT * pctinfo); STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo( STDMETHODIMP GetTypeInfo(
UINT itinfo, UINT itinfo,
LCID lcid, LCID lcid,
ITypeInfo ** pptinfo); __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames( STDMETHODIMP GetIDsOfNames(
REFIID riid, REFIID riid,
OLECHAR ** rgszNames, __in_ecount(cNames) LPOLESTR * rgszNames,
UINT cNames, UINT cNames,
LCID lcid, LCID lcid,
DISPID * rgdispid); __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke( STDMETHODIMP Invoke(
DISPID dispidMember, DISPID dispidMember,
REFIID riid, REFIID riid,
LCID lcid, LCID lcid,
WORD wFlags, WORD wFlags,
DISPPARAMS * pdispparams, __in DISPPARAMS * pdispparams,
VARIANT * pvarResult, __out_opt VARIANT * pvarResult,
EXCEPINFO * pexcepinfo, __out_opt EXCEPINFO * pexcepinfo,
UINT * puArgErr); __out_opt UINT * puArgErr);
}; };
@ -143,38 +143,38 @@ class AM_NOVTABLE CMediaPosition :
public: public:
CMediaPosition(const TCHAR *, LPUNKNOWN); CMediaPosition(__in_opt LPCTSTR, __in_opt LPUNKNOWN);
CMediaPosition(const TCHAR *, LPUNKNOWN, HRESULT *phr); CMediaPosition(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT *phr);
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
/* IDispatch methods */ /* IDispatch methods */
STDMETHODIMP GetTypeInfoCount(UINT * pctinfo); STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo( STDMETHODIMP GetTypeInfo(
UINT itinfo, UINT itinfo,
LCID lcid, LCID lcid,
ITypeInfo ** pptinfo); __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames( STDMETHODIMP GetIDsOfNames(
REFIID riid, REFIID riid,
OLECHAR ** rgszNames, __in_ecount(cNames) LPOLESTR * rgszNames,
UINT cNames, UINT cNames,
LCID lcid, LCID lcid,
DISPID * rgdispid); __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke( STDMETHODIMP Invoke(
DISPID dispidMember, DISPID dispidMember,
REFIID riid, REFIID riid,
LCID lcid, LCID lcid,
WORD wFlags, WORD wFlags,
DISPPARAMS * pdispparams, __in DISPPARAMS * pdispparams,
VARIANT * pvarResult, __out_opt VARIANT * pvarResult,
EXCEPINFO * pexcepinfo, __out_opt EXCEPINFO * pexcepinfo,
UINT * puArgErr); __out_opt UINT * puArgErr);
}; };
@ -275,7 +275,7 @@ private:
// Prevent bugs from constructing from LONG (which gets // Prevent bugs from constructing from LONG (which gets
// converted to double and then multiplied by 10000000 // converted to double and then multiplied by 10000000
COARefTime(LONG); COARefTime(LONG);
int operator=(LONG); LONG operator=(LONG);
}; };
@ -300,12 +300,12 @@ class CPosPassThru : public IMediaSeeking, public CMediaPosition
{ {
IPin *m_pPin; IPin *m_pPin;
HRESULT GetPeer(IMediaPosition **ppMP); HRESULT GetPeer(__deref_out IMediaPosition **ppMP);
HRESULT GetPeerSeeking(IMediaSeeking **ppMS); HRESULT GetPeerSeeking(__deref_out IMediaSeeking **ppMS);
public: public:
CPosPassThru(const TCHAR *, LPUNKNOWN, HRESULT*, IPin *); CPosPassThru(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT*, IPin *);
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
HRESULT ForceRefresh() { HRESULT ForceRefresh() {
@ -313,50 +313,52 @@ public:
}; };
// override to return an accurate current position // override to return an accurate current position
virtual HRESULT GetMediaTime(LONGLONG *pStartTime,LONGLONG *pEndTime) { virtual HRESULT GetMediaTime(__out LONGLONG *pStartTime, __out_opt LONGLONG *pEndTime) {
return E_FAIL; return E_FAIL;
} }
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,__deref_out void **ppv);
// IMediaSeeking methods // IMediaSeeking methods
STDMETHODIMP GetCapabilities( DWORD * pCapabilities ); STDMETHODIMP GetCapabilities( __out DWORD * pCapabilities );
STDMETHODIMP CheckCapabilities( DWORD * pCapabilities ); STDMETHODIMP CheckCapabilities( __inout DWORD * pCapabilities );
STDMETHODIMP SetTimeFormat(const GUID * pFormat); STDMETHODIMP SetTimeFormat(const GUID * pFormat);
STDMETHODIMP GetTimeFormat(GUID *pFormat); STDMETHODIMP GetTimeFormat(__out GUID *pFormat);
STDMETHODIMP IsUsingTimeFormat(const GUID * pFormat); STDMETHODIMP IsUsingTimeFormat(const GUID * pFormat);
STDMETHODIMP IsFormatSupported( const GUID * pFormat); STDMETHODIMP IsFormatSupported( const GUID * pFormat);
STDMETHODIMP QueryPreferredFormat( GUID *pFormat); STDMETHODIMP QueryPreferredFormat( __out GUID *pFormat);
STDMETHODIMP ConvertTimeFormat(LONGLONG * pTarget, const GUID * pTargetFormat, STDMETHODIMP ConvertTimeFormat(__out LONGLONG * pTarget,
LONGLONG Source, const GUID * pSourceFormat ); __in_opt const GUID * pTargetFormat,
STDMETHODIMP SetPositions( LONGLONG * pCurrent, DWORD CurrentFlags LONGLONG Source,
, LONGLONG * pStop, DWORD StopFlags ); __in_opt const GUID * pSourceFormat );
STDMETHODIMP SetPositions( __inout_opt LONGLONG * pCurrent, DWORD CurrentFlags
, __inout_opt LONGLONG * pStop, DWORD StopFlags );
STDMETHODIMP GetPositions( LONGLONG * pCurrent, LONGLONG * pStop ); STDMETHODIMP GetPositions( __out_opt LONGLONG * pCurrent, __out_opt LONGLONG * pStop );
STDMETHODIMP GetCurrentPosition( LONGLONG * pCurrent ); STDMETHODIMP GetCurrentPosition( __out LONGLONG * pCurrent );
STDMETHODIMP GetStopPosition( LONGLONG * pStop ); STDMETHODIMP GetStopPosition( __out LONGLONG * pStop );
STDMETHODIMP SetRate( double dRate); STDMETHODIMP SetRate( double dRate);
STDMETHODIMP GetRate( double * pdRate); STDMETHODIMP GetRate( __out double * pdRate);
STDMETHODIMP GetDuration( LONGLONG *pDuration); STDMETHODIMP GetDuration( __out LONGLONG *pDuration);
STDMETHODIMP GetAvailable( LONGLONG *pEarliest, LONGLONG *pLatest ); STDMETHODIMP GetAvailable( __out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest );
STDMETHODIMP GetPreroll( LONGLONG *pllPreroll ); STDMETHODIMP GetPreroll( __out LONGLONG *pllPreroll );
// IMediaPosition properties // IMediaPosition properties
STDMETHODIMP get_Duration(REFTIME * plength); STDMETHODIMP get_Duration(__out REFTIME * plength);
STDMETHODIMP put_CurrentPosition(REFTIME llTime); STDMETHODIMP put_CurrentPosition(REFTIME llTime);
STDMETHODIMP get_StopTime(REFTIME * pllTime); STDMETHODIMP get_StopTime(__out REFTIME * pllTime);
STDMETHODIMP put_StopTime(REFTIME llTime); STDMETHODIMP put_StopTime(REFTIME llTime);
STDMETHODIMP get_PrerollTime(REFTIME * pllTime); STDMETHODIMP get_PrerollTime(__out REFTIME * pllTime);
STDMETHODIMP put_PrerollTime(REFTIME llTime); STDMETHODIMP put_PrerollTime(REFTIME llTime);
STDMETHODIMP get_Rate(double * pdRate); STDMETHODIMP get_Rate(__out double * pdRate);
STDMETHODIMP put_Rate(double dRate); STDMETHODIMP put_Rate(double dRate);
STDMETHODIMP get_CurrentPosition(REFTIME * pllTime); STDMETHODIMP get_CurrentPosition(__out REFTIME * pllTime);
STDMETHODIMP CanSeekForward(LONG *pCanSeekForward); STDMETHODIMP CanSeekForward(__out LONG *pCanSeekForward);
STDMETHODIMP CanSeekBackward(LONG *pCanSeekBackward); STDMETHODIMP CanSeekBackward(__out LONG *pCanSeekBackward);
private: private:
HRESULT GetSeekingLongLong( HRESULT (__stdcall IMediaSeeking::*pMethod)( LONGLONG * ), HRESULT GetSeekingLongLong( HRESULT (__stdcall IMediaSeeking::*pMethod)( LONGLONG * ),
LONGLONG * pll ); __out LONGLONG * pll );
}; };
@ -373,19 +375,19 @@ public:
// Used to help with passing media times through graph // Used to help with passing media times through graph
CRendererPosPassThru(const TCHAR *, LPUNKNOWN, HRESULT*, IPin *); CRendererPosPassThru(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT*, IPin *);
HRESULT RegisterMediaTime(IMediaSample *pMediaSample); HRESULT RegisterMediaTime(IMediaSample *pMediaSample);
HRESULT RegisterMediaTime(LONGLONG StartTime,LONGLONG EndTime); HRESULT RegisterMediaTime(LONGLONG StartTime,LONGLONG EndTime);
HRESULT GetMediaTime(LONGLONG *pStartTime,LONGLONG *pEndTime); HRESULT GetMediaTime(__out LONGLONG *pStartTime,__out_opt LONGLONG *pEndTime);
HRESULT ResetMediaTime(); HRESULT ResetMediaTime();
HRESULT EOS(); HRESULT EOS();
}; };
STDAPI CreatePosPassThru( STDAPI CreatePosPassThru(
LPUNKNOWN pAgg, __in_opt LPUNKNOWN pAgg,
BOOL bRenderer, BOOL bRenderer,
IPin *pPin, IPin *pPin,
IUnknown **ppPassThru __deref_out IUnknown **ppPassThru
); );
// A class that handles the IDispatch part of IBasicAudio and leaves the // A class that handles the IDispatch part of IBasicAudio and leaves the
@ -397,37 +399,37 @@ class AM_NOVTABLE CBasicAudio : public IBasicAudio, public CUnknown
public: public:
CBasicAudio(const TCHAR *, LPUNKNOWN); CBasicAudio(__in_opt LPCTSTR, __in_opt LPUNKNOWN);
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
/* IDispatch methods */ /* IDispatch methods */
STDMETHODIMP GetTypeInfoCount(UINT * pctinfo); STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo( STDMETHODIMP GetTypeInfo(
UINT itinfo, UINT itinfo,
LCID lcid, LCID lcid,
ITypeInfo ** pptinfo); __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames( STDMETHODIMP GetIDsOfNames(
REFIID riid, REFIID riid,
OLECHAR ** rgszNames, __in_ecount(cNames) LPOLESTR * rgszNames,
UINT cNames, UINT cNames,
LCID lcid, LCID lcid,
DISPID * rgdispid); __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke( STDMETHODIMP Invoke(
DISPID dispidMember, DISPID dispidMember,
REFIID riid, REFIID riid,
LCID lcid, LCID lcid,
WORD wFlags, WORD wFlags,
DISPPARAMS * pdispparams, __in DISPPARAMS * pdispparams,
VARIANT * pvarResult, __out_opt VARIANT * pvarResult,
EXCEPINFO * pexcepinfo, __out_opt EXCEPINFO * pexcepinfo,
UINT * puArgErr); __out_opt UINT * puArgErr);
}; };
@ -440,41 +442,41 @@ class AM_NOVTABLE CBaseBasicVideo : public IBasicVideo2, public CUnknown
public: public:
CBaseBasicVideo(const TCHAR *, LPUNKNOWN); CBaseBasicVideo(__in_opt LPCTSTR, __in_opt LPUNKNOWN);
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
/* IDispatch methods */ /* IDispatch methods */
STDMETHODIMP GetTypeInfoCount(UINT * pctinfo); STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo( STDMETHODIMP GetTypeInfo(
UINT itinfo, UINT itinfo,
LCID lcid, LCID lcid,
ITypeInfo ** pptinfo); __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames( STDMETHODIMP GetIDsOfNames(
REFIID riid, REFIID riid,
OLECHAR ** rgszNames, __in_ecount(cNames) LPOLESTR * rgszNames,
UINT cNames, UINT cNames,
LCID lcid, LCID lcid,
DISPID * rgdispid); __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke( STDMETHODIMP Invoke(
DISPID dispidMember, DISPID dispidMember,
REFIID riid, REFIID riid,
LCID lcid, LCID lcid,
WORD wFlags, WORD wFlags,
DISPPARAMS * pdispparams, __in DISPPARAMS * pdispparams,
VARIANT * pvarResult, __out_opt VARIANT * pvarResult,
EXCEPINFO * pexcepinfo, __out_opt EXCEPINFO * pexcepinfo,
UINT * puArgErr); __out_opt UINT * puArgErr);
STDMETHODIMP GetPreferredAspectRatio( STDMETHODIMP GetPreferredAspectRatio(
long *plAspectX, __out long *plAspectX,
long *plAspectY) __out long *plAspectY)
{ {
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -490,37 +492,37 @@ class AM_NOVTABLE CBaseVideoWindow : public IVideoWindow, public CUnknown
public: public:
CBaseVideoWindow(const TCHAR *, LPUNKNOWN); CBaseVideoWindow(__in_opt LPCTSTR, __in_opt LPUNKNOWN);
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
/* IDispatch methods */ /* IDispatch methods */
STDMETHODIMP GetTypeInfoCount(UINT * pctinfo); STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo( STDMETHODIMP GetTypeInfo(
UINT itinfo, UINT itinfo,
LCID lcid, LCID lcid,
ITypeInfo ** pptinfo); __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames( STDMETHODIMP GetIDsOfNames(
REFIID riid, REFIID riid,
OLECHAR ** rgszNames, __in_ecount(cNames) LPOLESTR * rgszNames,
UINT cNames, UINT cNames,
LCID lcid, LCID lcid,
DISPID * rgdispid); __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke( STDMETHODIMP Invoke(
DISPID dispidMember, DISPID dispidMember,
REFIID riid, REFIID riid,
LCID lcid, LCID lcid,
WORD wFlags, WORD wFlags,
DISPPARAMS * pdispparams, __in DISPPARAMS * pdispparams,
VARIANT * pvarResult, __out_opt VARIANT * pvarResult,
EXCEPINFO * pexcepinfo, __out_opt EXCEPINFO * pexcepinfo,
UINT * puArgErr); __out_opt UINT * puArgErr);
}; };
@ -533,22 +535,22 @@ class AM_NOVTABLE CSourcePosition : public CMediaPosition
{ {
public: public:
CSourcePosition(const TCHAR *, LPUNKNOWN, HRESULT*, CCritSec *); CSourcePosition(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT*, __in CCritSec *);
// IMediaPosition methods // IMediaPosition methods
STDMETHODIMP get_Duration(REFTIME * plength); STDMETHODIMP get_Duration(__out REFTIME * plength);
STDMETHODIMP put_CurrentPosition(REFTIME llTime); STDMETHODIMP put_CurrentPosition(REFTIME llTime);
STDMETHODIMP get_StopTime(REFTIME * pllTime); STDMETHODIMP get_StopTime(__out REFTIME * pllTime);
STDMETHODIMP put_StopTime(REFTIME llTime); STDMETHODIMP put_StopTime(REFTIME llTime);
STDMETHODIMP get_PrerollTime(REFTIME * pllTime); STDMETHODIMP get_PrerollTime(__out REFTIME * pllTime);
STDMETHODIMP put_PrerollTime(REFTIME llTime); STDMETHODIMP put_PrerollTime(REFTIME llTime);
STDMETHODIMP get_Rate(double * pdRate); STDMETHODIMP get_Rate(__out double * pdRate);
STDMETHODIMP put_Rate(double dRate); STDMETHODIMP put_Rate(double dRate);
STDMETHODIMP CanSeekForward(LONG *pCanSeekForward); STDMETHODIMP CanSeekForward(__out LONG *pCanSeekForward);
STDMETHODIMP CanSeekBackward(LONG *pCanSeekBackward); STDMETHODIMP CanSeekBackward(__out LONG *pCanSeekBackward);
// override if you can return the data you are actually working on // override if you can return the data you are actually working on
STDMETHODIMP get_CurrentPosition(REFTIME * pllTime) { STDMETHODIMP get_CurrentPosition(__out REFTIME * pllTime) {
return E_NOTIMPL; return E_NOTIMPL;
}; };
@ -575,38 +577,40 @@ class AM_NOVTABLE CSourceSeeking :
public: public:
DECLARE_IUNKNOWN; DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
// IMediaSeeking methods // IMediaSeeking methods
STDMETHODIMP IsFormatSupported(const GUID * pFormat); STDMETHODIMP IsFormatSupported(const GUID * pFormat);
STDMETHODIMP QueryPreferredFormat(GUID *pFormat); STDMETHODIMP QueryPreferredFormat(__out GUID *pFormat);
STDMETHODIMP SetTimeFormat(const GUID * pFormat); STDMETHODIMP SetTimeFormat(const GUID * pFormat);
STDMETHODIMP IsUsingTimeFormat(const GUID * pFormat); STDMETHODIMP IsUsingTimeFormat(const GUID * pFormat);
STDMETHODIMP GetTimeFormat(GUID *pFormat); STDMETHODIMP GetTimeFormat(__out GUID *pFormat);
STDMETHODIMP GetDuration(LONGLONG *pDuration); STDMETHODIMP GetDuration(__out LONGLONG *pDuration);
STDMETHODIMP GetStopPosition(LONGLONG *pStop); STDMETHODIMP GetStopPosition(__out LONGLONG *pStop);
STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent); STDMETHODIMP GetCurrentPosition(__out LONGLONG *pCurrent);
STDMETHODIMP GetCapabilities( DWORD * pCapabilities ); STDMETHODIMP GetCapabilities( __out DWORD * pCapabilities );
STDMETHODIMP CheckCapabilities( DWORD * pCapabilities ); STDMETHODIMP CheckCapabilities( __inout DWORD * pCapabilities );
STDMETHODIMP ConvertTimeFormat( LONGLONG * pTarget, const GUID * pTargetFormat, STDMETHODIMP ConvertTimeFormat( __out LONGLONG * pTarget,
LONGLONG Source, const GUID * pSourceFormat ); __in_opt const GUID * pTargetFormat,
LONGLONG Source,
__in_opt const GUID * pSourceFormat );
STDMETHODIMP SetPositions( LONGLONG * pCurrent, DWORD CurrentFlags STDMETHODIMP SetPositions( __inout_opt LONGLONG * pCurrent, DWORD CurrentFlags
, LONGLONG * pStop, DWORD StopFlags ); , __inout_opt LONGLONG * pStop, DWORD StopFlags );
STDMETHODIMP GetPositions( LONGLONG * pCurrent, LONGLONG * pStop ); STDMETHODIMP GetPositions( __out_opt LONGLONG * pCurrent, __out_opt LONGLONG * pStop );
STDMETHODIMP GetAvailable( LONGLONG * pEarliest, LONGLONG * pLatest ); STDMETHODIMP GetAvailable( __out_opt LONGLONG * pEarliest, __out_opt LONGLONG * pLatest );
STDMETHODIMP SetRate( double dRate); STDMETHODIMP SetRate( double dRate);
STDMETHODIMP GetRate( double * pdRate); STDMETHODIMP GetRate( __out double * pdRate);
STDMETHODIMP GetPreroll(LONGLONG *pPreroll); STDMETHODIMP GetPreroll(__out LONGLONG *pPreroll);
protected: protected:
// ctor // ctor
CSourceSeeking(const TCHAR *, LPUNKNOWN, HRESULT*, CCritSec *); CSourceSeeking(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT*, __in CCritSec *);
// we call this to notify changes. Override to handle them // we call this to notify changes. Override to handle them
virtual HRESULT ChangeStart() PURE; virtual HRESULT ChangeStart() PURE;
@ -650,7 +654,7 @@ class CCmdQueue;
class CDispParams : public DISPPARAMS class CDispParams : public DISPPARAMS
{ {
public: public:
CDispParams(UINT nArgs, VARIANT* pArgs, HRESULT *phr = NULL); CDispParams(UINT nArgs, __in_ecount(nArgs) VARIANT* pArgs, __inout_opt HRESULT *phr = NULL);
~CDispParams(); ~CDispParams();
}; };
@ -668,34 +672,34 @@ class CDeferredCommand
public: public:
CDeferredCommand( CDeferredCommand(
CCmdQueue * pQ, __inout CCmdQueue * pQ,
LPUNKNOWN pUnk, // aggregation outer unk __in_opt LPUNKNOWN pUnk, // aggregation outer unk
HRESULT * phr, __inout HRESULT * phr,
LPUNKNOWN pUnkExecutor, // object that will execute this cmd __in LPUNKNOWN pUnkExecutor, // object that will execute this cmd
REFTIME time, REFTIME time,
GUID* iid, __in GUID* iid,
long dispidMethod, long dispidMethod,
short wFlags, short wFlags,
long cArgs, long cArgs,
VARIANT* pDispParams, __in_ecount(cArgs) VARIANT* pDispParams,
VARIANT* pvarResult, __out VARIANT* pvarResult,
short* puArgErr, __out short* puArgErr,
BOOL bStream BOOL bStream
); );
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
// override this to publicise our interfaces // override this to publicise our interfaces
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __out void **ppv);
// IDeferredCommand methods // IDeferredCommand methods
STDMETHODIMP Cancel(); STDMETHODIMP Cancel();
STDMETHODIMP Confidence( STDMETHODIMP Confidence(
LONG* pConfidence); __out LONG* pConfidence);
STDMETHODIMP Postpone( STDMETHODIMP Postpone(
REFTIME newtime); REFTIME newtime);
STDMETHODIMP GetHResult( STDMETHODIMP GetHResult(
HRESULT* phrResult); __out HRESULT* phrResult);
// other public methods // other public methods
@ -764,7 +768,7 @@ protected:
class AM_NOVTABLE CCmdQueue class AM_NOVTABLE CCmdQueue
{ {
public: public:
CCmdQueue(); CCmdQueue(__inout_opt HRESULT *phr = NULL);
virtual ~CCmdQueue(); virtual ~CCmdQueue();
// returns a new CDeferredCommand object that will be initialised with // returns a new CDeferredCommand object that will be initialised with
@ -772,23 +776,23 @@ public:
// returns S_OK if successfully created otherwise an error and // returns S_OK if successfully created otherwise an error and
// no object has been queued. // no object has been queued.
virtual HRESULT New( virtual HRESULT New(
CDeferredCommand **ppCmd, __out CDeferredCommand **ppCmd,
LPUNKNOWN pUnk, __in LPUNKNOWN pUnk,
REFTIME time, REFTIME time,
GUID* iid, __in GUID* iid,
long dispidMethod, long dispidMethod,
short wFlags, short wFlags,
long cArgs, long cArgs,
VARIANT* pDispParams, __in_ecount(cArgs) VARIANT* pDispParams,
VARIANT* pvarResult, __out VARIANT* pvarResult,
short* puArgErr, __out short* puArgErr,
BOOL bStream BOOL bStream
); );
// called by the CDeferredCommand object to add and remove itself // called by the CDeferredCommand object to add and remove itself
// from the queue // from the queue
virtual HRESULT Insert(CDeferredCommand* pCmd); virtual HRESULT Insert(__in CDeferredCommand* pCmd);
virtual HRESULT Remove(CDeferredCommand* pCmd); virtual HRESULT Remove(__in CDeferredCommand* pCmd);
// Command-Due Checking // Command-Due Checking
// //
@ -827,7 +831,7 @@ public:
// queue object. // queue object.
// set the clock used for timing // set the clock used for timing
virtual HRESULT SetSyncSource(IReferenceClock*); virtual HRESULT SetSyncSource(__in_opt IReferenceClock*);
// switch to run mode. Streamtime to Presentation time mapping known. // switch to run mode. Streamtime to Presentation time mapping known.
virtual HRESULT Run(REFERENCE_TIME tStreamTimeOffset); virtual HRESULT Run(REFERENCE_TIME tStreamTimeOffset);
@ -841,7 +845,7 @@ public:
// The command remains queued until invoked or cancelled. // The command remains queued until invoked or cancelled.
// Returns E_ABORT if timeout occurs, otherwise S_OK (or other error). // Returns E_ABORT if timeout occurs, otherwise S_OK (or other error).
// Returns an AddRef-ed object // Returns an AddRef-ed object
virtual HRESULT GetDueCommand(CDeferredCommand ** ppCmd, long msTimeout); virtual HRESULT GetDueCommand(__out CDeferredCommand ** ppCmd, long msTimeout);
// return the event handle that will be signalled whenever // return the event handle that will be signalled whenever
// there are deferred commands due for execution (when GetDueCommand // there are deferred commands due for execution (when GetDueCommand
@ -857,7 +861,7 @@ public:
// This method will not block. It will report VFW_E_NOT_FOUND if there // This method will not block. It will report VFW_E_NOT_FOUND if there
// are no commands due yet. // are no commands due yet.
// Returns an AddRef-ed object // Returns an AddRef-ed object
virtual HRESULT GetCommandDueFor(REFERENCE_TIME tStream, CDeferredCommand**ppCmd); virtual HRESULT GetCommandDueFor(REFERENCE_TIME tStream, __out CDeferredCommand**ppCmd);
// check if a given time is due (TRUE if it is due yet) // check if a given time is due (TRUE if it is due yet)
BOOL CheckTime(CRefTime time, BOOL bStream) { BOOL CheckTime(CRefTime time, BOOL bStream) {

View File

@ -4,13 +4,12 @@
// Desc: DirectShow base classes - implements routines for using DirectDraw // Desc: DirectShow base classes - implements routines for using DirectDraw
// on a multimonitor system. // on a multimonitor system.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//#include <strsafe.h> #include <streams.h>
#include <strmif.h> #include <ddraw.h>
#include <mmsystem.h>
#include "ddmm.h" #include "ddmm.h"
/* /*
@ -23,7 +22,7 @@ typedef struct {
BOOL fFound; BOOL fFound;
} FindDeviceData; } FindDeviceData;
BOOL CALLBACK FindDeviceCallback(GUID* lpGUID, LPSTR szName, LPSTR szDevice, LPVOID lParam) BOOL CALLBACK FindDeviceCallback(__in_opt GUID* lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam)
{ {
FindDeviceData *p = (FindDeviceData*)lParam; FindDeviceData *p = (FindDeviceData*)lParam;
@ -41,7 +40,7 @@ BOOL CALLBACK FindDeviceCallback(GUID* lpGUID, LPSTR szName, LPSTR szDevice, LPV
} }
BOOL CALLBACK FindDeviceCallbackEx(GUID* lpGUID, LPSTR szName, LPSTR szDevice, LPVOID lParam, HMONITOR hMonitor) BOOL CALLBACK FindDeviceCallbackEx(__in_opt GUID* lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam, HMONITOR hMonitor)
{ {
FindDeviceData *p = (FindDeviceData*)lParam; FindDeviceData *p = (FindDeviceData*)lParam;
@ -64,7 +63,7 @@ BOOL CALLBACK FindDeviceCallbackEx(GUID* lpGUID, LPSTR szName, LPSTR szDevice, L
* *
* create a DirectDraw object for a particular device * create a DirectDraw object for a particular device
*/ */
IDirectDraw * DirectDrawCreateFromDevice(LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, PDRAWENUM DirectDrawEnumerateP) IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, PDRAWENUM DirectDrawEnumerateP)
{ {
IDirectDraw* pdd = NULL; IDirectDraw* pdd = NULL;
FindDeviceData find; FindDeviceData find;
@ -99,7 +98,7 @@ IDirectDraw * DirectDrawCreateFromDevice(LPSTR szDevice, PDRAWCREATE DirectDrawC
* *
* create a DirectDraw object for a particular device * create a DirectDraw object for a particular device
*/ */
IDirectDraw * DirectDrawCreateFromDeviceEx(LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP) IDirectDraw * DirectDrawCreateFromDeviceEx(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP)
{ {
IDirectDraw* pdd = NULL; IDirectDraw* pdd = NULL;
FindDeviceData find; FindDeviceData find;

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - efines routines for using DirectDraw // Desc: DirectShow base classes - efines routines for using DirectDraw
// on a multimonitor system. // on a multimonitor system.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -20,8 +20,8 @@ extern "C" { /* Assume C declarations for C++ */
typedef HRESULT (*PDRAWCREATE)(IID *,LPDIRECTDRAW *,LPUNKNOWN); typedef HRESULT (*PDRAWCREATE)(IID *,LPDIRECTDRAW *,LPUNKNOWN);
typedef HRESULT (*PDRAWENUM)(LPDDENUMCALLBACKA, LPVOID); typedef HRESULT (*PDRAWENUM)(LPDDENUMCALLBACKA, LPVOID);
IDirectDraw * DirectDrawCreateFromDevice(LPSTR, PDRAWCREATE, PDRAWENUM); IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR, PDRAWCREATE, PDRAWENUM);
IDirectDraw * DirectDrawCreateFromDeviceEx(LPSTR, PDRAWCREATE, LPDIRECTDRAWENUMERATEEXA); IDirectDraw * DirectDrawCreateFromDeviceEx(__in_opt LPSTR, PDRAWCREATE, LPDIRECTDRAWENUMERATEEXA);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -159,7 +159,7 @@ void WINAPI Msr_Terminate(void);
// Call this to get an Id for an "incident" that you can pass to Start, Stop or Note // Call this to get an Id for an "incident" that you can pass to Start, Stop or Note
// everything that's logged is called an "incident". // everything that's logged is called an "incident".
int WINAPI Msr_Register(LPTSTR Incident); int WINAPI Msr_Register(__in LPTSTR Incident);
// Reset the statistical counts for an incident // Reset the statistical counts for an incident

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - provides support for a worker thread // Desc: DirectShow base classes - provides support for a worker thread
// class to which one can asynchronously post messages. // class to which one can asynchronously post messages.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -17,7 +17,7 @@ public:
LPVOID lpParam; LPVOID lpParam;
CAMEvent *pEvent; CAMEvent *pEvent;
CMsg(UINT u, DWORD dw, LPVOID lp, CAMEvent *pEvnt) CMsg(UINT u, DWORD dw, __inout_opt LPVOID lp, __in_opt CAMEvent *pEvnt)
: uMsg(u), dwFlags(dw), lpParam(lp), pEvent(pEvnt) {} : uMsg(u), dwFlags(dw), lpParam(lp), pEvent(pEvnt) {}
CMsg() CMsg()
@ -31,7 +31,7 @@ public:
// //
class AM_NOVTABLE CMsgThread { class AM_NOVTABLE CMsgThread {
private: private:
static DWORD WINAPI DefaultThreadProc(LPVOID lpParam); static DWORD WINAPI DefaultThreadProc(__inout LPVOID lpParam);
DWORD m_ThreadId; DWORD m_ThreadId;
HANDLE m_hThread; HANDLE m_hThread;
@ -58,7 +58,7 @@ public:
~CMsgThread(); ~CMsgThread();
// override this if you want to block on other things as well // override this if you want to block on other things as well
// as the message loop // as the message loop
void virtual GetThreadMsg(CMsg *msg); void virtual GetThreadMsg(__out CMsg *msg);
// override this if you want to do something on thread startup // override this if you want to do something on thread startup
virtual void OnThreadInit() { virtual void OnThreadInit() {
@ -66,7 +66,7 @@ public:
BOOL CreateThread(); BOOL CreateThread();
BOOL WaitForThreadExit(LPDWORD lpdwExitCode) { BOOL WaitForThreadExit(__out LPDWORD lpdwExitCode) {
if (m_hThread != NULL) { if (m_hThread != NULL) {
WaitForSingleObject(m_hThread, INFINITE); WaitForSingleObject(m_hThread, INFINITE);
return GetExitCodeThread(m_hThread, lpdwExitCode); return GetExitCodeThread(m_hThread, lpdwExitCode);
@ -100,7 +100,7 @@ public:
void PutThreadMsg(UINT uMsg, DWORD dwMsgFlags, void PutThreadMsg(UINT uMsg, DWORD dwMsgFlags,
LPVOID lpMsgParam, CAMEvent *pEvent = NULL) { __in_opt LPVOID lpMsgParam, __in_opt CAMEvent *pEvent = NULL) {
CAutoLock lck(&m_Lock); CAutoLock lck(&m_Lock);
CMsg* pMsg = new CMsg(uMsg, dwMsgFlags, lpMsgParam, pEvent); CMsg* pMsg = new CMsg(uMsg, dwMsgFlags, lpMsgParam, pEvent);
m_ThreadQueue.AddTail(pMsg); m_ThreadQueue.AddTail(pMsg);
@ -115,6 +115,6 @@ public:
// the creator thread. // the creator thread.
// //
virtual LRESULT ThreadMessageProc( virtual LRESULT ThreadMessageProc(
UINT uMsg, DWORD dwFlags, LPVOID lpParam, CAMEvent *pEvent) = 0; UINT uMsg, DWORD dwFlags, __inout_opt LPVOID lpParam, __in_opt CAMEvent *pEvent) = 0;
}; };

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - implements a class that holds and // Desc: DirectShow base classes - implements a class that holds and
// manages media type information. // manages media type information.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -12,7 +12,7 @@
// types etc. Has same data members as the struct AM_MEDIA_TYPE defined // types etc. Has same data members as the struct AM_MEDIA_TYPE defined
// in the streams IDL file, but also has (non-virtual) functions // in the streams IDL file, but also has (non-virtual) functions
#include "streams.h" #include <streams.h>
#include <mmreg.h> #include <mmreg.h>
CMediaType::~CMediaType(){ CMediaType::~CMediaType(){
@ -35,7 +35,7 @@ CMediaType::CMediaType(const GUID * type)
// copy constructor does a deep copy of the format block // copy constructor does a deep copy of the format block
CMediaType::CMediaType(const AM_MEDIA_TYPE& rt, HRESULT* phr) CMediaType::CMediaType(const AM_MEDIA_TYPE& rt, __out_opt HRESULT* phr)
{ {
HRESULT hr = CopyMediaType(this, &rt); HRESULT hr = CopyMediaType(this, &rt);
if (FAILED(hr) && (NULL != phr)) { if (FAILED(hr) && (NULL != phr)) {
@ -44,7 +44,7 @@ CMediaType::CMediaType(const AM_MEDIA_TYPE& rt, HRESULT* phr)
} }
CMediaType::CMediaType(const CMediaType& rt, HRESULT* phr) CMediaType::CMediaType(const CMediaType& rt, __out_opt HRESULT* phr)
{ {
HRESULT hr = CopyMediaType(this, &rt); HRESULT hr = CopyMediaType(this, &rt);
if (FAILED(hr) && (NULL != phr)) { if (FAILED(hr) && (NULL != phr)) {
@ -87,6 +87,7 @@ CMediaType::operator == (const CMediaType& rt) const
(IsEqualGUID(formattype,rt.formattype) == TRUE) && (IsEqualGUID(formattype,rt.formattype) == TRUE) &&
(cbFormat == rt.cbFormat) && (cbFormat == rt.cbFormat) &&
( (cbFormat == 0) || ( (cbFormat == 0) ||
pbFormat != NULL && rt.pbFormat != NULL &&
(memcmp(pbFormat, rt.pbFormat, cbFormat) == 0))); (memcmp(pbFormat, rt.pbFormat, cbFormat) == 0)));
} }
@ -179,7 +180,7 @@ CMediaType::SetTemporalCompression(BOOL bCompressed) {
} }
BOOL BOOL
CMediaType::SetFormat(BYTE * pformat, ULONG cb) CMediaType::SetFormat(__in_bcount(cb) BYTE * pformat, ULONG cb)
{ {
if (NULL == AllocFormatBuffer(cb)) if (NULL == AllocFormatBuffer(cb))
return(FALSE); return(FALSE);
@ -349,7 +350,7 @@ CMediaType::MatchesPartial(const CMediaType* ppartial) const
// implementation allocates the structures which you must later delete // implementation allocates the structures which you must later delete
// the format block may also be a pointer to an interface to release // the format block may also be a pointer to an interface to release
void WINAPI DeleteMediaType(AM_MEDIA_TYPE *pmt) void WINAPI DeleteMediaType(__inout_opt AM_MEDIA_TYPE *pmt)
{ {
// allow NULL pointers for coding simplicity // allow NULL pointers for coding simplicity
@ -393,7 +394,7 @@ AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc)
// Copy 1 media type to another // Copy 1 media type to another
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource) HRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource)
{ {
// We'll leak if we copy onto one that already exists - there's one // We'll leak if we copy onto one that already exists - there's one
// case we can check like that - copying to itself. // case we can check like that - copying to itself.
@ -419,7 +420,7 @@ HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtS
// Free an existing media type (ie free resources it holds) // Free an existing media type (ie free resources it holds)
void WINAPI FreeMediaType(AM_MEDIA_TYPE& mt) void WINAPI FreeMediaType(__inout AM_MEDIA_TYPE& mt)
{ {
if (mt.cbFormat != 0) { if (mt.cbFormat != 0) {
CoTaskMemFree((PVOID)mt.pbFormat); CoTaskMemFree((PVOID)mt.pbFormat);
@ -438,7 +439,7 @@ void WINAPI FreeMediaType(AM_MEDIA_TYPE& mt)
STDAPI CreateAudioMediaType( STDAPI CreateAudioMediaType(
const WAVEFORMATEX *pwfx, const WAVEFORMATEX *pwfx,
AM_MEDIA_TYPE *pmt, __out AM_MEDIA_TYPE *pmt,
BOOL bSetFormat BOOL bSetFormat
) )
{ {

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines a class that holds and manages // Desc: DirectShow base classes - defines a class that holds and manages
// media type information. // media type information.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -22,8 +22,8 @@ public:
~CMediaType(); ~CMediaType();
CMediaType(); CMediaType();
CMediaType(const GUID * majortype); CMediaType(const GUID * majortype);
CMediaType(const AM_MEDIA_TYPE&, HRESULT* phr = NULL); CMediaType(const AM_MEDIA_TYPE&, __out_opt HRESULT* phr = NULL);
CMediaType(const CMediaType&, HRESULT* phr = NULL); CMediaType(const CMediaType&, __out_opt HRESULT* phr = NULL);
CMediaType& operator=(const CMediaType&); CMediaType& operator=(const CMediaType&);
CMediaType& operator=(const AM_MEDIA_TYPE&); CMediaType& operator=(const AM_MEDIA_TYPE&);
@ -57,7 +57,7 @@ public:
void SetFormatType(const GUID *); void SetFormatType(const GUID *);
const GUID *FormatType() const {return &formattype; }; const GUID *FormatType() const {return &formattype; };
BOOL SetFormat(BYTE *pFormat, ULONG length); BOOL SetFormat(__in_bcount(length) BYTE *pFormat, ULONG length);
void ResetFormatBuffer(); void ResetFormatBuffer();
BYTE* AllocFormatBuffer(ULONG length); BYTE* AllocFormatBuffer(ULONG length);
BYTE* ReallocFormatBuffer(ULONG length); BYTE* ReallocFormatBuffer(ULONG length);
@ -73,16 +73,16 @@ public:
structure which is useful when using the IEnumMediaFormats interface as structure which is useful when using the IEnumMediaFormats interface as
the implementation allocates the structures which you must later delete */ the implementation allocates the structures which you must later delete */
void WINAPI DeleteMediaType(AM_MEDIA_TYPE *pmt); void WINAPI DeleteMediaType(__inout_opt AM_MEDIA_TYPE *pmt);
AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc); AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc);
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource); HRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource);
void WINAPI FreeMediaType(AM_MEDIA_TYPE& mt); void WINAPI FreeMediaType(__inout AM_MEDIA_TYPE& mt);
// Initialize a media type from a WAVEFORMATEX // Initialize a media type from a WAVEFORMATEX
STDAPI CreateAudioMediaType( STDAPI CreateAudioMediaType(
const WAVEFORMATEX *pwfx, const WAVEFORMATEX *pwfx,
AM_MEDIA_TYPE *pmt, __out AM_MEDIA_TYPE *pmt,
BOOL bSetFormat); BOOL bSetFormat);
#endif /* __MTYPE__ */ #endif /* __MTYPE__ */

View File

@ -6,11 +6,11 @@
// separate thread and sometimes call Receive() directly on the input // separate thread and sometimes call Receive() directly on the input
// pin. // pin.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
// //
@ -42,7 +42,7 @@
// //
COutputQueue::COutputQueue( COutputQueue::COutputQueue(
IPin *pInputPin, // Pin to send stuff to IPin *pInputPin, // Pin to send stuff to
HRESULT *phr, // 'Return code' __inout HRESULT *phr, // 'Return code'
BOOL bAuto, // Ask pin if queue or not BOOL bAuto, // Ask pin if queue or not
BOOL bQueue, // Send through queue BOOL bQueue, // Send through queue
LONG lBatchSize, // Batch LONG lBatchSize, // Batch
@ -58,6 +58,7 @@ COutputQueue::COutputQueue(
m_pPin(pInputPin), m_pPin(pInputPin),
m_ppSamples(NULL), m_ppSamples(NULL),
m_lWaiting(0), m_lWaiting(0),
m_evFlushComplete(FALSE, phr),
m_pInputPin(NULL), m_pInputPin(NULL),
m_bSendAnyway(FALSE), m_bSendAnyway(FALSE),
m_nBatched(0), m_nBatched(0),
@ -178,7 +179,7 @@ COutputQueue::~COutputQueue()
// //
// Call the real thread proc as a member function // Call the real thread proc as a member function
// //
DWORD WINAPI COutputQueue::InitialThreadProc(LPVOID pv) DWORD WINAPI COutputQueue::InitialThreadProc(__in LPVOID pv)
{ {
HRESULT hrCoInit = CAMThread::CoInitializeHelper(); HRESULT hrCoInit = CAMThread::CoInitializeHelper();
@ -591,10 +592,14 @@ HRESULT COutputQueue::Receive(IMediaSample *pSample)
// //
HRESULT COutputQueue::ReceiveMultiple ( HRESULT COutputQueue::ReceiveMultiple (
IMediaSample **ppSamples, __in_ecount(nSamples) IMediaSample **ppSamples,
long nSamples, long nSamples,
long *nSamplesProcessed) __out long *nSamplesProcessed)
{ {
if (nSamples < 0) {
return E_INVALIDARG;
}
CAutoLock lck(this); CAutoLock lck(this);
// Either call directly or queue up the samples // Either call directly or queue up the samples
@ -632,7 +637,7 @@ HRESULT COutputQueue::ReceiveMultiple (
// Loop processing the samples in batches // Loop processing the samples in batches
LONG iLost = 0; LONG iLost = 0;
long iDone; long iDone = 0;
for (iDone = 0; for (iDone = 0;
iDone < nSamples || (m_nBatched != 0 && m_bSendAnyway); iDone < nSamples || (m_nBatched != 0 && m_bSendAnyway);
) { ) {
@ -698,9 +703,11 @@ void COutputQueue::Reset()
if (!IsQueued()) { if (!IsQueued()) {
m_hr = S_OK; m_hr = S_OK;
} else { } else {
CAutoLock lck(this); {
QueueSample(RESET_PACKET); CAutoLock lck(this);
NotifyThread(); QueueSample(RESET_PACKET);
NotifyThread();
}
m_evFlushComplete.Wait(); m_evFlushComplete.Wait();
} }
} }

View File

@ -5,7 +5,7 @@
// makes a queue of samples and sends them to an output pin. The // makes a queue of samples and sends them to an output pin. The
// class will optionally send the samples to the pin directly. // class will optionally send the samples to the pin directly.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -16,7 +16,7 @@ class COutputQueue : public CCritSec
public: public:
// Constructor // Constructor
COutputQueue(IPin *pInputPin, // Pin to send stuff to COutputQueue(IPin *pInputPin, // Pin to send stuff to
HRESULT *phr, // 'Return code' __inout HRESULT *phr, // 'Return code'
BOOL bAuto = TRUE, // Ask pin if blocks BOOL bAuto = TRUE, // Ask pin if blocks
BOOL bQueue = TRUE, // Send through queue (ignored if BOOL bQueue = TRUE, // Send through queue (ignored if
// bAuto set) // bAuto set)
@ -50,9 +50,9 @@ public:
// do something with these media samples // do something with these media samples
HRESULT ReceiveMultiple ( HRESULT ReceiveMultiple (
IMediaSample **pSamples, __in_ecount(nSamples) IMediaSample **pSamples,
long nSamples, long nSamples,
long *nSamplesProcessed); __out long *nSamplesProcessed);
void Reset(); // Reset m_hr ready for more data void Reset(); // Reset m_hr ready for more data
@ -63,12 +63,12 @@ public:
void SetPopEvent(HANDLE hEvent); void SetPopEvent(HANDLE hEvent);
protected: protected:
static DWORD WINAPI InitialThreadProc(LPVOID pv); static DWORD WINAPI InitialThreadProc(__in LPVOID pv);
DWORD ThreadProc(); DWORD ThreadProc();
BOOL IsQueued() BOOL IsQueued()
{ {
return m_List != NULL; return m_List != NULL;
} };
// The critical section MUST be held when this is called // The critical section MUST be held when this is called
void QueueSample(IMediaSample *pSample); void QueueSample(IMediaSample *pSample);
@ -76,7 +76,7 @@ protected:
BOOL IsSpecialSample(IMediaSample *pSample) BOOL IsSpecialSample(IMediaSample *pSample)
{ {
return (DWORD_PTR)pSample > (DWORD_PTR)(LONG_PTR)(-16); return (DWORD_PTR)pSample > (DWORD_PTR)(LONG_PTR)(-16);
} };
// Remove and Release() batched and queued samples // Remove and Release() batched and queued samples
void FreeSamples(); void FreeSamples();
@ -109,8 +109,8 @@ protected:
HANDLE m_hSem; HANDLE m_hSem;
CAMEvent m_evFlushComplete; CAMEvent m_evFlushComplete;
HANDLE m_hThread; HANDLE m_hThread;
IMediaSample ** m_ppSamples; __field_ecount_opt(m_lBatchSize) IMediaSample ** m_ppSamples;
LONG m_nBatched; __range(0, m_lBatchSize) LONG m_nBatched;
// Wait optimization // Wait optimization
LONG m_lWaiting; LONG m_lWaiting;
@ -129,7 +129,7 @@ protected:
BOOL m_bSendAnyway; BOOL m_bSendAnyway;
// Deferred 'return code' // Deferred 'return code'
BOOL volatile m_hr; HRESULT volatile m_hr;
// an event that can be fired after every deliver // an event that can be fired after every deliver
HANDLE m_hEventPop; HANDLE m_hEventPop;

View File

@ -3,21 +3,22 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include <strsafe.h>
#ifdef PERF #ifdef PERF
#include <measure.h> #include <measure.h>
#endif #endif
// #include "pstream.h" in streams.h
// //
// Constructor // Constructor
// //
CPersistStream::CPersistStream(IUnknown *punk, HRESULT *phr) CPersistStream::CPersistStream(IUnknown *punk, __inout HRESULT *phr)
: mPS_fDirty(FALSE) : mPS_fDirty(FALSE)
{ {
mPS_dwFileVersion = GetSoftwareVersion(); mPS_dwFileVersion = GetSoftwareVersion();
@ -38,10 +39,10 @@ SAMPLE CODE TO COPY - not active at the moment
// NonDelegatingQueryInterface // NonDelegatingQueryInterface
// //
// This object supports IPersist & IPersistStream // This object supports IPersist & IPersistStream
STDMETHODIMP CPersistStream::NonDelegatingQueryInterface(REFIID riid, void **ppv) STDMETHODIMP CPersistStream::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{ {
if (riid == IID_IPersist) { if (riid == IID_IPersist) {
return GetInterface((IPersist *) this, ppv); return GetInterface((IPersist *) this, ppv); // ???
} }
else if (riid == IID_IPersistStream) { else if (riid == IID_IPersistStream) {
return GetInterface((IPersistStream *) this, ppv); return GetInterface((IPersistStream *) this, ppv);
@ -128,7 +129,7 @@ STDMETHODIMP CPersistStream::Save(LPSTREAM pStm, BOOL fClearDirty)
STDAPI WriteInt(IStream *pIStream, int n) STDAPI WriteInt(IStream *pIStream, int n)
{ {
WCHAR Buff[13]; // Allows for trailing null that we don't write WCHAR Buff[13]; // Allows for trailing null that we don't write
(void)StringCchPrintfW(Buff, NUMELMS(Buff), L"%011d ",n); (void)StringCchPrintfW(Buff, NUMELMS(Buff),L"%011d ",n);
return pIStream->Write(&(Buff[0]), 12*sizeof(WCHAR), NULL); return pIStream->Write(&(Buff[0]), 12*sizeof(WCHAR), NULL);
} // WriteInt } // WriteInt
@ -140,7 +141,7 @@ STDAPI WriteInt(IStream *pIStream, int n)
// where the value isn't actually truncated by squeezing it into 32 bits // where the value isn't actually truncated by squeezing it into 32 bits
// Striped down subset of what sscanf can do (without dragging in the C runtime) // Striped down subset of what sscanf can do (without dragging in the C runtime)
STDAPI_(int) ReadInt(IStream *pIStream, HRESULT &hr) STDAPI_(int) ReadInt(IStream *pIStream, __out HRESULT &hr)
{ {
int Sign = 1; int Sign = 1;

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines a class for persistent properties // Desc: DirectShow base classes - defines a class for persistent properties
// of filters. // of filters.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -61,13 +61,13 @@ class CPersistStream : public IPersistStream {
{return (mPS_fDirty ? S_OK : S_FALSE);} // note FALSE means clean {return (mPS_fDirty ? S_OK : S_FALSE);} // note FALSE means clean
STDMETHODIMP Load(LPSTREAM pStm); STDMETHODIMP Load(LPSTREAM pStm);
STDMETHODIMP Save(LPSTREAM pStm, BOOL fClearDirty); STDMETHODIMP Save(LPSTREAM pStm, BOOL fClearDirty);
STDMETHODIMP GetSizeMax(ULARGE_INTEGER * pcbSize) STDMETHODIMP GetSizeMax(__out ULARGE_INTEGER * pcbSize)
// Allow 24 bytes for version. // Allow 24 bytes for version.
{ pcbSize->QuadPart = 12*sizeof(WCHAR)+SizeMax(); return NOERROR; } { pcbSize->QuadPart = 12*sizeof(WCHAR)+SizeMax(); return NOERROR; }
// implementation // implementation
CPersistStream(IUnknown *punk, HRESULT *phr); CPersistStream(IUnknown *punk, __inout HRESULT *phr);
~CPersistStream(); ~CPersistStream();
HRESULT SetDirty(BOOL fDirty) HRESULT SetDirty(BOOL fDirty)
@ -80,7 +80,7 @@ class CPersistStream : public IPersistStream {
// --- IPersist --- // --- IPersist ---
// You must override this to provide your own class id // You must override this to provide your own class id
STDMETHODIMP GetClassID(CLSID *pClsid) PURE; STDMETHODIMP GetClassID(__out CLSID *pClsid) PURE;
// overrideable if you want // overrideable if you want
// file version number. Override it if you ever change format // file version number. Override it if you ever change format
@ -109,6 +109,6 @@ class CPersistStream : public IPersistStream {
STDAPI WriteInt(IStream *pIStream, int n); STDAPI WriteInt(IStream *pIStream, int n);
// inverse of WriteInt // inverse of WriteInt
STDAPI_(int) ReadInt(IStream *pIStream, HRESULT &hr); STDAPI_(int) ReadInt(IStream *pIStream, __out HRESULT &hr);
#endif // __PSTREAM__ #endif // __PSTREAM__

View File

@ -4,13 +4,16 @@
// Desc: DirectShow base classes - implements CPullPin class that pulls data // Desc: DirectShow base classes - implements CPullPin class that pulls data
// from IAsyncReader. // from IAsyncReader.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include "pullpin.h" #include "pullpin.h"
#ifdef DXMPERF
#include "dxmperf.h"
#endif // DXMPERF
CPullPin::CPullPin() CPullPin::CPullPin()
@ -18,11 +21,20 @@ CPullPin::CPullPin()
m_pAlloc(NULL), m_pAlloc(NULL),
m_State(TM_Exit) m_State(TM_Exit)
{ {
#ifdef DXMPERF
PERFLOG_CTOR( L"CPullPin", this );
#endif // DXMPERF
} }
CPullPin::~CPullPin() CPullPin::~CPullPin()
{ {
Disconnect(); Disconnect();
#ifdef DXMPERF
PERFLOG_DTOR( L"CPullPin", this );
#endif // DXMPERF
} }
// returns S_OK if successfully connected to an IAsyncReader interface // returns S_OK if successfully connected to an IAsyncReader interface
@ -40,12 +52,28 @@ CPullPin::Connect(IUnknown* pUnk, IMemAllocator* pAlloc, BOOL bSync)
HRESULT hr = pUnk->QueryInterface(IID_IAsyncReader, (void**)&m_pReader); HRESULT hr = pUnk->QueryInterface(IID_IAsyncReader, (void**)&m_pReader);
if (FAILED(hr)) { if (FAILED(hr)) {
#ifdef DXMPERF
{
AM_MEDIA_TYPE * pmt = NULL;
PERFLOG_CONNECT( this, pUnk, hr, pmt );
}
#endif // DXMPERF
return(hr); return(hr);
} }
hr = DecideAllocator(pAlloc, NULL); hr = DecideAllocator(pAlloc, NULL);
if (FAILED(hr)) { if (FAILED(hr)) {
Disconnect(); Disconnect();
#ifdef DXMPERF
{
AM_MEDIA_TYPE * pmt = NULL;
PERFLOG_CONNECT( this, pUnk, hr, pmt );
}
#endif // DXMPERF
return hr; return hr;
} }
@ -53,6 +81,14 @@ CPullPin::Connect(IUnknown* pUnk, IMemAllocator* pAlloc, BOOL bSync)
hr = m_pReader->Length(&llTotal, &llAvail); hr = m_pReader->Length(&llTotal, &llAvail);
if (FAILED(hr)) { if (FAILED(hr)) {
Disconnect(); Disconnect();
#ifdef DXMPERF
{
AM_MEDIA_TYPE * pmt = NULL;
PERFLOG_CONNECT( this, pUnk, hr, pmt );
}
#endif
return hr; return hr;
} }
@ -63,6 +99,14 @@ CPullPin::Connect(IUnknown* pUnk, IMemAllocator* pAlloc, BOOL bSync)
m_bSync = bSync; m_bSync = bSync;
#ifdef DXMPERF
{
AM_MEDIA_TYPE * pmt = NULL;
PERFLOG_CONNECT( this, pUnk, S_OK, pmt );
}
#endif // DXMPERF
return S_OK; return S_OK;
} }
@ -74,6 +118,12 @@ CPullPin::Disconnect()
StopThread(); StopThread();
#ifdef DXMPERF
PERFLOG_DISCONNECT( this, m_pReader, S_OK );
#endif // DXMPERF
if (m_pReader) { if (m_pReader) {
m_pReader->Release(); m_pReader->Release();
m_pReader = NULL; m_pReader = NULL;
@ -95,7 +145,7 @@ CPullPin::Disconnect()
HRESULT HRESULT
CPullPin::DecideAllocator( CPullPin::DecideAllocator(
IMemAllocator * pAlloc, IMemAllocator * pAlloc,
ALLOCATOR_PROPERTIES * pProps) __inout_opt ALLOCATOR_PROPERTIES * pProps)
{ {
ALLOCATOR_PROPERTIES *pRequest; ALLOCATOR_PROPERTIES *pRequest;
ALLOCATOR_PROPERTIES Request; ALLOCATOR_PROPERTIES Request;
@ -157,7 +207,7 @@ CPullPin::Seek(REFERENCE_TIME tStart, REFERENCE_TIME tStop)
} }
HRESULT HRESULT
CPullPin::Duration(REFERENCE_TIME* ptDuration) CPullPin::Duration(__out REFERENCE_TIME* ptDuration)
{ {
*ptDuration = m_tDuration; *ptDuration = m_tDuration;
return S_OK; return S_OK;
@ -284,7 +334,7 @@ CPullPin::ThreadProc(void)
HRESULT HRESULT
CPullPin::QueueSample( CPullPin::QueueSample(
REFERENCE_TIME& tCurrent, __inout REFERENCE_TIME& tCurrent,
REFERENCE_TIME tAlignStop, REFERENCE_TIME tAlignStop,
BOOL bDiscontinuity BOOL bDiscontinuity
) )
@ -352,16 +402,27 @@ CPullPin::DeliverSample(
{ {
// fix up sample if past actual stop (for sector alignment) // fix up sample if past actual stop (for sector alignment)
REFERENCE_TIME t1, t2; REFERENCE_TIME t1, t2;
pSample->GetTime(&t1, &t2); if (S_OK == pSample->GetTime(&t1, &t2)) {
if (t2 > tStop) { if (t2 > tStop) {
t2 = tStop; t2 = tStop;
}
// adjust times to be relative to (aligned) start time
t1 -= tStart;
t2 -= tStart;
HRESULT hr = pSample->SetTime(&t1, &t2);
if (FAILED(hr)) {
return hr;
}
} }
// adjust times to be relative to (aligned) start time #ifdef DXMPERF
t1 -= tStart; {
t2 -= tStart; AM_MEDIA_TYPE * pmt = NULL;
pSample->SetTime(&t1, &t2); pSample->GetMediaType( &pmt );
PERFLOG_RECEIVE( L"CPullPin", m_pReader, this, pSample, pmt );
}
#endif
HRESULT hr = Receive(pSample); HRESULT hr = Receive(pSample);
pSample->Release(); pSample->Release();

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes - defines CPullPin class. // Desc: DirectShow base classes - defines CPullPin class.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -57,7 +57,7 @@ class CPullPin : public CAMThread
// called from ProcessAsync to queue and collect requests // called from ProcessAsync to queue and collect requests
HRESULT QueueSample( HRESULT QueueSample(
REFERENCE_TIME& tCurrent, __inout REFERENCE_TIME& tCurrent,
REFERENCE_TIME tAlignStop, REFERENCE_TIME tAlignStop,
BOOL bDiscontinuity); BOOL bDiscontinuity);
@ -95,14 +95,14 @@ public:
// but no error occurs if it can't be met. // but no error occurs if it can't be met.
virtual HRESULT DecideAllocator( virtual HRESULT DecideAllocator(
IMemAllocator* pAlloc, IMemAllocator* pAlloc,
ALLOCATOR_PROPERTIES * pProps); __inout_opt ALLOCATOR_PROPERTIES * pProps);
// set start and stop position. if active, will start immediately at // set start and stop position. if active, will start immediately at
// the new position. Default is 0 to duration // the new position. Default is 0 to duration
HRESULT Seek(REFERENCE_TIME tStart, REFERENCE_TIME tStop); HRESULT Seek(REFERENCE_TIME tStart, REFERENCE_TIME tStop);
// return the total duration // return the total duration
HRESULT Duration(REFERENCE_TIME* ptDuration); HRESULT Duration(__out REFERENCE_TIME* ptDuration);
// start pulling data // start pulling data
HRESULT Active(void); HRESULT Active(void);

View File

@ -3,13 +3,16 @@
// //
// Desc: DirectShow base classes - implements the IReferenceClock interface. // Desc: DirectShow base classes - implements the IReferenceClock interface.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include <limits.h> #include <limits.h>
#ifdef DXMPERF
#include "dxmperf.h"
#endif // DXMPERF
// 'this' used in constructor list // 'this' used in constructor list
@ -18,7 +21,7 @@
STDMETHODIMP CBaseReferenceClock::NonDelegatingQueryInterface( STDMETHODIMP CBaseReferenceClock::NonDelegatingQueryInterface(
REFIID riid, REFIID riid,
void ** ppv) __deref_out void ** ppv)
{ {
HRESULT hr; HRESULT hr;
@ -26,6 +29,10 @@ STDMETHODIMP CBaseReferenceClock::NonDelegatingQueryInterface(
{ {
hr = GetInterface((IReferenceClock *) this, ppv); hr = GetInterface((IReferenceClock *) this, ppv);
} }
else if (riid == IID_IReferenceClockTimerControl)
{
hr = GetInterface((IReferenceClockTimerControl *) this, ppv);
}
else else
{ {
hr = CUnknown::NonDelegatingQueryInterface(riid, ppv); hr = CUnknown::NonDelegatingQueryInterface(riid, ppv);
@ -35,10 +42,16 @@ STDMETHODIMP CBaseReferenceClock::NonDelegatingQueryInterface(
CBaseReferenceClock::~CBaseReferenceClock() CBaseReferenceClock::~CBaseReferenceClock()
{ {
#ifdef DXMPERF
PERFLOG_DTOR( L"CBaseReferenceClock", (IReferenceClock *) this );
#endif // DXMPERF
if (m_TimerResolution) timeEndPeriod(m_TimerResolution); if (m_TimerResolution) timeEndPeriod(m_TimerResolution);
m_pSchedule->DumpLinkedList(); if (m_pSchedule)
{
m_pSchedule->DumpLinkedList();
}
if (m_hThread) if (m_hThread)
{ {
@ -55,7 +68,10 @@ CBaseReferenceClock::~CBaseReferenceClock()
// A derived class may supply a hThreadEvent if it has its own thread that will take care // A derived class may supply a hThreadEvent if it has its own thread that will take care
// of calling the schedulers Advise method. (Refere to CBaseReferenceClock::AdviseThread() // of calling the schedulers Advise method. (Refere to CBaseReferenceClock::AdviseThread()
// to see what such a thread has to do.) // to see what such a thread has to do.)
CBaseReferenceClock::CBaseReferenceClock( TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr, CAMSchedule * pShed ) CBaseReferenceClock::CBaseReferenceClock( __in_opt LPCTSTR pName,
__inout_opt LPUNKNOWN pUnk,
__inout HRESULT *phr,
__inout_opt CAMSchedule * pShed )
: CUnknown( pName, pUnk ) : CUnknown( pName, pUnk )
, m_rtLastGotTime(0) , m_rtLastGotTime(0)
, m_TimerResolution(0) , m_TimerResolution(0)
@ -64,51 +80,55 @@ CBaseReferenceClock::CBaseReferenceClock( TCHAR *pName, LPUNKNOWN pUnk, HRESULT
, m_hThread(0) , m_hThread(0)
{ {
#ifdef DXMPERF
PERFLOG_CTOR( pName ? pName : L"CBaseReferenceClock", (IReferenceClock *) this );
#endif // DXMPERF
ASSERT(m_pSchedule); ASSERT(m_pSchedule);
if (!m_pSchedule) if (!m_pSchedule)
{ {
*phr = E_OUTOFMEMORY; *phr = E_OUTOFMEMORY;
} }
else else
{ {
// Set up the highest resolution timer we can manage // Set up the highest resolution timer we can manage
TIMECAPS tc; TIMECAPS tc;
m_TimerResolution = (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc))) m_TimerResolution = (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc)))
? tc.wPeriodMin ? tc.wPeriodMin
: 1; : 1;
timeBeginPeriod(m_TimerResolution); timeBeginPeriod(m_TimerResolution);
/* Initialise our system times - the derived clock should set the right values */ /* Initialise our system times - the derived clock should set the right values */
m_dwPrevSystemTime = timeGetTime(); m_dwPrevSystemTime = timeGetTime();
m_rtPrivateTime = (UNITS / MILLISECONDS) * m_dwPrevSystemTime; m_rtPrivateTime = (UNITS / MILLISECONDS) * m_dwPrevSystemTime;
#ifdef PERF #ifdef PERF
m_idGetSystemTime = MSR_REGISTER(TEXT("CBaseReferenceClock::GetTime")); m_idGetSystemTime = MSR_REGISTER(TEXT("CBaseReferenceClock::GetTime"));
#endif #endif
if ( !pShed ) if ( !pShed )
{ {
DWORD ThreadID; DWORD ThreadID;
m_hThread = ::CreateThread(NULL, // Security attributes m_hThread = ::CreateThread(NULL, // Security attributes
(DWORD) 0, // Initial stack size (DWORD) 0, // Initial stack size
AdviseThreadFunction, // Thread start address AdviseThreadFunction, // Thread start address
(LPVOID) this, // Thread parameter (LPVOID) this, // Thread parameter
(DWORD) 0, // Creation flags (DWORD) 0, // Creation flags
&ThreadID); // Thread identifier &ThreadID); // Thread identifier
if (m_hThread) if (m_hThread)
{ {
SetThreadPriority( m_hThread, THREAD_PRIORITY_TIME_CRITICAL ); SetThreadPriority( m_hThread, THREAD_PRIORITY_TIME_CRITICAL );
} }
else else
{ {
*phr = E_FAIL; *phr = E_FAIL;
EXECUTE_ASSERT( CloseHandle(m_pSchedule->GetEvent()) ); EXECUTE_ASSERT( CloseHandle(m_pSchedule->GetEvent()) );
delete m_pSchedule; delete m_pSchedule;
} m_pSchedule = NULL;
} }
}
} }
} }
@ -119,7 +139,7 @@ void CBaseReferenceClock::Restart (IN REFERENCE_TIME rtMinTime)
Unlock(); Unlock();
} }
STDMETHODIMP CBaseReferenceClock::GetTime(REFERENCE_TIME *pTime) STDMETHODIMP CBaseReferenceClock::GetTime(__out REFERENCE_TIME *pTime)
{ {
HRESULT hr; HRESULT hr;
if (pTime) if (pTime)
@ -139,6 +159,11 @@ STDMETHODIMP CBaseReferenceClock::GetTime(REFERENCE_TIME *pTime)
*pTime = m_rtLastGotTime; *pTime = m_rtLastGotTime;
Unlock(); Unlock();
MSR_INTEGER(m_idGetSystemTime, LONG((*pTime) / (UNITS/MILLISECONDS)) ); MSR_INTEGER(m_idGetSystemTime, LONG((*pTime) / (UNITS/MILLISECONDS)) );
#ifdef DXMPERF
PERFLOG_GETTIME( (IReferenceClock *) this, *pTime );
#endif // DXMPERF
} }
else hr = E_POINTER; else hr = E_POINTER;
@ -150,8 +175,8 @@ STDMETHODIMP CBaseReferenceClock::GetTime(REFERENCE_TIME *pTime)
STDMETHODIMP CBaseReferenceClock::AdviseTime( STDMETHODIMP CBaseReferenceClock::AdviseTime(
REFERENCE_TIME baseTime, // base reference time REFERENCE_TIME baseTime, // base reference time
REFERENCE_TIME streamTime, // stream offset time REFERENCE_TIME streamTime, // stream offset time
HEVENT hEvent, // advise via this event HEVENT hEvent, // advise via this event
DWORD_PTR *pdwAdviseCookie) // where your cookie goes __out DWORD_PTR *pdwAdviseCookie)// where your cookie goes
{ {
CheckPointer(pdwAdviseCookie, E_POINTER); CheckPointer(pdwAdviseCookie, E_POINTER);
*pdwAdviseCookie = 0; *pdwAdviseCookie = 0;
@ -180,8 +205,8 @@ STDMETHODIMP CBaseReferenceClock::AdviseTime(
STDMETHODIMP CBaseReferenceClock::AdvisePeriodic( STDMETHODIMP CBaseReferenceClock::AdvisePeriodic(
REFERENCE_TIME StartTime, // starting at this time REFERENCE_TIME StartTime, // starting at this time
REFERENCE_TIME PeriodTime, // time between notifications REFERENCE_TIME PeriodTime, // time between notifications
HSEMAPHORE hSemaphore, // advise via a semaphore HSEMAPHORE hSemaphore, // advise via a semaphore
DWORD_PTR *pdwAdviseCookie) // where your cookie goes __out DWORD_PTR *pdwAdviseCookie) // where your cookie goes
{ {
CheckPointer(pdwAdviseCookie, E_POINTER); CheckPointer(pdwAdviseCookie, E_POINTER);
*pdwAdviseCookie = 0; *pdwAdviseCookie = 0;
@ -291,7 +316,7 @@ STDMETHODIMP CBaseReferenceClock::SetTimeDelta(const REFERENCE_TIME & TimeDelta)
// Thread stuff // Thread stuff
DWORD __stdcall CBaseReferenceClock::AdviseThreadFunction(LPVOID p) DWORD __stdcall CBaseReferenceClock::AdviseThreadFunction(__in LPVOID p)
{ {
return DWORD(reinterpret_cast<CBaseReferenceClock*>(p)->AdviseThread()); return DWORD(reinterpret_cast<CBaseReferenceClock*>(p)->AdviseThread());
} }
@ -338,3 +363,40 @@ HRESULT CBaseReferenceClock::AdviseThread()
}; };
return NOERROR; return NOERROR;
} }
HRESULT CBaseReferenceClock::SetDefaultTimerResolution(
REFERENCE_TIME timerResolution // in 100ns
)
{
CAutoLock cObjectLock(this);
if( 0 == timerResolution ) {
if( m_TimerResolution ) {
timeEndPeriod( m_TimerResolution );
m_TimerResolution = 0;
}
} else {
TIMECAPS tc;
DWORD dwMinResolution = (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc)))
? tc.wPeriodMin
: 1;
DWORD dwResolution = max( dwMinResolution, DWORD(timerResolution / 10000) );
if( dwResolution != m_TimerResolution ) {
timeEndPeriod(m_TimerResolution);
m_TimerResolution = dwResolution;
timeBeginPeriod( m_TimerResolution );
}
}
return S_OK;
}
HRESULT CBaseReferenceClock::GetDefaultTimerResolution(
__out REFERENCE_TIME* pTimerResolution // in 100ns
)
{
if( !pTimerResolution ) {
return E_POINTER;
}
CAutoLock cObjectLock(this);
*pTimerResolution = m_TimerResolution * 10000;
return S_OK;
}

View File

@ -3,14 +3,14 @@
// //
// Desc: DirectShow base classes - defines the IReferenceClock interface. // Desc: DirectShow base classes - defines the IReferenceClock interface.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#ifndef __BASEREFCLOCK__ #ifndef __BASEREFCLOCK__
#define __BASEREFCLOCK__ #define __BASEREFCLOCK__
#include "dsschedule.h" #include <Schedule.h>
const UINT RESOLUTION = 1; /* High resolution timer */ const UINT RESOLUTION = 1; /* High resolution timer */
const INT ADVISE_CACHE = 4; /* Default cache size */ const INT ADVISE_CACHE = 4; /* Default cache size */
@ -37,9 +37,9 @@ inline LONGLONG WINAPI ConvertToMilliseconds(const REFERENCE_TIME& RT)
* whatever source) have to be derived from this class. * whatever source) have to be derived from this class.
* *
* The abstract class provides implementations for: * The abstract class provides implementations for:
* CUnknown support * CUnknown support
* locking support (CCritSec) * locking support (CCritSec)
* client advise code (creates a thread) * client advise code (creates a thread)
* *
* Question: what can we do about quality? Change the timer * Question: what can we do about quality? Change the timer
* resolution to lower the system load? Up the priority of the * resolution to lower the system load? Up the priority of the
@ -72,14 +72,17 @@ inline LONGLONG WINAPI ConvertToMilliseconds(const REFERENCE_TIME& RT)
*/ */
class CBaseReferenceClock class CBaseReferenceClock
: public CUnknown, public IReferenceClock, public CCritSec : public CUnknown, public IReferenceClock, public CCritSec, public IReferenceClockTimerControl
{ {
protected: protected:
virtual ~CBaseReferenceClock(); // Don't let me be created on the stack! virtual ~CBaseReferenceClock(); // Don't let me be created on the stack!
public: public:
CBaseReferenceClock(TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr, CAMSchedule * pSched = 0 ); CBaseReferenceClock(__in_opt LPCTSTR pName,
__inout_opt LPUNKNOWN pUnk,
__inout HRESULT *phr,
__inout_opt CAMSchedule * pSched = 0 );
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,void ** ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
@ -90,7 +93,7 @@ public:
// clock has gone backwards and GetTime time has halted until internal // clock has gone backwards and GetTime time has halted until internal
// time has caught up. (Don't know if this will be much use to folk, // time has caught up. (Don't know if this will be much use to folk,
// but it seems odd not to use the return code for something useful.) // but it seems odd not to use the return code for something useful.)
STDMETHODIMP GetTime(REFERENCE_TIME *pTime); STDMETHODIMP GetTime(__out REFERENCE_TIME *pTime);
// When this is called, it sets m_rtLastGotTime to the time it returns. // When this is called, it sets m_rtLastGotTime to the time it returns.
/* Provide standard mechanisms for scheduling events */ /* Provide standard mechanisms for scheduling events */
@ -100,7 +103,7 @@ public:
REFERENCE_TIME baseTime, // base reference time REFERENCE_TIME baseTime, // base reference time
REFERENCE_TIME streamTime, // stream offset time REFERENCE_TIME streamTime, // stream offset time
HEVENT hEvent, // advise via this event HEVENT hEvent, // advise via this event
DWORD_PTR *pdwAdviseCookie // where your cookie goes __out DWORD_PTR *pdwAdviseCookie// where your cookie goes
); );
/* Ask for an asynchronous periodic notification that a time has elapsed */ /* Ask for an asynchronous periodic notification that a time has elapsed */
@ -108,7 +111,7 @@ public:
REFERENCE_TIME StartTime, // starting at this time REFERENCE_TIME StartTime, // starting at this time
REFERENCE_TIME PeriodTime, // time between notifications REFERENCE_TIME PeriodTime, // time between notifications
HSEMAPHORE hSemaphore, // advise via a semaphore HSEMAPHORE hSemaphore, // advise via a semaphore
DWORD_PTR *pdwAdviseCookie // where your cookie goes __out DWORD_PTR *pdwAdviseCookie// where your cookie goes
); );
/* Cancel a request for notification(s) - if the notification was /* Cancel a request for notification(s) - if the notification was
@ -135,6 +138,16 @@ public:
CAMSchedule * GetSchedule() const { return m_pSchedule; } CAMSchedule * GetSchedule() const { return m_pSchedule; }
// IReferenceClockTimerControl methods
//
// Setting a default of 0 disables the default of 1ms
STDMETHODIMP SetDefaultTimerResolution(
REFERENCE_TIME timerResolution // in 100ns
);
STDMETHODIMP GetDefaultTimerResolution(
__out REFERENCE_TIME* pTimerResolution // in 100ns
);
private: private:
REFERENCE_TIME m_rtPrivateTime; // Current best estimate of time REFERENCE_TIME m_rtPrivateTime; // Current best estimate of time
DWORD m_dwPrevSystemTime; // Last vaule we got from timeGetTime DWORD m_dwPrevSystemTime; // Last vaule we got from timeGetTime
@ -148,9 +161,9 @@ private:
// Thread stuff // Thread stuff
public: public:
void TriggerThread() // Wakes thread up. Need to do this if void TriggerThread() // Wakes thread up. Need to do this if
{ // time to next advise needs reevaluating. { // time to next advise needs reevaluating.
EXECUTE_ASSERT(SetEvent(m_pSchedule->GetEvent())); EXECUTE_ASSERT(SetEvent(m_pSchedule->GetEvent()));
} }
@ -159,10 +172,10 @@ private:
HANDLE m_hThread; // Thread handle HANDLE m_hThread; // Thread handle
HRESULT AdviseThread(); // Method in which the advise thread runs HRESULT AdviseThread(); // Method in which the advise thread runs
static DWORD __stdcall AdviseThreadFunction(LPVOID); // Function used to get there static DWORD __stdcall AdviseThreadFunction(__in LPVOID); // Function used to get there
protected: protected:
CAMSchedule * const m_pSchedule; CAMSchedule * m_pSchedule;
void Restart (IN REFERENCE_TIME rtMinTime = 0I64) ; void Restart (IN REFERENCE_TIME rtMinTime = 0I64) ;
}; };

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines CRefTime, a class that manages // Desc: DirectShow base classes - defines CRefTime, a class that manages
// reference times. // reference times.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -3,14 +3,14 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" // DirectShow base class definitions #include <streams.h> // DirectShow base class definitions
#include <mmsystem.h> // Needed for definition of timeGetTime #include <mmsystem.h> // Needed for definition of timeGetTime
#include <limits.h> // Standard data type limit definitions #include <limits.h> // Standard data type limit definitions
#include "measure.h" // Used for time critical log functions #include <measure.h> // Used for time critical log functions
#pragma warning(disable:4355) #pragma warning(disable:4355)
@ -28,15 +28,16 @@ int inline TimeDiff(REFERENCE_TIME rt)
// Implements the CBaseRenderer class // Implements the CBaseRenderer class
CBaseRenderer::CBaseRenderer(REFCLSID RenderClass, // CLSID for this renderer CBaseRenderer::CBaseRenderer(REFCLSID RenderClass, // CLSID for this renderer
TCHAR *pName, // Debug ONLY description __in_opt LPCTSTR pName, // Debug ONLY description
LPUNKNOWN pUnk, // Aggregated owner object __inout_opt LPUNKNOWN pUnk, // Aggregated owner object
HRESULT *phr) : // General OLE return code __inout HRESULT *phr) : // General OLE return code
CBaseFilter(pName,pUnk,&m_InterfaceLock,RenderClass), CBaseFilter(pName,pUnk,&m_InterfaceLock,RenderClass),
m_evComplete(TRUE), m_evComplete(TRUE, phr),
m_RenderEvent(FALSE, phr),
m_bAbort(FALSE), m_bAbort(FALSE),
m_pPosition(NULL), m_pPosition(NULL),
m_ThreadSignal(TRUE), m_ThreadSignal(TRUE, phr),
m_bStreaming(FALSE), m_bStreaming(FALSE),
m_bEOS(FALSE), m_bEOS(FALSE),
m_bEOSDelivered(FALSE), m_bEOSDelivered(FALSE),
@ -49,12 +50,14 @@ CBaseRenderer::CBaseRenderer(REFCLSID RenderClass, // CLSID for this renderer
m_bInReceive(FALSE), m_bInReceive(FALSE),
m_EndOfStreamTimer(0) m_EndOfStreamTimer(0)
{ {
Ready(); if (SUCCEEDED(*phr)) {
Ready();
#ifdef PERF #ifdef PERF
m_idBaseStamp = MSR_REGISTER(TEXT("BaseRenderer: sample time stamp")); m_idBaseStamp = MSR_REGISTER(TEXT("BaseRenderer: sample time stamp"));
m_idBaseRenderTime = MSR_REGISTER(TEXT("BaseRenderer: draw time (msec)")); m_idBaseRenderTime = MSR_REGISTER(TEXT("BaseRenderer: draw time (msec)"));
m_idBaseAccuracy = MSR_REGISTER(TEXT("BaseRenderer: Accuracy (msec)")); m_idBaseAccuracy = MSR_REGISTER(TEXT("BaseRenderer: Accuracy (msec)"));
#endif #endif
}
} }
@ -93,13 +96,18 @@ CBaseRenderer::~CBaseRenderer()
// This returns the IMediaPosition and IMediaSeeking interfaces // This returns the IMediaPosition and IMediaSeeking interfaces
HRESULT CBaseRenderer::GetMediaPositionInterface(REFIID riid,void **ppv) HRESULT CBaseRenderer::GetMediaPositionInterface(REFIID riid, __deref_out void **ppv)
{ {
CAutoLock cObjectCreationLock(&m_ObjectCreationLock); CAutoLock cObjectCreationLock(&m_ObjectCreationLock);
if (m_pPosition) { if (m_pPosition) {
return m_pPosition->NonDelegatingQueryInterface(riid,ppv); return m_pPosition->NonDelegatingQueryInterface(riid,ppv);
} }
CBasePin *pPin = GetPin(0);
if (NULL == pPin) {
return E_OUTOFMEMORY;
}
HRESULT hr = NOERROR; HRESULT hr = NOERROR;
// Create implementation of this dynamically since sometimes we may // Create implementation of this dynamically since sometimes we may
@ -110,7 +118,7 @@ HRESULT CBaseRenderer::GetMediaPositionInterface(REFIID riid,void **ppv)
m_pPosition = new CRendererPosPassThru(NAME("Renderer CPosPassThru"), m_pPosition = new CRendererPosPassThru(NAME("Renderer CPosPassThru"),
CBaseFilter::GetOwner(), CBaseFilter::GetOwner(),
(HRESULT *) &hr, (HRESULT *) &hr,
GetPin(0)); pPin);
if (m_pPosition == NULL) { if (m_pPosition == NULL) {
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
@ -126,7 +134,7 @@ HRESULT CBaseRenderer::GetMediaPositionInterface(REFIID riid,void **ppv)
// Overriden to say what interfaces we support and where // Overriden to say what interfaces we support and where
STDMETHODIMP CBaseRenderer::NonDelegatingQueryInterface(REFIID riid,void **ppv) STDMETHODIMP CBaseRenderer::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{ {
// Do we have this interface // Do we have this interface
@ -287,7 +295,7 @@ void CBaseRenderer::WaitForReceiveToComplete()
} }
MSG msg; MSG msg;
// Receive all interthread sendmessages // Receive all interthread snedmessages
PeekMessage(&msg, NULL, WM_NULL, WM_NULL, PM_NOREMOVE); PeekMessage(&msg, NULL, WM_NULL, WM_NULL, PM_NOREMOVE);
Sleep(1); Sleep(1);
@ -582,7 +590,11 @@ STDMETHODIMP CBaseRenderer::Run(REFERENCE_TIME StartTime)
int CBaseRenderer::GetPinCount() int CBaseRenderer::GetPinCount()
{ {
return 1; if (m_pInputPin == NULL) {
// Try to create it
(void)GetPin(0);
}
return m_pInputPin != NULL ? 1 : 0;
} }
@ -625,14 +637,17 @@ CBasePin *CBaseRenderer::GetPin(int n)
// If "In" then return the IPin for our input pin, otherwise NULL and error // If "In" then return the IPin for our input pin, otherwise NULL and error
STDMETHODIMP CBaseRenderer::FindPin(LPCWSTR Id, IPin **ppPin) STDMETHODIMP CBaseRenderer::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)
{ {
CheckPointer(ppPin,E_POINTER); CheckPointer(ppPin,E_POINTER);
if (0==lstrcmpW(Id,L"In")) { if (0==lstrcmpW(Id,L"In")) {
*ppPin = GetPin(0); *ppPin = GetPin(0);
ASSERT(*ppPin); if (*ppPin) {
(*ppPin)->AddRef(); (*ppPin)->AddRef();
} else {
return E_OUTOFMEMORY;
}
} else { } else {
*ppPin = NULL; *ppPin = NULL;
return VFW_E_NOT_FOUND; return VFW_E_NOT_FOUND;
@ -814,8 +829,8 @@ HRESULT CBaseRenderer::BreakConnect()
// which case the object should simply render the sample data immediately // which case the object should simply render the sample data immediately
HRESULT CBaseRenderer::GetSampleTimes(IMediaSample *pMediaSample, HRESULT CBaseRenderer::GetSampleTimes(IMediaSample *pMediaSample,
REFERENCE_TIME *pStartTime, __out REFERENCE_TIME *pStartTime,
REFERENCE_TIME *pEndTime) __out REFERENCE_TIME *pEndTime)
{ {
ASSERT(m_dwAdvise == 0); ASSERT(m_dwAdvise == 0);
ASSERT(pMediaSample); ASSERT(pMediaSample);
@ -849,8 +864,8 @@ HRESULT CBaseRenderer::GetSampleTimes(IMediaSample *pMediaSample,
// by the derived video renderer class in its quality management. // by the derived video renderer class in its quality management.
HRESULT CBaseRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample, HRESULT CBaseRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
REFERENCE_TIME *ptrStart, __out REFERENCE_TIME *ptrStart,
REFERENCE_TIME *ptrEnd) __out REFERENCE_TIME *ptrEnd)
{ {
return S_FALSE; return S_FALSE;
} }
@ -1544,9 +1559,9 @@ void CBaseRenderer::OnRenderEnd(IMediaSample *pMediaSample)
// Constructor must be passed the base renderer object // Constructor must be passed the base renderer object
CRendererInputPin::CRendererInputPin(CBaseRenderer *pRenderer, CRendererInputPin::CRendererInputPin(__inout CBaseRenderer *pRenderer,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pPinName) : __in_opt LPCWSTR pPinName) :
CBaseInputPin(NAME("Renderer pin"), CBaseInputPin(NAME("Renderer pin"),
pRenderer, pRenderer,
&pRenderer->m_InterfaceLock, &pRenderer->m_InterfaceLock,
@ -1685,16 +1700,17 @@ HRESULT CRendererInputPin::CompleteConnect(IPin *pReceivePin)
// Give the pin id of our one and only pin // Give the pin id of our one and only pin
STDMETHODIMP CRendererInputPin::QueryId(LPWSTR *Id) STDMETHODIMP CRendererInputPin::QueryId(__deref_out LPWSTR *Id)
{ {
CheckPointer(Id,E_POINTER); CheckPointer(Id,E_POINTER);
const size_t len = 4; const WCHAR szIn[] = L"In";
*Id = (LPWSTR)CoTaskMemAlloc(len * sizeof(WCHAR));
*Id = (LPWSTR)CoTaskMemAlloc(sizeof(szIn));
if (*Id == NULL) { if (*Id == NULL) {
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
(void)StringCchCopyW(*Id, len, L"In"); CopyMemory(*Id, szIn, sizeof(szIn));
return NOERROR; return NOERROR;
} }
@ -1753,9 +1769,9 @@ const TCHAR DRAWLATEFRAMES[] = TEXT("DrawLateFrames");
CBaseVideoRenderer::CBaseVideoRenderer( CBaseVideoRenderer::CBaseVideoRenderer(
REFCLSID RenderClass, // CLSID for this renderer REFCLSID RenderClass, // CLSID for this renderer
TCHAR *pName, // Debug ONLY description __in_opt LPCTSTR pName, // Debug ONLY description
LPUNKNOWN pUnk, // Aggregated owner object __inout_opt LPUNKNOWN pUnk, // Aggregated owner object
HRESULT *phr) : // General OLE return code __inout HRESULT *phr) : // General OLE return code
CBaseRenderer(RenderClass,pName,pUnk,phr), CBaseRenderer(RenderClass,pName,pUnk,phr),
m_cFramesDropped(0), m_cFramesDropped(0),
@ -1834,8 +1850,8 @@ HRESULT CBaseVideoRenderer::ResetStreamingTimes()
m_iTotAcc = 0; m_iTotAcc = 0;
m_iSumSqAcc = 0; m_iSumSqAcc = 0;
m_iSumSqFrameTime = 0; m_iSumSqFrameTime = 0;
m_trFrame = 0; // hygiene - not really needed m_trFrame = 0; // hygeine - not really needed
m_trLate = 0; // hygiene - not really needed m_trLate = 0; // hygeine - not really needed
m_iSumFrameTime = 0; m_iSumFrameTime = 0;
m_nNormal = 0; m_nNormal = 0;
m_trEarliness = 0; m_trEarliness = 0;
@ -2282,8 +2298,8 @@ HRESULT CBaseVideoRenderer::SendQuality(REFERENCE_TIME trLate,
// to make the decision // to make the decision
HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample, HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
REFERENCE_TIME *ptrStart, __inout REFERENCE_TIME *ptrStart,
REFERENCE_TIME *ptrEnd) __inout REFERENCE_TIME *ptrEnd)
{ {
// Don't call us unless there's a clock interface to synchronise with // Don't call us unless there's a clock interface to synchronise with
@ -2618,7 +2634,7 @@ BOOL CBaseVideoRenderer::ScheduleSample(IMediaSample *pMediaSample)
// our IQualProp interface. The AddRef and Release are handled automatically // our IQualProp interface. The AddRef and Release are handled automatically
// by the base class and will be passed on to the appropriate outer object // by the base class and will be passed on to the appropriate outer object
STDMETHODIMP CBaseVideoRenderer::get_FramesDroppedInRenderer(int *pcFramesDropped) STDMETHODIMP CBaseVideoRenderer::get_FramesDroppedInRenderer(__out int *pcFramesDropped)
{ {
CheckPointer(pcFramesDropped,E_POINTER); CheckPointer(pcFramesDropped,E_POINTER);
CAutoLock cVideoLock(&m_InterfaceLock); CAutoLock cVideoLock(&m_InterfaceLock);
@ -2669,7 +2685,7 @@ STDMETHODIMP CBaseVideoRenderer::get_AvgFrameRate( int *piAvgFrameRate)
// in mSec. The sync offset is the time in mSec between when the frame // in mSec. The sync offset is the time in mSec between when the frame
// should have been drawn and when the frame was actually drawn. // should have been drawn and when the frame was actually drawn.
STDMETHODIMP CBaseVideoRenderer::get_AvgSyncOffset( int *piAvg) STDMETHODIMP CBaseVideoRenderer::get_AvgSyncOffset(__out int *piAvg)
{ {
CheckPointer(piAvg,E_POINTER); CheckPointer(piAvg,E_POINTER);
CAutoLock cVideoLock(&m_InterfaceLock); CAutoLock cVideoLock(&m_InterfaceLock);
@ -2737,7 +2753,7 @@ int isqrt(int x)
// //
HRESULT CBaseVideoRenderer::GetStdDev( HRESULT CBaseVideoRenderer::GetStdDev(
int nSamples, int nSamples,
int *piResult, __out int *piResult,
LONGLONG llSumSq, LONGLONG llSumSq,
LONGLONG iTot LONGLONG iTot
) )
@ -2774,7 +2790,7 @@ HRESULT CBaseVideoRenderer::GetStdDev(
// Set *piDev to the standard deviation in mSec of the sync offset // Set *piDev to the standard deviation in mSec of the sync offset
// of each frame since streaming started. // of each frame since streaming started.
STDMETHODIMP CBaseVideoRenderer::get_DevSyncOffset( int *piDev) STDMETHODIMP CBaseVideoRenderer::get_DevSyncOffset(__out int *piDev)
{ {
// First frames have invalid stamps, so we get no stats for them // First frames have invalid stamps, so we get no stats for them
// So we need 2 frames to get 1 datum, so N is cFramesDrawn-1 // So we need 2 frames to get 1 datum, so N is cFramesDrawn-1
@ -2788,7 +2804,7 @@ STDMETHODIMP CBaseVideoRenderer::get_DevSyncOffset( int *piDev)
// Set *piJitter to the standard deviation in mSec of the inter-frame time // Set *piJitter to the standard deviation in mSec of the inter-frame time
// of frames since streaming started. // of frames since streaming started.
STDMETHODIMP CBaseVideoRenderer::get_Jitter( int *piJitter) STDMETHODIMP CBaseVideoRenderer::get_Jitter(__out int *piJitter)
{ {
// First frames have invalid stamps, so we get no stats for them // First frames have invalid stamps, so we get no stats for them
// So second frame gives invalid inter-frame time // So second frame gives invalid inter-frame time
@ -2803,7 +2819,7 @@ STDMETHODIMP CBaseVideoRenderer::get_Jitter( int *piJitter)
// Overidden to return our IQualProp interface // Overidden to return our IQualProp interface
STDMETHODIMP STDMETHODIMP
CBaseVideoRenderer::NonDelegatingQueryInterface(REFIID riid,VOID **ppv) CBaseVideoRenderer::NonDelegatingQueryInterface(REFIID riid,__deref_out VOID **ppv)
{ {
// We return IQualProp and delegate everything else // We return IQualProp and delegate everything else
@ -2820,7 +2836,7 @@ CBaseVideoRenderer::NonDelegatingQueryInterface(REFIID riid,VOID **ppv)
// the graph we can send an EC_WINDOW_DESTROYED event // the graph we can send an EC_WINDOW_DESTROYED event
STDMETHODIMP STDMETHODIMP
CBaseVideoRenderer::JoinFilterGraph(IFilterGraph *pGraph,LPCWSTR pName) CBaseVideoRenderer::JoinFilterGraph(__inout_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)
{ {
// Since we send EC_ACTIVATE, we also need to ensure // Since we send EC_ACTIVATE, we also need to ensure
// we send EC_WINDOW_DESTROYED or the resource manager may be // we send EC_WINDOW_DESTROYED or the resource manager may be
@ -2829,10 +2845,8 @@ CBaseVideoRenderer::JoinFilterGraph(IFilterGraph *pGraph,LPCWSTR pName)
// We were in a graph and now we're not // We were in a graph and now we're not
// Do this properly in case we are aggregated // Do this properly in case we are aggregated
IBaseFilter* pFilter; IBaseFilter* pFilter = this;
QueryInterface(IID_IBaseFilter,(void **) &pFilter);
NotifyEvent(EC_WINDOW_DESTROYED, (LPARAM) pFilter, 0); NotifyEvent(EC_WINDOW_DESTROYED, (LPARAM) pFilter, 0);
pFilter->Release();
} }
return CBaseFilter::JoinFilterGraph(pGraph, pName); return CBaseFilter::JoinFilterGraph(pGraph, pName);
} }

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines a generic ActiveX base renderer // Desc: DirectShow base classes - defines a generic ActiveX base renderer
// class. // class.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -27,9 +27,9 @@ protected:
public: public:
CRendererInputPin(CBaseRenderer *pRenderer, CRendererInputPin(__inout CBaseRenderer *pRenderer,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR Name); __in_opt LPCWSTR Name);
// Overriden from the base pin classes // Overriden from the base pin classes
@ -42,7 +42,7 @@ public:
// Add rendering behaviour to interface functions // Add rendering behaviour to interface functions
STDMETHODIMP QueryId(LPWSTR *Id); STDMETHODIMP QueryId(__deref_out LPWSTR *Id);
STDMETHODIMP EndOfStream(); STDMETHODIMP EndOfStream();
STDMETHODIMP BeginFlush(); STDMETHODIMP BeginFlush();
STDMETHODIMP EndFlush(); STDMETHODIMP EndFlush();
@ -97,16 +97,16 @@ protected:
public: public:
CBaseRenderer(REFCLSID RenderClass, // CLSID for this renderer CBaseRenderer(REFCLSID RenderClass, // CLSID for this renderer
TCHAR *pName, // Debug ONLY description __in_opt LPCTSTR pName, // Debug ONLY description
LPUNKNOWN pUnk, // Aggregated owner object __inout_opt LPUNKNOWN pUnk, // Aggregated owner object
HRESULT *phr); // General OLE return code __inout HRESULT *phr); // General OLE return code
~CBaseRenderer(); ~CBaseRenderer();
// Overriden to say what interfaces we support and where // Overriden to say what interfaces we support and where
virtual HRESULT GetMediaPositionInterface(REFIID riid,void **ppv); virtual HRESULT GetMediaPositionInterface(REFIID riid, __deref_out void **ppv);
STDMETHODIMP NonDelegatingQueryInterface(REFIID, void **); STDMETHODIMP NonDelegatingQueryInterface(REFIID, __deref_out void **);
virtual HRESULT SourceThreadCanWait(BOOL bCanWait); virtual HRESULT SourceThreadCanWait(BOOL bCanWait);
@ -145,8 +145,8 @@ public:
STDMETHODIMP Stop(); STDMETHODIMP Stop();
STDMETHODIMP Pause(); STDMETHODIMP Pause();
STDMETHODIMP Run(REFERENCE_TIME StartTime); STDMETHODIMP Run(REFERENCE_TIME StartTime);
STDMETHODIMP GetState(DWORD dwMSecs,FILTER_STATE *State); STDMETHODIMP GetState(DWORD dwMSecs, __out FILTER_STATE *State);
STDMETHODIMP FindPin(LPCWSTR Id, IPin **ppPin); STDMETHODIMP FindPin(LPCWSTR Id, __deref_out IPin **ppPin);
// These are available for a quality management implementation // These are available for a quality management implementation
@ -170,12 +170,12 @@ public:
virtual BOOL ScheduleSample(IMediaSample *pMediaSample); virtual BOOL ScheduleSample(IMediaSample *pMediaSample);
virtual HRESULT GetSampleTimes(IMediaSample *pMediaSample, virtual HRESULT GetSampleTimes(IMediaSample *pMediaSample,
REFERENCE_TIME *pStartTime, __out REFERENCE_TIME *pStartTime,
REFERENCE_TIME *pEndTime); __out REFERENCE_TIME *pEndTime);
virtual HRESULT ShouldDrawSampleNow(IMediaSample *pMediaSample, virtual HRESULT ShouldDrawSampleNow(IMediaSample *pMediaSample,
REFERENCE_TIME *ptrStart, __out REFERENCE_TIME *ptrStart,
REFERENCE_TIME *ptrEnd); __out REFERENCE_TIME *ptrEnd);
// Lots of end of stream complexities // Lots of end of stream complexities
@ -408,9 +408,9 @@ public:
CBaseVideoRenderer(REFCLSID RenderClass, // CLSID for this renderer CBaseVideoRenderer(REFCLSID RenderClass, // CLSID for this renderer
TCHAR *pName, // Debug ONLY description __in_opt LPCTSTR pName, // Debug ONLY description
LPUNKNOWN pUnk, // Aggregated owner object __inout_opt LPUNKNOWN pUnk, // Aggregated owner object
HRESULT *phr); // General OLE return code __inout HRESULT *phr); // General OLE return code
~CBaseVideoRenderer(); ~CBaseVideoRenderer();
@ -437,11 +437,11 @@ public:
virtual HRESULT ResetStreamingTimes(); virtual HRESULT ResetStreamingTimes();
BOOL ScheduleSample(IMediaSample *pMediaSample); BOOL ScheduleSample(IMediaSample *pMediaSample);
HRESULT ShouldDrawSampleNow(IMediaSample *pMediaSample, HRESULT ShouldDrawSampleNow(IMediaSample *pMediaSample,
REFERENCE_TIME *ptrStart, __inout REFERENCE_TIME *ptrStart,
REFERENCE_TIME *ptrEnd); __inout REFERENCE_TIME *ptrEnd);
virtual HRESULT SendQuality(REFERENCE_TIME trLate, REFERENCE_TIME trRealStream); virtual HRESULT SendQuality(REFERENCE_TIME trLate, REFERENCE_TIME trRealStream);
STDMETHODIMP JoinFilterGraph(IFilterGraph * pGraph, LPCWSTR pName); STDMETHODIMP JoinFilterGraph(__inout_opt IFilterGraph * pGraph, __in_opt LPCWSTR pName);
// //
// Do estimates for standard deviations for per-frame // Do estimates for standard deviations for per-frame
@ -453,7 +453,7 @@ public:
// //
HRESULT GetStdDev( HRESULT GetStdDev(
int nSamples, int nSamples,
int *piResult, __out int *piResult,
LONGLONG llSumSq, LONGLONG llSumSq,
LONGLONG iTot LONGLONG iTot
); );
@ -461,17 +461,17 @@ public:
// IQualProp property page support // IQualProp property page support
STDMETHODIMP get_FramesDroppedInRenderer(int *cFramesDropped); STDMETHODIMP get_FramesDroppedInRenderer(__out int *cFramesDropped);
STDMETHODIMP get_FramesDrawn(int *pcFramesDrawn); STDMETHODIMP get_FramesDrawn(__out int *pcFramesDrawn);
STDMETHODIMP get_AvgFrameRate(int *piAvgFrameRate); STDMETHODIMP get_AvgFrameRate(__out int *piAvgFrameRate);
STDMETHODIMP get_Jitter(int *piJitter); STDMETHODIMP get_Jitter(__out int *piJitter);
STDMETHODIMP get_AvgSyncOffset(int *piAvg); STDMETHODIMP get_AvgSyncOffset(__out int *piAvg);
STDMETHODIMP get_DevSyncOffset(int *piDev); STDMETHODIMP get_DevSyncOffset(__out int *piDev);
// Implement an IUnknown interface and expose IQualProp // Implement an IUnknown interface and expose IQualProp
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,VOID **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,__deref_out VOID **ppv);
}; };
#endif // __RENBASE__ #endif // __RENBASE__

View File

@ -3,11 +3,11 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1996-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
// DbgLog values (all on LOG_TIMING): // DbgLog values (all on LOG_TIMING):
// //
@ -117,11 +117,8 @@ HRESULT CAMSchedule::Unadvise(DWORD_PTR dwAdviseCookie)
CAdvisePacket * p_prev = &head; CAdvisePacket * p_prev = &head;
CAdvisePacket * p_n; CAdvisePacket * p_n;
m_Serialize.Lock(); m_Serialize.Lock();
while (1) // The Next() method returns NULL when it hits z while ( p_n = p_prev->Next() ) // The Next() method returns NULL when it hits z
{ {
p_n = p_prev->Next();
if (!p_n) break;
if ( p_n->m_dwAdviseCookie == dwAdviseCookie ) if ( p_n->m_dwAdviseCookie == dwAdviseCookie )
{ {
Delete( p_prev->RemoveNext() ); Delete( p_prev->RemoveNext() );
@ -190,7 +187,7 @@ REFERENCE_TIME CAMSchedule::Advise( const REFERENCE_TIME & rtTime )
/* Private methods */ /* Private methods */
DWORD_PTR CAMSchedule::AddAdvisePacket( CAdvisePacket * pPacket ) DWORD_PTR CAMSchedule::AddAdvisePacket( __inout CAdvisePacket * pPacket )
{ {
ASSERT(pPacket->m_rtEventTime >= 0 && pPacket->m_rtEventTime < MAX_TIME); ASSERT(pPacket->m_rtEventTime >= 0 && pPacket->m_rtEventTime < MAX_TIME);
ASSERT(CritCheckIn(&m_Serialize)); ASSERT(CritCheckIn(&m_Serialize));
@ -217,7 +214,7 @@ DWORD_PTR CAMSchedule::AddAdvisePacket( CAdvisePacket * pPacket )
return Result; return Result;
} }
void CAMSchedule::Delete( CAdvisePacket * pPacket ) void CAMSchedule::Delete( __inout CAdvisePacket * pPacket )
{ {
if ( m_dwCacheCount >= dwCacheMax ) delete pPacket; if ( m_dwCacheCount >= dwCacheMax ) delete pPacket;
else else

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1996-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -50,10 +50,10 @@ private:
HANDLE m_hNotify; // Handle to event or semephore HANDLE m_hNotify; // Handle to event or semephore
BOOL m_bPeriodic; // TRUE => Periodic event BOOL m_bPeriodic; // TRUE => Periodic event
CAdvisePacket( CAdvisePacket * next, LONGLONG time ) : m_next(next), m_rtEventTime(time) CAdvisePacket( __inout_opt CAdvisePacket * next, LONGLONG time ) : m_next(next), m_rtEventTime(time)
{} {}
void InsertAfter( CAdvisePacket * p ) void InsertAfter( __inout CAdvisePacket * p )
{ {
p->m_next = m_next; p->m_next = m_next;
m_next = p; m_next = p;
@ -99,7 +99,7 @@ private:
CCritSec m_Serialize; CCritSec m_Serialize;
// AddAdvisePacket: adds the packet, returns the cookie (0 if failed) // AddAdvisePacket: adds the packet, returns the cookie (0 if failed)
DWORD_PTR AddAdvisePacket( CAdvisePacket * pPacket ); DWORD_PTR AddAdvisePacket( __inout CAdvisePacket * pPacket );
// Event that we should set if the packed added above will be the next to fire. // Event that we should set if the packed added above will be the next to fire.
const HANDLE m_ev; const HANDLE m_ev;
@ -113,7 +113,7 @@ private:
DWORD m_dwCacheCount; DWORD m_dwCacheCount;
enum { dwCacheMax = 5 }; // Don't bother caching more than five enum { dwCacheMax = 5 }; // Don't bother caching more than five
void Delete( CAdvisePacket * pLink );// This "Delete" will cache the Link void Delete( __inout CAdvisePacket * pLink );// This "Delete" will cache the Link
// Attributes and methods for debugging // Attributes and methods for debugging
public: public:

View File

@ -3,11 +3,11 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include "seekpt.h" #include "seekpt.h"
//================================================================== //==================================================================
@ -17,13 +17,13 @@
// and save it in a static variable so that forever after we can return that. // and save it in a static variable so that forever after we can return that.
//================================================================== //==================================================================
CUnknown * CSeekingPassThru::CreateInstance(LPUNKNOWN pUnk, HRESULT *phr) CUnknown * CSeekingPassThru::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)
{ {
return new CSeekingPassThru(NAME("Seeking PassThru"),pUnk, phr); return new CSeekingPassThru(NAME("Seeking PassThru"),pUnk, phr);
} }
STDMETHODIMP CSeekingPassThru::NonDelegatingQueryInterface(REFIID riid, void ** ppv) STDMETHODIMP CSeekingPassThru::NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv)
{ {
if (riid == IID_ISeekingPassThru) { if (riid == IID_ISeekingPassThru) {
return GetInterface((ISeekingPassThru *) this, ppv); return GetInterface((ISeekingPassThru *) this, ppv);
@ -39,7 +39,7 @@ STDMETHODIMP CSeekingPassThru::NonDelegatingQueryInterface(REFIID riid, void **
} }
CSeekingPassThru::CSeekingPassThru( TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr ) CSeekingPassThru::CSeekingPassThru( __in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr )
: CUnknown(pName, pUnk, phr), : CUnknown(pName, pUnk, phr),
m_pPosPassThru(NULL) m_pPosPassThru(NULL)
{ {

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -14,12 +14,12 @@
class CSeekingPassThru : public ISeekingPassThru, public CUnknown class CSeekingPassThru : public ISeekingPassThru, public CUnknown
{ {
public: public:
static CUnknown *CreateInstance(LPUNKNOWN pUnk, HRESULT *phr); static CUnknown *CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);
CSeekingPassThru(TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr); CSeekingPassThru(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);
~CSeekingPassThru(); ~CSeekingPassThru();
DECLARE_IUNKNOWN; DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);
STDMETHODIMP Init(BOOL bSupportRendering, IPin *pPin); STDMETHODIMP Init(BOOL bSupportRendering, IPin *pPin);

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - implements CSource, which is a Quartz // Desc: DirectShow base classes - implements CSource, which is a Quartz
// source filter 'template.' // source filter 'template.'
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -18,7 +18,7 @@
// the threads processing loop, when it is safe to get the filter critical // the threads processing loop, when it is safe to get the filter critical
// section from within FillBuffer(). // section from within FillBuffer().
#include "streams.h" #include <streams.h>
// //
@ -26,14 +26,14 @@
// //
// Initialise the pin count for the filter. The user will create the pins in // Initialise the pin count for the filter. The user will create the pins in
// the derived class. // the derived class.
CSource::CSource(TCHAR *pName, LPUNKNOWN lpunk, CLSID clsid) CSource::CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid)
: CBaseFilter(pName, lpunk, &m_cStateLock, clsid), : CBaseFilter(pName, lpunk, &m_cStateLock, clsid),
m_iPins(0), m_iPins(0),
m_paStreams(NULL) m_paStreams(NULL)
{ {
} }
CSource::CSource(TCHAR *pName, LPUNKNOWN lpunk, CLSID clsid, HRESULT *phr) CSource::CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr)
: CBaseFilter(pName, lpunk, &m_cStateLock, clsid), : CBaseFilter(pName, lpunk, &m_cStateLock, clsid),
m_iPins(0), m_iPins(0),
m_paStreams(NULL) m_paStreams(NULL)
@ -42,14 +42,14 @@ CSource::CSource(TCHAR *pName, LPUNKNOWN lpunk, CLSID clsid, HRESULT *phr)
} }
#ifdef UNICODE #ifdef UNICODE
CSource::CSource(CHAR *pName, LPUNKNOWN lpunk, CLSID clsid) CSource::CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid)
: CBaseFilter(pName, lpunk, &m_cStateLock, clsid), : CBaseFilter(pName, lpunk, &m_cStateLock, clsid),
m_iPins(0), m_iPins(0),
m_paStreams(NULL) m_paStreams(NULL)
{ {
} }
CSource::CSource(CHAR *pName, LPUNKNOWN lpunk, CLSID clsid, HRESULT *phr) CSource::CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr)
: CBaseFilter(pName, lpunk, &m_cStateLock, clsid), : CBaseFilter(pName, lpunk, &m_cStateLock, clsid),
m_iPins(0), m_iPins(0),
m_paStreams(NULL) m_paStreams(NULL)
@ -76,7 +76,7 @@ CSource::~CSource()
// //
// Add a new pin // Add a new pin
// //
HRESULT CSource::AddPin(CSourceStream *pStream) HRESULT CSource::AddPin(__in CSourceStream *pStream)
{ {
CAutoLock lock(&m_cStateLock); CAutoLock lock(&m_cStateLock);
@ -100,7 +100,7 @@ HRESULT CSource::AddPin(CSourceStream *pStream)
// //
// Remove a pin - pStream is NOT deleted // Remove a pin - pStream is NOT deleted
// //
HRESULT CSource::RemovePin(CSourceStream *pStream) HRESULT CSource::RemovePin(__in CSourceStream *pStream)
{ {
int i; int i;
for (i = 0; i < m_iPins; i++) { for (i = 0; i < m_iPins; i++) {
@ -125,7 +125,7 @@ HRESULT CSource::RemovePin(CSourceStream *pStream)
// //
// Set *ppPin to the IPin* that has the id Id. // Set *ppPin to the IPin* that has the id Id.
// or to NULL if the Id cannot be matched. // or to NULL if the Id cannot be matched.
STDMETHODIMP CSource::FindPin(LPCWSTR Id, IPin **ppPin) STDMETHODIMP CSource::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)
{ {
CheckPointer(ppPin,E_POINTER); CheckPointer(ppPin,E_POINTER);
ValidateReadWritePtr(ppPin,sizeof(IPin *)); ValidateReadWritePtr(ppPin,sizeof(IPin *));
@ -145,7 +145,7 @@ STDMETHODIMP CSource::FindPin(LPCWSTR Id, IPin **ppPin)
// FindPinNumber // FindPinNumber
// //
// return the number of the pin with this IPin* or -1 if none // return the number of the pin with this IPin* or -1 if none
int CSource::FindPinNumber(IPin *iPin) { int CSource::FindPinNumber(__in IPin *iPin) {
int i; int i;
for (i=0; i<m_iPins; ++i) { for (i=0; i<m_iPins; ++i) {
if ((IPin *)(m_paStreams[i])==iPin) { if ((IPin *)(m_paStreams[i])==iPin) {
@ -196,7 +196,7 @@ CBasePin *CSource::GetPin(int n) {
// //
// Set Id to point to a CoTaskMemAlloc'd // Set Id to point to a CoTaskMemAlloc'd
STDMETHODIMP CSourceStream::QueryId(LPWSTR *Id) { STDMETHODIMP CSourceStream::QueryId(__deref_out LPWSTR *Id) {
CheckPointer(Id,E_POINTER); CheckPointer(Id,E_POINTER);
ValidateReadWritePtr(Id,sizeof(LPWSTR)); ValidateReadWritePtr(Id,sizeof(LPWSTR));
@ -204,11 +204,11 @@ STDMETHODIMP CSourceStream::QueryId(LPWSTR *Id) {
// FindPinNumber returns -1 for an invalid pin // FindPinNumber returns -1 for an invalid pin
int i = 1+ m_pFilter->FindPinNumber(this); int i = 1+ m_pFilter->FindPinNumber(this);
if (i<1) return VFW_E_NOT_FOUND; if (i<1) return VFW_E_NOT_FOUND;
*Id = (LPWSTR)CoTaskMemAlloc(4*sizeof(WCHAR)); *Id = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * 12);
if (*Id==NULL) { if (*Id==NULL) {
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
IntToWstr(i, *Id, 4); IntToWstr(i, *Id);
return NOERROR; return NOERROR;
} }
@ -219,10 +219,10 @@ STDMETHODIMP CSourceStream::QueryId(LPWSTR *Id) {
// //
// increments the number of pins present on the filter // increments the number of pins present on the filter
CSourceStream::CSourceStream( CSourceStream::CSourceStream(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
HRESULT *phr, __inout HRESULT *phr,
CSource *ps, __inout CSource *ps,
LPCWSTR pPinName) __in_opt LPCWSTR pPinName)
: CBaseOutputPin(pObjectName, ps, ps->pStateLock(), phr, pPinName), : CBaseOutputPin(pObjectName, ps, ps->pStateLock(), phr, pPinName),
m_pFilter(ps) { m_pFilter(ps) {
@ -231,10 +231,10 @@ CSourceStream::CSourceStream(
#ifdef UNICODE #ifdef UNICODE
CSourceStream::CSourceStream( CSourceStream::CSourceStream(
char *pObjectName, __in_opt LPCSTR pObjectName,
HRESULT *phr, __inout HRESULT *phr,
CSource *ps, __inout CSource *ps,
LPCWSTR pPinName) __in_opt LPCWSTR pPinName)
: CBaseOutputPin(pObjectName, ps, ps->pStateLock(), phr, pPinName), : CBaseOutputPin(pObjectName, ps, ps->pStateLock(), phr, pPinName),
m_pFilter(ps) { m_pFilter(ps) {
@ -275,7 +275,7 @@ HRESULT CSourceStream::CheckMediaType(const CMediaType *pMediaType) {
// //
// By default we support only one type // By default we support only one type
// iPosition indexes are 0-n // iPosition indexes are 0-n
HRESULT CSourceStream::GetMediaType(int iPosition, CMediaType *pMediaType) { HRESULT CSourceStream::GetMediaType(int iPosition, __inout CMediaType *pMediaType) {
CAutoLock lock(m_pFilter->pStateLock()); CAutoLock lock(m_pFilter->pStateLock());

View File

@ -5,7 +5,7 @@
// ActiveX source filters that support continuous generation of data. // ActiveX source filters that support continuous generation of data.
// No support is provided for IMediaControl or IMediaPosition. // No support is provided for IMediaControl or IMediaPosition.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -43,11 +43,11 @@ class CSourceStream; // The class that will handle each pin
class CSource : public CBaseFilter { class CSource : public CBaseFilter {
public: public:
CSource(TCHAR *pName, LPUNKNOWN lpunk, CLSID clsid, HRESULT *phr); CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr);
CSource(TCHAR *pName, LPUNKNOWN lpunk, CLSID clsid); CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid);
#ifdef UNICODE #ifdef UNICODE
CSource(CHAR *pName, LPUNKNOWN lpunk, CLSID clsid, HRESULT *phr); CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr);
CSource(CHAR *pName, LPUNKNOWN lpunk, CLSID clsid); CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid);
#endif #endif
~CSource(); ~CSource();
@ -58,15 +58,15 @@ public:
CCritSec* pStateLock(void) { return &m_cStateLock; } // provide our critical section CCritSec* pStateLock(void) { return &m_cStateLock; } // provide our critical section
HRESULT AddPin(CSourceStream *); HRESULT AddPin(__in CSourceStream *);
HRESULT RemovePin(CSourceStream *); HRESULT RemovePin(__in CSourceStream *);
STDMETHODIMP FindPin( STDMETHODIMP FindPin(
LPCWSTR Id, LPCWSTR Id,
IPin ** ppPin __deref_out IPin ** ppPin
); );
int FindPinNumber(IPin *iPin); int FindPinNumber(__in IPin *iPin);
protected: protected:
@ -88,15 +88,15 @@ protected:
class CSourceStream : public CAMThread, public CBaseOutputPin { class CSourceStream : public CAMThread, public CBaseOutputPin {
public: public:
CSourceStream(TCHAR *pObjectName, CSourceStream(__in_opt LPCTSTR pObjectName,
HRESULT *phr, __inout HRESULT *phr,
CSource *pms, __inout CSource *pms,
LPCWSTR pName); __in_opt LPCWSTR pName);
#ifdef UNICODE #ifdef UNICODE
CSourceStream(CHAR *pObjectName, CSourceStream(__in_opt LPCSTR pObjectName,
HRESULT *phr, __inout HRESULT *phr,
CSource *pms, __inout CSource *pms,
LPCWSTR pName); __in_opt LPCWSTR pName);
#endif #endif
virtual ~CSourceStream(void); // virtual destructor ensures derived class destructors are called too. virtual ~CSourceStream(void); // virtual destructor ensures derived class destructors are called too.
@ -155,16 +155,16 @@ protected:
// If you support more than one media type then override these 2 functions // If you support more than one media type then override these 2 functions
virtual HRESULT CheckMediaType(const CMediaType *pMediaType); virtual HRESULT CheckMediaType(const CMediaType *pMediaType);
virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType); // List pos. 0-n virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType); // List pos. 0-n
// If you support only one type then override this fn. // If you support only one type then override this fn.
// This will only be called by the default implementations // This will only be called by the default implementations
// of CheckMediaType and GetMediaType(int, CMediaType*) // of CheckMediaType and GetMediaType(int, CMediaType*)
// You must override this fn. or the above 2! // You must override this fn. or the above 2!
virtual HRESULT GetMediaType(CMediaType *pMediaType) {return E_UNEXPECTED;} virtual HRESULT GetMediaType(__inout CMediaType *pMediaType) {return E_UNEXPECTED;}
STDMETHODIMP QueryId( STDMETHODIMP QueryId(
LPWSTR * Id __deref_out LPWSTR * Id
); );
}; };

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes - defines overall streams architecture. // Desc: DirectShow base classes - defines overall streams architecture.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -13,13 +13,10 @@
#ifdef _MSC_VER #ifdef _MSC_VER
// disable some level-4 warnings, use #pragma warning(enable:###) to re-enable // disable some level-4 warnings, use #pragma warning(enable:###) to re-enable
#pragma warning(disable:4100) // warning C4100: unreferenced formal parameter #pragma warning(disable:4100) // warning C4100: unreferenced formal parameter
#pragma warning(disable:4127) // warning C4127: conditional expression is constant
#pragma warning(disable:4189) // warning C4189: local variable is initialized but not referenced
#pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union #pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
#pragma warning(disable:4511) // warning C4511: copy constructor could not be generated #pragma warning(disable:4511) // warning C4511: copy constructor could not be generated
#pragma warning(disable:4512) // warning C4512: assignment operator could not be generated #pragma warning(disable:4512) // warning C4512: assignment operator could not be generated
#pragma warning(disable:4514) // warning C4514: unreferenced inline function has been removed #pragma warning(disable:4514) // warning C4514: "unreferenced inline function has been removed"
#pragma warning(disable:4710) // warning C4710: 'function' not inlined
#if _MSC_VER>=1100 #if _MSC_VER>=1100
#define AM_NOVTABLE __declspec(novtable) #define AM_NOVTABLE __declspec(novtable)
@ -28,6 +25,7 @@
#endif #endif
#endif // MSC_VER #endif // MSC_VER
// Because of differences between Visual C++ and older Microsoft SDKs, // Because of differences between Visual C++ and older Microsoft SDKs,
// you may have defined _DEBUG without defining DEBUG. This logic // you may have defined _DEBUG without defining DEBUG. This logic
// ensures that both will be set if Visual C++ sets _DEBUG. // ensures that both will be set if Visual C++ sets _DEBUG.
@ -37,18 +35,20 @@
#endif #endif
#endif #endif
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#include <olectl.h> #include <olectl.h>
#include <ddraw.h>
// Disable warning message for C4201 - use of nameless struct/union
// Otherwise, strmif.h will generate warnings for Win32 debug builds
#pragma warning( disable : 4201 )
#include <mmsystem.h> #include <mmsystem.h>
#ifndef NUMELMS #ifndef NUMELMS
#if _WIN32_WINNT < 0x0600
#define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0])) #define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
#else
#define NUMELMS(aa) ARRAYSIZE(aa)
#endif
#endif #endif
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -123,64 +123,69 @@ typedef struct {
#ifndef DWLP_USER #ifndef DWLP_USER
#define DWLP_USER DWLP_DLGPROC + sizeof(DLGPROC) #define DWLP_USER DWLP_DLGPROC + sizeof(DLGPROC)
#endif #endif
#pragma warning(push)
#pragma warning(disable: 4312 4244)
// _GetWindowLongPtr
// Templated version of GetWindowLongPtr, to suppress spurious compiler warning.
template <class T>
T _GetWindowLongPtr(HWND hwnd, int nIndex)
{
return (T)GetWindowLongPtr(hwnd, nIndex);
}
// _SetWindowLongPtr
// Templated version of SetWindowLongPtr, to suppress spurious compiler warning.
template <class T>
LONG_PTR _SetWindowLongPtr(HWND hwnd, int nIndex, T p)
{
return SetWindowLongPtr(hwnd, nIndex, (LONG_PTR)p);
}
#pragma warning(pop)
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// End Platform SDK definitions // End Platform SDK definitions
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include <initguid.h>
#pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
#include <strmif.h> // Generated IDL header file for streams interfaces #include <strmif.h> // Generated IDL header file for streams interfaces
#include <intsafe.h> // required by amvideo.h
#include "reftime.h" // Helper class for REFERENCE_TIME management #include <reftime.h> // Helper class for REFERENCE_TIME management
#include "wxdebug.h" // Debug support for logging and ASSERTs #include <wxdebug.h> // Debug support for logging and ASSERTs
#include "amvideo.h" // ActiveMovie video interfaces and definitions #include <amvideo.h> // ActiveMovie video interfaces and definitions
//include amaudio.h explicitly if you need it. it requires the DirectX SDK. //include amaudio.h explicitly if you need it. it requires the DX SDK.
//#include "amaudio.h" // ActiveMovie audio interfaces and definitions //#include <amaudio.h> // ActiveMovie audio interfaces and definitions
#include "wxutil.h" // General helper classes for threads etc #include <wxutil.h> // General helper classes for threads etc
#include "combase.h" // Base COM classes to support IUnknown #include <combase.h> // Base COM classes to support IUnknown
//#include "dllsetup.h" // Filter registration support functions #include <measure.h> // Performance measurement
#include "measure.h" // Performance measurement #include <comlite.h> // Light weight com function prototypes
#include "comlite.h" // Light weight com function prototypes
#include "cache.h" // Simple cache container class #include <cache.h> // Simple cache container class
#include "wxlist.h" // Non MFC generic list class #include <wxlist.h> // Non MFC generic list class
#include "msgthrd.h" // CMsgThread #include <msgthrd.h> // CMsgThread
#include "mtype.h" // Helper class for managing media types #include <mtype.h> // Helper class for managing media types
#include "fourcc.h" // conversions between FOURCCs and GUIDs #include <fourcc.h> // conversions between FOURCCs and GUIDs
#include "control.h" // generated from control.odl #include <control.h> // generated from control.odl
#include "ctlutil.h" // control interface utility classes #include <ctlutil.h> // control interface utility classes
#include "evcode.h" // event code definitions #include <evcode.h> // event code definitions
#include "amfilter.h" // Main streams architecture class hierachy #include <amfilter.h> // Main streams architecture class hierachy
#include "transfrm.h" // Generic transform filter #include <transfrm.h> // Generic transform filter
#include "transip.h" // Generic transform-in-place filter #include <transip.h> // Generic transform-in-place filter
#include "uuids.h" // declaration of type GUIDs and well-known clsids #include <uuids.h> // declaration of type GUIDs and well-known clsids
#include "source.h" // Generic source filter #include <source.h> // Generic source filter
#include "outputq.h" // Output pin queueing #include <outputq.h> // Output pin queueing
#include "errors.h" // HRESULT status and error definitions #include <errors.h> // HRESULT status and error definitions
#include "renbase.h" // Base class for writing ActiveX renderers #include <renbase.h> // Base class for writing ActiveX renderers
//#include "winutil.h" // Helps with filters that manage windows #include <refclock.h> // Base clock class
//#include "winctrl.h" // Implements the IVideoWindow interface #include <sysclock.h> // System clock
//#include "videoctl.h" // Specifically video related classes #include <pstream.h> // IPersistStream helper class
#include "refclock.h" // Base clock class #include <vtrans.h> // Video Transform Filter base class
#include "sysclock.h" // System clock #include <amextra.h>
#include "pstream.h" // IPersistStream helper class #include <strmctl.h> // IAMStreamControl support
#include "vtrans.h" // Video Transform Filter base class #include <edevdefs.h> // External device control interface defines
#include "amextra.h" #include <audevcod.h> // audio filter device error event codes
//#include "cprop.h" // Base property page class
#include "strmctl.h" // IAMStreamControl support
#include "edevdefs.h" // External device control interface defines
#include "audevcod.h" // audio filter device error event codes
#include <tchar.h>
#define NO_SHLWAPI_STRFCNS
//#include <atlbase.h>
#include <strsafe.h>
#ifndef NUMELMS
#define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
#endif

View File

@ -3,18 +3,19 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1996-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include "strmctl.h" #include <strmctl.h>
CBaseStreamControl::CBaseStreamControl() CBaseStreamControl::CBaseStreamControl(__inout HRESULT *phr)
: m_StreamState(STREAM_FLOWING) : m_StreamState(STREAM_FLOWING)
, m_StreamStateOnStop(STREAM_FLOWING) // means no pending stop , m_StreamStateOnStop(STREAM_FLOWING) // means no pending stop
, m_tStartTime(MAX_TIME) , m_tStartTime(MAX_TIME)
, m_tStopTime(MAX_TIME) , m_tStopTime(MAX_TIME)
, m_StreamEvent(FALSE, phr)
, m_dwStartCookie(0) , m_dwStartCookie(0)
, m_dwStopCookie(0) , m_dwStopCookie(0)
, m_pRefClock(NULL) , m_pRefClock(NULL)
@ -120,7 +121,7 @@ STDMETHODIMP CBaseStreamControl::StartAt
} }
// Retrieve information about current settings // Retrieve information about current settings
STDMETHODIMP CBaseStreamControl::GetInfo(AM_STREAM_INFO *pInfo) STDMETHODIMP CBaseStreamControl::GetInfo(__out AM_STREAM_INFO *pInfo)
{ {
if (pInfo == NULL) if (pInfo == NULL)
return E_POINTER; return E_POINTER;
@ -231,7 +232,7 @@ void CBaseStreamControl::CancelStart()
enum CBaseStreamControl::StreamControlState CBaseStreamControl::CheckSampleTimes enum CBaseStreamControl::StreamControlState CBaseStreamControl::CheckSampleTimes
( const REFERENCE_TIME * pSampleStart, const REFERENCE_TIME * pSampleStop ) ( __in const REFERENCE_TIME * pSampleStart, __in const REFERENCE_TIME * pSampleStop )
{ {
CAutoLock lck(&m_CritSec); CAutoLock lck(&m_CritSec);

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1996-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -71,15 +71,15 @@ private:
// expires, throw the sample away. If the event // expires, throw the sample away. If the event
// fires, call me back - I've changed my mind. // fires, call me back - I've changed my mind.
// //
enum StreamControlState CheckSampleTimes( const REFERENCE_TIME * pSampleStart, enum StreamControlState CheckSampleTimes( __in const REFERENCE_TIME * pSampleStart,
const REFERENCE_TIME * pSampleStop ); __in const REFERENCE_TIME * pSampleStop );
public: public:
// You don't have to tell us much when we're created, but there are other // You don't have to tell us much when we're created, but there are other
// obligations that must be met. See SetSyncSource & NotifyFilterState // obligations that must be met. See SetSyncSource & NotifyFilterState
// below. // below.
// //
CBaseStreamControl(); CBaseStreamControl(__inout_opt HRESULT *phr = NULL);
~CBaseStreamControl(); ~CBaseStreamControl();
// If you want this class to work properly, there are thing you need to // If you want this class to work properly, there are thing you need to
@ -134,7 +134,7 @@ public:
DWORD dwCookie = 0 ); DWORD dwCookie = 0 );
STDMETHODIMP StartAt( const REFERENCE_TIME * ptStart = NULL, STDMETHODIMP StartAt( const REFERENCE_TIME * ptStart = NULL,
DWORD dwCookie = 0 ); DWORD dwCookie = 0 );
STDMETHODIMP GetInfo( AM_STREAM_INFO *pInfo); STDMETHODIMP GetInfo( __out AM_STREAM_INFO *pInfo);
// Helper function for pin's receive method. Call this with // Helper function for pin's receive method. Call this with
// the sample and we'll tell you what to do with it. We'll do a // the sample and we'll tell you what to do with it. We'll do a

View File

@ -4,11 +4,11 @@
// Desc: DirectShow base classes - implements a system clock based on // Desc: DirectShow base classes - implements a system clock based on
// IReferenceClock. // IReferenceClock.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include <limits.h> #include <limits.h>
@ -27,20 +27,20 @@ int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
#endif #endif
/* This goes in the factory template table to create new instances */ /* This goes in the factory template table to create new instances */
CUnknown * WINAPI CSystemClock::CreateInstance(LPUNKNOWN pUnk,HRESULT *phr) CUnknown * WINAPI CSystemClock::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)
{ {
return new CSystemClock(NAME("System reference clock"),pUnk, phr); return new CSystemClock(NAME("System reference clock"),pUnk, phr);
} }
CSystemClock::CSystemClock(TCHAR *pName,LPUNKNOWN pUnk,HRESULT *phr) : CSystemClock::CSystemClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr) :
CBaseReferenceClock(pName, pUnk, phr) CBaseReferenceClock(pName, pUnk, phr)
{ {
} }
STDMETHODIMP CSystemClock::NonDelegatingQueryInterface( STDMETHODIMP CSystemClock::NonDelegatingQueryInterface(
REFIID riid, REFIID riid,
void ** ppv) __deref_out void ** ppv)
{ {
if (riid == IID_IPersist) if (riid == IID_IPersist)
{ {
@ -58,7 +58,7 @@ STDMETHODIMP CSystemClock::NonDelegatingQueryInterface(
/* Return the clock's clsid */ /* Return the clock's clsid */
STDMETHODIMP STDMETHODIMP
CSystemClock::GetClassID(CLSID *pClsID) CSystemClock::GetClassID(__out CLSID *pClsID)
{ {
CheckPointer(pClsID,E_POINTER); CheckPointer(pClsID,E_POINTER);
ValidateReadWritePtr(pClsID,sizeof(CLSID)); ValidateReadWritePtr(pClsID,sizeof(CLSID));

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines a system clock implementation of // Desc: DirectShow base classes - defines a system clock implementation of
// IReferenceClock. // IReferenceClock.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -21,16 +21,16 @@ class CSystemClock : public CBaseReferenceClock, public IAMClockAdjust, public I
{ {
public: public:
// We must be able to create an instance of ourselves // We must be able to create an instance of ourselves
static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *phr); static CUnknown * WINAPI CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);
CSystemClock(TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr); CSystemClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);
DECLARE_IUNKNOWN DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,void ** ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);
// Yield up our class id so that we can be persisted // Yield up our class id so that we can be persisted
// Implement required Ipersist method // Implement required Ipersist method
STDMETHODIMP GetClassID(CLSID *pClsID); STDMETHODIMP GetClassID(__out CLSID *pClsID);
// IAMClockAdjust methods // IAMClockAdjust methods
STDMETHODIMP SetClockDelta(REFERENCE_TIME rtDelta); STDMETHODIMP SetClockDelta(REFERENCE_TIME rtDelta);

View File

@ -4,20 +4,20 @@
// Desc: DirectShow base classes - implements class for simple transform // Desc: DirectShow base classes - implements class for simple transform
// filters such as video decompressors. // filters such as video decompressors.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include "measure.h" #include <measure.h>
// ================================================================= // =================================================================
// Implements the CTransformFilter class // Implements the CTransformFilter class
// ================================================================= // =================================================================
CTransformFilter::CTransformFilter(TCHAR *pName, CTransformFilter::CTransformFilter(__in_opt LPCTSTR pName,
LPUNKNOWN pUnk, __inout_opt LPUNKNOWN pUnk,
REFCLSID clsid) : REFCLSID clsid) :
CBaseFilter(pName,pUnk,&m_csFilter, clsid), CBaseFilter(pName,pUnk,&m_csFilter, clsid),
m_pInput(NULL), m_pInput(NULL),
@ -32,8 +32,8 @@ CTransformFilter::CTransformFilter(TCHAR *pName,
} }
#ifdef UNICODE #ifdef UNICODE
CTransformFilter::CTransformFilter(char *pName, CTransformFilter::CTransformFilter(__in_opt LPCSTR pName,
LPUNKNOWN pUnk, __inout_opt LPUNKNOWN pUnk,
REFCLSID clsid) : REFCLSID clsid) :
CBaseFilter(pName,pUnk,&m_csFilter, clsid), CBaseFilter(pName,pUnk,&m_csFilter, clsid),
m_pInput(NULL), m_pInput(NULL),
@ -140,7 +140,7 @@ CTransformFilter::GetPin(int n)
// If Id is In or Out then return the IPin* for that pin // If Id is In or Out then return the IPin* for that pin
// creating the pin if need be. Otherwise return NULL with an error. // creating the pin if need be. Otherwise return NULL with an error.
STDMETHODIMP CTransformFilter::FindPin(LPCWSTR Id, IPin **ppPin) STDMETHODIMP CTransformFilter::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)
{ {
CheckPointer(ppPin,E_POINTER); CheckPointer(ppPin,E_POINTER);
ValidateReadWritePtr(ppPin,sizeof(IPin *)); ValidateReadWritePtr(ppPin,sizeof(IPin *));
@ -185,7 +185,7 @@ CTransformFilter::StopStreaming()
// override this to grab extra interfaces on connection // override this to grab extra interfaces on connection
HRESULT HRESULT
CTransformFilter::CheckConnect(PIN_DIRECTION dir,IPin *pPin) CTransformFilter::CheckConnect(PIN_DIRECTION dir, IPin *pPin)
{ {
UNREFERENCED_PARAMETER(dir); UNREFERENCED_PARAMETER(dir);
UNREFERENCED_PARAMETER(pPin); UNREFERENCED_PARAMETER(pPin);
@ -227,7 +227,7 @@ CTransformFilter::SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt)
// Set up our output sample // Set up our output sample
HRESULT HRESULT
CTransformFilter::InitializeOutputSample(IMediaSample *pSample, IMediaSample **ppOutSample) CTransformFilter::InitializeOutputSample(IMediaSample *pSample, __deref_out IMediaSample **ppOutSample)
{ {
IMediaSample *pOutSample; IMediaSample *pOutSample;
@ -578,10 +578,10 @@ CTransformInputPin::CheckStreaming()
// constructor // constructor
CTransformInputPin::CTransformInputPin( CTransformInputPin::CTransformInputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CTransformFilter *pTransformFilter, __inout CTransformFilter *pTransformFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pName) __in_opt LPCWSTR pName)
: CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName) : CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName)
{ {
DbgLog((LOG_TRACE,2,TEXT("CTransformInputPin::CTransformInputPin"))); DbgLog((LOG_TRACE,2,TEXT("CTransformInputPin::CTransformInputPin")));
@ -590,10 +590,10 @@ CTransformInputPin::CTransformInputPin(
#ifdef UNICODE #ifdef UNICODE
CTransformInputPin::CTransformInputPin( CTransformInputPin::CTransformInputPin(
CHAR *pObjectName, __in_opt LPCSTR pObjectName,
CTransformFilter *pTransformFilter, __inout CTransformFilter *pTransformFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pName) __in_opt LPCWSTR pName)
: CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName) : CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName)
{ {
DbgLog((LOG_TRACE,2,TEXT("CTransformInputPin::CTransformInputPin"))); DbgLog((LOG_TRACE,2,TEXT("CTransformInputPin::CTransformInputPin")));
@ -791,10 +791,10 @@ CTransformInputPin::NewSegment(
// constructor // constructor
CTransformOutputPin::CTransformOutputPin( CTransformOutputPin::CTransformOutputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CTransformFilter *pTransformFilter, __inout CTransformFilter *pTransformFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pPinName) __in_opt LPCWSTR pPinName)
: CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName), : CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName),
m_pPosition(NULL) m_pPosition(NULL)
{ {
@ -805,10 +805,10 @@ CTransformOutputPin::CTransformOutputPin(
#ifdef UNICODE #ifdef UNICODE
CTransformOutputPin::CTransformOutputPin( CTransformOutputPin::CTransformOutputPin(
CHAR *pObjectName, __in_opt LPCSTR pObjectName,
CTransformFilter *pTransformFilter, __inout CTransformFilter *pTransformFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pPinName) __in_opt LPCWSTR pPinName)
: CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName), : CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName),
m_pPosition(NULL) m_pPosition(NULL)
{ {
@ -831,7 +831,7 @@ CTransformOutputPin::~CTransformOutputPin()
// overriden to expose IMediaPosition and IMediaSeeking control interfaces // overriden to expose IMediaPosition and IMediaSeeking control interfaces
STDMETHODIMP STDMETHODIMP
CTransformOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv) CTransformOutputPin::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{ {
CheckPointer(ppv,E_POINTER); CheckPointer(ppv,E_POINTER);
ValidateReadWritePtr(ppv,sizeof(PVOID)); ValidateReadWritePtr(ppv,sizeof(PVOID));
@ -958,7 +958,7 @@ CTransformOutputPin::SetMediaType(const CMediaType* pmtOut)
HRESULT HRESULT
CTransformOutputPin::DecideBufferSize( CTransformOutputPin::DecideBufferSize(
IMemAllocator * pAllocator, IMemAllocator * pAllocator,
ALLOCATOR_PROPERTIES* pProp) __inout ALLOCATOR_PROPERTIES* pProp)
{ {
return m_pTransformFilter->DecideBufferSize(pAllocator, pProp); return m_pTransformFilter->DecideBufferSize(pAllocator, pProp);
} }
@ -970,7 +970,7 @@ CTransformOutputPin::DecideBufferSize(
HRESULT HRESULT
CTransformOutputPin::GetMediaType( CTransformOutputPin::GetMediaType(
int iPosition, int iPosition,
CMediaType *pMediaType) __inout CMediaType *pMediaType)
{ {
ASSERT(m_pTransformFilter->m_pInput != NULL); ASSERT(m_pTransformFilter->m_pInput != NULL);

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines classes from which simple // Desc: DirectShow base classes - defines classes from which simple
// transform codecs may be derived. // transform codecs may be derived.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -41,19 +41,19 @@ protected:
public: public:
CTransformInputPin( CTransformInputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CTransformFilter *pTransformFilter, __inout CTransformFilter *pTransformFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#ifdef UNICODE #ifdef UNICODE
CTransformInputPin( CTransformInputPin(
char *pObjectName, __in_opt LPCSTR pObjectName,
CTransformFilter *pTransformFilter, __inout CTransformFilter *pTransformFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#endif #endif
STDMETHODIMP QueryId(LPWSTR * Id) STDMETHODIMP QueryId(__deref_out LPWSTR * Id)
{ {
return AMGetWideString(L"In", Id); return AMGetWideString(L"In", Id);
} }
@ -118,25 +118,25 @@ public:
IUnknown * m_pPosition; IUnknown * m_pPosition;
CTransformOutputPin( CTransformOutputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CTransformFilter *pTransformFilter, __inout CTransformFilter *pTransformFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#ifdef UNICODE #ifdef UNICODE
CTransformOutputPin( CTransformOutputPin(
CHAR *pObjectName, __in_opt LPCSTR pObjectName,
CTransformFilter *pTransformFilter, __inout CTransformFilter *pTransformFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
#endif #endif
~CTransformOutputPin(); ~CTransformOutputPin();
// override to expose IMediaPosition // override to expose IMediaPosition
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
// --- CBaseOutputPin ------------ // --- CBaseOutputPin ------------
STDMETHODIMP QueryId(LPWSTR * Id) STDMETHODIMP QueryId(__deref_out LPWSTR * Id)
{ {
return AMGetWideString(L"Out", Id); return AMGetWideString(L"Out", Id);
} }
@ -157,10 +157,10 @@ public:
// the count and size of buffers we need. // the count and size of buffers we need.
HRESULT DecideBufferSize( HRESULT DecideBufferSize(
IMemAllocator * pAlloc, IMemAllocator * pAlloc,
ALLOCATOR_PROPERTIES *pProp); __inout ALLOCATOR_PROPERTIES *pProp);
// returns the preferred formats for a pin // returns the preferred formats for a pin
HRESULT GetMediaType(int iPosition,CMediaType *pMediaType); HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType);
// inherited from IQualityControl via CBasePin // inherited from IQualityControl via CBasePin
STDMETHODIMP Notify(IBaseFilter * pSender, Quality q); STDMETHODIMP Notify(IBaseFilter * pSender, Quality q);
@ -181,7 +181,7 @@ public:
virtual int GetPinCount(); virtual int GetPinCount();
virtual CBasePin * GetPin(int n); virtual CBasePin * GetPin(int n);
STDMETHODIMP FindPin(LPCWSTR Id, IPin **ppPin); STDMETHODIMP FindPin(LPCWSTR Id, __deref_out IPin **ppPin);
// override state changes to allow derived transform filter // override state changes to allow derived transform filter
// to control streaming start/stop // to control streaming start/stop
@ -190,9 +190,9 @@ public:
public: public:
CTransformFilter(TCHAR *, LPUNKNOWN, REFCLSID clsid); CTransformFilter(__in_opt LPCTSTR , __inout_opt LPUNKNOWN, REFCLSID clsid);
#ifdef UNICODE #ifdef UNICODE
CTransformFilter(CHAR *, LPUNKNOWN, REFCLSID clsid); CTransformFilter(__in_opt LPCSTR , __inout_opt LPUNKNOWN, REFCLSID clsid);
#endif #endif
~CTransformFilter(); ~CTransformFilter();
@ -211,15 +211,15 @@ public:
virtual HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut) PURE; virtual HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut) PURE;
// this goes in the factory template table to create new instances // this goes in the factory template table to create new instances
// static CCOMObject * CreateInstance(LPUNKNOWN, HRESULT *); // static CCOMObject * CreateInstance(__inout_opt LPUNKNOWN, HRESULT *);
// call the SetProperties function with appropriate arguments // call the SetProperties function with appropriate arguments
virtual HRESULT DecideBufferSize( virtual HRESULT DecideBufferSize(
IMemAllocator * pAllocator, IMemAllocator * pAllocator,
ALLOCATOR_PROPERTIES *pprop) PURE; __inout ALLOCATOR_PROPERTIES *pprop) PURE;
// override to suggest OUTPUT pin media types // override to suggest OUTPUT pin media types
virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType) PURE; virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType) PURE;
@ -246,7 +246,7 @@ public:
virtual HRESULT Receive(IMediaSample *pSample); virtual HRESULT Receive(IMediaSample *pSample);
// Standard setup for output sample // Standard setup for output sample
HRESULT InitializeOutputSample(IMediaSample *pSample, IMediaSample **ppOutSample); HRESULT InitializeOutputSample(IMediaSample *pSample, __deref_out IMediaSample **ppOutSample);
// if you override Receive, you may need to override these three too // if you override Receive, you may need to override these three too
virtual HRESULT EndOfStream(void); virtual HRESULT EndOfStream(void);

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - implements class for simple Transform- // Desc: DirectShow base classes - implements class for simple Transform-
// In-Place filters such as audio. // In-Place filters such as audio.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -251,9 +251,9 @@
// And that's IT!! Any further (essentially spurious) reconnects peter out // And that's IT!! Any further (essentially spurious) reconnects peter out
// with no change in the chain. // with no change in the chain.
#include "streams.h" #include <streams.h>
#include "measure.h" #include <measure.h>
#include "transip.h" #include <transip.h>
// ================================================================= // =================================================================
@ -261,10 +261,10 @@
// ================================================================= // =================================================================
CTransInPlaceFilter::CTransInPlaceFilter CTransInPlaceFilter::CTransInPlaceFilter
( TCHAR *pName, ( __in_opt LPCTSTR pName,
LPUNKNOWN pUnk, __inout_opt LPUNKNOWN pUnk,
REFCLSID clsid, REFCLSID clsid,
HRESULT *phr, __inout HRESULT *phr,
bool bModifiesData bool bModifiesData
) )
: CTransformFilter(pName, pUnk, clsid), : CTransformFilter(pName, pUnk, clsid),
@ -278,10 +278,10 @@ CTransInPlaceFilter::CTransInPlaceFilter
#ifdef UNICODE #ifdef UNICODE
CTransInPlaceFilter::CTransInPlaceFilter CTransInPlaceFilter::CTransInPlaceFilter
( CHAR *pName, ( __in_opt LPCSTR pName,
LPUNKNOWN pUnk, __inout_opt LPUNKNOWN pUnk,
REFCLSID clsid, REFCLSID clsid,
HRESULT *phr, __inout HRESULT *phr,
bool bModifiesData bool bModifiesData
) )
: CTransformFilter(pName, pUnk, clsid), : CTransformFilter(pName, pUnk, clsid),
@ -359,7 +359,7 @@ CTransInPlaceFilter::GetPin(int n)
// dir is the direction of our pin. // dir is the direction of our pin.
// pReceivePin is the pin we are connecting to. // pReceivePin is the pin we are connecting to.
HRESULT CTransInPlaceFilter::CompleteConnect(PIN_DIRECTION dir,IPin *pReceivePin) HRESULT CTransInPlaceFilter::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin)
{ {
UNREFERENCED_PARAMETER(pReceivePin); UNREFERENCED_PARAMETER(pReceivePin);
ASSERT(m_pInput); ASSERT(m_pInput);
@ -414,7 +414,7 @@ HRESULT CTransInPlaceFilter::CompleteConnect(PIN_DIRECTION dir,IPin *pReceivePin
HRESULT CTransInPlaceFilter::DecideBufferSize HRESULT CTransInPlaceFilter::DecideBufferSize
( IMemAllocator *pAlloc ( IMemAllocator *pAlloc
, ALLOCATOR_PROPERTIES *pProperties , __inout ALLOCATOR_PROPERTIES *pProperties
) )
{ {
ALLOCATOR_PROPERTIES Request, Actual; ALLOCATOR_PROPERTIES Request, Actual;
@ -431,8 +431,8 @@ HRESULT CTransInPlaceFilter::DecideBufferSize
return hr; return hr;
} }
} else { } else {
// We're reduced to blind guessing. Let's guess one byte and if // Propose one byte
// this isn't enough then when the other pin does get connected // If this isn't enough then when the other pin does get connected
// we can revise it. // we can revise it.
ZeroMemory(&Request, sizeof(Request)); ZeroMemory(&Request, sizeof(Request));
Request.cBuffers = 1; Request.cBuffers = 1;
@ -479,7 +479,7 @@ HRESULT CTransInPlaceFilter::DecideBufferSize
// Copy // Copy
// //
// return a pointer to an identical copy of pSample // return a pointer to an identical copy of pSample
IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource) __out_opt IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource)
{ {
IMediaSample * pDest; IMediaSample * pDest;
@ -502,11 +502,11 @@ IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource)
ASSERT(pDest); ASSERT(pDest);
IMediaSample2 *pSample2; IMediaSample2 *pSample2;
if (SUCCEEDED(pDest->QueryInterface(IID_IMediaSample2, (void **)&pSample2))) { if (SUCCEEDED(pDest->QueryInterface(IID_IMediaSample2, (void **)&pSample2))) {
HRESULT hr = pSample2->SetProperties( HRESULT hrProps = pSample2->SetProperties(
FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer), FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer),
(PBYTE)m_pInput->SampleProps()); (PBYTE)m_pInput->SampleProps());
pSample2->Release(); pSample2->Release();
if (FAILED(hr)) { if (FAILED(hrProps)) {
pDest->Release(); pDest->Release();
return NULL; return NULL;
} }
@ -545,7 +545,10 @@ IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource)
// Copy the actual data length and the actual data. // Copy the actual data length and the actual data.
{ {
const long lDataLength = pSource->GetActualDataLength(); const long lDataLength = pSource->GetActualDataLength();
pDest->SetActualDataLength(lDataLength); if (FAILED(pDest->SetActualDataLength(lDataLength))) {
pDest->Release();
return NULL;
}
// Copy the sample data // Copy the sample data
{ {
@ -555,8 +558,13 @@ IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource)
ASSERT(lDestSize >= lSourceSize && lDestSize >= lDataLength); ASSERT(lDestSize >= lSourceSize && lDestSize >= lDataLength);
pSource->GetPointer(&pSourceBuffer); if (FAILED(pSource->GetPointer(&pSourceBuffer)) ||
pDest->GetPointer(&pDestBuffer); FAILED(pDest->GetPointer(&pDestBuffer)) ||
lDestSize < lDataLength ||
lDataLength < 0) {
pDest->Release();
return NULL;
}
ASSERT(lDestSize == 0 || pSourceBuffer != NULL && pDestBuffer != NULL); ASSERT(lDestSize == 0 || pSourceBuffer != NULL && pDestBuffer != NULL);
CopyMemory( (PVOID) pDestBuffer, (PVOID) pSourceBuffer, lDataLength ); CopyMemory( (PVOID) pDestBuffer, (PVOID) pSourceBuffer, lDataLength );
@ -651,10 +659,10 @@ CTransInPlaceFilter::Receive(IMediaSample *pSample)
// constructor // constructor
CTransInPlaceInputPin::CTransInPlaceInputPin CTransInPlaceInputPin::CTransInPlaceInputPin
( TCHAR *pObjectName ( __in_opt LPCTSTR pObjectName
, CTransInPlaceFilter *pFilter , __inout CTransInPlaceFilter *pFilter
, HRESULT *phr , __inout HRESULT *phr
, LPCWSTR pName , __in_opt LPCWSTR pName
) )
: CTransformInputPin(pObjectName, : CTransformInputPin(pObjectName,
pFilter, pFilter,
@ -683,7 +691,7 @@ CTransInPlaceInputPin::CTransInPlaceInputPin
// ) or it could mean offering the one from downstream // ) or it could mean offering the one from downstream
// Else fail to offer any allocator at all. // Else fail to offer any allocator at all.
STDMETHODIMP CTransInPlaceInputPin::GetAllocator(IMemAllocator ** ppAllocator) STDMETHODIMP CTransInPlaceInputPin::GetAllocator(__deref_out IMemAllocator ** ppAllocator)
{ {
CheckPointer(ppAllocator,E_POINTER); CheckPointer(ppAllocator,E_POINTER);
ValidateReadWritePtr(ppAllocator,sizeof(IMemAllocator *)); ValidateReadWritePtr(ppAllocator,sizeof(IMemAllocator *));
@ -807,7 +815,7 @@ CTransInPlaceInputPin::NotifyAllocator(
// EnumMediaTypes // EnumMediaTypes
// - pass through to our downstream filter // - pass through to our downstream filter
STDMETHODIMP CTransInPlaceInputPin::EnumMediaTypes( IEnumMediaTypes **ppEnum ) STDMETHODIMP CTransInPlaceInputPin::EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum )
{ {
// Can only pass through if connected // Can only pass through if connected
if( !m_pTIPFilter->m_pOutput->IsConnected() ) if( !m_pTIPFilter->m_pOutput->IsConnected() )
@ -839,7 +847,7 @@ HRESULT CTransInPlaceInputPin::CheckMediaType(const CMediaType *pmt )
// If upstream asks us what our requirements are, we will try to ask downstream // If upstream asks us what our requirements are, we will try to ask downstream
// if that doesn't work, we'll just take the defaults. // if that doesn't work, we'll just take the defaults.
STDMETHODIMP STDMETHODIMP
CTransInPlaceInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps) CTransInPlaceInputPin::GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps)
{ {
if( m_pTIPFilter->m_pOutput->IsConnected() ) if( m_pTIPFilter->m_pOutput->IsConnected() )
@ -875,10 +883,10 @@ CTransInPlaceInputPin::CompleteConnect(IPin *pReceivePin)
// constructor // constructor
CTransInPlaceOutputPin::CTransInPlaceOutputPin( CTransInPlaceOutputPin::CTransInPlaceOutputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CTransInPlaceFilter *pFilter, __inout CTransInPlaceFilter *pFilter,
HRESULT * phr, __inout HRESULT * phr,
LPCWSTR pPinName) __in_opt LPCWSTR pPinName)
: CTransformOutputPin( pObjectName : CTransformOutputPin( pObjectName
, pFilter , pFilter
, phr , phr
@ -893,7 +901,7 @@ CTransInPlaceOutputPin::CTransInPlaceOutputPin(
// EnumMediaTypes // EnumMediaTypes
// - pass through to our upstream filter // - pass through to our upstream filter
STDMETHODIMP CTransInPlaceOutputPin::EnumMediaTypes( IEnumMediaTypes **ppEnum ) STDMETHODIMP CTransInPlaceOutputPin::EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum )
{ {
// Can only pass through if connected. // Can only pass through if connected.
if( ! m_pTIPFilter->m_pInput->IsConnected() ) if( ! m_pTIPFilter->m_pInput->IsConnected() )

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines classes from which simple // Desc: DirectShow base classes - defines classes from which simple
// Transform-In-Place filters may be derived. // Transform-In-Place filters may be derived.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -49,21 +49,21 @@ protected:
public: public:
CTransInPlaceInputPin( CTransInPlaceInputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CTransInPlaceFilter *pFilter, __inout CTransInPlaceFilter *pFilter,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
// --- IMemInputPin ----- // --- IMemInputPin -----
// Provide an enumerator for media types by getting one from downstream // Provide an enumerator for media types by getting one from downstream
STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum ); STDMETHODIMP EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum );
// Say whether media type is acceptable. // Say whether media type is acceptable.
HRESULT CheckMediaType(const CMediaType* pmt); HRESULT CheckMediaType(const CMediaType* pmt);
// Return our upstream allocator // Return our upstream allocator
STDMETHODIMP GetAllocator(IMemAllocator ** ppAllocator); STDMETHODIMP GetAllocator(__deref_out IMemAllocator ** ppAllocator);
// get told which allocator the upstream output pin is actually // get told which allocator the upstream output pin is actually
// going to use. // going to use.
@ -72,11 +72,11 @@ public:
// Allow the filter to see what allocator we have // Allow the filter to see what allocator we have
// N.B. This does NOT AddRef // N.B. This does NOT AddRef
IMemAllocator * PeekAllocator() const __out IMemAllocator * PeekAllocator() const
{ return m_pAllocator; } { return m_pAllocator; }
// Pass this on downstream if it ever gets called. // Pass this on downstream if it ever gets called.
STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps); STDMETHODIMP GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps);
HRESULT CompleteConnect(IPin *pReceivePin); HRESULT CompleteConnect(IPin *pReceivePin);
@ -98,10 +98,10 @@ protected:
public: public:
CTransInPlaceOutputPin( CTransInPlaceOutputPin(
TCHAR *pObjectName, __in_opt LPCTSTR pObjectName,
CTransInPlaceFilter *pFilter, __inout CTransInPlaceFilter *pFilter,
HRESULT *phr, __inout HRESULT *phr,
LPCWSTR pName); __in_opt LPCWSTR pName);
// --- CBaseOutputPin ------------ // --- CBaseOutputPin ------------
@ -113,7 +113,7 @@ public:
// virtual HRESULT DecideAllocator(IMemInputPin * pPin, IMemAllocator ** pAlloc); // virtual HRESULT DecideAllocator(IMemInputPin * pPin, IMemAllocator ** pAlloc);
// Provide a media type enumerator. Get it from upstream. // Provide a media type enumerator. Get it from upstream.
STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum ); STDMETHODIMP EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum );
// Say whether media type is acceptable. // Say whether media type is acceptable.
HRESULT CheckMediaType(const CMediaType* pmt); HRESULT CheckMediaType(const CMediaType* pmt);
@ -122,12 +122,12 @@ public:
// Also called by input pin's GetAllocator() // Also called by input pin's GetAllocator()
void SetAllocator(IMemAllocator * pAllocator); void SetAllocator(IMemAllocator * pAllocator);
IMemInputPin * ConnectedIMemInputPin() __out_opt IMemInputPin * ConnectedIMemInputPin()
{ return m_pInputPin; } { return m_pInputPin; }
// Allow the filter to see what allocator we have // Allow the filter to see what allocator we have
// N.B. This does NOT AddRef // N.B. This does NOT AddRef
IMemAllocator * PeekAllocator() const __out IMemAllocator * PeekAllocator() const
{ return m_pAllocator; } { return m_pAllocator; }
HRESULT CompleteConnect(IPin *pReceivePin); HRESULT CompleteConnect(IPin *pReceivePin);
@ -151,10 +151,10 @@ public:
// not modify the data samples (for instance it's just copying // not modify the data samples (for instance it's just copying
// them somewhere else or looking at the timestamps). // them somewhere else or looking at the timestamps).
CTransInPlaceFilter(TCHAR *, LPUNKNOWN, REFCLSID clsid, HRESULT *, CTransInPlaceFilter(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, REFCLSID clsid, __inout HRESULT *,
bool bModifiesData = true); bool bModifiesData = true);
#ifdef UNICODE #ifdef UNICODE
CTransInPlaceFilter(CHAR *, LPUNKNOWN, REFCLSID clsid, HRESULT *, CTransInPlaceFilter(__in_opt LPCSTR, __inout_opt LPUNKNOWN, REFCLSID clsid, __inout HRESULT *,
bool bModifiesData = true); bool bModifiesData = true);
#endif #endif
// The following are defined to avoid undefined pure virtuals. // The following are defined to avoid undefined pure virtuals.
@ -162,13 +162,13 @@ public:
// We override EnumMediaTypes to bypass the transform class enumerator // We override EnumMediaTypes to bypass the transform class enumerator
// which would otherwise call this. // which would otherwise call this.
HRESULT GetMediaType(int iPosition, CMediaType *pMediaType) HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType)
{ DbgBreak("CTransInPlaceFilter::GetMediaType should never be called"); { DbgBreak("CTransInPlaceFilter::GetMediaType should never be called");
return E_UNEXPECTED; return E_UNEXPECTED;
} }
// This is called when we actually have to provide out own allocator. // This is called when we actually have to provide our own allocator.
HRESULT DecideBufferSize(IMemAllocator*, ALLOCATOR_PROPERTIES *); HRESULT DecideBufferSize(IMemAllocator*, __inout ALLOCATOR_PROPERTIES *);
// The functions which call this in CTransform are overridden in this // The functions which call this in CTransform are overridden in this
// class to call CheckInputType with the assumption that the type // class to call CheckInputType with the assumption that the type
@ -211,7 +211,7 @@ public:
protected: protected:
IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource); __out_opt IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource);
#ifdef PERF #ifdef PERF
int m_idTransInPlace; // performance measuring id int m_idTransInPlace; // performance measuring id
@ -223,11 +223,11 @@ protected:
friend class CTransInPlaceInputPin; friend class CTransInPlaceInputPin;
friend class CTransInPlaceOutputPin; friend class CTransInPlaceOutputPin;
CTransInPlaceInputPin *InputPin() const __out CTransInPlaceInputPin *InputPin() const
{ {
return (CTransInPlaceInputPin *)m_pInput; return (CTransInPlaceInputPin *)m_pInput;
}; };
CTransInPlaceOutputPin *OutputPin() const __out CTransInPlaceOutputPin *OutputPin() const
{ {
return (CTransInPlaceOutputPin *)m_pOutput; return (CTransInPlaceOutputPin *)m_pOutput;
}; };

View File

@ -3,16 +3,16 @@
// //
// Desc: DirectShow base classes. // Desc: DirectShow base classes.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#include "measure.h" #include <measure.h>
// #include <vtransfr.h> // now in precomp file streams.h // #include <vtransfr.h> // now in precomp file streams.h
CVideoTransformFilter::CVideoTransformFilter CVideoTransformFilter::CVideoTransformFilter
( TCHAR *pName, LPUNKNOWN pUnk, REFCLSID clsid) ( __in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, REFCLSID clsid)
: CTransformFilter(pName, pUnk, clsid) : CTransformFilter(pName, pUnk, clsid)
, m_itrLate(0) , m_itrLate(0)
, m_nKeyFramePeriod(0) // No QM until we see at least 2 key frames , m_nKeyFramePeriod(0) // No QM until we see at least 2 key frames

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes - defines a video transform class. // Desc: DirectShow base classes - defines a video transform class.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -15,7 +15,7 @@ class CVideoTransformFilter : public CTransformFilter
{ {
public: public:
CVideoTransformFilter(TCHAR *, LPUNKNOWN, REFCLSID clsid); CVideoTransformFilter(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, REFCLSID clsid);
~CVideoTransformFilter(); ~CVideoTransformFilter();
HRESULT EndFlush(); HRESULT EndFlush();

View File

@ -4,13 +4,15 @@
// Desc: DirectShow base classes - implements ActiveX system debugging // Desc: DirectShow base classes - implements ActiveX system debugging
// facilities. // facilities.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h"
#include <streams.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <dvdmedia.h>
#ifdef DEBUG #ifdef DEBUG
#ifdef UNICODE #ifdef UNICODE
@ -20,7 +22,12 @@
#endif // UNICODE #endif // UNICODE
#endif // DEBUG #endif // DEBUG
#include <tchar.h>
#include <strsafe.h>
#ifdef DEBUG #ifdef DEBUG
static void DisplayBITMAPINFO(const BITMAPINFOHEADER* pbmi);
static void DisplayRECT(LPCTSTR szLabel, const RECT& rc);
// The Win32 wsprintf() function writes a maximum of 1024 characters to it's output buffer. // The Win32 wsprintf() function writes a maximum of 1024 characters to it's output buffer.
// See the documentation for wsprintf()'s lpOut parameter for more information. // See the documentation for wsprintf()'s lpOut parameter for more information.
@ -33,7 +40,7 @@ const INT iDEBUGINFO = 1024; // Used to format strings
HKEY_LOCAL_MACHINE\SOFTWARE\Debug\<Module Name>\<KeyName> key values HKEY_LOCAL_MACHINE\SOFTWARE\Debug\<Module Name>\<KeyName> key values
NOTE these must be in the same order as their enumeration definition */ NOTE these must be in the same order as their enumeration definition */
TCHAR *pKeyNames[] = { const LPCTSTR pKeyNames[] = {
TEXT("TIMING"), // Timing and performance measurements TEXT("TIMING"), // Timing and performance measurements
TEXT("TRACE"), // General step point call tracing TEXT("TRACE"), // General step point call tracing
TEXT("MEMORY"), // Memory and object allocation/destruction TEXT("MEMORY"), // Memory and object allocation/destruction
@ -66,11 +73,11 @@ bool g_fUseKASSERT = false; // don't create messagebox
bool g_fDbgInDllEntryPoint = false; bool g_fDbgInDllEntryPoint = false;
bool g_fAutoRefreshLevels = false; bool g_fAutoRefreshLevels = false;
const TCHAR *pBaseKey = TEXT("SOFTWARE\\Debug"); LPCTSTR pBaseKey = TEXT("SOFTWARE\\Microsoft\\DirectShow\\Debug");
const TCHAR *pGlobalKey = TEXT("GLOBAL"); LPCTSTR pGlobalKey = TEXT("GLOBAL");
static CHAR *pUnknownName = "UNKNOWN"; static CHAR *pUnknownName = "UNKNOWN";
TCHAR *TimeoutName = TEXT("TIMEOUT"); LPCTSTR TimeoutName = TEXT("TIMEOUT");
/* This sets the instance handle that the debug library uses to find /* This sets the instance handle that the debug library uses to find
the module's file name from the Win32 GetModuleFileName function */ the module's file name from the Win32 GetModuleFileName function */
@ -146,7 +153,7 @@ void WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax)
sizeof(DWORD)); // Size of the field buffer sizeof(DWORD)); // Size of the field buffer
if (lReturn != ERROR_SUCCESS) { if (lReturn != ERROR_SUCCESS) {
DbgLog((LOG_ERROR,0,TEXT("Could not create subkey %s"),pKeyNames[lKeyPos])); DbgLog((LOG_ERROR,1,TEXT("Could not create subkey %s"),pKeyNames[lKeyPos]));
dwKeyValue = 0; dwKeyValue = 0;
} }
} }
@ -188,7 +195,7 @@ void WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax)
sizeof(DWORD)); // Size of the field buffer sizeof(DWORD)); // Size of the field buffer
if (lReturn != ERROR_SUCCESS) { if (lReturn != ERROR_SUCCESS) {
DbgLog((LOG_ERROR,0,TEXT("Could not create subkey %s"),TimeoutName)); DbgLog((LOG_ERROR,1,TEXT("Could not create subkey %s"),pKeyNames[lKeyPos]));
dwWaitTimeout = INFINITE; dwWaitTimeout = INFINITE;
} }
} }
@ -211,6 +218,49 @@ void WINAPI DbgOutString(LPCTSTR psz)
} }
} }
HRESULT DbgUniqueProcessName(LPCTSTR inName, LPTSTR outName)
{
HRESULT hr = S_OK;
const TCHAR *pIn = inName;
int dotPos = -1;
//scan the input and record the last '.' position
while (*pIn && (pIn - inName) < MAX_PATH)
{
if ( TEXT('.') == *pIn )
dotPos = (int)(pIn-inName);
++pIn;
}
if (*pIn) //input should be zero-terminated within MAX_PATH
return E_INVALIDARG;
DWORD dwProcessId = GetCurrentProcessId();
if (dotPos < 0)
{
//no extension in the input, appending process id to the input
hr = StringCchPrintf(outName, MAX_PATH, TEXT("%s_%d"), inName, dwProcessId);
}
else
{
TCHAR pathAndBasename[MAX_PATH] = {0};
//there's an extension - zero-terminate the path and basename first by copying
hr = StringCchCopyN(pathAndBasename, MAX_PATH, inName, (size_t)dotPos);
//re-combine path, basename and extension with processId appended to a basename
if (SUCCEEDED(hr))
hr = StringCchPrintf(outName, MAX_PATH, TEXT("%s_%d%s"), pathAndBasename, dwProcessId, inName + dotPos);
}
return hr;
}
/* Called by DbgInitGlobalSettings to setup alternate logging destinations /* Called by DbgInitGlobalSettings to setup alternate logging destinations
*/ */
@ -271,12 +321,27 @@ void WINAPI DbgInitLogTo (
NULL, OPEN_ALWAYS, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_NORMAL,
NULL); NULL);
if (INVALID_HANDLE_VALUE != m_hOutput)
{ if (INVALID_HANDLE_VALUE == m_hOutput &&
GetLastError() == ERROR_SHARING_VIOLATION)
{
TCHAR uniqueName[MAX_PATH] = {0};
if (SUCCEEDED(DbgUniqueProcessName(szFile, uniqueName)))
{
m_hOutput = CreateFile(uniqueName, GENERIC_WRITE,
FILE_SHARE_READ,
NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
}
}
if (INVALID_HANDLE_VALUE != m_hOutput)
{
static const TCHAR cszBar[] = TEXT("\r\n\r\n=====DbgInitialize()=====\r\n\r\n"); static const TCHAR cszBar[] = TEXT("\r\n\r\n=====DbgInitialize()=====\r\n\r\n");
SetFilePointer (m_hOutput, 0, NULL, FILE_END); SetFilePointer (m_hOutput, 0, NULL, FILE_END);
DbgOutString (cszBar); DbgOutString (cszBar);
} }
} }
} }
} }
@ -303,13 +368,24 @@ void WINAPI DbgInitGlobalSettings(bool fTakeMax)
(DWORD) 0, // Reserved value (DWORD) 0, // Reserved value
NULL, // Address of class name NULL, // Address of class name
(DWORD) 0, // Special options flags (DWORD) 0, // Special options flags
KEY_ALL_ACCESS, // Desired security access GENERIC_READ | GENERIC_WRITE, // Desired security access
NULL, // Key security descriptor NULL, // Key security descriptor
&hGlobalKey, // Opened handle buffer &hGlobalKey, // Opened handle buffer
NULL); // What really happened NULL); // What really happened
if (lReturn != ERROR_SUCCESS) { if (lReturn != ERROR_SUCCESS) {
DbgLog((LOG_ERROR,0,TEXT("Could not access GLOBAL module key"))); lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
szInfo, // Address of subkey name
(DWORD) 0, // Reserved value
NULL, // Address of class name
(DWORD) 0, // Special options flags
GENERIC_READ, // Desired security access
NULL, // Key security descriptor
&hGlobalKey, // Opened handle buffer
NULL); // What really happened
if (lReturn != ERROR_SUCCESS) {
DbgLog((LOG_ERROR,1,TEXT("Could not access GLOBAL module key")));
}
return; return;
} }
@ -331,7 +407,7 @@ void WINAPI DbgInitModuleSettings(bool fTakeMax)
HKEY hModuleKey; // Module key handle HKEY hModuleKey; // Module key handle
/* Construct the base key name */ /* Construct the base key name */
(void)StringCchPrintf(szInfo,NUMELMS(szInfo), TEXT("%s\\%s"),pBaseKey,m_ModuleName); (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%s\\%s"),pBaseKey,m_ModuleName);
/* Create or open the key for this module */ /* Create or open the key for this module */
lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
@ -339,13 +415,24 @@ void WINAPI DbgInitModuleSettings(bool fTakeMax)
(DWORD) 0, // Reserved value (DWORD) 0, // Reserved value
NULL, // Address of class name NULL, // Address of class name
(DWORD) 0, // Special options flags (DWORD) 0, // Special options flags
KEY_ALL_ACCESS, // Desired security access GENERIC_READ | GENERIC_WRITE, // Desired security access
NULL, // Key security descriptor NULL, // Key security descriptor
&hModuleKey, // Opened handle buffer &hModuleKey, // Opened handle buffer
NULL); // What really happened NULL); // What really happened
if (lReturn != ERROR_SUCCESS) { if (lReturn != ERROR_SUCCESS) {
DbgLog((LOG_ERROR,0,TEXT("Could not access module key"))); lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
szInfo, // Address of subkey name
(DWORD) 0, // Reserved value
NULL, // Address of class name
(DWORD) 0, // Special options flags
GENERIC_READ, // Desired security access
NULL, // Key security descriptor
&hModuleKey, // Opened handle buffer
NULL); // What really happened
if (lReturn != ERROR_SUCCESS) {
DbgLog((LOG_ERROR,1,TEXT("Could not access module key")));
}
return; return;
} }
@ -360,7 +447,7 @@ void WINAPI DbgInitModuleSettings(bool fTakeMax)
void WINAPI DbgInitModuleName() void WINAPI DbgInitModuleName()
{ {
TCHAR FullName[iDEBUGINFO]; // Load the full path and module name TCHAR FullName[iDEBUGINFO]; // Load the full path and module name
TCHAR *pName; // Searches from the end for a backslash LPTSTR pName; // Searches from the end for a backslash
GetModuleFileName(m_hInst,FullName,iDEBUGINFO); GetModuleFileName(m_hInst,FullName,iDEBUGINFO);
pName = _tcsrchr(FullName,'\\'); pName = _tcsrchr(FullName,'\\');
@ -375,8 +462,8 @@ void WINAPI DbgInitModuleName()
struct MsgBoxMsg struct MsgBoxMsg
{ {
HWND hwnd; HWND hwnd;
TCHAR *szTitle; LPCTSTR szTitle;
TCHAR *szMessage; LPCTSTR szMessage;
DWORD dwFlags; DWORD dwFlags;
INT iResult; INT iResult;
}; };
@ -386,7 +473,7 @@ struct MsgBoxMsg
// random threads at bad times can confuse the host (eg IE). // random threads at bad times can confuse the host (eg IE).
// //
DWORD WINAPI MsgBoxThread( DWORD WINAPI MsgBoxThread(
LPVOID lpParameter // thread data __inout LPVOID lpParameter // thread data
) )
{ {
MsgBoxMsg *pmsg = (MsgBoxMsg *)lpParameter; MsgBoxMsg *pmsg = (MsgBoxMsg *)lpParameter;
@ -401,15 +488,17 @@ DWORD WINAPI MsgBoxThread(
INT MessageBoxOtherThread( INT MessageBoxOtherThread(
HWND hwnd, HWND hwnd,
TCHAR *szTitle, LPCTSTR szTitle,
TCHAR *szMessage, LPCTSTR szMessage,
DWORD dwFlags) DWORD dwFlags)
{ {
if(g_fDbgInDllEntryPoint) if(g_fDbgInDllEntryPoint)
{ {
// can't wait on another thread because we have the loader // can't wait on another thread because we have the loader
// lock held in the dll entry point. // lock held in the dll entry point.
return MessageBox(hwnd, szTitle, szMessage, dwFlags); // This can crash sometimes so just skip it
// return MessageBox(hwnd, szTitle, szMessage, dwFlags);
return IDCANCEL;
} }
else else
{ {
@ -436,7 +525,7 @@ INT MessageBoxOtherThread(
/* Displays a message box if the condition evaluated to FALSE */ /* Displays a message box if the condition evaluated to FALSE */
void WINAPI DbgAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine) void WINAPI DbgAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
{ {
if(g_fUseKASSERT) if(g_fUseKASSERT)
{ {
@ -447,7 +536,7 @@ void WINAPI DbgAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine)
TCHAR szInfo[iDEBUGINFO]; TCHAR szInfo[iDEBUGINFO];
(void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"), (void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"),
pCondition, iLine, pFileName); pCondition, iLine, pFileName);
INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("ASSERT Failed"), INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("ASSERT Failed"),
@ -475,7 +564,7 @@ void WINAPI DbgAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine)
/* Displays a message box at a break point */ /* Displays a message box at a break point */
void WINAPI DbgBreakPoint(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine) void WINAPI DbgBreakPoint(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
{ {
if(g_fUseKASSERT) if(g_fUseKASSERT)
{ {
@ -485,7 +574,7 @@ void WINAPI DbgBreakPoint(const TCHAR *pCondition,const TCHAR *pFileName,INT iLi
{ {
TCHAR szInfo[iDEBUGINFO]; TCHAR szInfo[iDEBUGINFO];
(void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"), (void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"),
pCondition, iLine, pFileName); pCondition, iLine, pFileName);
INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("Hard coded break point"), INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("Hard coded break point"),
@ -511,7 +600,7 @@ void WINAPI DbgBreakPoint(const TCHAR *pCondition,const TCHAR *pFileName,INT iLi
} }
} }
void WINAPI DbgBreakPoint(const TCHAR *pFileName,INT iLine,const TCHAR* szFormatString,...) void WINAPI DbgBreakPoint(LPCTSTR pFileName,INT iLine,__format_string LPCTSTR szFormatString,...)
{ {
// A debug break point message can have at most 2000 characters if // A debug break point message can have at most 2000 characters if
// ANSI or UNICODE characters are being used. A debug break point message // ANSI or UNICODE characters are being used. A debug break point message
@ -522,17 +611,15 @@ void WINAPI DbgBreakPoint(const TCHAR *pFileName,INT iLine,const TCHAR* szFormat
TCHAR szBreakPointMessage[MAX_BREAK_POINT_MESSAGE_SIZE]; TCHAR szBreakPointMessage[MAX_BREAK_POINT_MESSAGE_SIZE];
const DWORD MAX_CHARS_IN_BREAK_POINT_MESSAGE = sizeof(szBreakPointMessage) / sizeof(TCHAR);
va_list va; va_list va;
va_start( va, szFormatString ); va_start( va, szFormatString );
HRESULT hr = StringCchVPrintf( szBreakPointMessage, MAX_CHARS_IN_BREAK_POINT_MESSAGE, szFormatString, va ); HRESULT hr = StringCchVPrintf( szBreakPointMessage, NUMELMS(szBreakPointMessage), szFormatString, va );
va_end(va); va_end(va);
if( S_OK != hr ) { if( FAILED(hr) ) {
DbgBreak( "ERROR in DbgBreakPoint(). The variable length debug message could not be displayed because _vsnprintf() failed." ); DbgBreak( "ERROR in DbgBreakPoint(). The variable length debug message could not be displayed because StringCchVPrintf() failed." );
return; return;
} }
@ -620,7 +707,7 @@ void WINAPI DbgSetAutoRefreshLevels(bool fAuto)
// warning -- this function is implemented twice for ansi applications // warning -- this function is implemented twice for ansi applications
// linking to the unicode library // linking to the unicode library
// //
void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const CHAR *pFormat,...) void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCSTR pFormat,...)
{ {
/* Check the current level for this type combination */ /* Check the current level for this type combination */
@ -636,20 +723,16 @@ void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const CHAR *pFormat,...)
va_list va; va_list va;
va_start(va, pFormat); va_start(va, pFormat);
(void)StringCchCopy(szInfo,NUMELMS(szInfo),m_ModuleName); (void)StringCchPrintf(szInfo, NUMELMS(szInfo),
size_t len = lstrlen(szInfo); TEXT("%s(tid %x) %8d : "),
(void)StringCchPrintf(szInfo + len, m_ModuleName,
NUMELMS(szInfo) - len,
TEXT("(tid %x) %8d : "),
GetCurrentThreadId(), timeGetTime() - dwTimeOffset); GetCurrentThreadId(), timeGetTime() - dwTimeOffset);
CHAR szInfoA[2000]; CHAR szInfoA[2000];
WideCharToMultiByte(CP_ACP, 0, szInfo, -1, szInfoA, NUMELMS(szInfoA), 0, 0); WideCharToMultiByte(CP_ACP, 0, szInfo, -1, szInfoA, NUMELMS(szInfoA), 0, 0);
len = lstrlenA(szInfoA); (void)StringCchVPrintfA(szInfoA + lstrlenA(szInfoA), NUMELMS(szInfoA) - lstrlenA(szInfoA), pFormat, va);
(void)StringCchVPrintfA(szInfoA + len, NUMELMS(szInfoA) - len, pFormat, va); (void)StringCchCatA(szInfoA, NUMELMS(szInfoA), "\r\n");
len = lstrlenA(szInfoA);
(void)StringCchCatA(szInfoA, NUMELMS(szInfoA) - len, "\r\n");
WCHAR wszOutString[2000]; WCHAR wszOutString[2000];
MultiByteToWideChar(CP_ACP, 0, szInfoA, -1, wszOutString, NUMELMS(wszOutString)); MultiByteToWideChar(CP_ACP, 0, szInfoA, -1, wszOutString, NUMELMS(wszOutString));
@ -658,8 +741,7 @@ void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const CHAR *pFormat,...)
va_end(va); va_end(va);
} }
void WINAPI DbgAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
void WINAPI DbgAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLine)
{ {
if(g_fUseKASSERT) if(g_fUseKASSERT)
{ {
@ -670,7 +752,7 @@ void WINAPI DbgAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLine)
TCHAR szInfo[iDEBUGINFO]; TCHAR szInfo[iDEBUGINFO];
(void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%S \nAt line %d of %S\nContinue? (Cancel to debug)"), (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%hs \nAt line %d of %hs\nContinue? (Cancel to debug)"),
pCondition, iLine, pFileName); pCondition, iLine, pFileName);
INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("ASSERT Failed"), INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("ASSERT Failed"),
@ -698,7 +780,7 @@ void WINAPI DbgAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLine)
/* Displays a message box at a break point */ /* Displays a message box at a break point */
void WINAPI DbgBreakPoint(const CHAR *pCondition,const CHAR *pFileName,INT iLine) void WINAPI DbgBreakPoint(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
{ {
if(g_fUseKASSERT) if(g_fUseKASSERT)
{ {
@ -708,7 +790,7 @@ void WINAPI DbgBreakPoint(const CHAR *pCondition,const CHAR *pFileName,INT iLine
{ {
TCHAR szInfo[iDEBUGINFO]; TCHAR szInfo[iDEBUGINFO];
(void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%S \nAt line %d of %S\nContinue? (Cancel to debug)"), (void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%hs \nAt line %d of %hs\nContinue? (Cancel to debug)"),
pCondition, iLine, pFileName); pCondition, iLine, pFileName);
INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("Hard coded break point"), INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("Hard coded break point"),
@ -734,7 +816,7 @@ void WINAPI DbgBreakPoint(const CHAR *pCondition,const CHAR *pFileName,INT iLine
} }
} }
void WINAPI DbgKernelAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLine) void WINAPI DbgKernelAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
{ {
DbgLog((LOG_ERROR,0,TEXT("Assertion FAILED (%hs) at line %d in file %hs"), DbgLog((LOG_ERROR,0,TEXT("Assertion FAILED (%hs) at line %d in file %hs"),
pCondition, iLine, pFileName)); pCondition, iLine, pFileName));
@ -752,7 +834,7 @@ void WINAPI DbgKernelAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLi
// warning -- this function is implemented twice for ansi applications // warning -- this function is implemented twice for ansi applications
// linking to the unicode library // linking to the unicode library
// //
void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const TCHAR *pFormat,...) void WINAPI DbgLogInfo(DWORD Type,DWORD Level,LPCTSTR pFormat,...)
{ {
/* Check the current level for this type combination */ /* Check the current level for this type combination */
@ -769,15 +851,12 @@ void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const TCHAR *pFormat,...)
va_list va; va_list va;
va_start(va, pFormat); va_start(va, pFormat);
(void)StringCchCopy(szInfo, NUMELMS(szInfo), m_ModuleName); (void)StringCchPrintf(szInfo, NUMELMS(szInfo),
size_t len = lstrlen(szInfo); TEXT("%s(tid %x) %8d : "),
(void)StringCchPrintf(szInfo + len, NUMELMS(szInfo) - len, m_ModuleName,
TEXT("(tid %x) %8d : "),
GetCurrentThreadId(), timeGetTime() - dwTimeOffset); GetCurrentThreadId(), timeGetTime() - dwTimeOffset);
len = lstrlen(szInfo);
(void)StringCchVPrintf(szInfo + len, NUMELMS(szInfo) - len, pFormat, va);
(void)StringCchVPrintf(szInfo + lstrlen(szInfo), NUMELMS(szInfo) - lstrlen(szInfo), pFormat, va);
(void)StringCchCat(szInfo, NUMELMS(szInfo), TEXT("\r\n")); (void)StringCchCat(szInfo, NUMELMS(szInfo), TEXT("\r\n"));
DbgOutString(szInfo); DbgOutString(szInfo);
@ -789,7 +868,7 @@ void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const TCHAR *pFormat,...)
boxes to the user, this provides an alternative which puts the error boxes to the user, this provides an alternative which puts the error
condition on the debugger output with a suitable eye catching message */ condition on the debugger output with a suitable eye catching message */
void WINAPI DbgKernelAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine) void WINAPI DbgKernelAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
{ {
DbgLog((LOG_ERROR,0,TEXT("Assertion FAILED (%s) at line %d in file %s"), DbgLog((LOG_ERROR,0,TEXT("Assertion FAILED (%s) at line %d in file %s"),
pCondition, iLine, pFileName)); pCondition, iLine, pFileName));
@ -804,8 +883,8 @@ void WINAPI DbgKernelAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT i
uses to identify the object when it is destroyed later on. We update the uses to identify the object when it is destroyed later on. We update the
total number of active objects in the DLL mainly for debugging purposes */ total number of active objects in the DLL mainly for debugging purposes */
DWORD WINAPI DbgRegisterObjectCreation(const CHAR *szObjectName, DWORD WINAPI DbgRegisterObjectCreation(LPCSTR szObjectName,
const WCHAR *wszObjectName) LPCWSTR wszObjectName)
{ {
/* If this fires you have a mixed DEBUG/RETAIL build */ /* If this fires you have a mixed DEBUG/RETAIL build */
@ -937,22 +1016,9 @@ void WINAPI DbgDumpObjectRegister()
while (pObject) { while (pObject) {
if(pObject->m_wszName) { if(pObject->m_wszName) {
#ifdef UNICODE (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%5d (%p) %30ls"),pObject->m_dwCookie, &pObject, pObject->m_wszName);
LPCTSTR FORMAT_STRING = TEXT("%5d (%8x) %30s");
#else
LPCTSTR FORMAT_STRING = TEXT("%5d (%8x) %30S");
#endif
(void)StringCchPrintf(szInfo,NUMELMS(szInfo), FORMAT_STRING, pObject->m_dwCookie, &pObject, pObject->m_wszName);
} else { } else {
#ifdef UNICODE (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%5d (%p) %30hs"),pObject->m_dwCookie, &pObject, pObject->m_szName);
LPCTSTR FORMAT_STRING = TEXT("%5d (%8x) %30S");
#else
LPCTSTR FORMAT_STRING = TEXT("%5d (%8x) %30s");
#endif
(void)StringCchPrintf(szInfo,NUMELMS(szInfo),FORMAT_STRING,pObject->m_dwCookie, &pObject, pObject->m_szName);
} }
DbgLog((LOG_MEMORY,2,szInfo)); DbgLog((LOG_MEMORY,2,szInfo));
pObject = pObject->m_pNext; pObject = pObject->m_pNext;
@ -975,7 +1041,7 @@ DWORD WINAPI DbgWaitForSingleObject(HANDLE h)
return dwWaitResult; return dwWaitResult;
} }
DWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount, DWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount,
CONST HANDLE *lpHandles, __in_ecount(nCount) CONST HANDLE *lpHandles,
BOOL bWaitAll) BOOL bWaitAll)
{ {
DWORD dwWaitResult; DWORD dwWaitResult;
@ -1051,7 +1117,7 @@ CDisp::CDisp(LONGLONG ll, int Format)
li.QuadPart /= 10; li.QuadPart /= 10;
temp[--pos] = (TCHAR) digit+L'0'; temp[--pos] = (TCHAR) digit+L'0';
} while (li.QuadPart); } while (li.QuadPart);
(void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%s"), temp+pos); (void)StringCchCopy(m_String, NUMELMS(m_String), temp+pos);
break; break;
} }
case CDISP_HEX: case CDISP_HEX:
@ -1062,55 +1128,40 @@ CDisp::CDisp(LONGLONG ll, int Format)
CDisp::CDisp(REFCLSID clsid) CDisp::CDisp(REFCLSID clsid)
{ {
WCHAR strClass[CHARS_IN_GUID+1]; #ifdef UNICODE
StringFromGUID2(clsid, strClass, sizeof(strClass) / sizeof(strClass[0])); (void)StringFromGUID2(clsid, m_String, NUMELMS(m_String));
ASSERT(sizeof(m_String)/sizeof(m_String[0]) >= CHARS_IN_GUID+1); #else
#ifdef UNICODE WCHAR wszTemp[50];
(void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%s"), strClass); (void)StringFromGUID2(clsid, wszTemp, NUMELMS(wszTemp));
#else (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%S"), wszTemp);
(void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%S"), strClass); #endif
#endif
}; };
#ifdef __STREAMS__ #ifdef __STREAMS__
/* Display stuff */ /* Display stuff */
CDisp::CDisp(CRefTime llTime) CDisp::CDisp(CRefTime llTime)
{ {
LPTSTR lpsz = m_String;
size_t len = NUMELMS(m_String);
LONGLONG llDiv; LONGLONG llDiv;
if (llTime < 0) { if (llTime < 0) {
llTime = -llTime; llTime = -llTime;
(void)StringCchPrintf(lpsz, len, TEXT("-")); (void)StringCchCopy(m_String, NUMELMS(m_String), TEXT("-"));
size_t t = lstrlen(lpsz);
lpsz += t;
len -= t;
} }
llDiv = (LONGLONG)24 * 3600 * 10000000; llDiv = (LONGLONG)24 * 3600 * 10000000;
if (llTime >= llDiv) { if (llTime >= llDiv) {
(void)StringCchPrintf(lpsz, len, TEXT("%d days "), (LONG)(llTime / llDiv)); (void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT("%d days "), (LONG)(llTime / llDiv));
size_t t = lstrlen(lpsz);
lpsz += t;
len -= t;
llTime = llTime % llDiv; llTime = llTime % llDiv;
} }
llDiv = (LONGLONG)3600 * 10000000; llDiv = (LONGLONG)3600 * 10000000;
if (llTime >= llDiv) { if (llTime >= llDiv) {
(void)StringCchPrintf(lpsz, len, TEXT("%d hrs "), (LONG)(llTime / llDiv)); (void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT("%d hrs "), (LONG)(llTime / llDiv));
size_t t = lstrlen(lpsz);
lpsz += t;
len -= t;
llTime = llTime % llDiv; llTime = llTime % llDiv;
} }
llDiv = (LONGLONG)60 * 10000000; llDiv = (LONGLONG)60 * 10000000;
if (llTime >= llDiv) { if (llTime >= llDiv) {
(void)StringCchPrintf(lpsz, len, TEXT("%d mins "), (LONG)(llTime / llDiv)); (void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT("%d mins "), (LONG)(llTime / llDiv));
size_t t = lstrlen(lpsz);
lpsz += t;
len -= t;
llTime = llTime % llDiv; llTime = llTime % llDiv;
} }
(void)StringCchPrintf(lpsz, len, TEXT("%d.%3.3d sec"), (void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT("%d.%3.3d sec"),
(LONG)llTime / 10000000, (LONG)llTime / 10000000,
(LONG)((llTime % 10000000) / 10000)); (LONG)((llTime % 10000000) / 10000));
}; };
@ -1139,19 +1190,12 @@ CDisp::CDisp(IPin *pPin)
(void)StringCchCopy(str, NUMELMS(str), TEXT("NULL IPin")); (void)StringCchCopy(str, NUMELMS(str), TEXT("NULL IPin"));
} }
size_t len = lstrlen(str)+64; m_pString = (PTCHAR) new TCHAR[lstrlen(str)+64];
m_pString = (TCHAR*) new TCHAR[len];
if (!m_pString) { if (!m_pString) {
return; return;
} }
#ifdef UNICODE (void)StringCchPrintf(m_pString, lstrlen(str) + 64, TEXT("%hs(%s)"), GuidNames[clsid], str);
LPCTSTR FORMAT_STRING = TEXT("%S(%s)");
#else
LPCTSTR FORMAT_STRING = TEXT("%s(%s)");
#endif
(void)StringCchPrintf(m_pString, len, FORMAT_STRING, GuidNames[clsid], str);
} }
/* Display filter or pin */ /* Display filter or pin */
@ -1168,16 +1212,15 @@ CDisp::CDisp(IUnknown *pUnk)
QueryFilterInfoReleaseGraph(fi); QueryFilterInfoReleaseGraph(fi);
size_t len = lstrlenW(fi.achName) + 1; size_t len = lstrlenW(fi.achName) + 1;
m_pString = new TCHAR[len]; m_pString = new TCHAR[len];
if(m_pString) if(m_pString)
{ {
#ifdef UNICODE #ifdef UNICODE
LPCTSTR FORMAT_STRING = TEXT("%s"); (void)StringCchCopy(m_pString, len, fi.achName);
#else #else
LPCTSTR FORMAT_STRING = TEXT("%S"); (void)StringCchPrintf(m_pString, len, "%S", fi.achName);
#endif #endif
(void)StringCchPrintf(m_pString, len, FORMAT_STRING, fi.achName);
} }
} }
@ -1210,11 +1253,7 @@ CDispBasic::~CDispBasic()
CDisp::CDisp(double d) CDisp::CDisp(double d)
{ {
#ifdef DEBUG
(void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%.16g"), d);
#else
(void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%d.%03d"), (int) d, (int) ((d - (int) d) * 1000)); (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%d.%03d"), (int) d, (int) ((d - (int) d) * 1000));
#endif
} }
@ -1225,100 +1264,116 @@ CDisp::CDisp(double d)
succeed as we do not accept input types unless the format is big enough */ succeed as we do not accept input types unless the format is big enough */
#ifdef DEBUG #ifdef DEBUG
void WINAPI DisplayType(LPTSTR label, const AM_MEDIA_TYPE *pmtIn, DWORD dwLevel) void WINAPI DisplayType(LPCTSTR label, const AM_MEDIA_TYPE *pmtIn)
{ {
/* Dump the GUID types and a short description */ /* Dump the GUID types and a short description */
DbgLog((LOG_TRACE,dwLevel,TEXT(""))); DbgLog((LOG_TRACE,5,TEXT("")));
DbgLog((LOG_TRACE,dwLevel,TEXT("%s M type %hs S type %hs"), label, DbgLog((LOG_TRACE,2,TEXT("%s M type %hs S type %hs"), label,
GuidNames[pmtIn->majortype], GuidNames[pmtIn->majortype],
GuidNames[pmtIn->subtype])); GuidNames[pmtIn->subtype]));
DbgLog((LOG_TRACE,dwLevel,TEXT("Subtype description %s"),GetSubtypeName(&pmtIn->subtype))); DbgLog((LOG_TRACE,5,TEXT("Subtype description %s"),GetSubtypeName(&pmtIn->subtype)));
/* Dump the generic media types */ /* Dump the generic media types */
if (pmtIn->bTemporalCompression) { if (pmtIn->bTemporalCompression) {
DbgLog((LOG_TRACE,dwLevel,TEXT("Temporally compressed"))); DbgLog((LOG_TRACE,5,TEXT("Temporally compressed")));
} else { } else {
DbgLog((LOG_TRACE,dwLevel,TEXT("Not temporally compressed"))); DbgLog((LOG_TRACE,5,TEXT("Not temporally compressed")));
} }
if (pmtIn->bFixedSizeSamples) { if (pmtIn->bFixedSizeSamples) {
DbgLog((LOG_TRACE,dwLevel,TEXT("Sample size %d"),pmtIn->lSampleSize)); DbgLog((LOG_TRACE,5,TEXT("Sample size %d"),pmtIn->lSampleSize));
} else { } else {
DbgLog((LOG_TRACE,dwLevel,TEXT("Variable size samples"))); DbgLog((LOG_TRACE,5,TEXT("Variable size samples")));
} }
if (pmtIn->formattype == FORMAT_VideoInfo) { if (pmtIn->formattype == FORMAT_VideoInfo) {
/* Dump the contents of the BITMAPINFOHEADER structure */
BITMAPINFOHEADER *pbmi = HEADER(pmtIn->pbFormat);
VIDEOINFOHEADER *pVideoInfo = (VIDEOINFOHEADER *)pmtIn->pbFormat;
DbgLog((LOG_TRACE,dwLevel,TEXT("Source rectangle (Left %d Top %d Right %d Bottom %d)"), VIDEOINFOHEADER *pVideoInfo = (VIDEOINFOHEADER *)pmtIn->pbFormat;
pVideoInfo->rcSource.left,
pVideoInfo->rcSource.top,
pVideoInfo->rcSource.right,
pVideoInfo->rcSource.bottom));
DbgLog((LOG_TRACE,dwLevel,TEXT("Target rectangle (Left %d Top %d Right %d Bottom %d)"), DisplayRECT(TEXT("Source rectangle"),pVideoInfo->rcSource);
pVideoInfo->rcTarget.left, DisplayRECT(TEXT("Target rectangle"),pVideoInfo->rcTarget);
pVideoInfo->rcTarget.top, DisplayBITMAPINFO(HEADER(pmtIn->pbFormat));
pVideoInfo->rcTarget.right,
pVideoInfo->rcTarget.bottom));
DbgLog((LOG_TRACE,dwLevel,TEXT("Size of BITMAPINFO structure %d"),pbmi->biSize)); } if (pmtIn->formattype == FORMAT_VideoInfo2) {
if (pbmi->biCompression < 256) {
DbgLog((LOG_TRACE,dwLevel,TEXT("%dx%dx%d bit (%d)"),
pbmi->biWidth, pbmi->biHeight,
pbmi->biBitCount, pbmi->biCompression));
} else {
DbgLog((LOG_TRACE,dwLevel,TEXT("%dx%dx%d bit '%4.4hs'"),
pbmi->biWidth, pbmi->biHeight,
pbmi->biBitCount, &pbmi->biCompression));
}
DbgLog((LOG_TRACE,dwLevel,TEXT("Image size %d"),pbmi->biSizeImage)); VIDEOINFOHEADER2 *pVideoInfo2 = (VIDEOINFOHEADER2 *)pmtIn->pbFormat;
DbgLog((LOG_TRACE,dwLevel,TEXT("Planes %d"),pbmi->biPlanes));
DbgLog((LOG_TRACE,dwLevel,TEXT("X Pels per metre %d"),pbmi->biXPelsPerMeter)); DisplayRECT(TEXT("Source rectangle"),pVideoInfo2->rcSource);
DbgLog((LOG_TRACE,dwLevel,TEXT("Y Pels per metre %d"),pbmi->biYPelsPerMeter)); DisplayRECT(TEXT("Target rectangle"),pVideoInfo2->rcTarget);
DbgLog((LOG_TRACE,dwLevel,TEXT("Colours used %d"),pbmi->biClrUsed)); DbgLog((LOG_TRACE, 5, TEXT("Aspect Ratio: %d:%d"),
pVideoInfo2->dwPictAspectRatioX,
pVideoInfo2->dwPictAspectRatioY));
DisplayBITMAPINFO(&pVideoInfo2->bmiHeader);
} else if (pmtIn->majortype == MEDIATYPE_Audio) { } else if (pmtIn->majortype == MEDIATYPE_Audio) {
DbgLog((LOG_TRACE,dwLevel,TEXT(" Format type %hs"), DbgLog((LOG_TRACE,2,TEXT(" Format type %hs"),
GuidNames[pmtIn->formattype])); GuidNames[pmtIn->formattype]));
DbgLog((LOG_TRACE,dwLevel,TEXT(" Subtype %hs"), DbgLog((LOG_TRACE,2,TEXT(" Subtype %hs"),
GuidNames[pmtIn->subtype])); GuidNames[pmtIn->subtype]));
if ((pmtIn->subtype != MEDIASUBTYPE_MPEG1Packet) if ((pmtIn->subtype != MEDIASUBTYPE_MPEG1Packet)
&& (pmtIn->cbFormat >= sizeof(PCMWAVEFORMAT))) && (pmtIn->cbFormat >= sizeof(PCMWAVEFORMAT)))
{ {
/* Dump the contents of the WAVEFORMATEX type-specific format structure */ /* Dump the contents of the WAVEFORMATEX type-specific format structure */
WAVEFORMATEX *pwfx = (WAVEFORMATEX *) pmtIn->pbFormat; WAVEFORMATEX *pwfx = (WAVEFORMATEX *) pmtIn->pbFormat;
DbgLog((LOG_TRACE,dwLevel,TEXT("wFormatTag %u"), pwfx->wFormatTag)); DbgLog((LOG_TRACE,2,TEXT("wFormatTag %u"), pwfx->wFormatTag));
DbgLog((LOG_TRACE,dwLevel,TEXT("nChannels %u"), pwfx->nChannels)); DbgLog((LOG_TRACE,2,TEXT("nChannels %u"), pwfx->nChannels));
DbgLog((LOG_TRACE,dwLevel,TEXT("nSamplesPerSec %lu"), pwfx->nSamplesPerSec)); DbgLog((LOG_TRACE,2,TEXT("nSamplesPerSec %lu"), pwfx->nSamplesPerSec));
DbgLog((LOG_TRACE,dwLevel,TEXT("nAvgBytesPerSec %lu"), pwfx->nAvgBytesPerSec)); DbgLog((LOG_TRACE,2,TEXT("nAvgBytesPerSec %lu"), pwfx->nAvgBytesPerSec));
DbgLog((LOG_TRACE,dwLevel,TEXT("nBlockAlign %u"), pwfx->nBlockAlign)); DbgLog((LOG_TRACE,2,TEXT("nBlockAlign %u"), pwfx->nBlockAlign));
DbgLog((LOG_TRACE,dwLevel,TEXT("wBitsPerSample %u"), pwfx->wBitsPerSample)); DbgLog((LOG_TRACE,2,TEXT("wBitsPerSample %u"), pwfx->wBitsPerSample));
/* PCM uses a WAVEFORMAT and does not have the extra size field */ /* PCM uses a WAVEFORMAT and does not have the extra size field */
if (pmtIn->cbFormat >= sizeof(WAVEFORMATEX)) { if (pmtIn->cbFormat >= sizeof(WAVEFORMATEX)) {
DbgLog((LOG_TRACE,dwLevel,TEXT("cbSize %u"), pwfx->cbSize)); DbgLog((LOG_TRACE,2,TEXT("cbSize %u"), pwfx->cbSize));
} }
} else { } else {
} }
} else { } else {
DbgLog((LOG_TRACE,dwLevel,TEXT(" Format type %hs"), DbgLog((LOG_TRACE,2,TEXT(" Format type %hs"),
GuidNames[pmtIn->formattype])); GuidNames[pmtIn->formattype]));
// !!!! should add code to dump wave format, others
} }
} }
void DisplayBITMAPINFO(const BITMAPINFOHEADER* pbmi)
{
DbgLog((LOG_TRACE,5,TEXT("Size of BITMAPINFO structure %d"),pbmi->biSize));
if (pbmi->biCompression < 256) {
DbgLog((LOG_TRACE,2,TEXT("%dx%dx%d bit (%d)"),
pbmi->biWidth, pbmi->biHeight,
pbmi->biBitCount, pbmi->biCompression));
} else {
DbgLog((LOG_TRACE,2,TEXT("%dx%dx%d bit '%4.4hs'"),
pbmi->biWidth, pbmi->biHeight,
pbmi->biBitCount, &pbmi->biCompression));
}
DbgLog((LOG_TRACE,2,TEXT("Image size %d"),pbmi->biSizeImage));
DbgLog((LOG_TRACE,5,TEXT("Planes %d"),pbmi->biPlanes));
DbgLog((LOG_TRACE,5,TEXT("X Pels per metre %d"),pbmi->biXPelsPerMeter));
DbgLog((LOG_TRACE,5,TEXT("Y Pels per metre %d"),pbmi->biYPelsPerMeter));
DbgLog((LOG_TRACE,5,TEXT("Colours used %d"),pbmi->biClrUsed));
}
void DisplayRECT(LPCTSTR szLabel, const RECT& rc)
{
DbgLog((LOG_TRACE,5,TEXT("%s (Left %d Top %d Right %d Bottom %d)"),
szLabel,
rc.left,
rc.top,
rc.right,
rc.bottom));
}
void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel) void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel)
{ {
if( !pGraph ) if( !pGraph )
@ -1340,13 +1395,13 @@ void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel)
FILTER_INFO info; FILTER_INFO info;
if (FAILED(pFilter->QueryFilterInfo(&info))) { if (FAILED(pFilter->QueryFilterInfo(&info))) {
DbgLog((LOG_TRACE,dwLevel,TEXT(" Filter [%x] -- failed QueryFilterInfo"), pFilter)); DbgLog((LOG_TRACE,dwLevel,TEXT(" Filter [%p] -- failed QueryFilterInfo"), pFilter));
} else { } else {
QueryFilterInfoReleaseGraph(info); QueryFilterInfoReleaseGraph(info);
// !!! should QueryVendorInfo here! // !!! should QueryVendorInfo here!
DbgLog((LOG_TRACE,dwLevel,TEXT(" Filter [%x] '%ls'"), pFilter, info.achName)); DbgLog((LOG_TRACE,dwLevel,TEXT(" Filter [%p] '%ls'"), pFilter, info.achName));
IEnumPins *pins; IEnumPins *pins;
@ -1356,29 +1411,29 @@ void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel)
IPin *pPin; IPin *pPin;
while (pins->Next(1, &pPin, &n) == S_OK) { while (pins->Next(1, &pPin, &n) == S_OK) {
PIN_INFO info; PIN_INFO pinInfo;
if (FAILED(pPin->QueryPinInfo(&info))) { if (FAILED(pPin->QueryPinInfo(&pinInfo))) {
DbgLog((LOG_TRACE,dwLevel,TEXT(" Pin [%x] -- failed QueryPinInfo"), pPin)); DbgLog((LOG_TRACE,dwLevel,TEXT(" Pin [%x] -- failed QueryPinInfo"), pPin));
} else { } else {
QueryPinInfoReleaseFilter(info); QueryPinInfoReleaseFilter(pinInfo);
IPin *pPinConnected = NULL; IPin *pPinConnected = NULL;
HRESULT hr = pPin->ConnectedTo(&pPinConnected); HRESULT hr = pPin->ConnectedTo(&pPinConnected);
if (pPinConnected) { if (pPinConnected) {
DbgLog((LOG_TRACE,dwLevel,TEXT(" Pin [%x] '%ls' [%sput]") DbgLog((LOG_TRACE,dwLevel,TEXT(" Pin [%p] '%ls' [%sput]")
TEXT(" Connected to pin [%x]"), TEXT(" Connected to pin [%p]"),
pPin, info.achName, pPin, pinInfo.achName,
info.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out"), pinInfo.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out"),
pPinConnected)); pPinConnected));
pPinConnected->Release(); pPinConnected->Release();
// perhaps we should really dump the type both ways as a sanity // perhaps we should really dump the type both ways as a sanity
// check? // check?
if (info.dir == PINDIR_OUTPUT) { if (pinInfo.dir == PINDIR_OUTPUT) {
AM_MEDIA_TYPE mt; AM_MEDIA_TYPE mt;
hr = pPin->ConnectionMediaType(&mt); hr = pPin->ConnectionMediaType(&mt);
@ -1392,8 +1447,8 @@ void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel)
} else { } else {
DbgLog((LOG_TRACE,dwLevel, DbgLog((LOG_TRACE,dwLevel,
TEXT(" Pin [%x] '%ls' [%sput]"), TEXT(" Pin [%x] '%ls' [%sput]"),
pPin, info.achName, pPin, pinInfo.achName,
info.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out"))); pinInfo.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out")));
} }
} }

View File

@ -3,7 +3,7 @@
// //
// Desc: DirectShow base classes - provides debugging facilities. // Desc: DirectShow base classes - provides debugging facilities.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -64,8 +64,8 @@ enum { CDISP_HEX = 0x01,
// we have registered so that we can dump a list of remaining objects // we have registered so that we can dump a list of remaining objects
typedef struct tag_ObjectDesc { typedef struct tag_ObjectDesc {
const CHAR *m_szName; LPCSTR m_szName;
const WCHAR *m_wszName; LPCWSTR m_wszName;
DWORD m_dwCookie; DWORD m_dwCookie;
tag_ObjectDesc *m_pNext; tag_ObjectDesc *m_pNext;
} ObjectDesc; } ObjectDesc;
@ -84,7 +84,7 @@ typedef struct tag_ObjectDesc {
void WINAPI DbgInitModuleSettings(bool fTakeMax); void WINAPI DbgInitModuleSettings(bool fTakeMax);
void WINAPI DbgInitModuleName(); void WINAPI DbgInitModuleName();
DWORD WINAPI DbgRegisterObjectCreation( DWORD WINAPI DbgRegisterObjectCreation(
const CHAR *szObjectName, const WCHAR *wszObjectName); LPCSTR szObjectName, LPCWSTR wszObjectName);
BOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie); BOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie);
@ -103,30 +103,30 @@ typedef struct tag_ObjectDesc {
// Display error and logging to the user // Display error and logging to the user
void WINAPI DbgAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine); void WINAPI DbgAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine);
void WINAPI DbgBreakPoint(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine); void WINAPI DbgBreakPoint(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine);
void WINAPI DbgBreakPoint(const TCHAR *pFileName,INT iLine,const TCHAR* szFormatString,...); void WINAPI DbgBreakPoint(LPCTSTR pFileName,INT iLine,__format_string LPCTSTR szFormatString,...);
void WINAPI DbgKernelAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine); void WINAPI DbgKernelAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine);
void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const TCHAR *pFormat,...); void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCTSTR pFormat,...);
#ifdef UNICODE #ifdef UNICODE
void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const CHAR *pFormat,...); void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCSTR pFormat,...);
void WINAPI DbgAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLine); void WINAPI DbgAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine);
void WINAPI DbgBreakPoint(const CHAR *pCondition,const CHAR *pFileName,INT iLine); void WINAPI DbgBreakPoint(LPCSTR pCondition,LPCSTR pFileName,INT iLine);
void WINAPI DbgKernelAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLine); void WINAPI DbgKernelAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine);
#endif #endif
void WINAPI DbgOutString(LPCTSTR psz); void WINAPI DbgOutString(LPCTSTR psz);
// Debug infinite wait stuff // Debug infinite wait stuff
DWORD WINAPI DbgWaitForSingleObject(HANDLE h); DWORD WINAPI DbgWaitForSingleObject(HANDLE h);
DWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount, DWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount,
CONST HANDLE *lpHandles, __in_ecount(nCount) CONST HANDLE *lpHandles,
BOOL bWaitAll); BOOL bWaitAll);
void WINAPI DbgSetWaitTimeout(DWORD dwTimeout); void WINAPI DbgSetWaitTimeout(DWORD dwTimeout);
#ifdef __strmif_h__ #ifdef __strmif_h__
// Display a media type: Terse at level 2, verbose at level 5 // Display a media type: Terse at level 2, verbose at level 5
void WINAPI DisplayType(LPTSTR label, const AM_MEDIA_TYPE *pmtIn, DWORD dwLevel = 5); void WINAPI DisplayType(LPCTSTR label, const AM_MEDIA_TYPE *pmtIn);
// Dump lots of information about a filter graph // Dump lots of information about a filter graph
void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel); void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel);
@ -176,7 +176,7 @@ typedef struct tag_ObjectDesc {
// (public entry points compile to nothing) so if you go trying to call // (public entry points compile to nothing) so if you go trying to call
// any of the private entry points in your source they won't compile // any of the private entry points in your source they won't compile
#define NAME(_x_) ((TCHAR *) NULL) #define NAME(_x_) ((LPTSTR) NULL)
#define DbgInitialise(hInst) #define DbgInitialise(hInst)
#define DbgTerminate() #define DbgTerminate()
@ -236,46 +236,12 @@ typedef struct tag_ObjectDesc {
// CheckPointer(pBar,FALSE) // CheckPointer(pBar,FALSE)
// } // }
// These validate pointers when symbol VFWROBUST is defined #define ValidateReadPtr(p,cb) 0
// This will normally be defined in debug not retail builds #define ValidateWritePtr(p,cb) 0
#define ValidateReadWritePtr(p,cb) 0
#ifdef DEBUG #define ValidateStringPtr(p) 0
#define VFWROBUST #define ValidateStringPtrA(p) 0
#endif #define ValidateStringPtrW(p) 0
#ifdef VFWROBUST
#define ValidateReadPtr(p,cb) \
{if(IsBadReadPtr((PVOID)p,cb) == TRUE) \
DbgBreak("Invalid read pointer");}
#define ValidateWritePtr(p,cb) \
{if(IsBadWritePtr((PVOID)p,cb) == TRUE) \
DbgBreak("Invalid write pointer");}
#define ValidateReadWritePtr(p,cb) \
{ValidateReadPtr(p,cb) ValidateWritePtr(p,cb)}
#define ValidateStringPtr(p) \
{if(IsBadStringPtr((LPCTSTR)p,INFINITE) == TRUE) \
DbgBreak("Invalid string pointer");}
#define ValidateStringPtrA(p) \
{if(IsBadStringPtrA((LPCSTR)p,INFINITE) == TRUE) \
DbgBreak("Invalid ANSI string pointer");}
#define ValidateStringPtrW(p) \
{if(IsBadStringPtrW((LPCWSTR)p,INFINITE) == TRUE) \
DbgBreak("Invalid UNICODE string pointer");}
#else
#define ValidateReadPtr(p,cb) 0
#define ValidateWritePtr(p,cb) 0
#define ValidateReadWritePtr(p,cb) 0
#define ValidateStringPtr(p) 0
#define ValidateStringPtrA(p) 0
#define ValidateStringPtrW(p) 0
#endif
#ifdef _OBJBASE_H_ #ifdef _OBJBASE_H_
@ -326,7 +292,7 @@ public:
CDispBasic() { m_pString = m_String; }; CDispBasic() { m_pString = m_String; };
~CDispBasic(); ~CDispBasic();
protected: protected:
TCHAR* m_pString; // normally points to m_String... unless too much data PTCHAR m_pString; // normally points to m_String... unless too much data
TCHAR m_String[50]; TCHAR m_String[50];
}; };
class CDisp : public CDispBasic class CDisp : public CDispBasic
@ -356,12 +322,12 @@ public:
class CAutoTrace class CAutoTrace
{ {
private: private:
const TCHAR* _szBlkName; LPCTSTR _szBlkName;
const int _level; const int _level;
static const TCHAR _szEntering[]; static const TCHAR _szEntering[];
static const TCHAR _szLeaving[]; static const TCHAR _szLeaving[];
public: public:
CAutoTrace(const TCHAR* szBlkName, const int level = 15) CAutoTrace(LPCTSTR szBlkName, const int level = 15)
: _szBlkName(szBlkName), _level(level) : _szBlkName(szBlkName), _level(level)
{DbgLog((LOG_TRACE, _level, _szEntering, _szBlkName));} {DbgLog((LOG_TRACE, _level, _szEntering, _szBlkName));}

View File

@ -3,8 +3,7 @@
// //
// Desc: DirectShow base classes - implements a non-MFC based generic list // Desc: DirectShow base classes - implements a non-MFC based generic list
// template class. // template class.
// // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -51,7 +50,7 @@
*/ */
#include "streams.h" #include <streams.h>
/* set cursor to the position of each element of list in turn */ /* set cursor to the position of each element of list in turn */
#define INTERNALTRAVERSELIST(list, cursor) \ #define INTERNALTRAVERSELIST(list, cursor) \
@ -78,7 +77,7 @@ for ( cursor = (list).GetTailPositionI() \
cache but no event object so the list cannot be used in calls cache but no event object so the list cannot be used in calls
to WaitForSingleObject to WaitForSingleObject
*/ */
CBaseList::CBaseList(TCHAR *pName, // Descriptive list name CBaseList::CBaseList(__in_opt LPCTSTR pName, // Descriptive list name
INT iItems) : // Node cache size INT iItems) : // Node cache size
#ifdef DEBUG #ifdef DEBUG
CBaseObject(pName), CBaseObject(pName),
@ -90,7 +89,7 @@ CBaseList::CBaseList(TCHAR *pName, // Descriptive list name
{ {
} // constructor } // constructor
CBaseList::CBaseList(TCHAR *pName) : // Descriptive list name CBaseList::CBaseList(__in_opt LPCTSTR pName) : // Descriptive list name
#ifdef DEBUG #ifdef DEBUG
CBaseObject(pName), CBaseObject(pName),
#endif #endif
@ -102,7 +101,7 @@ CBaseList::CBaseList(TCHAR *pName) : // Descriptive list name
} // constructor } // constructor
#ifdef UNICODE #ifdef UNICODE
CBaseList::CBaseList(CHAR *pName, // Descriptive list name CBaseList::CBaseList(__in_opt LPCSTR pName, // Descriptive list name
INT iItems) : // Node cache size INT iItems) : // Node cache size
#ifdef DEBUG #ifdef DEBUG
CBaseObject(pName), CBaseObject(pName),
@ -114,7 +113,7 @@ CBaseList::CBaseList(CHAR *pName, // Descriptive list name
{ {
} // constructor } // constructor
CBaseList::CBaseList(CHAR *pName) : // Descriptive list name CBaseList::CBaseList(__in_opt LPCSTR pName) : // Descriptive list name
#ifdef DEBUG #ifdef DEBUG
CBaseObject(pName), CBaseObject(pName),
#endif #endif
@ -181,16 +180,16 @@ void CBaseList::RemoveAll()
enumerators that you have may be invalid (since the node enumerators that you have may be invalid (since the node
may be gone). may be gone).
*/ */
WXLIST_POSITION CBaseList::GetHeadPositionI() const __out_opt POSITION CBaseList::GetHeadPositionI() const
{ {
return (WXLIST_POSITION) m_pFirst; return (POSITION) m_pFirst;
} // GetHeadPosition } // GetHeadPosition
WXLIST_POSITION CBaseList::GetTailPositionI() const __out_opt POSITION CBaseList::GetTailPositionI() const
{ {
return (WXLIST_POSITION) m_pLast; return (POSITION) m_pLast;
} // GetTailPosition } // GetTailPosition
@ -215,7 +214,7 @@ int CBaseList::GetCountI() const
You may still call this function once we return NULL but You may still call this function once we return NULL but
we will continue to return a NULL position value we will continue to return a NULL position value
*/ */
void *CBaseList::GetNextI(WXLIST_POSITION& rp) const __out void *CBaseList::GetNextI(__inout POSITION& rp) const
{ {
/* have we reached the end of the list */ /* have we reached the end of the list */
@ -231,7 +230,7 @@ void *CBaseList::GetNextI(WXLIST_POSITION& rp) const
CNode *pn = (CNode *) rp; CNode *pn = (CNode *) rp;
ASSERT(pn != NULL); ASSERT(pn != NULL);
rp = (WXLIST_POSITION) pn->Next(); rp = (POSITION) pn->Next();
/* Get the object at the original position from the list */ /* Get the object at the original position from the list */
@ -249,7 +248,7 @@ void *CBaseList::GetNextI(WXLIST_POSITION& rp) const
then locking would only result in a change from one bad then locking would only result in a change from one bad
behaviour to another. behaviour to another.
*/ */
void *CBaseList::GetI(WXLIST_POSITION p) const __out_opt void *CBaseList::GetI(__in_opt POSITION p) const
{ {
if (p == NULL) { if (p == NULL) {
return NULL; return NULL;
@ -261,14 +260,21 @@ void *CBaseList::GetI(WXLIST_POSITION p) const
return pObject; return pObject;
} //Get } //Get
__out void *CBaseList::GetValidI(__in POSITION p) const
{
CNode * pn = (CNode *) p;
void *pObject = pn->GetData();
// ASSERT(pObject != NULL); // NULL pointers in the list are allowed.
return pObject;
} //Get
/* Return the first position in the list which holds the given pointer. /* Return the first position in the list which holds the given pointer.
Return NULL if it's not found. Return NULL if it's not found.
*/ */
WXLIST_POSITION CBaseList::FindI( void * pObj) const __out_opt POSITION CBaseList::FindI( __in void * pObj) const
{ {
WXLIST_POSITION pn; POSITION pn;
INTERNALTRAVERSELIST(*this, pn){ INTERNALTRAVERSELIST(*this, pn){
if (GetI(pn)==pObj) { if (GetI(pn)==pObj) {
return pn; return pn;
@ -283,7 +289,7 @@ WXLIST_POSITION CBaseList::FindI( void * pObj) const
from the list, does not free the object itself). from the list, does not free the object itself).
Return the pointer to its object or NULL if empty Return the pointer to its object or NULL if empty
*/ */
void *CBaseList::RemoveHeadI() __out_opt void *CBaseList::RemoveHeadI()
{ {
/* All we do is get the head position and ask for that to be deleted. /* All we do is get the head position and ask for that to be deleted.
We could special case this since some of the code path checking We could special case this since some of the code path checking
@ -292,7 +298,7 @@ void *CBaseList::RemoveHeadI()
added complexity added complexity
*/ */
return RemoveI((WXLIST_POSITION)m_pFirst); return RemoveI((POSITION)m_pFirst);
} // RemoveHead } // RemoveHead
@ -301,7 +307,7 @@ void *CBaseList::RemoveHeadI()
from the list, does not free the object itself). from the list, does not free the object itself).
Return the pointer to its object or NULL if empty Return the pointer to its object or NULL if empty
*/ */
void *CBaseList::RemoveTailI() __out_opt void *CBaseList::RemoveTailI()
{ {
/* All we do is get the tail position and ask for that to be deleted. /* All we do is get the tail position and ask for that to be deleted.
We could special case this since some of the code path checking We could special case this since some of the code path checking
@ -310,7 +316,7 @@ void *CBaseList::RemoveTailI()
added complexity added complexity
*/ */
return RemoveI((WXLIST_POSITION)m_pLast); return RemoveI((POSITION)m_pLast);
} // RemoveTail } // RemoveTail
@ -323,7 +329,7 @@ void *CBaseList::RemoveTailI()
it can be used again. it can be used again.
Remove(NULL) is a harmless no-op - but probably is a wart. Remove(NULL) is a harmless no-op - but probably is a wart.
*/ */
void *CBaseList::RemoveI(WXLIST_POSITION pos) __out_opt void *CBaseList::RemoveI(__in_opt POSITION pos)
{ {
/* Lock the critical section before continuing */ /* Lock the critical section before continuing */
@ -384,7 +390,7 @@ void *CBaseList::RemoveI(WXLIST_POSITION pos)
Return the new tail position. Return the new tail position.
*/ */
WXLIST_POSITION CBaseList::AddTailI(void *pObject) __out_opt POSITION CBaseList::AddTailI(__in void *pObject)
{ {
/* Lock the critical section before continuing */ /* Lock the critical section before continuing */
@ -427,7 +433,7 @@ WXLIST_POSITION CBaseList::AddTailI(void *pObject)
m_pLast = pNode; m_pLast = pNode;
++m_Count; ++m_Count;
return (WXLIST_POSITION) pNode; return (POSITION) pNode;
} // AddTail(object) } // AddTail(object)
@ -435,7 +441,7 @@ WXLIST_POSITION CBaseList::AddTailI(void *pObject)
/* Add this object to the head end of our list /* Add this object to the head end of our list
Return the new head position. Return the new head position.
*/ */
WXLIST_POSITION CBaseList::AddHeadI(void *pObject) __out_opt POSITION CBaseList::AddHeadI(__in void *pObject)
{ {
CNode *pNode; CNode *pNode;
// ASSERT(pObject); // NULL pointers in the list are allowed. // ASSERT(pObject); // NULL pointers in the list are allowed.
@ -473,7 +479,7 @@ WXLIST_POSITION CBaseList::AddHeadI(void *pObject)
++m_Count; ++m_Count;
return (WXLIST_POSITION) pNode; return (POSITION) pNode;
} // AddHead(object) } // AddHead(object)
@ -482,14 +488,14 @@ WXLIST_POSITION CBaseList::AddHeadI(void *pObject)
Return TRUE if it all worked, FALSE if it didn't. Return TRUE if it all worked, FALSE if it didn't.
If it fails some elements may have been added. If it fails some elements may have been added.
*/ */
BOOL CBaseList::AddTail(CBaseList *pList) BOOL CBaseList::AddTail(__in CBaseList *pList)
{ {
/* lock the object before starting then enumerate /* lock the object before starting then enumerate
each entry in the source list and add them one by one to each entry in the source list and add them one by one to
our list (while still holding the object lock) our list (while still holding the object lock)
Lock the other list too. Lock the other list too.
*/ */
WXLIST_POSITION pos = pList->GetHeadPositionI(); POSITION pos = pList->GetHeadPositionI();
while (pos) { while (pos) {
if (NULL == AddTailI(pList->GetNextI(pos))) { if (NULL == AddTailI(pList->GetNextI(pos))) {
@ -505,7 +511,7 @@ BOOL CBaseList::AddTail(CBaseList *pList)
Return TRUE if it all worked, FALSE if it didn't. Return TRUE if it all worked, FALSE if it didn't.
If it fails some elements may have been added. If it fails some elements may have been added.
*/ */
BOOL CBaseList::AddHead(CBaseList *pList) BOOL CBaseList::AddHead(__in CBaseList *pList)
{ {
/* lock the object before starting then enumerate /* lock the object before starting then enumerate
each entry in the source list and add them one by one to each entry in the source list and add them one by one to
@ -515,10 +521,10 @@ BOOL CBaseList::AddHead(CBaseList *pList)
To avoid reversing the list, traverse it backwards. To avoid reversing the list, traverse it backwards.
*/ */
WXLIST_POSITION pos; POSITION pos;
INTERNALREVERSETRAVERSELIST(*pList, pos) { INTERNALREVERSETRAVERSELIST(*pList, pos) {
if (NULL== AddHeadI(pList->GetI(pos))){ if (NULL== AddHeadI(pList->GetValidI(pos))){
return FALSE; return FALSE;
} }
} }
@ -532,7 +538,7 @@ BOOL CBaseList::AddHead(CBaseList *pList)
AddAfter(NULL,x) adds x to the start - same as AddHead AddAfter(NULL,x) adds x to the start - same as AddHead
Return the position of the new object, NULL if it failed Return the position of the new object, NULL if it failed
*/ */
WXLIST_POSITION CBaseList::AddAfterI(WXLIST_POSITION pos, void * pObj) __out_opt POSITION CBaseList::AddAfterI(__in_opt POSITION pos, __in void * pObj)
{ {
if (pos==NULL) if (pos==NULL)
return AddHeadI(pObj); return AddHeadI(pObj);
@ -578,18 +584,18 @@ WXLIST_POSITION CBaseList::AddAfterI(WXLIST_POSITION pos, void * pObj)
++m_Count; ++m_Count;
return (WXLIST_POSITION) pNode; return (POSITION) pNode;
} // AddAfter(object) } // AddAfter(object)
BOOL CBaseList::AddAfter(WXLIST_POSITION p, CBaseList *pList) BOOL CBaseList::AddAfter(__in_opt POSITION p, __in CBaseList *pList)
{ {
WXLIST_POSITION pos; POSITION pos;
INTERNALTRAVERSELIST(*pList, pos) { INTERNALTRAVERSELIST(*pList, pos) {
/* p follows along the elements being added */ /* p follows along the elements being added */
p = AddAfterI(p, pList->GetI(pos)); p = AddAfterI(p, pList->GetValidI(pos));
if (p==NULL) return FALSE; if (p==NULL) return FALSE;
} }
return TRUE; return TRUE;
@ -602,7 +608,7 @@ BOOL CBaseList::AddAfter(WXLIST_POSITION p, CBaseList *pList)
p is still valid after the operation. p is still valid after the operation.
AddBefore(NULL,x) adds x to the end - same as AddTail AddBefore(NULL,x) adds x to the end - same as AddTail
*/ */
WXLIST_POSITION CBaseList::AddBeforeI(WXLIST_POSITION pos, void * pObj) __out_opt POSITION CBaseList::AddBeforeI(__in_opt POSITION pos, __in void * pObj)
{ {
if (pos==NULL) if (pos==NULL)
return AddTailI(pObj); return AddTailI(pObj);
@ -646,18 +652,18 @@ WXLIST_POSITION CBaseList::AddBeforeI(WXLIST_POSITION pos, void * pObj)
++m_Count; ++m_Count;
return (WXLIST_POSITION) pNode; return (POSITION) pNode;
} // Addbefore(object) } // Addbefore(object)
BOOL CBaseList::AddBefore(WXLIST_POSITION p, CBaseList *pList) BOOL CBaseList::AddBefore(__in_opt POSITION p, __in CBaseList *pList)
{ {
WXLIST_POSITION pos; POSITION pos;
INTERNALREVERSETRAVERSELIST(*pList, pos) { INTERNALREVERSETRAVERSELIST(*pList, pos) {
/* p follows along the elements being added */ /* p follows along the elements being added */
p = AddBeforeI(p, pList->GetI(pos)); p = AddBeforeI(p, pList->GetValidI(pos));
if (p==NULL) return FALSE; if (p==NULL) return FALSE;
} }
return TRUE; return TRUE;
@ -682,7 +688,7 @@ BOOL CBaseList::AddBefore(WXLIST_POSITION p, CBaseList *pList)
MoveElementsFromHeadThroughPositionToOtherTail MoveElementsFromHeadThroughPositionToOtherTail
*/ */
BOOL CBaseList::MoveToTail BOOL CBaseList::MoveToTail
(WXLIST_POSITION pos, CBaseList *pList) (__in_opt POSITION pos, __in CBaseList *pList)
{ {
/* Algorithm: /* Algorithm:
Note that the elements (including their order) in the concatenation Note that the elements (including their order) in the concatenation
@ -756,7 +762,7 @@ BOOL CBaseList::MoveToTail
concatenates foo onto the start of bar and empties foo. concatenates foo onto the start of bar and empties foo.
*/ */
BOOL CBaseList::MoveToHead BOOL CBaseList::MoveToHead
(WXLIST_POSITION pos, CBaseList *pList) (__in_opt POSITION pos, __in CBaseList *pList)
{ {
/* See the comments on the algorithm in MoveToTail */ /* See the comments on the algorithm in MoveToTail */

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines a non-MFC generic template list // Desc: DirectShow base classes - defines a non-MFC generic template list
// class. // class.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -49,8 +49,10 @@
This definition is the same as the POSITION type for MFCs, so we must This definition is the same as the POSITION type for MFCs, so we must
avoid defining it twice. avoid defining it twice.
*/ */
struct __WXLIST_POSITION { int unused; }; #ifndef __AFX_H__
typedef __WXLIST_POSITION* WXLIST_POSITION; struct __POSITION { int unused; };
typedef __POSITION* POSITION;
#endif
const int DEFAULTCACHE = 10; /* Default node object cache size */ const int DEFAULTCACHE = 10; /* Default node object cache size */
@ -93,27 +95,27 @@ public:
/* Return the previous node before this one */ /* Return the previous node before this one */
CNode *Prev() const { return m_pPrev; }; __out CNode *Prev() const { return m_pPrev; };
/* Return the next node after this one */ /* Return the next node after this one */
CNode *Next() const { return m_pNext; }; __out CNode *Next() const { return m_pNext; };
/* Set the previous node before this one */ /* Set the previous node before this one */
void SetPrev(CNode *p) { m_pPrev = p; }; void SetPrev(__in_opt CNode *p) { m_pPrev = p; };
/* Set the next node after this one */ /* Set the next node after this one */
void SetNext(CNode *p) { m_pNext = p; }; void SetNext(__in_opt CNode *p) { m_pNext = p; };
/* Get the pointer to the object for this node */ /* Get the pointer to the object for this node */
void *GetData() const { return m_pObject; }; __out void *GetData() const { return m_pObject; };
/* Set the pointer to the object for this node */ /* Set the pointer to the object for this node */
void SetData(void *p) { m_pObject = p; }; void SetData(__in void *p) { m_pObject = p; };
}; };
class CNodeCache class CNodeCache
@ -131,7 +133,7 @@ public:
delete pCurrent; delete pCurrent;
} }
}; };
void AddToCache(CNode *pNode) void AddToCache(__inout CNode *pNode)
{ {
if (m_iUsed < m_iCacheSize) { if (m_iUsed < m_iCacheSize) {
pNode->SetNext(m_pHead); pNode->SetNext(m_pHead);
@ -187,15 +189,15 @@ private:
public: public:
CBaseList(TCHAR *pName, CBaseList(__in_opt LPCTSTR pName,
INT iItems); INT iItems);
CBaseList(TCHAR *pName); CBaseList(__in_opt LPCTSTR pName);
#ifdef UNICODE #ifdef UNICODE
CBaseList(CHAR *pName, CBaseList(__in_opt LPCSTR pName,
INT iItems); INT iItems);
CBaseList(CHAR *pName); CBaseList(__in_opt LPCSTR pName);
#endif #endif
~CBaseList(); ~CBaseList();
@ -204,11 +206,11 @@ public:
/* Return a cursor which identifies the first element of *this */ /* Return a cursor which identifies the first element of *this */
WXLIST_POSITION GetHeadPositionI() const; __out_opt POSITION GetHeadPositionI() const;
/* Return a cursor which identifies the last element of *this */ /* Return a cursor which identifies the last element of *this */
WXLIST_POSITION GetTailPositionI() const; __out_opt POSITION GetTailPositionI() const;
/* Return the number of objects in *this */ /* Return the number of objects in *this */
@ -222,13 +224,14 @@ protected:
GetPrev is not implemented. GetPrev is not implemented.
Use Next, Prev and Get separately. Use Next, Prev and Get separately.
*/ */
void *GetNextI(WXLIST_POSITION& rp) const; __out void *GetNextI(__inout POSITION& rp) const;
/* Return a pointer to the object at p /* Return a pointer to the object at p
Asking for the object at NULL will return NULL harmlessly. Asking for the object at NULL will return NULL harmlessly.
*/ */
void *GetI(WXLIST_POSITION p) const; __out_opt void *GetI(__in_opt POSITION p) const;
__out void *GetValidI(__in POSITION p) const;
public: public:
/* return the next / prev position in *this /* return the next / prev position in *this
@ -246,32 +249,32 @@ public:
2. If you are keeping a list sorted (fairly common) and you 2. If you are keeping a list sorted (fairly common) and you
search forward for an element to insert before and don't search forward for an element to insert before and don't
find it you finish up with NULL as the element before which find it you finish up with NULL as the element before which
to insert. You then want that NULL to be a valid WXLIST_POSITION to insert. You then want that NULL to be a valid POSITION
so that you can insert before it and you want that insertion so that you can insert before it and you want that insertion
point to mean the (n+1)-th one that doesn't have a WXLIST_POSITION. point to mean the (n+1)-th one that doesn't have a POSITION.
(symmetrically if you are working backwards through the list). (symmetrically if you are working backwards through the list).
3. It simplifies the algebra which the methods generate. 3. It simplifies the algebra which the methods generate.
e.g. AddBefore(p,x) is identical to AddAfter(Prev(p),x) e.g. AddBefore(p,x) is identical to AddAfter(Prev(p),x)
in ALL cases. All the other arguments probably are reflections in ALL cases. All the other arguments probably are reflections
of the algebraic point. of the algebraic point.
*/ */
WXLIST_POSITION Next(WXLIST_POSITION pos) const __out_opt POSITION Next(__in_opt POSITION pos) const
{ {
if (pos == NULL) { if (pos == NULL) {
return (WXLIST_POSITION) m_pFirst; return (POSITION) m_pFirst;
} }
CNode *pn = (CNode *) pos; CNode *pn = (CNode *) pos;
return (WXLIST_POSITION) pn->Next(); return (POSITION) pn->Next();
} //Next } //Next
// See Next // See Next
WXLIST_POSITION Prev(WXLIST_POSITION pos) const __out_opt POSITION Prev(__in_opt POSITION pos) const
{ {
if (pos == NULL) { if (pos == NULL) {
return (WXLIST_POSITION) m_pLast; return (POSITION) m_pLast;
} }
CNode *pn = (CNode *) pos; CNode *pn = (CNode *) pos;
return (WXLIST_POSITION) pn->Prev(); return (POSITION) pn->Prev();
} //Prev } //Prev
@ -279,14 +282,20 @@ public:
pointer. Return NULL if the pointer was not not found. pointer. Return NULL if the pointer was not not found.
*/ */
protected: protected:
WXLIST_POSITION FindI( void * pObj) const; __out_opt POSITION FindI( __in void * pObj) const;
// ??? Should there be (or even should there be only)
// ??? POSITION FindNextAfter(void * pObj, POSITION p)
// ??? And of course FindPrevBefore too.
// ??? List.Find(&Obj) then becomes List.FindNextAfter(&Obj, NULL)
/* Remove the first node in *this (deletes the pointer to its /* Remove the first node in *this (deletes the pointer to its
object from the list, does not free the object itself). object from the list, does not free the object itself).
Return the pointer to its object. Return the pointer to its object.
If *this was already empty it will harmlessly return NULL. If *this was already empty it will harmlessly return NULL.
*/ */
void *RemoveHeadI(); __out_opt void *RemoveHeadI();
/* Remove the last node in *this (deletes the pointer to its /* Remove the last node in *this (deletes the pointer to its
@ -294,7 +303,7 @@ protected:
Return the pointer to its object. Return the pointer to its object.
If *this was already empty it will harmlessly return NULL. If *this was already empty it will harmlessly return NULL.
*/ */
void *RemoveTailI(); __out_opt void *RemoveTailI();
/* Remove the node identified by p from the list (deletes the pointer /* Remove the node identified by p from the list (deletes the pointer
@ -302,14 +311,14 @@ protected:
Asking to Remove the object at NULL will harmlessly return NULL. Asking to Remove the object at NULL will harmlessly return NULL.
Return the pointer to the object removed. Return the pointer to the object removed.
*/ */
void *RemoveI(WXLIST_POSITION p); __out_opt void *RemoveI(__in_opt POSITION p);
/* Add single object *pObj to become a new last element of the list. /* Add single object *pObj to become a new last element of the list.
Return the new tail position, NULL if it fails. Return the new tail position, NULL if it fails.
If you are adding a COM objects, you might want AddRef it first. If you are adding a COM objects, you might want AddRef it first.
Other existing POSITIONs in *this are still valid Other existing POSITIONs in *this are still valid
*/ */
WXLIST_POSITION AddTailI(void * pObj); __out_opt POSITION AddTailI(__in void * pObj);
public: public:
@ -324,7 +333,7 @@ public:
If you actually want to MOVE the elements, use MoveToTail instead. If you actually want to MOVE the elements, use MoveToTail instead.
*/ */
BOOL AddTail(CBaseList *pList); BOOL AddTail(__in CBaseList *pList);
/* Mirror images of AddHead: */ /* Mirror images of AddHead: */
@ -334,7 +343,7 @@ public:
Existing POSITIONs in *this are still valid Existing POSITIONs in *this are still valid
*/ */
protected: protected:
WXLIST_POSITION AddHeadI(void * pObj); __out_opt POSITION AddHeadI(__in void * pObj);
public: public:
/* Add all the elements in *pList to the head of *this. /* Add all the elements in *pList to the head of *this.
@ -344,7 +353,7 @@ public:
If you actually want to MOVE the elements, use MoveToHead instead. If you actually want to MOVE the elements, use MoveToHead instead.
*/ */
BOOL AddHead(CBaseList *pList); BOOL AddHead(__in CBaseList *pList);
/* Add the object *pObj to *this after position p in *this. /* Add the object *pObj to *this after position p in *this.
@ -353,7 +362,7 @@ public:
Existing POSITIONs in *this are undisturbed, including p. Existing POSITIONs in *this are undisturbed, including p.
*/ */
protected: protected:
WXLIST_POSITION AddAfterI(WXLIST_POSITION p, void * pObj); __out_opt POSITION AddAfterI(__in_opt POSITION p, __in void * pObj);
public: public:
/* Add the list *pList to *this after position p in *this /* Add the list *pList to *this after position p in *this
@ -362,7 +371,7 @@ public:
If it fails, some of the objects may be added If it fails, some of the objects may be added
Existing POSITIONs in *this are undisturbed, including p. Existing POSITIONs in *this are undisturbed, including p.
*/ */
BOOL AddAfter(WXLIST_POSITION p, CBaseList *pList); BOOL AddAfter(__in_opt POSITION p, __in CBaseList *pList);
/* Mirror images: /* Mirror images:
@ -372,7 +381,7 @@ public:
Existing POSITIONs in *this are undisturbed, including p. Existing POSITIONs in *this are undisturbed, including p.
*/ */
protected: protected:
WXLIST_POSITION AddBeforeI(WXLIST_POSITION p, void * pObj); __out_opt POSITION AddBeforeI(__in_opt POSITION p, __in void * pObj);
public: public:
/* Add the list *pList to *this before position p in *this /* Add the list *pList to *this before position p in *this
@ -381,7 +390,7 @@ public:
If it fails, some of the objects may be added If it fails, some of the objects may be added
Existing POSITIONs in *this are undisturbed, including p. Existing POSITIONs in *this are undisturbed, including p.
*/ */
BOOL AddBefore(WXLIST_POSITION p, CBaseList *pList); BOOL AddBefore(__in_opt POSITION p, __in CBaseList *pList);
/* Note that AddAfter(p,x) is equivalent to AddBefore(Next(p),x) /* Note that AddAfter(p,x) is equivalent to AddBefore(Next(p),x)
@ -425,7 +434,7 @@ public:
(and quite a few no-ops) (and quite a few no-ops)
!!WARNING!! The type checking won't buy you much if you get list !!WARNING!! The type checking won't buy you much if you get list
positions muddled up - e.g. use a WXLIST_POSITION that's in a different positions muddled up - e.g. use a POSITION that's in a different
list and see what a mess you get! list and see what a mess you get!
*/ */
@ -445,7 +454,7 @@ public:
A better, except excessively long name might be A better, except excessively long name might be
MoveElementsFromHeadThroughPositionToOtherTail MoveElementsFromHeadThroughPositionToOtherTail
*/ */
BOOL MoveToTail(WXLIST_POSITION pos, CBaseList *pList); BOOL MoveToTail(__in_opt POSITION pos, __in CBaseList *pList);
/* Mirror image: /* Mirror image:
@ -461,7 +470,7 @@ public:
foo->MoveToHead(foo->GetHeadPosition, bar); foo->MoveToHead(foo->GetHeadPosition, bar);
concatenates foo onto the start of bar and empties foo. concatenates foo onto the start of bar and empties foo.
*/ */
BOOL MoveToHead(WXLIST_POSITION pos, CBaseList *pList); BOOL MoveToHead(__in_opt POSITION pos, __in CBaseList *pList);
/* Reverse the order of the [pointers to] objects in *this /* Reverse the order of the [pointers to] objects in *this
@ -491,7 +500,7 @@ public:
template<class OBJECT> class CGenericList : public CBaseList template<class OBJECT> class CGenericList : public CBaseList
{ {
public: public:
CGenericList(TCHAR *pName, CGenericList(__in_opt LPCTSTR pName,
INT iItems, INT iItems,
BOOL bLock = TRUE, BOOL bLock = TRUE,
BOOL bAlert = FALSE) : BOOL bAlert = FALSE) :
@ -499,37 +508,38 @@ public:
UNREFERENCED_PARAMETER(bAlert); UNREFERENCED_PARAMETER(bAlert);
UNREFERENCED_PARAMETER(bLock); UNREFERENCED_PARAMETER(bLock);
}; };
CGenericList(TCHAR *pName) : CGenericList(__in_opt LPCTSTR pName) :
CBaseList(pName) { CBaseList(pName) {
}; };
WXLIST_POSITION GetHeadPosition() const { return (WXLIST_POSITION)m_pFirst; } __out_opt POSITION GetHeadPosition() const { return (POSITION)m_pFirst; }
WXLIST_POSITION GetTailPosition() const { return (WXLIST_POSITION)m_pLast; } __out_opt POSITION GetTailPosition() const { return (POSITION)m_pLast; }
int GetCount() const { return m_Count; } int GetCount() const { return m_Count; }
OBJECT *GetNext(WXLIST_POSITION& rp) const { return (OBJECT *) GetNextI(rp); } __out OBJECT *GetNext(__inout POSITION& rp) const { return (OBJECT *) GetNextI(rp); }
OBJECT *Get(WXLIST_POSITION p) const { return (OBJECT *) GetI(p); } __out_opt OBJECT *Get(__in_opt POSITION p) const { return (OBJECT *) GetI(p); }
OBJECT *GetHead() const { return Get(GetHeadPosition()); } __out OBJECT *GetValid(__in POSITION p) const { return (OBJECT *) GetValidI(p); }
__out_opt OBJECT *GetHead() const { return Get(GetHeadPosition()); }
OBJECT *RemoveHead() { return (OBJECT *) RemoveHeadI(); } __out_opt OBJECT *RemoveHead() { return (OBJECT *) RemoveHeadI(); }
OBJECT *RemoveTail() { return (OBJECT *) RemoveTailI(); } __out_opt OBJECT *RemoveTail() { return (OBJECT *) RemoveTailI(); }
OBJECT *Remove(WXLIST_POSITION p) { return (OBJECT *) RemoveI(p); } __out_opt OBJECT *Remove(__in_opt POSITION p) { return (OBJECT *) RemoveI(p); }
WXLIST_POSITION AddBefore(WXLIST_POSITION p, OBJECT * pObj) { return AddBeforeI(p, pObj); } __out_opt POSITION AddBefore(__in_opt POSITION p, __in OBJECT * pObj) { return AddBeforeI(p, pObj); }
WXLIST_POSITION AddAfter(WXLIST_POSITION p, OBJECT * pObj) { return AddAfterI(p, pObj); } __out_opt POSITION AddAfter(__in_opt POSITION p, __in OBJECT * pObj) { return AddAfterI(p, pObj); }
WXLIST_POSITION AddHead(OBJECT * pObj) { return AddHeadI(pObj); } __out_opt POSITION AddHead(__in OBJECT * pObj) { return AddHeadI(pObj); }
WXLIST_POSITION AddTail(OBJECT * pObj) { return AddTailI(pObj); } __out_opt POSITION AddTail(__in OBJECT * pObj) { return AddTailI(pObj); }
BOOL AddTail(CGenericList<OBJECT> *pList) BOOL AddTail(__in CGenericList<OBJECT> *pList)
{ return CBaseList::AddTail((CBaseList *) pList); } { return CBaseList::AddTail((CBaseList *) pList); }
BOOL AddHead(CGenericList<OBJECT> *pList) BOOL AddHead(__in CGenericList<OBJECT> *pList)
{ return CBaseList::AddHead((CBaseList *) pList); } { return CBaseList::AddHead((CBaseList *) pList); }
BOOL AddAfter(WXLIST_POSITION p, CGenericList<OBJECT> *pList) BOOL AddAfter(__in_opt POSITION p, __in CGenericList<OBJECT> *pList)
{ return CBaseList::AddAfter(p, (CBaseList *) pList); }; { return CBaseList::AddAfter(p, (CBaseList *) pList); };
BOOL AddBefore(WXLIST_POSITION p, CGenericList<OBJECT> *pList) BOOL AddBefore(__in_opt POSITION p, __in CGenericList<OBJECT> *pList)
{ return CBaseList::AddBefore(p, (CBaseList *) pList); }; { return CBaseList::AddBefore(p, (CBaseList *) pList); };
WXLIST_POSITION Find( OBJECT * pObj) const { return FindI(pObj); } __out_opt POSITION Find( __in OBJECT * pObj) const { return FindI(pObj); }
}; // end of class declaration }; // end of class declaration

View File

@ -4,69 +4,34 @@
// Desc: DirectShow base classes - implements helper classes for building // Desc: DirectShow base classes - implements helper classes for building
// multimedia filters. // multimedia filters.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "streams.h" #include <streams.h>
#define STRSAFE_NO_DEPRECATE
#include <strsafe.h>
//
// Declare function from largeint.h we need so that PPC can build
//
//
// Enlarged integer divide - 64-bits / 32-bits > 32-bits
//
#ifndef _X86_
#define LLtoU64(x) (*(unsigned __int64*)(void*)(&(x)))
__inline
ULONG
WINAPI
EnlargedUnsignedDivide (
IN ULARGE_INTEGER Dividend,
IN ULONG Divisor,
IN PULONG Remainder
)
{
// return remainder if necessary
if (Remainder != NULL)
*Remainder = (ULONG)(LLtoU64(Dividend) % Divisor);
return (ULONG)(LLtoU64(Dividend) / Divisor);
}
#else
__inline
ULONG
WINAPI
EnlargedUnsignedDivide (
IN ULARGE_INTEGER Dividend,
IN ULONG Divisor,
IN PULONG Remainder
)
{
ULONG ulResult;
_asm {
mov eax,Dividend.LowPart
mov edx,Dividend.HighPart
mov ecx,Remainder
div Divisor
or ecx,ecx
jz short label
mov [ecx],edx
label:
mov ulResult,eax
}
return ulResult;
}
#endif
// --- CAMEvent ----------------------- // --- CAMEvent -----------------------
CAMEvent::CAMEvent(BOOL fManualReset) CAMEvent::CAMEvent(BOOL fManualReset, __inout_opt HRESULT *phr)
{ {
m_hEvent = CreateEvent(NULL, fManualReset, FALSE, NULL); m_hEvent = CreateEvent(NULL, fManualReset, FALSE, NULL);
if (NULL == m_hEvent) {
if (NULL != phr && SUCCEEDED(*phr)) {
*phr = E_OUTOFMEMORY;
}
}
}
CAMEvent::CAMEvent(__inout_opt HRESULT *phr)
{
m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (NULL == m_hEvent) {
if (NULL != phr && SUCCEEDED(*phr)) {
*phr = E_OUTOFMEMORY;
}
}
} }
CAMEvent::~CAMEvent() CAMEvent::~CAMEvent()
@ -80,6 +45,10 @@ CAMEvent::~CAMEvent()
// --- CAMMsgEvent ----------------------- // --- CAMMsgEvent -----------------------
// One routine. The rest is handled in CAMEvent // One routine. The rest is handled in CAMEvent
CAMMsgEvent::CAMMsgEvent(__inout_opt HRESULT *phr) : CAMEvent(FALSE, phr)
{
}
BOOL CAMMsgEvent::WaitMsg(DWORD dwTimeout) BOOL CAMMsgEvent::WaitMsg(DWORD dwTimeout)
{ {
// wait for the event to be signalled, or for the // wait for the event to be signalled, or for the
@ -127,8 +96,9 @@ BOOL CAMMsgEvent::WaitMsg(DWORD dwTimeout)
// --- CAMThread ---------------------- // --- CAMThread ----------------------
CAMThread::CAMThread() CAMThread::CAMThread(__inout_opt HRESULT *phr)
: m_EventSend(TRUE) // must be manual-reset for CheckRequest() : m_EventSend(TRUE, phr), // must be manual-reset for CheckRequest()
m_EventComplete(FALSE, phr)
{ {
m_hThread = NULL; m_hThread = NULL;
} }
@ -141,7 +111,7 @@ CAMThread::~CAMThread() {
// when the thread starts, it calls this function. We unwrap the 'this' // when the thread starts, it calls this function. We unwrap the 'this'
//pointer and call ThreadProc. //pointer and call ThreadProc.
DWORD WINAPI DWORD WINAPI
CAMThread::InitialThreadProc(LPVOID pv) CAMThread::InitialThreadProc(__inout LPVOID pv)
{ {
HRESULT hrCoInit = CAMThread::CoInitializeHelper(); HRESULT hrCoInit = CAMThread::CoInitializeHelper();
if(FAILED(hrCoInit)) { if(FAILED(hrCoInit)) {
@ -218,7 +188,7 @@ CAMThread::GetRequest()
// is there a request? // is there a request?
BOOL BOOL
CAMThread::CheckRequest(DWORD * pParam) CAMThread::CheckRequest(__out_opt DWORD * pParam)
{ {
if (!m_EventSend.Check()) { if (!m_EventSend.Check()) {
return FALSE; return FALSE;
@ -296,7 +266,7 @@ CMsgThread::~CMsgThread()
EXECUTE_ASSERT(CloseHandle(m_hThread)); EXECUTE_ASSERT(CloseHandle(m_hThread));
} }
WXLIST_POSITION pos = m_ThreadQueue.GetHeadPosition(); POSITION pos = m_ThreadQueue.GetHeadPosition();
while (pos) { while (pos) {
CMsg * pMsg = m_ThreadQueue.GetNext(pos); CMsg * pMsg = m_ThreadQueue.GetNext(pos);
delete pMsg; delete pMsg;
@ -330,7 +300,7 @@ CMsgThread::CreateThread(
DWORD WINAPI DWORD WINAPI
CMsgThread::DefaultThreadProc( CMsgThread::DefaultThreadProc(
LPVOID lpParam __inout LPVOID lpParam
) )
{ {
CMsgThread *lpThis = (CMsgThread *)lpParam; CMsgThread *lpThis = (CMsgThread *)lpParam;
@ -359,7 +329,7 @@ CMsgThread::DefaultThreadProc(
// Block until the next message is placed on the list m_ThreadQueue. // Block until the next message is placed on the list m_ThreadQueue.
// copies the message to the message pointed to by *pmsg // copies the message to the message pointed to by *pmsg
void void
CMsgThread::GetThreadMsg(CMsg *msg) CMsgThread::GetThreadMsg(__out CMsg *msg)
{ {
CMsg * pmsg = NULL; CMsg * pmsg = NULL;
@ -385,207 +355,24 @@ CMsgThread::GetThreadMsg(CMsg *msg)
} }
// NOTE: as we need to use the same binaries on Win95 as on NT this code should
// be compiled WITHOUT unicode being defined. Otherwise we will not pick up
// these internal routines and the binary will not run on Win95.
#ifndef UNICODE
// Windows 95 doesn't implement this, so we provide an implementation.
// LPWSTR
// WINAPI
// lstrcpyWInternal(
// LPWSTR lpString1,
// LPCWSTR lpString2
// )
// {
// LPWSTR lpReturn = lpString1;
// while (*lpString1++ = *lpString2++);
//
// return lpReturn;
// }
// Windows 95 doesn't implement this, so we provide an implementation.
LPWSTR
WINAPI
lstrcpynWInternal(
LPWSTR lpString1,
LPCWSTR lpString2,
int iMaxLength
)
{
ASSERT(iMaxLength);
LPWSTR lpReturn = lpString1;
if (iMaxLength) {
while (--iMaxLength) {
if (!*lpString2) break;
*lpString1++ = *lpString2++;
};
// If we ran out of room (which will be the case if
// iMaxLength is now 0) we still need to terminate the
// string.
if (!iMaxLength) *lpString1 = L'\0';
}
return lpReturn;
}
int
WINAPI
lstrcmpWInternal(
LPCWSTR lpString1,
LPCWSTR lpString2
)
{
do {
WCHAR c1 = *lpString1;
WCHAR c2 = *lpString2;
if (c1 != c2)
return (int) c1 - (int) c2;
} while (*lpString1++ && *lpString2++);
return 0;
}
int
WINAPI
lstrcmpiWInternal(
LPCWSTR lpString1,
LPCWSTR lpString2
)
{
do {
WCHAR c1 = *lpString1;
WCHAR c2 = *lpString2;
if (c1 >= L'A' && c1 <= L'Z')
c1 -= (WCHAR) (L'A' - L'a');
if (c2 >= L'A' && c2 <= L'Z')
c2 -= (WCHAR) (L'A' - L'a');
if (c1 != c2)
return (int) c1 - (int) c2;
} while (*lpString1++ && *lpString2++);
return 0;
}
int
WINAPI
lstrlenWInternal(
LPCWSTR lpString
)
{
int i = -1;
while (*(lpString+(++i)))
;
return i;
}
// int WINAPIV wsprintfWInternal(LPWSTR wszOut, LPCWSTR pszFmt, ...)
// {
// char fmt[256]; // !!!
// char ach[256]; // !!!
// int i;
//
// va_list va;
// va_start(va, pszFmt);
// WideCharToMultiByte(GetACP(), 0, pszFmt, -1, fmt, 256, NULL, NULL);
// (void)StringCchVPrintf(ach, NUMELMS(ach), fmt, va);
// i = lstrlenA(ach);
// va_end(va);
//
// MultiByteToWideChar(CP_ACP, 0, ach, -1, wszOut, i+1);
//
// return i;
// }
#else
// need to provide the implementations in unicode for non-unicode
// builds linking with the unicode strmbase.lib
//LPWSTR WINAPI lstrcpyWInternal(
// LPWSTR lpString1,
// LPCWSTR lpString2
// )
//{
// return lstrcpyW(lpString1, lpString2);
//}
LPWSTR WINAPI lstrcpynWInternal(
LPWSTR lpString1,
LPCWSTR lpString2,
int iMaxLength
)
{
return lstrcpynW(lpString1, lpString2, iMaxLength);
}
int WINAPI lstrcmpWInternal(
LPCWSTR lpString1,
LPCWSTR lpString2
)
{
return lstrcmpW(lpString1, lpString2);
}
int WINAPI lstrcmpiWInternal(
LPCWSTR lpString1,
LPCWSTR lpString2
)
{
return lstrcmpiW(lpString1, lpString2);
}
int WINAPI lstrlenWInternal(
LPCWSTR lpString
)
{
return lstrlenW(lpString);
}
//int WINAPIV wsprintfWInternal(
// LPWSTR wszOut, LPCWSTR pszFmt, ...)
//{
// va_list va;
// va_start(va, pszFmt);
// int i = wvsprintfW(wszOut, pszFmt, va);
// va_end(va);
// return i;
//}
#endif
// Helper function - convert int to WSTR // Helper function - convert int to WSTR
void WINAPI IntToWstr(int i, LPWSTR wstr, size_t len) void WINAPI IntToWstr(int i, __out_ecount(12) LPWSTR wstr)
{ {
#ifdef UNICODE #ifdef UNICODE
(void)StringCchPrintf(wstr, len, L"%d", i); if (FAILED(StringCchPrintf(wstr, 12, L"%d", i))) {
wstr[0] = 0;
}
#else #else
TCHAR temp[32]; TCHAR temp[12];
(void)StringCchPrintf(temp, NUMELMS(temp), "%d", i); if (FAILED(StringCchPrintf(temp, NUMELMS(temp), "%d", i))) {
MultiByteToWideChar(CP_ACP, 0, temp, -1, wstr, int(len) ); wstr[0] = 0;
} else {
MultiByteToWideChar(CP_ACP, 0, temp, -1, wstr, 12);
}
#endif #endif
} // IntToWstr } // IntToWstr
#if 0
void * memchrInternal(const void *pv, int c, size_t sz)
{
BYTE *pb = (BYTE *) pv;
while (sz--) {
if (*pb == c)
return (void *) pb;
pb++;
}
return NULL;
}
#endif
#define MEMORY_ALIGNMENT 4 #define MEMORY_ALIGNMENT 4
#define MEMORY_ALIGNMENT_LOG2 2 #define MEMORY_ALIGNMENT_LOG2 2
#define MEMORY_ALIGNMENT_MASK MEMORY_ALIGNMENT - 1 #define MEMORY_ALIGNMENT_MASK MEMORY_ALIGNMENT - 1
@ -642,301 +429,33 @@ memmove_done:
return ret; return ret;
} }
/* Arithmetic functions to help with time format conversions HRESULT AMSafeMemMoveOffset(
*/ __in_bcount(dst_size) void * dst,
__in size_t dst_size,
#ifdef _M_ALPHA __in DWORD cb_dst_offset,
// work around bug in version 12.00.8385 of the alpha compiler where __in_bcount(src_size) const void * src,
// UInt32x32To64 sign-extends its arguments (?) __in size_t src_size,
#undef UInt32x32To64 __in DWORD cb_src_offset,
#define UInt32x32To64(a, b) (((ULONGLONG)((ULONG)(a)) & 0xffffffff) * ((ULONGLONG)((ULONG)(b)) & 0xffffffff)) __in size_t count)
#endif
/* Compute (a * b + d) / c */
LONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG d)
{ {
/* Compute the absolute values to avoid signed arithmetic problems */ // prevent read overruns
ULARGE_INTEGER ua, ub; if( count + cb_src_offset < count || // prevent integer overflow
DWORDLONG uc; count + cb_src_offset > src_size) // prevent read overrun
{
ua.QuadPart = (DWORDLONG)(a >= 0 ? a : -a); return E_INVALIDARG;
ub.QuadPart = (DWORDLONG)(b >= 0 ? b : -b);
uc = (DWORDLONG)(c >= 0 ? c : -c);
BOOL bSign = (a < 0) ^ (b < 0);
/* Do long multiplication */
ULARGE_INTEGER p[2];
p[0].QuadPart = UInt32x32To64(ua.LowPart, ub.LowPart);
/* This next computation cannot overflow into p[1].HighPart because
the max number we can compute here is:
(2 ** 32 - 1) * (2 ** 32 - 1) + // ua.LowPart * ub.LowPart
(2 ** 32) * (2 ** 31) * (2 ** 32 - 1) * 2 // x.LowPart * y.HighPart * 2
== 2 ** 96 - 2 ** 64 + (2 ** 64 - 2 ** 33 + 1)
== 2 ** 96 - 2 ** 33 + 1
< 2 ** 96
*/
ULARGE_INTEGER x;
x.QuadPart = UInt32x32To64(ua.LowPart, ub.HighPart) +
UInt32x32To64(ua.HighPart, ub.LowPart) +
p[0].HighPart;
p[0].HighPart = x.LowPart;
p[1].QuadPart = UInt32x32To64(ua.HighPart, ub.HighPart) + x.HighPart;
if (d != 0) {
ULARGE_INTEGER ud[2];
if (bSign) {
ud[0].QuadPart = (DWORDLONG)(-d);
if (d > 0) {
/* -d < 0 */
ud[1].QuadPart = (DWORDLONG)(LONGLONG)-1;
} else {
ud[1].QuadPart = (DWORDLONG)0;
}
} else {
ud[0].QuadPart = (DWORDLONG)d;
if (d < 0) {
ud[1].QuadPart = (DWORDLONG)(LONGLONG)-1;
} else {
ud[1].QuadPart = (DWORDLONG)0;
}
}
/* Now do extended addition */
ULARGE_INTEGER uliTotal;
/* Add ls DWORDs */
uliTotal.QuadPart = (DWORDLONG)ud[0].LowPart + p[0].LowPart;
p[0].LowPart = uliTotal.LowPart;
/* Propagate carry */
uliTotal.LowPart = uliTotal.HighPart;
uliTotal.HighPart = 0;
/* Add 2nd most ls DWORDs */
uliTotal.QuadPart += (DWORDLONG)ud[0].HighPart + p[0].HighPart;
p[0].HighPart = uliTotal.LowPart;
/* Propagate carry */
uliTotal.LowPart = uliTotal.HighPart;
uliTotal.HighPart = 0;
/* Add MS DWORDLONGs - no carry expected */
p[1].QuadPart += ud[1].QuadPart + uliTotal.QuadPart;
/* Now see if we got a sign change from the addition */
if ((LONG)p[1].HighPart < 0) {
bSign = !bSign;
/* Negate the current value (ugh!) */
p[0].QuadPart = ~p[0].QuadPart;
p[1].QuadPart = ~p[1].QuadPart;
p[0].QuadPart += 1;
p[1].QuadPart += (p[0].QuadPart == 0);
}
} }
/* Now for the division */ // prevent write overruns
if (c < 0) { if( count + cb_dst_offset < count || // prevent integer overflow
bSign = !bSign; count + cb_dst_offset > dst_size) // prevent write overrun
{
return E_INVALIDARG;
} }
memmoveInternal( (BYTE *)dst+cb_dst_offset, (BYTE *)src+cb_src_offset, count);
/* This will catch c == 0 and overflow */ return S_OK;
if (uc <= p[1].QuadPart) {
return bSign ? (LONGLONG)0x8000000000000000 :
(LONGLONG)0x7FFFFFFFFFFFFFFF;
}
DWORDLONG ullResult;
/* Do the division */
/* If the dividend is a DWORD_LONG use the compiler */
if (p[1].QuadPart == 0) {
ullResult = p[0].QuadPart / uc;
return bSign ? -(LONGLONG)ullResult : (LONGLONG)ullResult;
}
/* If the divisor is a DWORD then its simpler */
ULARGE_INTEGER ulic;
ulic.QuadPart = uc;
if (ulic.HighPart == 0) {
ULARGE_INTEGER uliDividend;
ULARGE_INTEGER uliResult;
DWORD dwDivisor = (DWORD)uc;
// ASSERT(p[1].HighPart == 0 && p[1].LowPart < dwDivisor);
uliDividend.HighPart = p[1].LowPart;
uliDividend.LowPart = p[0].HighPart;
#ifndef USE_LARGEINT
uliResult.HighPart = (DWORD)(uliDividend.QuadPart / dwDivisor);
p[0].HighPart = (DWORD)(uliDividend.QuadPart % dwDivisor);
uliResult.LowPart = 0;
uliResult.QuadPart = p[0].QuadPart / dwDivisor + uliResult.QuadPart;
#else
/* NOTE - this routine will take exceptions if
the result does not fit in a DWORD
*/
if (uliDividend.QuadPart >= (DWORDLONG)dwDivisor) {
uliResult.HighPart = EnlargedUnsignedDivide(
uliDividend,
dwDivisor,
&p[0].HighPart);
} else {
uliResult.HighPart = 0;
}
uliResult.LowPart = EnlargedUnsignedDivide(
p[0],
dwDivisor,
NULL);
#endif
return bSign ? -(LONGLONG)uliResult.QuadPart :
(LONGLONG)uliResult.QuadPart;
}
ullResult = 0;
/* OK - do long division */
for (int i = 0; i < 64; i++) {
ullResult <<= 1;
/* Shift 128 bit p left 1 */
p[1].QuadPart <<= 1;
if ((p[0].HighPart & 0x80000000) != 0) {
p[1].LowPart++;
}
p[0].QuadPart <<= 1;
/* Compare */
if (uc <= p[1].QuadPart) {
p[1].QuadPart -= uc;
ullResult += 1;
}
}
return bSign ? - (LONGLONG)ullResult : (LONGLONG)ullResult;
} }
LONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG d)
{
ULARGE_INTEGER ua;
DWORD ub;
DWORD uc;
/* Compute the absolute values to avoid signed arithmetic problems */
ua.QuadPart = (DWORDLONG)(a >= 0 ? a : -a);
ub = (DWORD)(b >= 0 ? b : -b);
uc = (DWORD)(c >= 0 ? c : -c);
BOOL bSign = (a < 0) ^ (b < 0);
/* Do long multiplication */
ULARGE_INTEGER p0;
DWORD p1;
p0.QuadPart = UInt32x32To64(ua.LowPart, ub);
if (ua.HighPart != 0) {
ULARGE_INTEGER x;
x.QuadPart = UInt32x32To64(ua.HighPart, ub) + p0.HighPart;
p0.HighPart = x.LowPart;
p1 = x.HighPart;
} else {
p1 = 0;
}
if (d != 0) {
ULARGE_INTEGER ud0;
DWORD ud1;
if (bSign) {
//
// Cast d to LONGLONG first otherwise -0x80000000 sign extends
// incorrectly
//
ud0.QuadPart = (DWORDLONG)(-(LONGLONG)d);
if (d > 0) {
/* -d < 0 */
ud1 = (DWORD)-1;
} else {
ud1 = (DWORD)0;
}
} else {
ud0.QuadPart = (DWORDLONG)d;
if (d < 0) {
ud1 = (DWORD)-1;
} else {
ud1 = (DWORD)0;
}
}
/* Now do extended addition */
ULARGE_INTEGER uliTotal;
/* Add ls DWORDs */
uliTotal.QuadPart = (DWORDLONG)ud0.LowPart + p0.LowPart;
p0.LowPart = uliTotal.LowPart;
/* Propagate carry */
uliTotal.LowPart = uliTotal.HighPart;
uliTotal.HighPart = 0;
/* Add 2nd most ls DWORDs */
uliTotal.QuadPart += (DWORDLONG)ud0.HighPart + p0.HighPart;
p0.HighPart = uliTotal.LowPart;
/* Add MS DWORDLONGs - no carry expected */
p1 += ud1 + uliTotal.HighPart;
/* Now see if we got a sign change from the addition */
if ((LONG)p1 < 0) {
bSign = !bSign;
/* Negate the current value (ugh!) */
p0.QuadPart = ~p0.QuadPart;
p1 = ~p1;
p0.QuadPart += 1;
p1 += (p0.QuadPart == 0);
}
}
/* Now for the division */
if (c < 0) {
bSign = !bSign;
}
/* This will catch c == 0 and overflow */
if (uc <= p1) {
return bSign ? (LONGLONG)0x8000000000000000 :
(LONGLONG)0x7FFFFFFFFFFFFFFF;
}
/* Do the division */
/* If the divisor is a DWORD then its simpler */
ULARGE_INTEGER uliDividend;
ULARGE_INTEGER uliResult;
DWORD dwDivisor = uc;
uliDividend.HighPart = p1;
uliDividend.LowPart = p0.HighPart;
/* NOTE - this routine will take exceptions if
the result does not fit in a DWORD
*/
if (uliDividend.QuadPart >= (DWORDLONG)dwDivisor) {
uliResult.HighPart = EnlargedUnsignedDivide(
uliDividend,
dwDivisor,
&p0.HighPart);
} else {
uliResult.HighPart = 0;
}
uliResult.LowPart = EnlargedUnsignedDivide(
p0,
dwDivisor,
NULL);
return bSign ? -(LONGLONG)uliResult.QuadPart :
(LONGLONG)uliResult.QuadPart;
}
#ifdef DEBUG #ifdef DEBUG
/******************************Public*Routine******************************\ /******************************Public*Routine******************************\
@ -950,10 +469,9 @@ LONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG d)
* *
\**************************************************************************/ \**************************************************************************/
CCritSec::CCritSec(DWORD id) CCritSec::CCritSec()
{ {
InitializeCriticalSection(&m_CritSec); InitializeCriticalSection(&m_CritSec);
m_id = id;
m_currentOwner = m_lockCount = 0; m_currentOwner = m_lockCount = 0;
m_fTrace = FALSE; m_fTrace = FALSE;
} }
@ -979,9 +497,7 @@ void CCritSec::Lock()
// critical section // critical section
} }
} }
EnterCriticalSection(&m_CritSec);
EnterCriticalSection(&m_CritSec);
if (0 == m_lockCount++) { if (0 == m_lockCount++) {
// we now own it for the first time. Set owner information // we now own it for the first time. Set owner information
m_currentOwner = us; m_currentOwner = us;
@ -1031,7 +547,7 @@ BOOL WINAPI CritCheckOut(const CCritSec * pcCrit)
#endif #endif
STDAPI WriteBSTR(BSTR *pstrDest, LPCWSTR szSrc) STDAPI WriteBSTR(__deref_out BSTR *pstrDest, LPCWSTR szSrc)
{ {
*pstrDest = SysAllocString( szSrc ); *pstrDest = SysAllocString( szSrc );
if( !(*pstrDest) ) return E_OUTOFMEMORY; if( !(*pstrDest) ) return E_OUTOFMEMORY;
@ -1039,9 +555,9 @@ STDAPI WriteBSTR(BSTR *pstrDest, LPCWSTR szSrc)
} }
STDAPI FreeBSTR(BSTR* pstr) STDAPI FreeBSTR(__deref_in BSTR* pstr)
{ {
if( *pstr == NULL ) return S_FALSE; if( (PVOID)*pstr == NULL ) return S_FALSE;
SysFreeString( *pstr ); SysFreeString( *pstr );
return NOERROR; return NOERROR;
} }
@ -1052,16 +568,21 @@ STDAPI FreeBSTR(BSTR* pstr)
// S_OK - no error // S_OK - no error
// E_POINTER - ppszReturn == NULL // E_POINTER - ppszReturn == NULL
// E_OUTOFMEMORY - can't allocate memory for returned string // E_OUTOFMEMORY - can't allocate memory for returned string
STDAPI AMGetWideString(LPCWSTR psz, LPWSTR *ppszReturn) STDAPI AMGetWideString(LPCWSTR psz, __deref_out LPWSTR *ppszReturn)
{ {
CheckPointer(ppszReturn, E_POINTER); CheckPointer(ppszReturn, E_POINTER);
ValidateReadWritePtr(ppszReturn, sizeof(LPWSTR)); ValidateReadWritePtr(ppszReturn, sizeof(LPWSTR));
DWORD nameLen = sizeof(WCHAR) * (lstrlenW(psz)+1); *ppszReturn = NULL;
*ppszReturn = (LPWSTR)CoTaskMemAlloc(nameLen); size_t nameLen;
HRESULT hr = StringCbLengthW(psz, 100000, &nameLen);
if (FAILED(hr)) {
return hr;
}
*ppszReturn = (LPWSTR)CoTaskMemAlloc(nameLen + sizeof(WCHAR));
if (*ppszReturn == NULL) { if (*ppszReturn == NULL) {
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
CopyMemory(*ppszReturn, psz, nameLen); CopyMemory(*ppszReturn, psz, nameLen + sizeof(WCHAR));
return NOERROR; return NOERROR;
} }
@ -1079,8 +600,8 @@ DWORD WINAPI WaitDispatchingMessages(
{ {
BOOL bPeeked = FALSE; BOOL bPeeked = FALSE;
DWORD dwResult; DWORD dwResult;
DWORD dwStart = 0; DWORD dwStart;
DWORD dwThreadPriority = 0; DWORD dwThreadPriority;
static UINT uMsgId = 0; static UINT uMsgId = 0;
@ -1177,7 +698,7 @@ HRESULT AmGetLastErrorToHResult()
} }
} }
IUnknown* QzAtlComPtrAssign(IUnknown** pp, IUnknown* lp) IUnknown* QzAtlComPtrAssign(__deref_inout_opt IUnknown** pp, __in_opt IUnknown* lp)
{ {
if (lp != NULL) if (lp != NULL)
lp->AddRef(); lp->AddRef();
@ -1204,7 +725,7 @@ Return Value:
the Platform SDK for more information. the Platform SDK for more information.
******************************************************************************/ ******************************************************************************/
MMRESULT CompatibleTimeSetEvent( UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent ) MMRESULT CompatibleTimeSetEvent( UINT uDelay, UINT uResolution, __in LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent )
{ {
#if WINVER >= 0x0501 #if WINVER >= 0x0501
{ {

View File

@ -4,7 +4,7 @@
// Desc: DirectShow base classes - defines helper classes and functions for // Desc: DirectShow base classes - defines helper classes and functions for
// building multimedia filters. // building multimedia filters.
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -26,12 +26,11 @@ class CCritSec {
#ifdef DEBUG #ifdef DEBUG
public: public:
DWORD m_id;
DWORD m_currentOwner; DWORD m_currentOwner;
DWORD m_lockCount; DWORD m_lockCount;
BOOL m_fTrace; // Trace this one BOOL m_fTrace; // Trace this one
public: public:
CCritSec(DWORD id = 0); CCritSec();
~CCritSec(); ~CCritSec();
void Lock(); void Lock();
void Unlock(); void Unlock();
@ -117,7 +116,8 @@ class CAMEvent
protected: protected:
HANDLE m_hEvent; HANDLE m_hEvent;
public: public:
CAMEvent(BOOL fManualReset = FALSE); CAMEvent(BOOL fManualReset = FALSE, __inout_opt HRESULT *phr = NULL);
CAMEvent(__inout_opt HRESULT *phr);
~CAMEvent(); ~CAMEvent();
// Cast to HANDLE - we don't support this as an lvalue // Cast to HANDLE - we don't support this as an lvalue
@ -141,6 +141,8 @@ class CAMMsgEvent : public CAMEvent
public: public:
CAMMsgEvent(__inout_opt HRESULT *phr = NULL);
// Allow SEND messages to be processed while waiting // Allow SEND messages to be processed while waiting
BOOL WaitMsg(DWORD dwTimeout = INFINITE); BOOL WaitMsg(DWORD dwTimeout = INFINITE);
}; };
@ -150,6 +152,7 @@ public:
// support for a worker thread // support for a worker thread
#ifdef AM_NOVTABLE
// simple thread class supports creation of worker thread, synchronization // simple thread class supports creation of worker thread, synchronization
// and communication. Can be derived to simplify parameter passing // and communication. Can be derived to simplify parameter passing
class AM_NOVTABLE CAMThread { class AM_NOVTABLE CAMThread {
@ -173,7 +176,7 @@ protected:
virtual DWORD ThreadProc() = 0; virtual DWORD ThreadProc() = 0;
public: public:
CAMThread(); CAMThread(__inout_opt HRESULT *phr = NULL);
virtual ~CAMThread(); virtual ~CAMThread();
CCritSec m_AccessLock; // locks access by client threads CCritSec m_AccessLock; // locks access by client threads
@ -181,7 +184,7 @@ public:
// thread initially runs this. param is actually 'this'. function // thread initially runs this. param is actually 'this'. function
// just gets this and calls ThreadProc // just gets this and calls ThreadProc
static DWORD WINAPI InitialThreadProc(LPVOID pv); static DWORD WINAPI InitialThreadProc(__inout LPVOID pv);
// start thread running - error if already running // start thread running - error if already running
BOOL Create(); BOOL Create();
@ -193,13 +196,12 @@ public:
// accessor thread calls this when done with thread (having told thread // accessor thread calls this when done with thread (having told thread
// to exit) // to exit)
void Close() { void Close() {
#pragma warning( push )
// C4312: 'type cast' : conversion from 'LONG' to 'PVOID' of greater size // Disable warning: Conversion from LONG to PVOID of greater size
// #pragma warning(push)
// This code works correctly on 32-bit and 64-bit systems. #pragma warning(disable: 4312)
#pragma warning( disable : 4312 )
HANDLE hThread = (HANDLE)InterlockedExchangePointer(&m_hThread, 0); HANDLE hThread = (HANDLE)InterlockedExchangePointer(&m_hThread, 0);
#pragma warning( pop ) #pragma warning(pop)
if (hThread) { if (hThread) {
WaitForSingleObject(hThread, INFINITE); WaitForSingleObject(hThread, INFINITE);
@ -222,7 +224,7 @@ public:
DWORD GetRequest(); DWORD GetRequest();
// is there a request? // is there a request?
BOOL CheckRequest(DWORD * pParam); BOOL CheckRequest(__out_opt DWORD * pParam);
// reply to the request // reply to the request
void Reply(DWORD); void Reply(DWORD);
@ -238,6 +240,7 @@ public:
// available. S_FALSE means it's not available. // available. S_FALSE means it's not available.
static HRESULT CoInitializeHelper(); static HRESULT CoInitializeHelper();
}; };
#endif // AM_NOVTABLE
// CQueue // CQueue
@ -334,52 +337,27 @@ public:
} }
}; };
// miscellaneous string conversion functions // Ensures that memory is not read past the length source buffer
// NOTE: as we need to use the same binaries on Win95 as on NT this code should // and that memory is not written past the length of the dst buffer
// be compiled WITHOUT unicode being defined. Otherwise we will not pick up // dst - buffer to copy to
// these internal routines and the binary will not run on Win95. // dst_size - total size of destination buffer
// cb_dst_offset - offset, first byte copied to dst+cb_dst_offset
// int WINAPIV wsprintfWInternal(LPWSTR, LPCWSTR, ...); // src - buffer to copy from
// src_size - total size of source buffer
//LPWSTR // cb_src_offset - offset, first byte copied from src+cb_src_offset
//WINAPI // count - number of bytes to copy
//lstrcpyWInternal( //
// LPWSTR lpString1, // Returns:
// LPCWSTR lpString2 // S_OK - no error
// ); // E_INVALIDARG - values passed would lead to overrun
LPWSTR HRESULT AMSafeMemMoveOffset(
WINAPI __in_bcount(dst_size) void * dst,
lstrcpynWInternal( __in size_t dst_size,
LPWSTR lpString1, __in DWORD cb_dst_offset,
LPCWSTR lpString2, __in_bcount(src_size) const void * src,
int iMaxLength __in size_t src_size,
); __in DWORD cb_src_offset,
int __in size_t count);
WINAPI
lstrcmpWInternal(
LPCWSTR lpString1,
LPCWSTR lpString2
);
int
WINAPI
lstrcmpiWInternal(
LPCWSTR lpString1,
LPCWSTR lpString2
);
int
WINAPI
lstrlenWInternal(
LPCWSTR lpString
);
#ifndef UNICODE
#define wsprintfW wsprintfWInternal
#define lstrcpyW lstrcpyWInternal
#define lstrcpynW lstrcpynWInternal
#define lstrcmpW lstrcmpWInternal
#define lstrcmpiW lstrcmpiWInternal
#define lstrlenW lstrlenWInternal
#endif
extern "C" extern "C"
void * __stdcall memmoveInternal(void *, const void *, size_t); void * __stdcall memmoveInternal(void *, const void *, size_t);
@ -413,7 +391,7 @@ exit_memchr:
#endif #endif
} }
void WINAPI IntToWstr(int i, LPWSTR wstr, size_t len); void WINAPI IntToWstr(int i, __out_ecount(12) LPWSTR wstr);
#define WstrToInt(sz) _wtoi(sz) #define WstrToInt(sz) _wtoi(sz)
#define atoiW(sz) _wtoi(sz) #define atoiW(sz) _wtoi(sz)
@ -447,8 +425,11 @@ STDAPI_(WCHAR *) GetSubtypeNameW(const GUID *pSubtype);
STDAPI_(LONG) GetBitmapFormatSize(const BITMAPINFOHEADER *pHeader); STDAPI_(LONG) GetBitmapFormatSize(const BITMAPINFOHEADER *pHeader);
STDAPI_(DWORD) GetBitmapSize(const BITMAPINFOHEADER *pHeader); STDAPI_(DWORD) GetBitmapSize(const BITMAPINFOHEADER *pHeader);
#ifdef __AMVIDEO__
STDAPI_(BOOL) ContainsPalette(const VIDEOINFOHEADER *pVideoInfo); STDAPI_(BOOL) ContainsPalette(const VIDEOINFOHEADER *pVideoInfo);
STDAPI_(const RGBQUAD *) GetBitmapPalette(const VIDEOINFOHEADER *pVideoInfo); STDAPI_(const RGBQUAD *) GetBitmapPalette(const VIDEOINFOHEADER *pVideoInfo);
#endif // __AMVIDEO__
// Compares two interfaces and returns TRUE if they are on the same object // Compares two interfaces and returns TRUE if they are on the same object
@ -466,15 +447,15 @@ LONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG rnd);
// Avoids us dyna-linking to SysAllocString to copy BSTR strings // Avoids us dyna-linking to SysAllocString to copy BSTR strings
STDAPI WriteBSTR(BSTR * pstrDest, LPCWSTR szSrc); STDAPI WriteBSTR(__deref_out BSTR * pstrDest, LPCWSTR szSrc);
STDAPI FreeBSTR(BSTR* pstr); STDAPI FreeBSTR(__deref_in BSTR* pstr);
// Return a wide string - allocating memory for it // Return a wide string - allocating memory for it
// Returns: // Returns:
// S_OK - no error // S_OK - no error
// E_POINTER - ppszReturn == NULL // E_POINTER - ppszReturn == NULL
// E_OUTOFMEMORY - can't allocate memory for returned string // E_OUTOFMEMORY - can't allocate memory for returned string
STDAPI AMGetWideString(LPCWSTR pszString, LPWSTR *ppszReturn); STDAPI AMGetWideString(LPCWSTR pszString, __deref_out LPWSTR *ppszReturn);
// Special wait for objects owning windows // Special wait for objects owning windows
DWORD WINAPI WaitDispatchingMessages( DWORD WINAPI WaitDispatchingMessages(
@ -496,7 +477,7 @@ HRESULT AmGetLastErrorToHResult(void);
// duplicate of ATL's CComPtr to avoid linker conflicts. // duplicate of ATL's CComPtr to avoid linker conflicts.
IUnknown* QzAtlComPtrAssign(IUnknown** pp, IUnknown* lp); IUnknown* QzAtlComPtrAssign(__deref_inout_opt IUnknown** pp, __in_opt IUnknown* lp);
template <class T> template <class T>
class QzCComPtr class QzCComPtr
@ -535,7 +516,17 @@ public:
T* p; T* p;
}; };
MMRESULT CompatibleTimeSetEvent( UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent ); MMRESULT CompatibleTimeSetEvent( UINT uDelay, UINT uResolution, __in LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent );
bool TimeKillSynchronousFlagAvailable( void ); bool TimeKillSynchronousFlagAvailable( void );
// Helper to replace lstrcpmi
__inline int lstrcmpiLocaleIndependentW(LPCWSTR lpsz1, LPCWSTR lpsz2)
{
return CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, lpsz1, -1, lpsz2, -1) - CSTR_EQUAL;
}
__inline int lstrcmpiLocaleIndependentA(LPCSTR lpsz1, LPCSTR lpsz2)
{
return CompareStringA(LOCALE_INVARIANT, NORM_IGNORECASE, lpsz1, -1, lpsz2, -1) - CSTR_EQUAL;
}
#endif /* __WXUTIL__ */ #endif /* __WXUTIL__ */

View File

@ -82,7 +82,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "3rdparty\libpng\p
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pthreads4w", "3rdparty\pthreads4w\build\pthreads4w.vcxproj", "{0FAE817D-9A32-4830-857E-81DA57246E16}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pthreads4w", "3rdparty\pthreads4w\build\pthreads4w.vcxproj", "{0FAE817D-9A32-4830-857E-81DA57246E16}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baseclasses", "unfree\baseclasses\baseclasses.vcxproj", "{27F17499-A372-4408-8AFA-4F9F4584FBD3}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baseclasses", "3rdparty\baseclasses\baseclasses.vcxproj", "{27F17499-A372-4408-8AFA-4F9F4584FBD3}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetype", "3rdparty\freetype\builds\windows\freetype.vcxproj", "{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetype", "3rdparty\freetype\builds\windows\freetype.vcxproj", "{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}"
EndProject EndProject

View File

@ -23,7 +23,7 @@
#include "GSDialog.h" #include "GSDialog.h"
#include "resource.h" #include "resource.h"
#include "baseclasses/streams.h" #include <streams.h>
class GSCaptureDlg : public GSDialog class GSCaptureDlg : public GSDialog
{ {

View File

@ -323,7 +323,7 @@
<ProjectReference Include="..\..\3rdparty\xz\liblzma.vcxproj"> <ProjectReference Include="..\..\3rdparty\xz\liblzma.vcxproj">
<Project>{12728250-16ec-4dc6-94d7-e21dd88947f8}</Project> <Project>{12728250-16ec-4dc6-94d7-e21dd88947f8}</Project>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\unfree\baseclasses\baseclasses.vcxproj"> <ProjectReference Include="..\..\3rdparty\baseclasses\baseclasses.vcxproj">
<Project>{27f17499-a372-4408-8afa-4f9f4584fbd3}</Project> <Project>{27f17499-a372-4408-8afa-4f9f4584fbd3}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>

View File

@ -13,7 +13,7 @@
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4456;4458;4996;4995;4324;4100;4101;4201;4556;4127;4512;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4456;4458;4996;4995;4324;4100;4101;4201;4556;4127;4512;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(VTUNE_AMPLIFIER_XE_2015_DIR)include;$(ProjectDir);$(SolutionDir)unfree;$(SolutionDir)3rdparty;$(SolutionDir)3rdparty\freetype\include;$(SolutionDir)3rdparty\libpng;$(SolutionDir)3rdparty\opencl;$(SolutionDir)3rdparty\xz\xz\src\liblzma\api;$(SolutionDir)3rdparty\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(VTUNE_AMPLIFIER_XE_2015_DIR)include;$(ProjectDir);$(SolutionDir)3rdparty\baseclasses;$(SolutionDir)3rdparty;$(SolutionDir)3rdparty\freetype\include;$(SolutionDir)3rdparty\libpng;$(SolutionDir)3rdparty\opencl;$(SolutionDir)3rdparty\xz\xz\src\liblzma\api;$(SolutionDir)3rdparty\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>LZMA_API_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LZMA_API_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>

View File

@ -1,142 +0,0 @@
//------------------------------------------------------------------------------
// File: Activex.rcv
//
// Desc: DirectShow base classes - this file defines the version resource
// used for the application.
//
// NOTE: All strings MUST have an explicit \0 for termination!
//
// For a complete description of the Version Resource, search the
// Microsoft Developer's Network (MSDN) CD-ROM for 'version resource'..
//
// Copyright (c) 1992 - 2002, Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
#ifndef _ACTIVEX_RCV_
#define _ACTIVEX_RCV_
#ifndef WIN32
#define WIN32
#endif
#include <winver.h>
#ifndef _ACTIVEX_VER_
#include <activex.ver>
#endif
//
// Version flags.
//
// OFFICIAL and FINAL should be defined when appropriate.
//
#ifndef OFFICIAL
#define VER_PRIVATEBUILD VS_FF_PRIVATEBUILD
#else
#define VER_PRIVATEBUILD 0
#endif
#ifndef FINAL
#define VER_PRERELEASE VS_FF_PRERELEASE
#else
#define VER_PRERELEASE 0
#endif
#ifdef DEBUG
#define VER_DEBUG VS_FF_DEBUG
#else
#define VER_DEBUG 0
#endif
//
// Version definitions
//
#define VERSION_RES_FLAGSMASK 0x0030003FL
#define VERSION_RES_FLAGS (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
#ifndef VERSION_RES_OS
#define VERSION_RES_OS VOS__WINDOWS32
#endif
#ifndef VERSION_RES_TYPE
#define VERSION_RES_TYPE VFT_DLL
#endif
#ifndef VERSION_RES_SUBTYPE
#define VERSION_RES_SUBTYPE VFT2_UNKNOWN
#endif
#define VERSION_RES_LANGUAGE 0x409
#ifndef VERSION_RES_CHARSET
#ifdef UNICODE
#define VERSION_RES_CHARSET 1200
#else
#define VERSION_RES_CHARSET 1252
#endif
#endif
#ifndef VERSION_RES_ACTIVEX
#define VERSION_RES_ACTIVEX "Filter dll\0"
#endif
#ifdef AMOVIE_SELF_REGISTER
#ifndef OLE_SELF_REGISTER
#define OLE_SELF_REGISTER
#endif
#endif
#ifdef OLE_SELF_REGISTER
#ifdef AMOVIE_SELF_REGISTER
#define VERSION_RES_SELFREGISTER "AM20\0"
#else
#define VERSION_RES_SELFREGISTER "\0"
#endif
#endif
//
// Version resource
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_RES_MAJOR_VER, VERSION_RES_MINOR_VER, 0, VERSION_RES_BUILD
PRODUCTVERSION VERSION_RES_MAJOR_VER, VERSION_RES_MINOR_VER, 0, VERSION_RES_BUILD
FILEFLAGSMASK VERSION_RES_FLAGSMASK
FILEFLAGS VERSION_RES_FLAGS
FILEOS VERSION_RES_OS
FILETYPE VERSION_RES_TYPE
FILESUBTYPE VERSION_RES_SUBTYPE
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VERSION_RES_COMPANY_NAME
VALUE "Comment", VERSION_RES_COMMENT
VALUE "FileDescription", VERSION_RES_BIN_DESCRIPTION
VALUE "FileVersion", VERSION_RES_STRING
VALUE "InternalName", VERSION_RES_BIN_NAME
VALUE "LegalCopyright", VERSION_RES_COPYRIGHT
VALUE "OriginalFilename", VERSION_RES_BIN_NAME
VALUE "ProductName", VERSION_RES_PRODUCT_NAME
#ifdef DEBUG
VALUE "ProductVersion", VERSION_RES_STRING_D
#else
VALUE "ProductVersion", VERSION_RES_STRING
#endif
VALUE "ActiveMovie", VERSION_RES_ACTIVEX
#ifdef OLE_SELF_REGISTER
VALUE "OLESelfRegister", VERSION_RES_SELFREGISTER
#endif
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", VERSION_RES_LANGUAGE, VERSION_RES_CHARSET
END
END
#endif
// _ACTIVEX_RCV_

View File

@ -1,56 +0,0 @@
//------------------------------------------------------------------------------
// File: Activex.ver
//
// Desc: DirectShow base classes - common versioning information for
// ACTIVEX binaries.
//
// Copyright (c) 1996-2002, Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
#ifndef _ACTIVEX_VER_
#define _ACTIVEX_VER_
// NOTE: all string resources that will be used in ACTIVEX.RCV for the
// version resource information *MUST* have an explicit \0 terminator!
#define VERSION_RES_MAJOR_VER 9
#define VERSION_RES_MINOR_VER 0
#define VERSION_RES_BUILD 0
#define VERSION_RES_STRING_D "9.00 (Debug)\0"
#define VERSION_RES_STRING "9.00\0"
#define VERSION_RES_PRODUCT_NAME "DirectX 9.0 Sample\0"
#define VERSION_RES_COMMENT "DirectShow Sample\0"
#define VERSION_RES_COMPANY_NAME "Microsoft Corporation\0"
#define VERSION_RES_COPYRIGHT "Copyright (C) 1992-2002 Microsoft Corporation\0"
// The following defines are required on a file-by-file basis
//
// #define VERSION_RES_BIN_NAME "sample.ax\0"
// #define VERSION_RES_BIN_DESCRIPTION "Sample Filter\0"
//
// Also required, if you don't want the defaults, are
//
// #define VERSION_RES_ACTIVEX "Filter dll\0" (the default value)
//
// A string defining the type of component.
//
// #define VERSION_RES_TYPE VFT_DLL (default)
// VFT_APP
// VFT_VXD
// VFT_DRV
// VFT_FONT
// VFT_STATIC_LIB
// VFT_UNKNOWN
//
// #define VERSION_RES_SUBTYPE VFT2_UNKNOWN (default)
// VFT2_DRV_INSTALLABLE
// VFT2_DRV_SOUND
// <several other options>
//
// See winver.h for further details
#endif

View File

@ -1,128 +0,0 @@
//------------------------------------------------------------------------------
// File: DSSchedule.h (replaces DirectX 8's schedule.h)
//
// Desc: DirectShow base classes.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
#ifndef __CAMSchedule__
#define __CAMSchedule__
class CAMSchedule : private CBaseObject
{
public:
virtual ~CAMSchedule();
// ev is the event we should fire if the advise time needs re-evaluating
CAMSchedule( HANDLE ev );
DWORD GetAdviseCount();
REFERENCE_TIME GetNextAdviseTime();
// We need a method for derived classes to add advise packets, we return the cookie
DWORD_PTR AddAdvisePacket( const REFERENCE_TIME & time1, const REFERENCE_TIME & time2, HANDLE h, BOOL periodic );
// And a way to cancel
HRESULT Unadvise(DWORD_PTR dwAdviseCookie);
// Tell us the time please, and we'll dispatch the expired events. We return the time of the next event.
// NB: The time returned will be "useless" if you start adding extra Advises. But that's the problem of
// whoever is using this helper class (typically a clock).
REFERENCE_TIME Advise( const REFERENCE_TIME & rtTime );
// Get the event handle which will be set if advise time requires re-evaluation.
HANDLE GetEvent() const { return m_ev; }
private:
// We define the nodes that will be used in our singly linked list
// of advise packets. The list is ordered by time, with the
// elements that will expire first at the front.
class CAdvisePacket
{
public:
CAdvisePacket()
{}
CAdvisePacket * m_next;
DWORD_PTR m_dwAdviseCookie;
REFERENCE_TIME m_rtEventTime; // Time at which event should be set
REFERENCE_TIME m_rtPeriod; // Periodic time
HANDLE m_hNotify; // Handle to event or semephore
BOOL m_bPeriodic; // TRUE => Periodic event
CAdvisePacket( CAdvisePacket * next, LONGLONG time ) : m_next(next), m_rtEventTime(time)
{}
void InsertAfter( CAdvisePacket * p )
{
p->m_next = m_next;
m_next = p;
}
int IsZ() const // That is, is it the node that represents the end of the list
{ return m_next == 0; }
CAdvisePacket * RemoveNext()
{
CAdvisePacket *const next = m_next;
CAdvisePacket *const new_next = next->m_next;
m_next = new_next;
return next;
}
void DeleteNext()
{
delete RemoveNext();
}
CAdvisePacket * Next() const
{
CAdvisePacket * result = m_next;
if (result->IsZ()) result = 0;
return result;
}
DWORD_PTR Cookie() const
{ return m_dwAdviseCookie; }
};
// Structure is:
// head -> elmt1 -> elmt2 -> z -> null
// So an empty list is: head -> z -> null
// Having head & z as links makes insertaion,
// deletion and shunting much easier.
CAdvisePacket head, z; // z is both a tail and a sentry
volatile DWORD_PTR m_dwNextCookie; // Strictly increasing
volatile DWORD m_dwAdviseCount; // Number of elements on list
CCritSec m_Serialize;
// AddAdvisePacket: adds the packet, returns the cookie (0 if failed)
DWORD_PTR AddAdvisePacket( CAdvisePacket * pPacket );
// Event that we should set if the packed added above will be the next to fire.
const HANDLE m_ev;
// A Shunt is where we have changed the first element in the
// list and want it re-evaluating (i.e. repositioned) in
// the list.
void ShuntHead();
// Rather than delete advise packets, we cache them for future use
CAdvisePacket * m_pAdviseCache;
DWORD m_dwCacheCount;
enum { dwCacheMax = 5 }; // Don't bother caching more than five
void Delete( CAdvisePacket * pLink );// This "Delete" will cache the Link
// Attributes and methods for debugging
public:
#ifdef DEBUG
void DumpLinkedList();
#else
void DumpLinkedList() {}
#endif
};
#endif // __CAMSchedule__