CAutoUsingOutputPin Class

 
Microsoft DirectShow 9.0

CAutoUsingOutputPin Class

The CAutoUsingOutputPin class obtains and releases access to a CDynamicOutputPin object.

When certain methods are called on CDynamicOutputPin, the caller must obtain access to the pin and then release that access. To obtain access, the caller uses the CDynamicOutputPin::StartUsingOutputPin method. To release access, it calls the CDynamicOutputPin::StopUsingOutputPin method. The CAutoUsingOutputPin class is a helper class that handles these tasks in its constructor and destructor methods. The following code example shows how to use this class:

CDynamicOutputPin *pPin;
HRESULT hr = S_OK;  // Important! Initialize to S_OK.

// Obtain a pointer to the pin (not shown).
{
    CAutoUsingOutputPin UsingPin(pPin, &hr)
    if (SUCCEEDED(hr)) {
        // Safe to use the pin.
        pPin->Deliver(pSample);
    }
} // Object goes out of scope here.

// No longer safe to use the pin.

Requirements

**  Header:** Declared in Amfilter.h; include Streams.h.

**  Library:** Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).

Public Methods  
CAutoUsingOutputPin Constructor method. Obtains access to the specified pin.
~CAutoUsingOutputPin Destructor method. Releases access to the pin.